chen
2025-05-16 4cdc4b3d488e15b1d6572bdcd61a2ce92d0c8c9b
keil/include/main/main.c
@@ -158,6 +158,7 @@
    LOG_INFO(TRACE_MODULE_APP,"固件版本:4G-GPS定位手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff);
    LOG_INFO(TRACE_MODULE_APP,"服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port);
}
static void board_init(void)
{
    uint32_t internal_flash = (REG_READ(0x40000018) >> 17) & 0x1;
@@ -165,6 +166,7 @@
    // Clock configuration
    board_clock_run();
      boot_deinit();//新加的
    // Pin configuration
    board_pins_config();
    // Trace configuration
@@ -203,7 +205,7 @@
#else
      Program_Init();
    // led
   // board_led_init();
    board_led_init();
//    board_led_on(BOARD_LED_1);
#endif
    board_configure();
@@ -241,13 +243,15 @@
}
int main(void)
{
    // Initialize MCU system
{
   // Initialize MCU system
    board_init();
    // Disable watchdog timer
    // Disable watchdog timer
    wdt_close(WDT_ID0);
    LOG_INFO(TRACE_MODULE_APP, "UCI FiRa example\r\n");
   if(gpio_pin_get_val(MODE_CHANGE_PIN))
   {
      
      // Platform init for WSF
    PalSysInit();
@@ -288,35 +292,40 @@
    uwb_test_init(handlerId);
#endif
#ifndef MY_MODE
    uwb_open();
//    // set advanced parameters
//    struct PHY_ADV_CONFIG_T adv_config =
//    {
//        // RPM0: 40, RPM3: 60
//        .thres_fap_detect = 60,
//        // RPM0: 4, RPM3: 8
//        .nth_scale_factor = 8,
//        // RFrame SP0: 0/1, Others: 0/1/2/3
//        .ranging_performance_mode = 3,
//#if RX_ANT_PORTS_NUM == 4
//        .skip_weakest_port_en = 1,
//#else
//        .skip_weakest_port_en = 0,
//#endif
//    };
//    phy_adv_params_configure(&adv_config);
    // set advanced parameters
    struct PHY_ADV_CONFIG_T adv_config =
    {
        // RPM0: 40, RPM3: 60
        .thres_fap_detect = 60,
        // RPM0: 4, RPM3: 8
        .nth_scale_factor = 8,
        // RFrame SP0: 0/1, Others: 0/1/2/3
        .ranging_performance_mode = 3,
#if RX_ANT_PORTS_NUM == 4
        .skip_weakest_port_en = 1,
#else
        .skip_weakest_port_en = 0,
#endif
    };
    phy_adv_params_configure(&adv_config);
//    // which RX ports will be used for AoA/PDoA
//    phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION);
    // which RX ports will be used for AoA/PDoA
    phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION);
//    uwbs_init();
//    uwb_app_config.ranging_flow_mode = (uint8_t)(RANGING_FLOW_FIRA);
//    uwb_app_config.filter_en = (uint8_t)(FILTER_EN);
//    uwb_app_config.session_param.tx_power_level = board_param.tx_power_fcc[CALIB_CH(uwb_app_config.ppdu_params.ch_num)];
//    uwb_app_config.ppdu_params.rx_ant_id = (uint8_t)(RX_MAIN_ANT_PORT);
    uwbs_init();
    uwb_app_config.ranging_flow_mode = (uint8_t)(RANGING_FLOW_FIRA);
    uwb_app_config.filter_en = (uint8_t)(FILTER_EN);
    uwb_app_config.session_param.tx_power_level = board_param.tx_power_fcc[CALIB_CH(uwb_app_config.ppdu_params.ch_num)];
    uwb_app_config.ppdu_params.rx_ant_id = (uint8_t)(RX_MAIN_ANT_PORT);
#elif defined MY_MODE
      Uwb_init();//默认为我们测距配置
      OpenUWB();
      uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback);
#endif
    //
    // Create UCI transmission layer task
    //
@@ -335,19 +344,30 @@
    // Enable sleep timer
    sleep_timer_open(true, SLEEP_TIMER_MODE_ONESHOT, sleep_timer_callback);
      uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback);
    while (1)
    {
        wsfOsDispatcher();
#ifdef MY_MODE
            if(normal_flag)
            {
            IdleTask();
            }
#endif
        power_manage();
    }
   }else{
//             adc_open(&usr_adc_cfg);
      Uwb_init();//默认为我们测距配置
      OpenUWB();
      uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback);
          while (1)
            {
            uwb_app_poll();//我们的测距逻辑
            IdleTask();
            }
        power_manage();
    }
   }
}
void app_restore_from_power_down(void)