chen
2024-11-29 1ad0399f0cdc7959b8259c6b159980d3702d3794
keil/uwb_app.c
@@ -775,7 +775,7 @@
            }
                  recev_error_num=0;
              //range_timeout_us=5000;//恢复为5000进入range后
           LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 包序%d\r\n",g_com_receive_id,distance,frame_seq_nb2);
           //LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 包序%d\r\n",g_com_receive_id,distance,frame_seq_nb2);
                check_if_in_or_out_car(g_com_receive_id,distance,sts_rssi[0],sts_rssi[2]);
               
               
@@ -812,36 +812,48 @@
}
void Uwb_init(void)
{
   #ifdef STS_MODE
 // Set STS key and IV
    phy_sts_key_configure(&sts_iv_key);
   
   // which RX ports will be used for AoA/PDoA
    phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION);
   #endif
    // Set calibration parameters
    uwb_calibration_params_set(config.phy_cfg.ch_num);
   #ifndef STS_MODE
   // set advanced parameters
    struct PHY_ADV_CONFIG_T adv_config = {
        .thres_fap_detect = 40,
        .nth_scale_factor = 4,
        .ranging_performance_mode = 0,
        .skip_weakest_port_en = 0,
    };
   #else
    // set advanced parameters
    struct PHY_ADV_CONFIG_T adv_config = {
        .thres_fap_detect = 40,
        .nth_scale_factor = 4,
        .ranging_performance_mode = 3,
        .skip_weakest_port_en = 0,
    };
   #endif
    phy_adv_params_configure(&adv_config);
    // uwb configure
    uwb_configure(config.phy_work_mode, board_param.tx_power_fcc[CALIB_CH(config.phy_cfg.ch_num)], &config.phy_cfg);
      #ifdef STS_MODE
      ranging_lib_init();
      #endif
    ranging_frame_type_set(config.phy_cfg.sts_pkt_cfg);
      #ifdef STS_MODE
      aoa_aux_info_set(AOA_AUX_ANT_IQ_RSSI_PDOA_AOA_FOM);
    aoa_steering_vector_set((const float *)((uint32_t)((config.phy_cfg.ch_num == 9) ? svec_ch9_ptr : svec_ch5_ptr) | SRAM_BASE));
    aoa_param_config();
      
      phy_rx_sts_switch_mode_set(config.phy_cfg.sts_pkt_cfg, STS_SWITCH_EVERY_4SYM, 0, 0);
      #endif
}
//主函数绑定接受逻辑
int UwbSearch(void)
@@ -851,36 +863,51 @@
    // The following peripherals will be initialized in the uwb_open function
    // phy/mac/aes/lsp/phy timers initialized
    uwb_open();
   #ifdef STS_MODE
  // Set STS key and IV
    phy_sts_key_configure(&sts_iv_key);
   
   // which RX ports will be used for AoA/PDoA
    phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION);
   #endif
    // Set calibration parameters
    uwb_calibration_params_set(config.phy_cfg.ch_num);
   #ifndef STS_MODE
   // set advanced parameters
    struct PHY_ADV_CONFIG_T adv_config = {
        .thres_fap_detect = 40,
        .nth_scale_factor = 4,
        .ranging_performance_mode = 0,
        .skip_weakest_port_en = 0,
    };
      #else
        // set advanced parameters
    struct PHY_ADV_CONFIG_T adv_config = {
        .thres_fap_detect = 40,
        .nth_scale_factor = 4,
        .ranging_performance_mode = 3,
        .skip_weakest_port_en = 0,
    };
      #endif
    phy_adv_params_configure(&adv_config);
    // uwb configure
    uwb_configure(config.phy_work_mode, board_param.tx_power_fcc[CALIB_CH(config.phy_cfg.ch_num)], &config.phy_cfg);
      
      #ifdef STS_MODE
      ranging_lib_init();
      #endif
    ranging_frame_type_set(config.phy_cfg.sts_pkt_cfg);
      
      #ifdef STS_MODE
      aoa_aux_info_set(AOA_AUX_ANT_IQ_RSSI_PDOA_AOA_FOM);
    aoa_steering_vector_set((const float *)((uint32_t)((config.phy_cfg.ch_num == 9) ? svec_ch9_ptr : svec_ch5_ptr) | SRAM_BASE));
    aoa_param_config();
      
      phy_rx_sts_switch_mode_set(config.phy_cfg.sts_pkt_cfg, STS_SWITCH_EVERY_4SYM, 0, 0);
      #endif
    // Register rx interrupt callback function
    mac_register_process_handler(tx_int_callback, rx_int_callback);