From 887757c42242894806a72324d54c6ad19178b61e Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期二, 29 四月 2025 18:04:23 +0800 Subject: [PATCH] 1.2,加入1分钟初始化一次串口 --- Src/main.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Src/main.c b/Src/main.c index 9e00373..9208771 100644 --- a/Src/main.c +++ b/Src/main.c @@ -115,9 +115,15 @@ uint16_t hardware_version,hardware_pici,hardware_type; u16 current_time; uint8_t state5v; +uint8_t uart_time; +uint8_t uart_init_flag; void IdleTask(void) { - + if(uart_init_flag) + { + UsartInit(); + uart_init_flag=0; + } UART_CheckReceive(); UART_CheckSend(); @@ -133,7 +139,7 @@ // LED_TR_OFF; current_time=GetLPTime(); //motor_state=2; - + // bat_percent=Get_Battary(); // if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) // { @@ -239,7 +245,7 @@ hardware_pici= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2); hardware_type= STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4); //deca_sleep(1000); - g_com_map[VERSION] = (1<<8)|1; + g_com_map[VERSION] = (1<<8)|2; // g_com_map[DEV_ID]=0x0011; #ifdef DEBUG_MODE @@ -950,6 +956,8 @@ extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag; float key_keeptime; extern float motor_ontime,button_delay; +uint8_t uart_time; +uint8_t uart_init_flag; void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { static uint8_t i=0; @@ -961,6 +969,12 @@ if(button_delay<1) button_delay+=1/(float)tag_frequency; nomove_count+=1/(float)tag_frequency; + uart_time++; + if(uart_time>60) + { + uart_init_flag=1; + uart_time=0; + } // if(motor_keeptime>0) // { // motor_keeptime-=1/(float)tag_frequency; -- Gitblit v1.9.3