From 89d1221d104e5283832a871c8c734b7ddb421ddb Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期三, 22 十一月 2023 14:41:44 +0800 Subject: [PATCH] 未修改完成,先提交。防撞测距正常,改为1024前导码,并加入LDE抗反射。 --- Src/main.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Src/main.c b/Src/main.c index a83bbd0..2db5abe 100644 --- a/Src/main.c +++ b/Src/main.c @@ -33,7 +33,7 @@ #define NSH1 0x0001 #define GP 0x0002 #define FLASH_HARDWARE_VERSION_MAP (uint32_t)0x08004F00 //硬件版本号和批次信息位置 -//#define DEBUG_MODE +#define DEBUG_MODE /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -303,7 +303,7 @@ slot_startcount=tyncpoll_time*1000/LPTIMER_LSB; lastpoll_time=tyncpoll_time; tag_frequency = 1000/g_com_map[COM_INTERVAL]; - bigslot_num = TOTAL_SLOTNUM/tag_frequency; +// bigslot_num = TOTAL_SLOTNUM/tag_frequency; total_slotnum = 1000/g_com_map[COM_INTERVAL]; nomovesleeptime = g_com_map[NOMOVESLEEP_TIME]; if(active_flag==0) @@ -909,6 +909,8 @@ } extern uint8_t tx_near_msg[80],stationary_flag; float key_keeptime; +uint16_t current_count1; +uint16_t lpcount1; void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { static uint8_t i=0; @@ -916,6 +918,16 @@ g_start_send_flag=1; current_slotnum++; // SetNextPollTime(tyncpoll_time); + + current_count1=HAL_LPTIM_ReadCounter(&hlptim1); + lpcount1 = current_count1+32.768*g_com_map[COM_INTERVAL];; + if(lpcount1>=32768) + { + lpcount1 -=32768; + } + __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount1); + + nomove_count+=(float)g_com_map[COM_INTERVAL]/1000; if(motor_keeptime>0) { @@ -943,7 +955,7 @@ } if(nomove_count>=nomovesleeptime-1&&imu_enable) { - tx_near_msg[TAGSTATE] = tx_near_msg[TAGSTATE]|GOINGSLEEPBIT; +// tx_near_msg[TAGSTATE] = tx_near_msg[TAGSTATE]|GOINGSLEEPBIT; } if(nomove_count>nomovesleeptime&&imu_enable) { -- Gitblit v1.9.3