chen
2025-05-15 6e5211bf6d6279e343cf0f8fca0341b78a29de9e
keil/include/components/app/src/ranging_fira.c
@@ -136,7 +136,8 @@
// This function will be called by uwbapi_session_init()
void app_session_init(void)
{
{
      normal_uwb_change_to_fira();//变为fira配置的uwb
    // register process handler for MAC TX done and RX done
    mac_register_process_handler(ranging_tx_process, ranging_rx_process);
@@ -145,7 +146,7 @@
void ranging_configure(void)
{      
      normal_uwb_change_to_fira();//变为fira配置的uwb
    fira_keys_generate();
    aes_update_key(AES_ID0, &fira_key.devPayKey.ukey.keyByte[0]);
@@ -308,7 +309,7 @@
    .phy_cfg.rx_ant_id = UWB_RX_ANT_3,        /* UWB RX antenna port                       */
};
#endif
uint8_t normal_flag;
uint8_t normal_flag=1;
void uwb_fira_init(void)
{
      uwb_open();
@@ -341,51 +342,19 @@
}
void uwb_normal_init(void)
{
 // 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);
#endif
    // Set calibration parameters
    uwb_calibration_params_set(config.phy_cfg.ch_num);
#ifdef STS_MODE
    // 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,
    };
#else
    // 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,
    };
#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);
#if (defined STS_MODE) || (defined MK_MODE)
      ranging_lib_init();
#endif
    ranging_frame_type_set(config.phy_cfg.sts_pkt_cfg);
Uwb_init();
}
void fira_uwb_change_to_normal(void)
{
uwb_close();
//uwb_close();
   CloseUWB();
uwb_normal_init();
normal_flag=1;   
}
void normal_uwb_change_to_fira(void)
void normal_uwb_change_to_fira(void)//少个回调设置
{
uwb_close();
//uwb_close();
   CloseUWB();
uwb_fira_init();
normal_flag=0;
}