/*
 * Copyright (c) 2021 Pimax. All rights reserved.
 * Author    Date          ChangeLog
 * Master    2021-03-18    First version
 */
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "alps_config.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#include "led.h"

#define TASK_DELAY        1000           /**< Task delay. Delays a LED0 task for 200 ms */

TaskHandle_t  led_indicator_task_handle;

/**@brief LED0 task entry function.
 *
 * @param[in] pvParameter   Pointer that will be used as the parameter for the task.
 */
static void led_indicator_task_function (void * pvParameter)
{
    UNUSED_PARAMETER(pvParameter);

    while (true)
    {
        led_on(1);
        vTaskDelay(TASK_DELAY);
        led_off(1);
        vTaskDelay(TASK_DELAY);
    }
}


void led_task_init(void)
{
    BaseType_t ret;
#ifdef ALPS_IN_PCA10040
    led_gpio_init();
#endif
 /* Create task for LED0 blinking with priority set to 2 */
    ret = xTaskCreate(led_indicator_task_function, 
                     LED_THREAD_NAME, 
                     LED_THREAD_STACK_SZIE, NULL, 
                     LED_THREAD_PRIORITY, &led_indicator_task_handle);
    if(ret == pdPASS)
    {
        NRF_LOG_INFO("led task is startup");
    }
}

