| | |
| | | } |
| | | if(HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) |
| | | { |
| | | nomove_count = 0; |
| | | //nomove_count = 0; |
| | | bat_percent=Get_Battary(); |
| | | if(state5v==0) |
| | | { |
| | |
| | | if(bat_percent>99) |
| | | { |
| | | LED_LR_OFF; |
| | | LED_LG_ON; |
| | | //LED_LG_ON; |
| | | }else{ |
| | | LED_LR_ON; |
| | | // LED_LR_ON; |
| | | LED_LG_OFF; |
| | | } |
| | | }else{ |
| | |
| | | |
| | | u16 total_slotnum,current_slotnum; |
| | | extern int32_t offsettimeus; |
| | | |
| | | int32_t lpcount,lptime,target_time; |
| | | void SetNextPollTime(u16 time) |
| | | { |
| | | int32_t lpcount,lptime,target_time; |
| | | |
| | | if(current_slotnum>=total_slotnum) |
| | | current_slotnum-=total_slotnum; |
| | | |
| | | target_time=((current_slotnum*g_com_map[COM_INTERVAL])+time)*1000; |
| | | //if(target_time<90000) |
| | | { |
| | | lptime=target_time-offsettimeus; |
| | | lpcount = lptime/LPTIMER_LSB; |
| | | |
| | | // if(current_slotnum>=total_slotnum) |
| | | // current_slotnum-=total_slotnum; |
| | | // |
| | | // target_time=((current_slotnum*g_com_map[COM_INTERVAL])+time)*1000; |
| | | // //if(target_time<90000) |
| | | // { |
| | | // lptime=target_time-offsettimeus; |
| | | // lpcount = lptime/LPTIMER_LSB; |
| | | lpcount+=g_com_map[COM_INTERVAL]*LPTIMER_LSB; |
| | | if(lpcount>LPTIMER_1S_COUNT) |
| | | lpcount-=LPTIMER_1S_COUNT; |
| | | if(lpcount<0) |
| | |
| | | lpcount+=LPTIMER_1S_COUNT; |
| | | } |
| | | __HAL_LPTIM_COMPARE_SET(&hlptim1, lpcount); |
| | | } |
| | | } |
| | | |
| | | void HardWareTypeDiffConfig(void) |
| | |
| | | imu_enable=g_com_map[IMU_ENABLE]; |
| | | motor_enable=g_com_map[MOTOR_ENABLE]; |
| | | |
| | | g_com_map[GROUP_ID] = 98; |
| | | group_id=g_com_map[GROUP_ID]; |
| | | dev_id = g_com_map[DEV_ID]; |
| | | slottime=ceil((double)g_com_map[MAX_REPORT_ANC_NUM]*SLOT_SCALE)+3; |
| | |
| | | // g_com_map[MAX_REPORT_ANC_NUM]=1; |
| | | g_com_map[NOMOVESLEEP_TIME]=10; |
| | | #endif |
| | | if(g_com_map[COM_INTERVAL]==0) |
| | | |
| | | g_com_map[COM_INTERVAL]=100; |
| | | if(g_com_map[COM_INTERVAL]==0) |
| | | { |
| | | g_com_map[COM_INTERVAL]=100; |
| | | } |
| | |
| | | Error_Handler(); |
| | | } |
| | | //g_com_map[NOMOVESLEEP_TIME]=5; |
| | | printf("标签ID: %d .\r\n",dev_id); |
| | | printf("通讯间隔: %d ms.\r\n",g_com_map[COM_INTERVAL]); |
| | | printf("单次通讯基站数量: %d个.\r\n",g_com_map[MAX_REPORT_ANC_NUM]); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t0.bco=63488"); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t0.txt=\"等待串口通讯\""); |
| | | |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t1.bco=63488"); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t1.txt=\"等待测距\""); |
| | | |
| | | // USART_putc(0xff); |
| | | // USART_putc(0xff); |
| | | // USART_putc(0xff); |
| | | // printf("t2.bco=2024"); |
| | | // USART_putc(0xff); |
| | | // USART_putc(0xff); |
| | | // USART_putc(0xff); |
| | | // printf("t2.txt=\"无测距\""); |
| | | |
| | | |
| | | // printf("DEVICE PAIRID: %d .\r\n",g_com_map[PAIR_ID]); |
| | |
| | | { |
| | | //SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader |
| | | } |
| | | u8 flag_entersleep1=0,flag_entersleep2=0; |
| | | /* USER CODE END 0 */ |
| | | |
| | | /** |
| | |
| | | /* USER CODE END WHILE */ |
| | | |
| | | /* USER CODE BEGIN 3 */ |
| | | if(g_start_send_flag&&active_flag) |
| | | if(g_start_send_flag) |
| | | { static uint16_t blink_count=0; |
| | | SystemClock_Config(); |
| | | g_start_send_flag = 0; |
| | |
| | | if(m_bEUARTTxEn==0&&waitusart_timer==0&&(motor_state==0||motor_state==3)) |
| | | { |
| | | #ifndef DEBUG_MODE |
| | | if(!HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) |
| | | if(flag_entersleep1*flag_entersleep2==1) |
| | | HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); |
| | | #endif |
| | | } |
| | |
| | | /*Enter the Standby mode*/ |
| | | HAL_PWR_EnterSTANDBYMode(); |
| | | } |
| | | extern u8 flag_usartrecok,flag_uwbrange_ok; |
| | | extern int32_t uwb_dist; |
| | | void LCDPROCESS(void) |
| | | { |
| | | if(flag_usartrecok) |
| | | { |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t0.bco=2024"); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t0.txt=\"串口通讯成功\""); |
| | | flag_entersleep1 = 1; |
| | | |
| | | }else{ |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t0.bco=63488"); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t0.txt=\"等待串口通讯\""); |
| | | } |
| | | if(flag_uwbrange_ok) |
| | | { |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t1.bco=2024"); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t1.txt=\"测距成功\""); |
| | | |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t2.bco=2024"); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t2.txt=\"距离:%d\"",uwb_dist); |
| | | flag_entersleep2 = 1; |
| | | }else{ |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t1.bco=63488"); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | USART_putc(0xff); |
| | | printf("t1.txt=\"等待测距\""); |
| | | } |
| | | |
| | | } |
| | | float lcd_count=0; |
| | | extern uint8_t tx_near_msg[80],stationary_flag; |
| | | float key_keeptime; |
| | | float key_keeptime,lcdtimer; |
| | | void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) |
| | | { |
| | | static uint8_t i=0; |
| | |
| | | current_slotnum++; |
| | | SetNextPollTime(tyncpoll_time); |
| | | nomove_count+=(float)g_com_map[COM_INTERVAL]/1000; |
| | | lcdtimer+=(float)g_com_map[COM_INTERVAL]/1000; |
| | | if(lcdtimer-lcd_count>0.5) |
| | | { |
| | | lcd_count = lcdtimer; |
| | | LCDPROCESS(); |
| | | } |
| | | if(motor_keeptime>0) |
| | | { |
| | | motor_keeptime-=(float)g_com_map[COM_INTERVAL]/1000; |