chen
2025-05-15 6e5211bf6d6279e343cf0f8fca0341b78a29de9e
初步能连接上,但是直接停止无任何测距版本
已修改2个文件
107 ■■■■■ 文件已修改
keil/include/components/app/src/ranging_fira.c 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
keil/include/main/main.c 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
}
keil/include/main/main.c
@@ -246,33 +246,33 @@
    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);
        Uwb_init();//默认为我们测距配置
        OpenUWB();
    //
    // Create UCI transmission layer task
    //
@@ -295,6 +295,12 @@
    while (1)
    {
        wsfOsDispatcher();
                if(normal_flag)
                {
                uwb_app_poll();//我们的测距逻辑
                IdleTask();
                }
        power_manage();
    }