| | |
| | | MX_ADC_Init(); |
| | | |
| | | // MX_IWDG_Init(); |
| | | /* USER CODE BEGIN 2 */ |
| | | // /* USER CODE BEGIN 2 */ |
| | | LED_LG_ON; |
| | | Program_Init(); |
| | | // LIS3DH_Data_Init(); |
| | | Dw1000_Init(); |
| | | Dw1000_App_Init(); |
| | | // HardWareTypeDiffConfig(); |
| | | dwt_configuresleep(DWT_CONFIG|DWT_PGFCAL, DWT_PRES_SLEEP | DWT_WAKE_CSN | DWT_WAKE_WUP | DWT_SLP_EN); |
| | | // dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_CONFIG, DWT_WAKE_CS | DWT_WAKE_WK| DWT_SLP_EN); |
| | | // dwt_entersleep(); |
| | | dwt_configuresleep(DWT_CONFIG|DWT_PGFCAL, DWT_PRES_SLEEP | DWT_WAKE_CSN | DWT_WAKE_WUP | DWT_SLP_EN|DWT_SLEEP); |
| | | dwt_entersleep(); |
| | | // DW_DISABLE; |
| | | Tag_App666(); |
| | | if(HAL_UART_Receive_DMA(&huart1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE)) |
| | | { |
| | | Error_Handler(); |
| | | } |
| | | HAL_Delay(2000); |
| | | // dw3000_id=dwt_read32bitreg(0x44);; |
| | | // mcu_sleep(); |
| | | //LED0_BLINK; |
| | | // SystemPower_Config(); |
| | | //HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); |
| | | |
| | | /* USER CODE END 2 */ |
| | | |
| | | /* Infinite loop */ |
| | |
| | | /* USER CODE BEGIN 3 */ |
| | | if(g_start_send_flag) |
| | | { static uint16_t blink_count=0; |
| | | // SystemClock_Config(); |
| | | SystemClock_Config(); |
| | | g_start_send_flag = 0; |
| | | // HAL_IWDG_Refresh(&hiwdg); |
| | | // if(current_count>slot_startcount&¤t_count<slot_startcount+interval_count) |
| | | // { |
| | | // HAL_GPIO_WritePin(LED0_GPIO, GPIO_PIN_9, GPIO_PIN_SET); |
| | | // }else{ |
| | | // HAL_GPIO_WritePin(LED0_GPIO, GPIO_PIN_9, GPIO_PIN_RESET); |
| | | // } |
| | | // LED_TR_BLINK;s |
| | | Tag_App(); |
| | | |
| | | // if(bat_percent>15) |
| | | // { LED_TB_ON; |
| | | HAL_IWDG_Refresh(&hiwdg); |
| | | |
| | | |
| | | // Tag_App(); |
| | | // LED_TB_OFF; |
| | | // }else{ |
| | | // LED_TR_ON; |
| | | // Tag_App(); |
| | | // LED_TR_OFF; |
| | | // } |
| | | if(bat_percent>15) |
| | | { LED_TB_ON; |
| | | Tag_App(); |
| | | LED_TB_OFF; |
| | | }else{ |
| | | LED_TR_ON; |
| | | Tag_App(); |
| | | LED_TR_OFF; |
| | | } |
| | | // //LED0_BLINK; |
| | | // IdleTask(); |
| | | // if(waitusart_timer>0) |
| | | // { |
| | | // waitusart_timer--; |
| | | // } |
| | | // }else{ |
| | | // IdleTask(); |
| | | // } |
| | | IdleTask(); |
| | | if(waitusart_timer>0) |
| | | { |
| | | waitusart_timer--; |
| | | } |
| | | }else{ |
| | | IdleTask(); |
| | | } |
| | | // if(m_bEUARTTxEn==0&&waitusart_timer==0) |
| | | // { |
| | | // if(memcmp(g_com_map2,g_com_map,200)!=0) |
| | | // { |
| | | // SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; |
| | | // } |
| | | // #ifndef DEBUG_MODE |
| | | // if(!HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) |
| | | // HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); |
| | | // #endif |
| | | // } |
| | | #ifndef DEBUG_MODE |
| | | if(!HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)) |
| | | HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); |
| | | #endif |
| | | } |
| | | // HAL_Delay(100); |
| | | // Get_Battary(); |
| | | |
| | |
| | | if(freqlost_count>FREQ_LOST_TIME) |
| | | { |
| | | tag_frequency = NOTAG_FREQ; |
| | | if(lost_jumpcount++>=0) //无测距情况下,每5秒发一次; |
| | | if(lost_jumpcount++>=4) //无测距情况下,每5秒发一次; |
| | | { |
| | | lost_jumpcount = 0; |
| | | g_start_send_flag=1; |
| | |
| | | { |
| | | SetNextPollTime(0); |
| | | }else{ |
| | | SetNextPollTime(0); |
| | | SetNextPollTime(5); |
| | | } |
| | | nomove_count+=1/(float)tag_frequency; |
| | | if(motor_keeptime>0) |