| | |
| | | if(lp_time-battery_timer>=60) |
| | | { |
| | | bat_percent=Battery_GetPercentage(); |
| | | if(bat_percent>100) |
| | | { |
| | | bat_percent=100; |
| | | } |
| | | battery_timer=lp_time; |
| | | } |
| | | } |
| | |
| | | MX_SPI1_Init(); |
| | | MX_TIM21_Init(); |
| | | MX_LPTIM1_Init(); |
| | | MX_IWDG_Init(); |
| | | // MX_IWDG_Init(); |
| | | /* USER CODE BEGIN 2 */ |
| | | Program_Init(); |
| | | #ifndef UWB_OFF_FANGCHAI_ON |
| | |
| | | HAL_Delay(500); |
| | | Set4LEDColor(GREEN,GREEN,GREEN,GREEN); |
| | | HAL_Delay(500); |
| | | MX_IWDG_Init(); |
| | | // MX_IWDG_Init(); |
| | | // NVIC_SystemReset(); |
| | | /* USER CODE END 2 */ |
| | | |
| | |
| | | /* USER CODE BEGIN WHILE */ |
| | | while (1) |
| | | { |
| | | HAL_IWDG_Refresh(&hiwdg); |
| | | // HAL_IWDG_Refresh(&hiwdg); |
| | | APL_Poll();//lora接收,gps接收时间判断,单片机休眠函数,蜂鸣器判断函数。 |
| | | #ifndef UWB_OFF_FANGCHAI_ON |
| | | Uwb_Poll(); |
| | |
| | | /** Configure LSE Drive Capability |
| | | */ |
| | | HAL_PWR_EnableBkUpAccess(); |
| | | __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); |
| | | __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH); |
| | | /** Initializes the RCC Oscillators according to the specified parameters |
| | | * in the RCC_OscInitTypeDef structure. |
| | | */ |
| | |
| | | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| | | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | /*Configure GPIO pins : PB1 PB5 PB7 PB9 */ |
| | | GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_5|GPIO_PIN_7|GPIO_PIN_9; |
| | | /*Configure GPIO pins : PB1 PB5 PB7 */ |
| | | GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_5|GPIO_PIN_7; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | |
| | | lp_time++; |
| | | nomove_time++;//设备没有移动的时间 |
| | | if(nomove_time>g_com_map[NOMOVESLEEP_TIME]) |
| | | {nomove_flag=1;} |
| | | // {} |
| | | // {nomove_flag=1;} |
| | | {} |
| | | else |
| | | {nomove_flag=0;} |
| | | if(lora_sendfinal_rx_bag_flag==1)//如果进入lora等待接收回复的状态 |