zhangbo
2025-05-16 fcbbc2c7c81a2c9c163e81d38fe028c309c4295b
keil/include/main/main.c
@@ -101,6 +101,7 @@
bool uwb_is_on = false;                                // UWB当前状态标记
void test_Delay_us(uint16_t time);
int LEDTask(uint8_t Uwb_led,uint8_t Bt_led,uint8_t Lora_led,uint8_t Power_led);
void Lora_UploadHeartBeartPoll(void);
void upload_apppoll();
extern uint8_t mUsartReceivePack[100];
@@ -334,6 +335,7 @@
extern uint8_t lora_tx_flag;
extern uint16_t sleep_time;
uint8_t input5v_time;
extern uint8_t uwbled,btled,loraled,powerled;
static void sleep_timer_callback(void *dev, uint32_t time)
{
     input5v_time=1;
@@ -341,8 +343,8 @@
     HIDO_TimerTick();
//     lora_tx_flag++;
     uwb_time_count++;
//     upload_apppoll();
//    upload_apppoll();
      if (current_state == STATE_NORMAL)
     {
@@ -354,19 +356,18 @@
    {
       if(bat_percent>15)
        {
               led_state=!led_state;
               if(led_state)
                 GREEN_LED_ON;
               uint8_t state=0;
               state=!state;
               if(state==1)
                  GREEN_LED_ON;
               else
               {
                 GREEN_LED_OFF;
               }
            GREEN_LED_OFF;
        }
         else
            {
            RED_LED_ON;
                 GREEN_LED_OFF;
            powerled=0;
        }
      }
      input5v_time=1;
@@ -613,8 +614,8 @@
                  RED_LED_OFF;
                  BT_LED_OFF;            
             PCA9555_Set_One_Value_Output(BT_EN,0);
              PCA9555_Set_One_Value_Config(BT_IRQ,0);        //设置BT_IRQ为输出拉低
             PCA9555_Set_One_Value_Output(BT_IRQ,0);
//              PCA9555_Set_One_Value_Config(BT_IRQ,0);        //设置BT_IRQ为输出拉低
//             PCA9555_Set_One_Value_Output(BT_IRQ,0);
                  sleep_timer_stop();   
            power_enter_power_down_mode(1);
                  sys_reset(0);
@@ -746,6 +747,7 @@
      check_input_change();
}
extern uint32_t uwb_time_count;
uint8_t uwbled,btled,loraled,powerled;
void upload_apppoll()
{   
     uint32_t elapsed_time_jibu;
@@ -757,18 +759,20 @@
                switch(elapsed_time_jibu)
                  {
                     case UWB_OPEN_COUNT:
                                 UWB_LED_OFF;
                             LORA_LED_OFF;
                             LoraReportPoll();
                                 CloseUWB();
                            LoraReportPoll();
                              CloseUWB();
                    LEDTask(0,0,0,2);
                     break;
                     
                     case UWB_MEASUREMENT_INTERVAL:
                              PCA9555_Set_One_Value_Output(BT_IRQ ,0);
                                 CloseUWB();
                             Uwbinit();
                                 OpenUWB();
                      state_start_time = uwb_time_count;
                           LEDTask(uwbled,btled,loraled,powerled);
                              CloseUWB();
                              Uwbinit();
                              OpenUWB();
                              state_start_time = uwb_time_count;
                     break;                  
                  }
            break;
@@ -778,22 +782,70 @@
                switch(elapsed_time_jibu)
                  {
                     case UWB_OPEN_COUNT:
                                 UWB_LED_OFF;
                             LORA_LED_OFF;
                             LoraReportPoll();
                                 CloseUWB();
                            PCA9555_Set_One_Value_Output(BT_IRQ ,0);
                            CloseUWB();
                           LoraReportPoll();
                           LEDTask(0,0,0,2);
                     break;
                     
                     case UWB_MEASUREMENT_INTERVAL_SLEEP:
                              PCA9555_Set_One_Value_Output(BT_IRQ ,0);
                                 CloseUWB();
                             Uwbinit();
                                 OpenUWB();
                      state_start_time = uwb_time_count;
                           LEDTask(uwbled,btled,loraled,powerled);
                              CloseUWB();
                              Uwbinit();
                              OpenUWB();
                              state_start_time = uwb_time_count;
                     break;                  
                  }
            break;
         }   
}
int LEDTask(uint8_t Uwb_led,uint8_t Bt_led,uint8_t Lora_led,uint8_t Power_led)
{
   if(Uwb_led==1)
   {
    UWB_LED_ON;
   }else
   {
    UWB_LED_OFF;
   }
   if(Bt_led==1)
   {
    BT_LED_ON;
   }else
   {
    BT_LED_OFF;
   }
   if(Lora_led==1)
   {
    LORA_LED_ON;
   }else
   {
    LORA_LED_OFF;
   }
   if(powerled==1)
   {
    GREEN_LED_ON;
    RED_LED_OFF;
   }
   else if(powerled==2)
   {
    RED_LED_OFF;
    GREEN_LED_OFF;
   }
   else if(powerled==0)
   {
    RED_LED_ON;
    GREEN_LED_OFF;
   }
//   PCA9555_Set_One_Value_Output(BT_IRQ ,0);
}
uint8_t io14_state;
@@ -844,14 +896,14 @@
//      boot_deinit();
    while (1)
    { 
      step_count = mir3da_get_step(); // 获取步数
         BT_LED_OFF;
        step_count = mir3da_get_step(); // 获取步数
//       Lora_Tx_Poll();
//         uwb_app_poll();
         uwb_app_poll();
         check_step_and_update_state();
         upload_apppoll();
//         upload_apppoll();
      IdleTask();
         IMUTask();
//         if(1) 
//       {
////               test1=gpio_pin_get_val(_4G_USART_RX_Pin);