Motion_EC_Stm32_archived/App/Src/th_led.c

83 lines
2.1 KiB
C
Raw Permalink Normal View History

2021-03-10 11:03:35 +08:00
/*
* @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",
2021-03-15 19:26:10 +08:00
.priority = (osPriority_t) osPriorityLow,
2021-03-14 23:24:59 +08:00
.stack_size = 256 * 4
2021-03-10 11:03:35 +08:00
};
2021-03-15 19:26:10 +08:00
/* USER CODE BEGIN Header_LedBlinkTask */
2021-03-10 11:03:35 +08:00
/**
* @brief Function implementing the LedBlinkTask thread.
* @param argument: Not used
* @retval None
*/
2021-03-15 19:26:10 +08:00
/* USER CODE END Header_LedBlinkTask */
void LedBlinkTask(void *argument)
2021-03-10 11:03:35 +08:00
{
2021-03-15 19:26:10 +08:00
/* USER CODE BEGIN LedBlinkTask */
2021-03-10 11:03:35 +08:00
/* Infinite loop */
log_d("Start LED Blink Task");
2021-03-10 11:03:35 +08:00
for(;;)
{
osDelay(1000);
switch(NaviKit.sys.sta){
case run: {
2021-03-15 19:26:10 +08:00
if(false == PWR_Status(SYS_PWR_LED))
PWR_Enable(SYS_PWR_LED,true,0);//turn on power led
2021-03-10 11:03:35 +08:00
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:{
2021-03-15 19:26:10 +08:00
if(true == PWR_Status(SYS_PWR_LED))
PWR_Enable(SYS_PWR_LED,false,0);//turn off power led
2021-03-10 11:03:35 +08:00
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;
}
}
2021-03-15 19:26:10 +08:00
/* USER CODE END LedBlinkTask */
2021-03-10 11:03:35 +08:00
}