diff --git a/.cproject b/.cproject index d186578..2837e5d 100644 --- a/.cproject +++ b/.cproject @@ -29,6 +29,7 @@ + @@ -44,13 +45,14 @@ + - + @@ -85,19 +87,13 @@ - - - - - - - - + + - + diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml index 6f0f543..862ce42 100644 --- a/.settings/language.settings.xml +++ b/.settings/language.settings.xml @@ -6,7 +6,7 @@ - + @@ -18,7 +18,7 @@ - + diff --git a/.vscode/settings.json b/.vscode/settings.json index 083b6c7..ba6487b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,8 @@ "*.tcu": "cpp", "*.json": "json", "*.txt": "txt", - "navikit.h": "c" + "navikit.h": "c", + "isp.h": "c", + "cdc.h": "c" } } \ No newline at end of file diff --git a/Core/Inc/isp.h b/App/Inc/isp.h similarity index 57% rename from Core/Inc/isp.h rename to App/Inc/isp.h index bf11179..c3fad42 100644 --- a/Core/Inc/isp.h +++ b/App/Inc/isp.h @@ -1,6 +1,17 @@ +/* + * @Description: + * @Date: 2021-03-09 10:22:15 + * @LastEditors: CK.Zh + * @LastEditTime: 2021-03-09 10:26:05 + * @FilePath: \NaviKit_EC_stm32\App\Inc\isp.h + */ + +#ifndef __ISP_H__ +#define __ISP_H__ #include "main.h" + #define ISP_ADDRESS 0x1fffb000 //In-System-Program address in flash #define MAGIC_VALUE_ADDRESS RTC_BKP_DR1 #define MAGIC_VALUE 0xa5a5 //jump to isp while ISP_BKP_DR's value equal this @@ -9,3 +20,5 @@ void ISP_Jump(); void ISP_Judge(); bool ISP_Prepare(); + +#endif \ No newline at end of file diff --git a/App/Inc/th_cdc.h b/App/Inc/th_cdc.h new file mode 100644 index 0000000..46ea9a2 --- /dev/null +++ b/App/Inc/th_cdc.h @@ -0,0 +1,18 @@ +/* + * @Description: + * @Date: 2021-03-09 10:37:34 + * @LastEditors: CK.Zh + * @LastEditTime: 2021-03-09 10:42:05 + * @FilePath: \NaviKit_EC_stm32\App\Inc\cdc.h + */ +#ifndef __TH_CDC_H__ +#define __TH_CDC_H__ + +#include "cmsis_os2.h" + +osThreadId_t cdcMonitorTaskHandle; +const osThreadAttr_t cdcMonitorTask_attributes; + +void StartCdcMonitorTask(void *argument); + +#endif diff --git a/App/Inc/th_demo.h b/App/Inc/th_demo.h new file mode 100644 index 0000000..bec5c01 --- /dev/null +++ b/App/Inc/th_demo.h @@ -0,0 +1,15 @@ +#ifndef __TH_DEMO_H__ +#define __TH_DEMO_H__ + +#include "cmsis_os2.h" + +osThreadId_t DemoTask2Handle; +osThreadId_t DemoTask1Handle; + +const osThreadAttr_t DemoTask1_attributes; +const osThreadAttr_t DemoTask2_attributes; + +void StartDemoTask1(void *argument); +void StartDemoTask2(void *argument); + +#endif diff --git a/App/Inc/th_elog.h b/App/Inc/th_elog.h new file mode 100644 index 0000000..57e11e6 --- /dev/null +++ b/App/Inc/th_elog.h @@ -0,0 +1,10 @@ +#ifndef __TH_ELOG_H__ +#define __TH_ELOG_H__ + +#include "cmsis_os2.h" +osThreadId_t ElogInitTaskHandle; +const osThreadAttr_t ElogInitTask_attributes; + +void StartElogInitTask(void *argument); +void my_elog_init(); +#endif diff --git a/Core/Src/isp.c b/App/Src/isp.c similarity index 78% rename from Core/Src/isp.c rename to App/Src/isp.c index 5fa0a31..f47eec7 100644 --- a/Core/Src/isp.c +++ b/App/Src/isp.c @@ -1,4 +1,11 @@ -#include "isp.h" +/* + * @Description: + * @Date: 2021-03-09 10:21:58 + * @LastEditors: CK.Zh + * @LastEditTime: 2021-03-09 17:42:16 + * @FilePath: \NaviKit_EC_stm32\App\Src\isp.c + */ +#include #include "cmsis_os2.h" // ::CMSIS:RTOS2 void ISP_Jump(){ @@ -33,6 +40,8 @@ void ISP_Judge() ISP_Jump(); } } + + bool ISP_Prepare(){ RTC_HandleTypeDef hrtc; @@ -50,11 +59,12 @@ bool ISP_Prepare(){ if(HAL_RTCEx_BKUPRead(&hrtc,MAGIC_VALUE_ADDRESS) == MAGIC_VALUE) {//write successful TaskBeep(400,5); - Log(trace,sys,"Enter to EC update state."); - Log(info,sys,"EC will reboot ,then run ISP automatic."); + log_v("Enter to EC update state."); + log_i("EC will reboot ,then run ISP automatic."); HAL_NVIC_SystemReset(); } else{ - Log(error,sys,"Backup register writen error, can not enter EC update state."); + log_e("Backup register writen error, can not enter EC update state."); + return false; } } diff --git a/App/Src/th_cdc.c b/App/Src/th_cdc.c new file mode 100644 index 0000000..2d96d80 --- /dev/null +++ b/App/Src/th_cdc.c @@ -0,0 +1,57 @@ + +#define LOG_TAG "TH-CDC" + +#include +#include "main.h" +#include "usbd_cdc_if.h" +#include "navikit.h" + + +//global variable +extern uint8_t port_restart[]; +extern uint32_t number_restart; + + +//task attributes +const osThreadAttr_t cdcMonitorTask_attributes = { + .name = "cdcMonitorTask", + .priority = (osPriority_t) osPriorityNormal, + .stack_size = 128 * 4 +}; + +//task instance +void StartCdcMonitorTask(void *argument){ + uint8_t port_restart_temp[64]={0}; + uint32_t number_restart_temp =0; + bool beep_flag = false; + for(;;){ + if(number_restart){ + number_restart_temp = number_restart; + memcpy(port_restart_temp,&port_restart,number_restart_temp<=12 ? number_restart_temp : 12); + number_restart = 0; + // turn off usb port device + for(uint8_t i=0;i +#include "main.h" + + +const osThreadAttr_t DemoTask1_attributes = { + .name = "DemoTask1", + .priority = (osPriority_t) osPriorityNormal, + .stack_size = 128 * 4 +}; +const osThreadAttr_t DemoTask2_attributes = { + .name = "DemoTask2", + .priority = (osPriority_t) osPriorityBelowNormal, + .stack_size = 128 * 4 +}; +void StartDemoTask1(void *argument){ + uint8_t i=0; + for(;;){ + log_v("demo task 1 [%d].",i++); + osDelay(1000); + } +} +void StartDemoTask2(void *argument){ + uint8_t i=0; + for(;;){ + log_v("demo task 2 [%d].",i++); + osDelay(1000); + } +} diff --git a/App/Src/th_elog.c b/App/Src/th_elog.c new file mode 100644 index 0000000..63041ba --- /dev/null +++ b/App/Src/th_elog.c @@ -0,0 +1,86 @@ +/* + * @Description: + * @Date: 2021-03-09 11:30:52 + * @LastEditors: CK.Zh + * @LastEditTime: 2021-03-09 17:50:24 + * @FilePath: \NaviKit_EC_stm32\App\Src\th_elog.c + */ + +#define LOG_TAG "TH-Elog" + +#include +#include "main.h" + + +const osThreadAttr_t ElogInitTask_attributes = { + .name = "ElogInitTask", + .priority = (osPriority_t) osPriorityLow, + .stack_size = 128 * 4 +}; + +void StartElogInitTask(void *argument){ + + elog_init(); + /* close printf buffer */ + setbuf(stdout, NULL); +#ifndef DEBUG //release mode :only output level、tag、time information + ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME; +#else //debug mode:output all information + ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_ALL ; +#endif + /* set EasyLogger log format */ + /* 断言:输出所有内容 */ + elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_SETTING); + /* 错误:输出级别、标签和时间 */ + elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_SETTING); + /* 警告:输出级别、标签和时间 */ + elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_SETTING); + /* 信息:输出级别、标签和时间 */ + elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_SETTING); + /* 调试:输出除了方法名之外的所有内容 */ + elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_SETTING); + /* 详细:输出除了方法名之外的所有内容 */ + elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_SETTING); + + /* start EasyLogger */ + elog_start(); + + + +// log_a("Hello EasyLogger!"); +// log_e("Hello EasyLogger!"); +// log_w("Hello EasyLogger!"); +// log_i("Hello EasyLogger!"); +// log_d("Hello EasyLogger!"); +// log_v("Hello EasyLogger!"); +// +// osDelay(10000); +// log_d("Hello EasyLogger!"); +// osThreadExit();//exit this thread,execute this code only once +} +void my_elog_init(){ + elog_init(); + /* close printf buffer */ + setbuf(stdout, NULL); +#ifndef DEBUG //release mode :only output level、tag、time information + ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_LVL | ELOG_FMT_TAG | ELOG_FMT_TIME; +#else //debug mode:output all information + ElogFmtIndex ELOG_FMT_SETTING = ELOG_FMT_ALL ; +#endif + /* set EasyLogger log format */ + /* 断言:输出所有内容 */ + elog_set_fmt(ELOG_LVL_ASSERT, ELOG_FMT_SETTING); + /* 错误:输出级别、标签和时间 */ + elog_set_fmt(ELOG_LVL_ERROR, ELOG_FMT_SETTING); + /* 警告:输出级别、标签和时间 */ + elog_set_fmt(ELOG_LVL_WARN, ELOG_FMT_SETTING); + /* 信息:输出级别、标签和时间 */ + elog_set_fmt(ELOG_LVL_INFO, ELOG_FMT_SETTING); + /* 调试:输出除了方法名之外的所有内容 */ + elog_set_fmt(ELOG_LVL_DEBUG, ELOG_FMT_SETTING); + /* 详细:输出除了方法名之外的所有内容 */ + elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_SETTING); + + /* start EasyLogger */ + elog_start(); +} diff --git a/Core/Inc/main.h b/Core/Inc/main.h index 438acad..ea2b4ca 100644 --- a/Core/Inc/main.h +++ b/Core/Inc/main.h @@ -34,6 +34,8 @@ extern "C" { /* USER CODE BEGIN Includes */ #include "stdbool.h" #include "log.h" +#include "elog.h" +#include /* USER CODE END Includes */ /* Exported types ------------------------------------------------------------*/ diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index b8bf849..518bb11 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -1,3 +1,10 @@ +/* + * @Description: + * @Date: 2020-04-02 21:44:31 + * @LastEditors: CK.Zh + * @LastEditTime: 2021-03-09 18:11:08 + * @FilePath: \NaviKit_EC_stm32\Core\Src\freertos.c + */ /* USER CODE BEGIN Header */ /** ****************************************************************************** @@ -16,9 +23,13 @@ * ****************************************************************************** */ + +//TODO:拆分该文件中的功能到不同的文件中,按照任务进行模块化拆分 + /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ + #include "FreeRTOS.h" #include "task.h" #include "main.h" @@ -29,7 +40,10 @@ #include "timers.h" #include "navikit.h" #include "coulomb.h" -#include "usbd_cdc_if.h" +#include +#include +#include + /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -49,8 +63,7 @@ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN Variables */ -extern uint8_t port_restart; -extern uint8_t number_restart; + //Timer osTimerId_t PwrBtnLongPressTimerHandle; const osTimerAttr_t PwrBtnLongPressTimer_attributes = { @@ -75,13 +88,6 @@ const osTimerAttr_t IdleStateHoldTimer_attributes = { //Thread -osThreadId_t cdcMonitorTaskHandle; -const osThreadAttr_t cdcMonitorTask_attributes = { - .name = "cdcMonitorTask", - .priority = (osPriority_t) osPriorityNormal, - .stack_size = 128 * 4 -}; - osThreadId_t LogtoUartTaskHandle; const osThreadAttr_t LogtoUartTask_attributes = { .name = "LogtoUartTask", @@ -89,18 +95,7 @@ const osThreadAttr_t LogtoUartTask_attributes = { .stack_size = 128 * 4 }; -osThreadId_t TestTask1Handle; -const osThreadAttr_t TestTask1_attributes = { - .name = "TestTask1", - .priority = (osPriority_t) osPriorityNormal, - .stack_size = 128 * 4 -}; -osThreadId_t TestTask2Handle; -const osThreadAttr_t TestTask2_attributes = { - .name = "TestTask2", - .priority = (osPriority_t) osPriorityBelowNormal, - .stack_size = 128 * 4 -}; + //Queue //osMessageQueueId_t LogMessageQueueHandle; @@ -159,10 +154,7 @@ void IdleStateHoldTimerCallback(void *argument); //task void StartLogtoUartTask(void *argument); -void StartCdcMonitorTask(void *argument); -void StartTestTask1(void *argument); -void StartTestTask2(void *argument); /* USER CODE END FunctionPrototypes */ @@ -251,7 +243,9 @@ __weak void PostSleepProcessing(uint32_t *ulExpectedIdleTime) */ void MX_FREERTOS_Init(void) { /* USER CODE BEGIN Init */ - +// elog_init(); + my_elog_init(); + NaviKit_var_init(); /* USER CODE END Init */ /* USER CODE BEGIN RTOS_MUTEX */ @@ -297,10 +291,12 @@ void MX_FREERTOS_Init(void) { /* USER CODE BEGIN RTOS_THREADS */ /* add threads, ... */ // LogtoUartTaskHandle = osThreadNew(StartLogtoUartTask, NULL, &LogtoUartTask_attributes); -// TestTask1Handle = osThreadNew(StartTestTask1, NULL, &TestTask1_attributes); -// TestTask2Handle = osThreadNew(StartTestTask2, NULL, &TestTask2_attributes); +// DemoTask1Handle = osThreadNew(StartDemoTask1, NULL, &DemoTask1_attributes); +// DemoTask2Handle = osThreadNew(StartDemoTask2, NULL, &DemoTask2_attributes); cdcMonitorTaskHandle = osThreadNew(StartCdcMonitorTask, NULL, &cdcMonitorTask_attributes); +// ElogInitTaskHandle = osThreadNew(StartElogInitTask, NULL, &ElogInitTask_attributes); +// ElogOutputMutexHandle = osMutexNew(&ElogOutputMutex_attributes); /* USER CODE END RTOS_THREADS */ @@ -338,38 +334,43 @@ void StartDefaultTask(void *argument) else{ NaviKit.sys.power_btn = true; } - Log(info,sys,"EC Reset source :Power Button WakeUP"); + log_i("EC Reset source :Power Button WakeUP"); }else{ NaviKit.sys.next_sta = idle; - Log(info,sys,"EC Reset source :RTC WakeUP"); + log_i("EC Reset source :RTC WakeUP"); enter_standby_state(); } }else{//judge reset source "power on" - Log(info,sys,"EC Reset source :PowerON"); + log_i("EC Reset source :PowerON"); if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET){ - Log(debug,sys,"EC next state isp"); + log_d("EC next state isp"); NaviKit.sys.next_sta = isp; }else{ NaviKit.sys.next_sta = idle; } - TaskBeep(50,1); +// TaskBeep(50,1); } - Log(info,sys,"----------------------------------------------"); - Log(info,sys,"Copyright (c) Powered by www.autolabor.com.cn"); + log_i("----------------------------------------------"); + log_i("Copyright (c) Powered by www.autolabor.com.cn"); - Log(info,sys,"EC Firmware: %s[%s], build: %s, %s, by STD:%u",APP_VERSION,DEPLOY_MODE,__DATE__ ,__TIME__,__STDC_VERSION__ ); - Log(info,sys,"HAL Version: %u ", HAL_GetHalVersion()); - Log(info,sys,"Revision ID: %u ", HAL_GetREVID()); - Log(info,sys,"Device ID: %u ", HAL_GetDEVID()); - Log(info,sys,"Chip UID: %u%u%u ", HAL_GetUIDw0(),HAL_GetUIDw1(),HAL_GetUIDw2()); + log_i("EC Firmware: %s[%s], build: %s, %s, by STD:%u",APP_VERSION,DEPLOY_MODE,__DATE__ ,__TIME__,__STDC_VERSION__ ); + 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(info,sys,"OS Kernel Version: %u ", osVersion.kernel); - Log(info,sys,"OS Kernel ID: %s ",id_buf); + log_i("OS Kernel Version: %u ", osVersion.kernel); + log_i("OS Kernel ID: %s ",id_buf); } - Log(info,sys,"Core initial successfully"); - Log(info,sys,"----------------------------------------------"); + log_i("OS Kernel Tick Frequence: %d ",osKernelGetTickFreq()); + log_i("OS Kernel System Timer Frequence: %d ",osKernelGetSysTimerFreq()); + log_i("Log Library Version: V%s",ELOG_SW_VERSION); + + log_i("Core initial successfully"); + // log_i("EasyLogger V%s is initialize success.", ELOG_SW_VERSION); + log_i("----------------------------------------------"); /* Infinite loop */ for(;;) @@ -392,8 +393,8 @@ void StartDefaultTask(void *argument) // }else{ // NaviKit.sys.next_sta = NaviKit.sys.sta; // TaskBeep(500,2); -// Log(error,pmb,"Main power not exist, retry after plug in it."); -// Log(fatal,pmb,"Main power is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); +// log_e(,"Main power not exist, retry after plug in it."); +// log_e("Main power is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); // } }break; case sleep:{ @@ -407,8 +408,8 @@ void StartDefaultTask(void *argument) // }else{ // NaviKit.sys.next_sta = NaviKit.sys.sta; // TaskBeep(500,2); -// Log(error,pmb,"Main power not exist, retry after plug in it."); -// Log(fatal,pmb,"Main power is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); +// log_e(,"Main power not exist, retry after plug in it."); +// log_e("Main power is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); // } }break; case isp:{ @@ -444,7 +445,7 @@ void StartLedBlinkTask(void *argument) { /* USER CODE BEGIN StartLedBlinkTask */ /* Infinite loop */ -// Log(trace,"Start LED Blink"); +// log_v("Start LED Blink"); for(;;) { @@ -504,7 +505,7 @@ void StartLedBlinkTask(void *argument) void StartCoulombRead(void *argument) { /* USER CODE BEGIN StartCoulombRead */ -// Log(trace,"Start Coulomb Read Task"); +// log_v("Start Coulomb Read Task"); //写寄存器方法 coulomb_write_config_load(); coulomb_write_config_actual_to_raw(); @@ -523,6 +524,7 @@ void StartCoulombRead(void *argument) osDelay(500); else osDelay(5000); + } /* USER CODE END StartCoulombRead */ } @@ -537,7 +539,7 @@ void StartCoulombRead(void *argument) void StartPowerMonitTask(void *argument) { /* USER CODE BEGIN StartPowerMonitTask */ -// Log(trace,"Start Power Monitor Task"); +// log_v("Start Power Monitor Task"); HAL_ADCEx_Calibration_Start(&hadc1); HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&(NaviKit.pmb.rails.adc), ADC_CH_COUNT); osDelay(100); @@ -547,10 +549,10 @@ void StartPowerMonitTask(void *argument) if(NaviKit.pmb.rails.main_pwr > 30){ TaskBeep(200,1); - Log(fatal,pmb,"Main power is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); + log_e("Main power is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); } if(NaviKit.pmb.rails.bkp_bat > 15){ - Log(fatal,pmb,"Backup battery is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); + log_e("Backup battery is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); TaskBeep(200,1); } //stat1 stat2 lead-acid @@ -562,40 +564,40 @@ void StartPowerMonitTask(void *argument) NaviKit.pmb.sta.chrg_stat2 = (bool)HAL_GPIO_ReadPin(PMB_CHRG_STAT2_GPIO_Port, PMB_CHRG_STAT2_Pin); if(!NaviKit.pmb.sta.chrg_stat1 && !NaviKit.pmb.sta.chrg_stat2) - Log(trace,pmb,"Backup battery status:%dmV Bulk Charge(Vth=12.6V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); + log_v("Backup battery status:%dmV Bulk Charge(Vth=12.6V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); if(!NaviKit.pmb.sta.chrg_stat1 && NaviKit.pmb.sta.chrg_stat2) - Log(trace,pmb,"Backup battery status:%dmV Absorption Charge(Vth=14.4V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); + log_v("Backup battery status:%dmV Absorption Charge(Vth=14.4V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); if(NaviKit.pmb.sta.chrg_stat1 && !NaviKit.pmb.sta.chrg_stat2) - Log(trace,pmb,"Backup battery status:%dmV Float Charge(Vth=13.3V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); + log_v("Backup battery status:%dmV Float Charge(Vth=13.3V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); if(NaviKit.pmb.sta.chrg_stat1 && NaviKit.pmb.sta.chrg_stat2) - Log(trace,pmb,"Backup battery status:%dmV Not Charge",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); + log_v("Backup battery status:%dmV Not Charge",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); if(NaviKit.sys.sta == run || NaviKit.sys.sta == dfu ){ if(NaviKit.pmb.rails.main_pwr < 19){ TaskBeep(200,1); - Log(warning,pmb,"Main power has been lost, please shutdown computer as soon as possible:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); + log_w("Main power has been lost, please shutdown computer as soon as possible:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); }else - Log(trace,pmb,"Main power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); + log_v("Main power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000)); if(NaviKit.pmb.rails.out_24v > 26.4 || NaviKit.pmb.rails.out_24v < 21.6) - Log(fatal,pmb,"24V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_24v*1000)); + log_e("24V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_24v*1000)); else - Log(trace,pmb,"24V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_24v*1000)); + log_v("24V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_24v*1000)); if(NaviKit.pmb.rails.out_5v > 5.5 || NaviKit.pmb.rails.out_5v < 4.5) - Log(fatal,pmb,"5V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_5v*1000)); + log_e("5V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_5v*1000)); else - Log(trace,pmb,"5V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_5v*1000)); + log_v("5V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_5v*1000)); if(NaviKit.pmb.rails.out_12v > 13.2 || NaviKit.pmb.rails.out_12v < 10.8) - Log(fatal ,pmb,"12V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_12v*1000)); + log_e("12V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_12v*1000)); else - Log(trace,pmb,"12V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_12v*1000)); + log_v("12V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_12v*1000)); if(NaviKit.pmb.rails.bkp_bat < 9.5) - Log(warning,pmb,"Backup battery exception:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); + log_w("Backup battery exception:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); else - Log(trace,pmb,"Backup battery is regular:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); + log_v("Backup battery is regular:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000)); osDelay(2000); @@ -603,8 +605,8 @@ void StartPowerMonitTask(void *argument) osDelay(5000); } -// Log(debug,sys,"state :%d",NaviKit.sys.sta); -// Log(debug,sys,"next_state :%d",NaviKit.sys.next_sta); +// log_d("state :%d",NaviKit.sys.sta); +// log_d("next_state :%d",NaviKit.sys.next_sta); } /* USER CODE END StartPowerMonitTask */ @@ -621,7 +623,7 @@ void StartEventDetect(void *argument) { /* USER CODE BEGIN StartEventDetect */ /* Infinite loop */ -// Log(trace,"Start Event Detect Task."); +// log_v("Start Event Detect Task."); for(;;) { //power button @@ -646,6 +648,8 @@ void StartEventDetect(void *argument) osTimerStart(CustBtnShortPressTimerHandle,100); } osDelay(2); + + } /* USER CODE END StartEventDetect */ } @@ -653,75 +657,27 @@ void StartEventDetect(void *argument) /* Private application code --------------------------------------------------*/ /* USER CODE BEGIN Application */ -void StartCdcMonitorTask(void *argument){ - uint8_t port_restart_temp[64]={0}; - uint32_t number_restart_temp =0; - bool beep_flag = false; - for(;;){ - if(number_restart){ - number_restart_temp = number_restart; - memcpy(port_restart_temp,&port_restart,number_restart_temp<=12 ? number_restart_temp : 12); - number_restart = 0; - // turn off usb port device - for(uint8_t i=0;i -#include -#include - -typedef enum { - trace = 0, - debug = 1, - info = 2, - warning = 3, - error = 4, - fatal =5 -}LogLevel_t; - -typedef enum { - sys = 0,//system:board device and ec device - som = 1,//system on module: jetson nano - pmb = 2,//power manage board -}LogPositon_t; - -void Log(LogLevel_t level,LogPositon_t positon,char *format, ...); -#endif /* LOG_LOG_H_ */