| | |
| | | uint8_t anjian_flag; |
| | | uint8_t stationary_flag; |
| | | uint16_t stationary_num; |
| | | uint16_t Lora_send_time; |
| | | u16 GetLPTime(void) |
| | | { |
| | | u16 count=HAL_LPTIM_ReadCounter(&hlptim1); |
| | |
| | | hardware_pici = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+2); |
| | | hardware_type = STMFLASH_ReadHalfWord(FLASH_HARDWARE_VERSION_MAP+4); |
| | | //deca_sleep(1000); |
| | | g_com_map[VERSION] = (1<<8)|34; |
| | | g_com_map[VERSION] = (1<<8)|35; |
| | | // g_com_map[DEV_ID]=1158; |
| | | g_com_map[GROUP_ID]=3; |
| | | // g_com_map[COM_INTERVAL] = 1000; |
| | |
| | | } |
| | | |
| | | } |
| | | if(GPIO_Pin == GPIO_PIN_0)//加速度 |
| | | { |
| | | SystemClock_Config(); |
| | | if(sleep_flag) |
| | | {HAL_NVIC_SystemReset();} |
| | | stationary_flag =0; |
| | | stationary_num=0; |
| | | } |
| | | // if(GPIO_Pin == GPIO_PIN_0)//加速度 |
| | | // { |
| | | // SystemClock_Config(); |
| | | // if(sleep_flag) |
| | | //// {HAL_NVIC_SystemReset();} |
| | | // stationary_flag =0; |
| | | // stationary_num=0; |
| | | // } |
| | | } |
| | | |
| | | static uint8_t send_frame1[EUART_RX_BUF_SIZE]; |
| | |
| | | uint8_t dwt_entersleep_flag; |
| | | extern u8 lora_jianting_flag; |
| | | uint8_t lora_busy_flag; |
| | | uint8_t one_flag; |
| | | extern u8 fasongwancheng_flag; |
| | | extern uint8_t Lora_send_flag; |
| | | /* USER CODE END 0 */ |
| | | |
| | | /** |
| | |
| | | { |
| | | while(1) |
| | | { |
| | | if(uwb_kaiguanrx_falg==2&&dwt_entersleep_flag==0) |
| | | { |
| | | dwt_entersleep(); |
| | | dwt_entersleep_flag=1; |
| | | } |
| | | // if(uwb_kaiguanrx_falg==2&&dwt_entersleep_flag==0) |
| | | // { |
| | | // dwt_entersleep(); |
| | | // dwt_entersleep_flag=1; |
| | | // } |
| | | HAL_IWDG_Refresh(&hiwdg); |
| | | IdleTask(); |
| | | if(!HAL_GPIO_ReadPin(INPUT_5V_GPIO_Port,INPUT_5V_Pin)&&motor_keeptime==0) |
| | | { |
| | | HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); |
| | | LedOff_task(); |
| | | } |
| | | } |
| | | } |
| | | if(g_com_map[MODBUS_MODE]) |
| | | if(Lora_send_time<20) |
| | | { |
| | | if(uwb_kaiguanrx_falg==1) |
| | | { |
| | | MbxTagUwbRec(); |
| | | // uwb_kaiguanrx_falg=0; |
| | | // UWB_RXON(); |
| | | } |
| | | if(uwb_kaiguanrx_falg==2&&dwt_entersleep_flag==0) |
| | | { |
| | | dwt_entersleep(); |
| | | dwt_entersleep_flag=1; |
| | | } |
| | | MbxTagUwbRec(); |
| | | } |
| | | else |
| | | if(Lora_send_time>20&&one_flag==0) |
| | | { |
| | | if(lora_jianting_flag&&lora_busy_flag==0) |
| | | { |
| | | HAL_GPIO_WritePin(RADIO_NSS_GPIO_Port, RADIO_NSS_Pin, GPIO_PIN_SET); |
| | | HAL_GPIO_WritePin(SPIx_CS_GPIO, SPIx_CS, GPIO_PIN_RESET); |
| | | SPIx_CS_GPIO->BRR = SPIx_CS; |
| | | MbxTagUwbRec(); |
| | | dwt_entersleep_flag=0; |
| | | HAL_GPIO_WritePin(RADIO_NSS_GPIO_Port, RADIO_NSS_Pin, GPIO_PIN_RESET); |
| | | HAL_GPIO_WritePin(SPIx_CS_GPIO, SPIx_CS, GPIO_PIN_SET); |
| | | } |
| | | else |
| | | { |
| | | if(dwt_entersleep_flag==0) |
| | | one_flag=1; |
| | | dwt_entersleep(); |
| | | dwt_entersleep_flag=1; |
| | | } |
| | | if(one_flag&&!fasongwancheng_flag&&Lora_send_flag) |
| | | { |
| | | Lora_send_flag=0; |
| | | LoraReportPoll(); |
| | | } |
| | | if(fasongwancheng_flag) |
| | | { |
| | | if(sleep_flag==0) |
| | | { |
| | | dwt_entersleep(); |
| | | dwt_entersleep_flag=1; |
| | | Radio.Standby(); |
| | | Radio.Sleep(); |
| | | sleep_flag = 1; |
| | | LedOff_task(); |
| | | delay_ms(100); |
| | | // dwt_entersleep(); |
| | | // uwb_kaiguanrx_falg=2; |
| | | dwt_entersleep_flag=0; |
| | | uwbrxflag=0; |
| | | } |
| | | } |
| | | } |
| | | // if(g_com_map[MODBUS_MODE]) |
| | | // { |
| | | // if(uwb_kaiguanrx_falg==1) |
| | | // { |
| | | // MbxTagUwbRec(); |
| | | // // uwb_kaiguanrx_falg=0; |
| | | // // UWB_RXON(); |
| | | // } |
| | | // if(uwb_kaiguanrx_falg==2&&dwt_entersleep_flag==0) |
| | | // { |
| | | // dwt_entersleep(); |
| | | // dwt_entersleep_flag=1; |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // if(lora_jianting_flag&&lora_busy_flag==0) |
| | | // { |
| | | // HAL_GPIO_WritePin(RADIO_NSS_GPIO_Port, RADIO_NSS_Pin, GPIO_PIN_SET); |
| | | // HAL_GPIO_WritePin(SPIx_CS_GPIO, SPIx_CS, GPIO_PIN_RESET); |
| | | // SPIx_CS_GPIO->BRR = SPIx_CS; |
| | | // MbxTagUwbRec(); |
| | | // dwt_entersleep_flag=0; |
| | | // HAL_GPIO_WritePin(RADIO_NSS_GPIO_Port, RADIO_NSS_Pin, GPIO_PIN_RESET); |
| | | // HAL_GPIO_WritePin(SPIx_CS_GPIO, SPIx_CS, GPIO_PIN_SET); |
| | | // } |
| | | // else |
| | | // { |
| | | // if(dwt_entersleep_flag==0) |
| | | // { |
| | | // dwt_entersleep(); |
| | | // dwt_entersleep_flag=1; |
| | | // } |
| | | // } |
| | | // } |
| | | OneSecondTask(); |
| | | IdleTask(); |
| | | // if(g_com_map[LORA_SEND_INDEX]) |
| | | // { |
| | | Lora_Send_Poll(); |
| | | // Lora_Send_Poll(); |
| | | // } |
| | | LoraUp_Poll(); |
| | | |
| | |
| | | uint8_t no_yingdatime,tflag1,tflag2; |
| | | extern uint16_t tagdist_list[ANC_MAX_NUM]; |
| | | extern uint8_t Lora_send_flag; |
| | | uint8_t Lora_send_time; |
| | | uint16_t test1; |
| | | void HAL_LPTIM_CompareMatchCallback(LPTIM_HandleTypeDef *hlptim) |
| | | { |
| | |
| | | { |
| | | Lora_send_time++; |
| | | flag_onesecond = 1; |
| | | if(g_com_map[MODBUS_MODE]) |
| | | { |
| | | if(lora_jianting_flag) |
| | | { |
| | | if(Lora_send_time%3==1) |
| | | { |
| | | // UWB_RXON(); |
| | | uwb_kaiguanrx_falg=1; |
| | | } |
| | | if(Lora_send_time%3==2) |
| | | { |
| | | // UWB_RXOFF(); |
| | | |
| | | uwb_kaiguanrx_falg=2; |
| | | dwt_entersleep_flag=0; |
| | | // dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_CONFIG, DWT_WAKE_CS | DWT_WAKE_WK| DWT_SLP_EN); |
| | | // test1++; |
| | | // delay_ms(100); |
| | | // dwt_entersleep(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(uwb_kaiguanrx_falg!=0) |
| | | { |
| | | // uwb_kaiguanrx_falg=0; |
| | | uwb_kaiguanrx_falg=2; |
| | | dwt_entersleep_flag=0; |
| | | } |
| | | } |
| | | if(Lora_send_time%3==0) |
| | | { |
| | | Lora_send_flag=1; |
| | | uwb_kaiguanrx_falg=0; |
| | | } |
| | | } |
| | | else |
| | | if(Lora_send_time>3600) |
| | | { |
| | | HAL_NVIC_SystemReset(); |
| | | } |
| | | // if(g_com_map[MODBUS_MODE]) |
| | | // { |
| | | // if(lora_jianting_flag) |
| | | // { |
| | | // if(dwt_entersleep_flag) |
| | | // { |
| | | // |
| | | // } |
| | | // if(Lora_send_time%3==1) |
| | | // { |
| | | // // UWB_RXON(); |
| | | // uwb_kaiguanrx_falg=1; |
| | | // } |
| | | // if(Lora_send_time%3==2) |
| | | // { |
| | | // // UWB_RXOFF(); |
| | | // |
| | | // uwb_kaiguanrx_falg=2; |
| | | // dwt_entersleep_flag=0; |
| | | // // dwt_configuresleep(DWT_PRESRV_SLEEP | DWT_CONFIG, DWT_WAKE_CS | DWT_WAKE_WK| DWT_SLP_EN); |
| | | // // test1++; |
| | | // // delay_ms(100); |
| | | // // dwt_entersleep(); |
| | | // } |
| | | // } |
| | | // else |
| | | // { |
| | | // if(dwt_entersleep_flag!=1) |
| | | // if(uwb_kaiguanrx_falg!=0) |
| | | // { |
| | | // dwt_entersleep(); |
| | | // dwt_entersleep_flag=1; |
| | | // // uwb_kaiguanrx_falg=0; |
| | | // uwb_kaiguanrx_falg=2; |
| | | // dwt_entersleep_flag=0; |
| | | // } |
| | | // } |
| | | // if(Lora_send_time%3==0) |
| | | // { |
| | | Lora_send_flag=1; |
| | | // Lora_send_flag=1; |
| | | // uwb_kaiguanrx_falg=0; |
| | | // } |
| | | } |
| | | // } |
| | | // else |
| | | // { |
| | | //// if(lora_jianting_flag) |
| | | //// { |
| | | //// if(dwt_entersleep_flag) |
| | | //// { |
| | | //// |
| | | //// } |
| | | //// } |
| | | //// else |
| | | //// { |
| | | //// if(dwt_entersleep_flag!=1) |
| | | //// { |
| | | //// dwt_entersleep(); |
| | | //// dwt_entersleep_flag=1; |
| | | //// } |
| | | //// } |
| | | //// if(Lora_send_time%3==0) |
| | | //// { |
| | | Lora_send_flag=1; |
| | | //// uwb_kaiguanrx_falg=0; |
| | | //// } |
| | | // } |
| | | |
| | | #ifndef DEBUG_MODE |
| | | if(nomove_count>g_com_map[NOMOVESLEEP_TIME]&&imu_enable&&motor_keeptime==0) |
| | | { |
| | | if(sleep_flag==0) |
| | | { |
| | | Radio.Standby(); |
| | | Radio.Sleep(); |
| | | sleep_flag = 1; |
| | | LedOff_task(); |
| | | delay_ms(100); |
| | | // dwt_entersleep(); |
| | | uwb_kaiguanrx_falg=2; |
| | | dwt_entersleep_flag=0; |
| | | uwbrxflag=0; |
| | | } |
| | | } |
| | | #endif |
| | | //#ifndef DEBUG_MODE |
| | | // if(nomove_count>g_com_map[NOMOVESLEEP_TIME]&&imu_enable&&motor_keeptime==0) |
| | | // { |
| | | // if(sleep_flag==0) |
| | | // { |
| | | // Radio.Standby(); |
| | | // Radio.Sleep(); |
| | | // sleep_flag = 1; |
| | | // LedOff_task(); |
| | | // delay_ms(100); |
| | | //// dwt_entersleep(); |
| | | //// uwb_kaiguanrx_falg=2; |
| | | // dwt_entersleep_flag=0; |
| | | // uwbrxflag=0; |
| | | // } |
| | | // } |
| | | //#endif |
| | | if(nomove_count++>g_com_map[STATIONARY_TIME]) |
| | | { |
| | | stationary_flag = 1; |
| | |
| | | gotosleep_flag=0; |
| | | } |
| | | }else{ |
| | | if(nomove_count<g_com_map[NOMOVESLEEP_TIME]) |
| | | { |
| | | SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; |
| | | } |
| | | // if(nomove_count<g_com_map[NOMOVESLEEP_TIME]) |
| | | // { |
| | | // SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; |
| | | // } |
| | | } |
| | | } |
| | | if(!GET_USERKEY) //长按重启逻辑 |