81 lines
2.0 KiB
C
81 lines
2.0 KiB
C
|
/*
|
||
|
* @Description:
|
||
|
* @Date: 2021-03-10 10:11:18
|
||
|
* @LastEditors: CK.Zh
|
||
|
* @LastEditTime: 2021-03-10 10:13:16
|
||
|
* @FilePath: \NaviKit_EC_stm32\App\Src\th_led.c
|
||
|
*/
|
||
|
#define LOG_TAG "TH-Led"
|
||
|
|
||
|
#include <th_led.h>
|
||
|
#include "main.h"
|
||
|
#include "navikit.h"
|
||
|
|
||
|
const osThreadAttr_t LedBlinkTask_attributes = {
|
||
|
.name = "LedBlinkTask",
|
||
|
.priority = (osPriority_t) osPriorityLow,
|
||
|
.stack_size = 128 * 4
|
||
|
};
|
||
|
|
||
|
/* USER CODE BEGIN Header_StartLedBlinkTask */
|
||
|
/**
|
||
|
* @brief Function implementing the LedBlinkTask thread.
|
||
|
* @param argument: Not used
|
||
|
* @retval None
|
||
|
*/
|
||
|
/* USER CODE END Header_StartLedBlinkTask */
|
||
|
void StartLedBlinkTask(void *argument)
|
||
|
{
|
||
|
/* USER CODE BEGIN StartLedBlinkTask */
|
||
|
/* Infinite loop */
|
||
|
log_v("Start LED Blink Task");
|
||
|
for(;;)
|
||
|
{
|
||
|
|
||
|
osDelay(1000);
|
||
|
switch(NaviKit.sys.sta){
|
||
|
case run: {
|
||
|
PWR_Enable(SYS_PWR_LED,true,0);//turn on power led
|
||
|
|
||
|
PWR_Enable(SYS_RUN_LED,true,50);//turn on sys run led
|
||
|
PWR_Enable(SYS_RUN_LED,false,0);//turn off sys run led
|
||
|
}break;
|
||
|
case idle:{
|
||
|
PWR_Enable(SYS_PWR_LED,false,0);//turn on power led//turn off power led
|
||
|
|
||
|
PWR_Enable(SYS_RUN_LED,true,20);//turn on sys run led
|
||
|
PWR_Enable(SYS_RUN_LED,false,3000);//turn off sys run led
|
||
|
}break;
|
||
|
case sleep:{//sleep mode
|
||
|
for(uint16_t i=0;i<25;i++){//20 light level
|
||
|
for(uint16_t j=0;j<3;j++){//the time length of every light level
|
||
|
PWR_Enable(SYS_PWR_LED,false,0);
|
||
|
PWR_Enable(SYS_RUN_LED,false,0);
|
||
|
osDelay(i);
|
||
|
PWR_Enable(SYS_PWR_LED,true,0);
|
||
|
PWR_Enable(SYS_RUN_LED,true,0);
|
||
|
osDelay(25-i);
|
||
|
}
|
||
|
}
|
||
|
for(uint16_t i=0;i<25;i++){
|
||
|
for(uint16_t j=0;j<3;j++){
|
||
|
PWR_Enable(SYS_PWR_LED,false,0);
|
||
|
PWR_Enable(SYS_RUN_LED,false,0);
|
||
|
osDelay(25-i);
|
||
|
PWR_Enable(SYS_PWR_LED,true,0);
|
||
|
PWR_Enable(SYS_RUN_LED,true,0);
|
||
|
osDelay(i);
|
||
|
}
|
||
|
}
|
||
|
}break;
|
||
|
case dfu:{
|
||
|
PWR_Enable(SYS_PWR_LED,!PWR_Status(SYS_PWR_LED),0);
|
||
|
PWR_Enable(SYS_RUN_LED,!PWR_Status(SYS_PWR_LED),0);
|
||
|
}break;
|
||
|
default : break;
|
||
|
}
|
||
|
}
|
||
|
/* USER CODE END StartLedBlinkTask */
|
||
|
}
|
||
|
|