From bc6afcc8e1361a5ca81beb4f19d229e0748d4da2 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期六, 31 十月 2020 16:12:01 +0800 Subject: [PATCH] V2.4 固定时间片版本 9标签20HZ测试通过 --- Src/main.c | 44 +++++++++++++++++++++++++++----------------- 1 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Src/main.c b/Src/main.c index 486d88b..679a53c 100644 --- a/Src/main.c +++ b/Src/main.c @@ -212,15 +212,22 @@ u16 total_slotnum,current_slotnum; extern int32_t offsettimeus; - -void SetNextPollTime(u16 time) +#define FIXSLOT +uint16_t bigslot_num; +uint8_t fix_slotpos =8; +int32_t lpcount,lptime,target_time; +void SetNextPollTime(u16 slotpos) { - int32_t lpcount,lptime,target_time; +u16 slotpos_intoatl; +#ifdef FIXSLOT + slotpos = fix_slotpos; +#endif if(current_slotnum>=total_slotnum) current_slotnum-=total_slotnum; - - target_time=((current_slotnum*g_com_map[COM_INTERVAL])+time)*1000; + slotpos_intoatl = current_slotnum*bigslot_num+slotpos; + + target_time=(slotpos_intoatl*SLOTTIME_MS+100)*100; //if(target_time<90000) { lptime=target_time-offsettimeus; @@ -241,7 +248,7 @@ Usart1ParseDataCallback = UsartParseDataHandler; parameter_init(); //deca_sleep(1000); - g_com_map[VERSION] = 0x0203; + g_com_map[VERSION] = 0x0204; #ifdef DEBUG_MODE // g_com_map[DEV_ROLE]=1; g_com_map[DEV_ID]=0x123; @@ -251,13 +258,13 @@ // g_com_map[IMU_ENABLE]=0; #endif //g_com_map[NOMOVESLEEP_TIME]=10; -// g_com_map[COM_INTERVAL]=100; + g_com_map[COM_INTERVAL]=50; if(g_com_map[COM_INTERVAL]==0) { g_com_map[COM_INTERVAL]=100; } - if(module_power>67) - {module_power=67;} + if(module_power>MAX_RFPOWER) + {module_power=MAX_RFPOWER;} if(module_power<0) {module_power=0;} module_power = g_com_map[POWER]; @@ -274,6 +281,7 @@ lastpoll_time=tyncpoll_time; tag_frequency = 1000/g_com_map[COM_INTERVAL]; total_slotnum = 1000/g_com_map[COM_INTERVAL]; + bigslot_num = TOTAL_SLOTNUM/tag_frequency; current_slotnum=1; current_time=GetLPTime(); if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIMER_1S_COUNT, slot_startcount) != HAL_OK) //system time is 1010ms 1 puls=30.518us @@ -645,12 +653,12 @@ Error_Handler(); } /* USER CODE BEGIN USART1_Init 2 */ - GPIO_InitStruct.Pin = GPIO_PIN_10; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF4_USART1; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); +// GPIO_InitStruct.Pin = GPIO_PIN_9; +// GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; +// GPIO_InitStruct.Pull = GPIO_PULLUP; +// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; +// GPIO_InitStruct.Alternate = GPIO_AF4_USART1; +// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); // if(HAL_UART_Receive_IT(&huart1, (uint8_t *)aRxBuffer, 1) != HAL_OK) // { // Error_Handler(); @@ -801,7 +809,7 @@ /*Enter the Standby mode*/ HAL_PWR_EnterSTANDBYMode(); } -extern uint8_t tx_near_msg[80],stationary_flag; +extern uint8_t tx_near_msg[80],stationary_flag,gotosleep_flag; float key_keeptime; void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { @@ -829,7 +837,9 @@ } if(nomove_count>=g_com_map[NOMOVESLEEP_TIME]-1&&imu_enable) { - tx_near_msg[TAGSTATE] = tx_near_msg[TAGSTATE]|GOINGSLEEPBIT; + gotosleep_flag=1; + }else{ + gotosleep_flag=0; } if(nomove_count>g_com_map[NOMOVESLEEP_TIME]&&imu_enable) { -- Gitblit v1.9.3