zhangbo
2025-03-20 de542f653793306c903085bc3a1b590ce29caec8
keil/include/main/main.c
@@ -275,7 +275,7 @@
        MinuteTask();
    }
    //UWB更新列表
    TagListUpdate();
//    TagListUpdate();
    //GPS_Poll();
      gps_power_state=1;//测试gps长开
    //UWB状态检测
@@ -297,22 +297,26 @@
        }
    }
//    HIDO_TimerTick();
    nomove_count++;
    HIDO_TimerTick();
}
uint8_t  stationary_flag;
uint8_t flag_sleeptimer,flag_secondtask,secondtask_count;
uint8_t  lora_wg_up=0;
extern uint8_t lora_tx_flag;
static void sleep_timer_callback(void *dev, uint32_t time)
{
    g_start_send_flag=1;
//     HIDO_TimerGetTick();
     HIDO_TimerTick();
   //      #ifdef DEBUG_BOXING
////      gpio_pin_clr(IO_PIN_5);//测试
   //   gpio_pin_set(IO_PIN_5);//测试
     // lora_wg_up=1;
      
      lora_tx_flag=1;
      lora_tx_flag++;
//      lora_qiehuan++;
//    IO_control_init();
//    UWBPoll();
@@ -348,13 +352,25 @@
    }
 
    //GPS工作逻辑
      if(nomove_count++>g_com_map[STATIONARY_TIME])
    {
     stationary_flag = 1;
    } else
      {
     stationary_flag = 0;
    }
//    nomove_count++;
      #ifdef DEBUG_BOXING
//      gpio_pin_clr(BOXING_PIN);//测试
      gpio_pin_set(BOXING_PIN);//测试
      #endif
      delay_us(1000);
}
void phy_timer_callback(uint32_t time)
{
 lora_tx_flag++;
}
//void phy_timer_callback(uint32_t time)
//{
// lora_tx_flag++;
//}
void uart0_receive_callback()
{
@@ -381,10 +397,11 @@
    Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为
    parameter_init_anchor();//g_com_map表初始化角色默认为基站
    g_com_map[DEV_ID]=0x1234;
     g_com_map[STATIONARY_TIME] = 10;
//    g_com_map[GROUP_ID]=1;
    dev_id=g_com_map[DEV_ID];//这里不太对
    group_id=g_com_map[GROUP_ID];//组ID
     g_com_map[LORA_POWER]=22;
//    group_id=g_com_map[GROUP_ID];//组ID
     group_id=0x04;
    tag_frequency = 1000/g_com_map[COM_INTERVAL];//测距频率这个存的是测距时间
    memcpy(&disoffset,&g_com_map[DIST_OFFSET],2);
//    g_com_map[ALARM_DISTANCE1] = 40;
@@ -498,8 +515,8 @@
     uart_receive(UART_ID0,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart0_receive_callback);//开启dma
     //串口1
      io_pin_mux_set(UART1_RX, IO_FUNC4);
    io_pin_mux_set(UART1_TX, IO_FUNC4);
//      io_pin_mux_set(UART1_RX, IO_FUNC4);
//    io_pin_mux_set(UART1_TX, IO_FUNC4);
}
void spi_init()
{
@@ -556,7 +573,31 @@
/********************************************************************************************************/
/********************************************************************************************************/
/********************************************************************************************************/
//static uint16_t delaytime = 771;
//extern uint16_t wg_report_freq,wg_report_id;
//extern uint32_t wg_lost_count;
//extern uint8_t shengji_flag;
//extern uint8_t lora_jianting_flag,report_ancnum;
//uint8_t imu_enable,motor_enable;
//uint32_t time_flag_lorarx=0;
//uint32_t lora_huanxing_count=0;
//uint16_t Lora_wangguanid=0;
//wg_state_enum wg_state = WG_Lost;
//uint16_t wangguan_up_id;
//uint8_t LoraUp_flag;
//uint16_t rec_wenjian_daxiao;
//uint16_t recnum[3];
//uint16_t recv_flag=0;
//uint16_t tx_flag=0;
//uint16_t CRC16=0;
//uint16_t DEST_ID=0;
//uint16_t rec_value,rec_delaytime,rx_count,datalen_offset;
//uint16_t Loratx_flag=0;
//uint16_t Lorarx_flag=0;
//uint16_t Lorarx_time_out_flag=0;
//uint8_t tx_buf[5]={0,1,0,1,1};
//uint32_t sleep_time_count=0;
//uint32_t uwb_ceju_count=0;
wg_state_enum wg_state = WG_Lost;
/********************************************************************************************************/
static void Lora_irq_handler(enum IO_PIN_T pin)
@@ -564,17 +605,12 @@
   RadioIrqProcess();            
}
void Board_LORA_NVIC_Init(GPIO_IRQ_HANDLER_T irq_handler)  //LORA 中断配置
{
//        io_pin_mux_set(_4G_USART_RX_Pin,IO_FUNC0);//把原先io 变为普通GPIO
      gpio_pin_set_dir(LORA_DIO , GPIO_DIR_IN, 0);
      io_pull_set(LORA_DIO, IO_HIGH_Z, IO_PULL_UP_NONE);
        gpio_enable_irq(LORA_DIO, GPIO_IRQ_TYPE_RISING_EDGE, irq_handler);
    gpio_enable_irq(LORA_DIO, GPIO_IRQ_TYPE_RISING_EDGE, irq_handler);
}
extern uint8_t pca9555writedata_input[10];//暂存输入寄存器所有配置的数组
static void pca_handler(enum IO_PIN_T pin)
@@ -588,7 +624,6 @@
uint8_t TXBuffer[8]={0,1,2,3,4,5,6,7};
uint8_t test_buf[10]={0,1,1,1,1,1,1,1,1,1};
int main(void)
{
    board_clock_run();
      //  boot_deinit();
@@ -604,27 +639,35 @@
    Board_gpio_init();
    //board_led_init();
    spi_init();
    Board_LORA_NVIC_Init(Lora_irq_handler);
     pca_input_detection_init(pca_handler);
      IIC2_Init();
    Accelerometer_Init();
      PCA9555_init();
      Lora_1268_Init();
//    SwitchLoraSettings(473,7,0);
    SwitchLoraSettings(478,7,22);
      Program_Init();
    sleep_timer_open(true, SLEEP_TIMER_MODE_RELOAD, sleep_timer_callback);
      sleep_timer_start(__MS_TO_32K_CNT(1000));//测试
    
#ifdef DEBUG_BOXING
      io_pin_mux_set(BOXING_PIN,IO_FUNC0);
      gpio_pin_set_dir(BOXING_PIN,GPIO_DIR_OUT,0);
      io_pull_set(BOXING_PIN,IO_PULL_DOWN,IO_PULL_UP_LEVEL4);
#endif
    Uwbinit();
      OpenUWB();
    while (1)
    { 
         #ifdef DEBUG_BOXING
      gpio_pin_clr(BOXING_PIN);//测试
//      gpio_pin_set(BOXING_PIN);//测试
      #endif
       Lora_Tx_Poll();
//         uwb_app_poll();
         uwb_app_poll();
      IdleTask();
    }
}