From 53af02c7fe54b93919d270c1c846809d7462f7d6 Mon Sep 17 00:00:00 2001 From: zhyinch <zhyinch@gmail.com> Date: 星期五, 06 十一月 2020 17:33:33 +0800 Subject: [PATCH] 11 --- Src/main.c | 30 ++++++++++++++++++++++-------- 1 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Src/main.c b/Src/main.c index 5eb9090..a8269c4 100644 --- a/Src/main.c +++ b/Src/main.c @@ -87,6 +87,7 @@ uint16_t slottime,max_slotpos; uint16_t lastpoll_count,interval_count,slot_startcount,tag_frequency,lastpoll_time,current_time; extern uint8_t module_power; +extern float nomove_count; uint8_t imu_enable,motor_enable; u16 GetLPTime(void) { @@ -149,6 +150,7 @@ } if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) { + nomove_count = 0; if(state5v==0) { state5v=1; @@ -200,6 +202,10 @@ delay_ms(100); SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader } + if(g_com_map[MAP_SIGN_INDEX]!=0x55AA||g_com_map[COM_INTERVAL]==0) + { + SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader + } } @@ -235,7 +241,7 @@ Usart1ParseDataCallback = UsartParseDataHandler; parameter_init(); //deca_sleep(1000); - g_com_map[VERSION] = 0x010f; + g_com_map[VERSION] = 0x0111; #ifdef DEBUG_MODE // g_com_map[DEV_ROLE]=1; // g_com_map[DEV_ID]=1; @@ -244,14 +250,21 @@ g_com_map[NOMOVESLEEP_TIME]=10; #endif - + if(g_com_map[COM_INTERVAL]==0) + { + g_com_map[COM_INTERVAL]=100; + } + if(module_power>67) + {module_power=67;} + if(module_power<0) + {module_power=0;} module_power = g_com_map[POWER]; imu_enable=g_com_map[IMU_ENABLE]; motor_enable=g_com_map[MOTOR_ENABLE]; group_id=g_com_map[GROUP_ID]; dev_id = g_com_map[DEV_ID]; - slottime=ceil((double)g_com_map[MAX_REPORT_ANC_NUM]*0.4)+2; + slottime=ceil((double)g_com_map[MAX_REPORT_ANC_NUM]*SLOT_SCALE)+3; max_slotpos=g_com_map[COM_INTERVAL]/slottime; tyncpoll_time=(g_com_map[DEV_ID]%max_slotpos)*slottime; slot_startcount=tyncpoll_time*1000/LPTIMER_LSB; @@ -330,7 +343,7 @@ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_LPTIM1_Init(); - MX_DMA_Init(); + MX_DMA_Init(); MX_USART1_UART_Init(); MX_SPI1_Init(); MX_ADC_Init(); @@ -675,7 +688,7 @@ HAL_GPIO_WritePin(GPIOA, SCL_Pin|SDA_Pin|SPI_CS_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, BAT_MEAS_GND_Pin|MOTOR_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(GPIOB, BAT_MEAS_GND_Pin|MOTOR_Pin|PWR_CTL_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, LED1_G_Pin|LED1_R_Pin|LED2_R_Pin, GPIO_PIN_RESET); @@ -722,8 +735,10 @@ GPIO_InitStruct.Pull = GPIO_PULLUP; HAL_GPIO_Init(USER_KEY_GPIO_Port, &GPIO_InitStruct); - /*Configure GPIO pins : MOTOR_Pin LED1_G_Pin LED1_R_Pin LED2_R_Pin */ - GPIO_InitStruct.Pin = MOTOR_Pin|LED1_G_Pin|LED1_R_Pin|LED2_R_Pin; + /*Configure GPIO pins : MOTOR_Pin LED1_G_Pin LED1_R_Pin LED2_R_Pin + PWR_CTL_Pin */ + GPIO_InitStruct.Pin = MOTOR_Pin|LED1_G_Pin|LED1_R_Pin|LED2_R_Pin + |PWR_CTL_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; @@ -780,7 +795,6 @@ HAL_PWR_EnterSTANDBYMode(); } extern uint8_t tx_near_msg[80],stationary_flag; -extern float nomove_count; float key_keeptime; void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) { -- Gitblit v1.9.3