From d31ca55f8030d459250b5b92564df3920e8ac0a0 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期一, 20 一月 2025 15:54:19 +0800 Subject: [PATCH] 2.10 改为充电也休眠 --- Src/main.c | 40 ++++++++++++++++++++++++++++++---------- 1 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Src/main.c b/Src/main.c index c53542e..d1fb4bb 100644 --- a/Src/main.c +++ b/Src/main.c @@ -134,9 +134,10 @@ bat_percent=Get_Battary(); if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) { - nomove_count = 0; +// nomove_count = 0; if(state5v==0) { + UWB_RXOFF(); state5v=1; UsartInit(); } @@ -224,6 +225,7 @@ uint8_t uwb_active_flag = 0; u8 active_flag=0; u16 nomovesleep_time=0,interval; +extern uint8_t uwb_onflag; void Program_Init(void) { float temp; uint16_t temp2; @@ -234,7 +236,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] = (2<<8)|1; + g_com_map[VERSION] = (2<<8)|10; // g_com_map[DEV_ID]=0x7; #ifdef DEBUG_MODE @@ -253,6 +255,7 @@ active_flag = g_com_map[ACTIVE_INDEX]; //g_com_map[HEIGHTOFFEST_INDEX]=g_com_map[MAX_REPORT_ANC_NUM]; + uwb_onflag=g_com_map[UWB_ONFLAG]; module_power = g_com_map[POWER]; imu_enable=g_com_map[IMU_ENABLE]; motor_enable=g_com_map[MOTOR_ENABLE]; @@ -331,7 +334,6 @@ // break; // } } - void DoubleClickProcess(void) { char temp[50]; uint8_t len; @@ -347,6 +349,14 @@ HAL_Delay(1000); HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_3); } +if(uwb_onflag) +{ +UWB_RXOFF(); +} +else +{ +UWB_RXON(); +} g_com_map[UWB_ACTIVE_FLAG_IDX]= uwb_active_flag; save_com_map_to_flash(); } @@ -354,6 +364,8 @@ { //SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader } + +uint8_t userkey_num; /* USER CODE END 0 */ /** @@ -402,9 +414,17 @@ // dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_CONFIG, DWT_WAKE_CS | DWT_WAKE_WK| DWT_SLP_EN); // dwt_entersleep(); // waitusart_timer=tag_frequency*USART_KEEPWAKE_TIME;; - dwt_setinterrupt( DWT_INT_RFCG | (DWT_INT_ARFE | DWT_INT_RFSL | DWT_INT_SFDT | DWT_INT_RPHE | DWT_INT_RFCE | DWT_INT_RFTO | DWT_INT_RXPTO), 1); - dwt_setrxtimeout(0);//设定接收超时时间,0位没有 - dwt_rxenable(0); +// dwt_setinterrupt( DWT_INT_RFCG | (DWT_INT_ARFE | DWT_INT_RFSL | DWT_INT_SFDT | DWT_INT_RPHE | DWT_INT_RFCE | DWT_INT_RFTO | DWT_INT_RXPTO), 1); +// dwt_setrxtimeout(0);//设定接收超时时间,0位没有 +// dwt_rxenable(0); + if(uwb_onflag) + { + UWB_RXON(); + } + else + { + UWB_RXOFF(); + } DW_DISABLE; if(HAL_UART_Receive_DMA(&huart1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE)) { @@ -437,7 +457,7 @@ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); #endif } - if(g_start_send_flag) + if(g_start_send_flag&&uwb_onflag) { static uint16_t blink_count=0; g_start_send_flag = 0; // GetPressAndTemp(); @@ -469,7 +489,6 @@ }else{ IdleTask(); } - // HAL_Delay(100); // Get_Battary(); @@ -923,6 +942,7 @@ static uint8_t i=0; SystemClock_Config(); g_start_send_flag=1; + userkey_num=0; // current_slotnum++; // SetNextPollTime(tagslotpos); if(button_delay<1) @@ -991,12 +1011,12 @@ }else{ gotosleep_flag=0; } -#ifndef DEBUG_MODE +//#ifndef DEBUG_MODE if(nomove_count>g_com_map[NOMOVESLEEP_TIME]&&imu_enable) { mcu_sleep(); } -#endif +//#endif } /* USER CODE END 4 */ -- Gitblit v1.9.3