diff --git a/App/Src/isp.c b/App/Src/isp.c index bdb7b36..1d91a31 100644 --- a/App/Src/isp.c +++ b/App/Src/isp.c @@ -58,9 +58,9 @@ bool ISP_Prepare(){ osDelay(10); if(HAL_RTCEx_BKUPRead(&hrtc,MAGIC_VALUE_ADDRESS) == MAGIC_VALUE) {//write successful - TaskBeep(400,5); log_v("Enter to EC update state."); log_i("EC will reboot ,then run ISP automatic."); + TaskBeep(400,5); HAL_NVIC_SystemReset(); return true; } diff --git a/App/Src/th_elog.c b/App/Src/th_elog.c index a52f6f2..8b64826 100644 --- a/App/Src/th_elog.c +++ b/App/Src/th_elog.c @@ -45,7 +45,7 @@ void ElogInitTask(void *argument){ //interval:buffer flush time interval void ElogFlushTask(uint8_t intervnal){ - log_d("Start log Flush Task"); + log_d("Start Log Flush Task"); for(;;){ elog_flush(); osDelay(intervnal); @@ -59,8 +59,8 @@ void my_elog_init(){ setbuf(stdout, NULL); #ifdef DEBUG //debug mode:output all information ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_ALL ; -#else //release mode :only output level、tag、time information - ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME; +#else //release mode :only output level、time information + ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_LVL | ELOG_FMT_TIME; #endif /* set EasyLogger log format */ /* 断言:输出所有内容 */ @@ -83,8 +83,9 @@ void my_elog_init(){ elog_start(); } -void HAL_UART1_TxHalfCpltCallback(UART_HandleTypeDef *huart){ +void HAL_UART1_TxCpltCallback(UART_HandleTypeDef *huart){ - osSemaphoreRelease(ElogUartBinarySemHandle); } + +//void elog_set_filter(uint8_t level, const char *tag, const char *keyword); diff --git a/App/Src/th_info.c b/App/Src/th_info.c index 6335c21..c322013 100644 --- a/App/Src/th_info.c +++ b/App/Src/th_info.c @@ -9,16 +9,40 @@ #include #include "main.h" +#include "cmsis_os2.h" const osThreadAttr_t InfoOutputTask_attributes = { .name = "InfoOutputTask", - .priority = (osPriority_t) osPriorityLow2, + .priority = (osPriority_t) osPriorityLow1, .stack_size = 256 * 4 }; void InfoOutputTask(void *argument){ + + osVersion_t osVersion; + char id_buf[20]; + unsigned char id_size=20; + log_d("Start Info Output Task"); - for(;;){ - osThreadExit(); + + log_i("Copyright (c) Powered by www.autolabor.com.cn"); +#ifdef DEBUG + log_i("EC Firmware: %s[DEBUG], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__); +#else + log_i("EC Firmware: %s[RELEASE], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__); +#endif + log_i("HAL Version: 0x%X ", HAL_GetHalVersion()); + log_i("Revision ID: 0x%X ", HAL_GetREVID()); + log_i("Device ID : 0x%X ", HAL_GetDEVID()); + log_i("Chip UID : 0x%X%X%X ", HAL_GetUIDw0(),HAL_GetUIDw1(),HAL_GetUIDw2()); + + if(osOK == osKernelGetInfo(&osVersion,id_buf,id_size)){ + log_i("OS Kernel Version : %u ", osVersion.kernel); + log_i("OS Kernel ID : %s ",id_buf); } + log_i("OS Kernel Tick Frequency: %d Hz",osKernelGetTickFreq()); + log_i("System Timer Frequency : %d Hz",osKernelGetSysTimerFreq()); + log_i("Log Library Version : V%s",ELOG_SW_VERSION); + + osThreadExit(); } diff --git a/App/Src/th_led.c b/App/Src/th_led.c index 468aa01..200b90b 100644 --- a/App/Src/th_led.c +++ b/App/Src/th_led.c @@ -28,7 +28,7 @@ void LedBlinkTask(void *argument) { /* USER CODE BEGIN LedBlinkTask */ /* Infinite loop */ - log_d(" LED Blink Task"); + log_d("Start LED Blink Task"); for(;;) { diff --git a/App/Src/th_power.c b/App/Src/th_power.c index 0a8f87f..d71a214 100644 --- a/App/Src/th_power.c +++ b/App/Src/th_power.c @@ -44,7 +44,7 @@ void PowerMonitTask(void *argument) { if((NaviKit.pmb.rails.main_pwr > 30) || (NaviKit.pmb.rails.main_pwr < 19)){ NaviKit.pmb.main_pwr_good = false; - log_e("Main power:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); + log_e("Main power :%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); if((NaviKit.sys.next_sta == run) && (NaviKit.sys.next_sta == run)){ TaskBeep(200,2); } diff --git a/Core/Inc/main.h b/Core/Inc/main.h index d89a0d3..a7e28e7 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -189,7 +189,7 @@ void Error_Handler(void); /* USER CODE BEGIN Private defines */ //define application software version -#define APP_VERSION "v0.9.6" +#define APP_VERSION "v0.9.7" // set iwdg enable or disable //#define IWDG_ENABLE diff --git a/Core/Inc/navikit.h b/Core/Inc/navikit.h index 2e5a1ab..f2e302f 100644 --- a/Core/Inc/navikit.h +++ b/Core/Inc/navikit.h @@ -105,7 +105,7 @@ bool PWR_Status(enum Device_t device); void NaviKit_var_init(); //power state machine switch function -void enter_standby_state(); +void enter_standby_state(uint16_t delay); void enter_isp_state(); void enter_run_state(uint16_t delay); void enter_idle_state(uint16_t delay); diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index f15e2a1..e6d0dc3 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -38,6 +38,7 @@ #include #include #include +#include /* USER CODE END Includes */ @@ -170,11 +171,12 @@ __weak void PostSleepProcessing(uint32_t *ulExpectedIdleTime) void MX_FREERTOS_Init(void) { /* USER CODE BEGIN Init */ - ElogUartBinarySemHandle = osSemaphoreNew(1, 0, &ElogUartBinarySem_attributes); - ElogOutputBinarySemHandle = osSemaphoreNew(1, 0, &ElogOutputBinarySem_attributes); - +// ElogUartBinarySemHandle = osSemaphoreNew(1, 1, &ElogUartBinarySem_attributes); + ElogOutputBinarySemHandle = osSemaphoreNew(1, 1, &ElogOutputBinarySem_attributes); my_elog_init(); - NaviKit_var_init(); + + NaviKit_var_init(); + /* USER CODE END Init */ /* USER CODE BEGIN RTOS_MUTEX */ @@ -244,6 +246,9 @@ void MX_FREERTOS_Init(void) { // DemoTask2Handle = osThreadNew(DemoTask2, NULL, &DemoTask2_attributes); + //InfoOutput-------------------------------------------- + InfoOutputTaskHandle = osThreadNew(InfoOutputTask, NULL, &InfoOutputTask_attributes); + /* USER CODE END RTOS_THREADS */ /* USER CODE BEGIN RTOS_EVENTS */ @@ -266,9 +271,6 @@ void StartDefaultTask(void *argument) /* init code for USB_DEVICE */ MX_USB_DEVICE_Init(); /* USER CODE BEGIN StartDefaultTask */ -osVersion_t osVersion; - char id_buf[20]; - unsigned char id_size=20; // ResetSourceJudge(); HAL_GPIO_WritePin(USB2_FS_ENUM_CTL_GPIO_Port,USB2_FS_ENUM_CTL_Pin, GPIO_PIN_SET); if(isWakeUpFromReset()){//judge reset source form "wakeup event" @@ -283,7 +285,7 @@ osVersion_t osVersion; }else{ NaviKit.sys.next_sta = idle; log_i("EC Reset source: [RTC WakeUP]"); - enter_standby_state(); + enter_standby_state(100); } }else{//judge reset source "power on" log_i("EC Reset source: [PowerON]"); @@ -296,35 +298,16 @@ osVersion_t osVersion; TaskBeep(50,1); } - log_i("Copyright (c) Powered by www.autolabor.com.cn"); -#ifdef DEBUG - log_i("EC Firmware: %s[DEBUG], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__); -#else - log_i("EC Firmware: %s[RELEASE], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__); -#endif - log_i("HAL Version: 0x%X ", HAL_GetHalVersion()); - log_i("Revision ID: 0x%X ", HAL_GetREVID()); - log_i("Device ID : 0x%X ", HAL_GetDEVID()); - log_i("Chip UID : 0x%X%X%X ", HAL_GetUIDw0(),HAL_GetUIDw1(),HAL_GetUIDw2()); - - if(osOK == osKernelGetInfo(&osVersion,id_buf,id_size)){ - log_i("OS Kernel Version : %u ", osVersion.kernel); - log_i("OS Kernel ID : %s ",id_buf); - } - log_i("OS Kernel Tick Frequency: %d Hz",osKernelGetTickFreq()); - log_i("System Timer Frequency : %d Hz",osKernelGetSysTimerFreq()); - log_i("Log Library Version : V%s",ELOG_SW_VERSION); - log_i("Core initial successfully"); /* Infinite loop */ for(;;) { - osDelay(20); + osDelay(50); if(NaviKit.sys.sta != NaviKit.sys.next_sta){ switch(NaviKit.sys.next_sta){ case standby: { - enter_standby_state(); + enter_standby_state(100); }break; case idle: { enter_idle_state(100); @@ -332,6 +315,7 @@ osVersion_t osVersion; } break; case run: { if(NaviKit.pmb.main_pwr_good){ + log_d("Main power good."); enter_run_state(100); NaviKit.sys.sta = NaviKit.sys.next_sta; }else{ @@ -346,6 +330,7 @@ osVersion_t osVersion; }break; case dfu:{ if(NaviKit.pmb.main_pwr_good){ + log_d("Main power good."); enter_dfu_state(100); NaviKit.sys.sta = NaviKit.sys.next_sta; }else{ @@ -365,7 +350,6 @@ osVersion_t osVersion; // || (NaviKit.pmb.sta.chrg_stat1 && !NaviKit.pmb.sta.chrg_stat2)){//Not Charge or float charge // NaviKit.sys.next_sta = standby; // } - if(!osTimerIsRunning(IdleStateHoldTimerHandle)){ osTimerStart(IdleStateHoldTimerHandle,5000); log_i("Idle state hold timer started."); diff --git a/Core/Src/navikit.c b/Core/Src/navikit.c index 4bba0e2..825d6c9 100644 --- a/Core/Src/navikit.c +++ b/Core/Src/navikit.c @@ -23,6 +23,7 @@ void NaviKit_var_init() { NaviKit.sys.sta = idle; NaviKit.sys.next_sta = idle; + NaviKit.pmb.main_pwr_good = true; } void TaskBeep(uint32_t time_ms , uint8_t n) @@ -59,9 +60,9 @@ void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc) } -void enter_standby_state(){ +void enter_standby_state(uint16_t delay){ log_i("EC enter to STANDBY Mode to save power, see you!"); - osDelay(10); + osDelay(delay); HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);//Enable PA0 wakeup function __HAL_RCC_RTC_DISABLE(); HAL_PWR_EnterSTANDBYMode(); @@ -180,7 +181,7 @@ void PWR_Enable(enum Device_t device,bool en,uint16_t delay){ bool result = false; result = PWR_Enable_IRQ(device,en,0); if(result){ - log_v("Device 0x%X has been %s",device,en ? "enabled" : "disabled"); + log_v("Device 0x%02X -> %s",device,(en == true) ? "[ON]" : "[OFF]"); osDelay(delay); }else{ log_e("Power_Enable device parameter is invalid!"); diff --git a/Core/Src/usart.c b/Core/Src/usart.c index d8ec6c6..31a4029 100644 --- a/Core/Src/usart.c +++ b/Core/Src/usart.c @@ -269,12 +269,12 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) } /* USER CODE BEGIN 1 */ -void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart){ +void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart){ if(huart->Instance == USART1){ - HAL_UART1_TxHalfCpltCallback(huart); + HAL_UART1_TxCpltCallback(huart); } } -__weak void HAL_UART1_TxHalfCpltCallback(UART_HandleTypeDef *huart){ +__weak void HAL_UART1_TxCpltCallback(UART_HandleTypeDef *huart){ UNUSED(huart); } diff --git a/Middlewares/EasyLogger b/Middlewares/EasyLogger index 69ca6cd..949ef83 160000 --- a/Middlewares/EasyLogger +++ b/Middlewares/EasyLogger @@ -1 +1 @@ -Subproject commit 69ca6cd42c7370db783c8df9943fc44bc3761574 +Subproject commit 949ef83b618c5119d915cba163f772c923310051 diff --git a/NaviKit_EC_stm32 Debug.launch b/NaviKit_EC_stm32 Debug.launch index 2124351..7bcb97c 100644 --- a/NaviKit_EC_stm32 Debug.launch +++ b/NaviKit_EC_stm32 Debug.launch @@ -35,7 +35,7 @@ - + @@ -68,6 +68,10 @@ + + + + diff --git a/NaviKit_EC_stm32 Release.launch b/NaviKit_EC_stm32 Release.launch index 1dec609..2e2756a 100644 --- a/NaviKit_EC_stm32 Release.launch +++ b/NaviKit_EC_stm32 Release.launch @@ -5,7 +5,7 @@ - + @@ -24,18 +24,18 @@ - + - + - + @@ -58,7 +58,7 @@ - + @@ -68,6 +68,11 @@ + + + + +