| | |
| | | |
| | | // This function will be called by uwbapi_session_init() |
| | | void app_session_init(void) |
| | | { |
| | | { |
| | | #ifdef MY_MODE |
| | | normal_uwb_change_to_fira(); |
| | | #endif |
| | | // register process handler for MAC TX done and RX done |
| | | mac_register_process_handler(ranging_tx_process, ranging_rx_process); |
| | | uwbs_handler_init(&op); |
| | | |
| | | uwbs_handler_init(&op); |
| | | } |
| | | |
| | | 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]); |
| | |
| | | .phy_cfg.rx_ant_id = UWB_RX_ANT_3, /* UWB RX antenna port */ |
| | | }; |
| | | #endif |
| | | uint8_t normal_flag; |
| | | |
| | | void uwb_fira_init(void) |
| | | { |
| | | uwb_open(); |
| | | // uwb_open(); |
| | | |
| | | // set advanced parameters |
| | | struct PHY_ADV_CONFIG_T adv_config = |
| | |
| | | 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); |
| | | } |
| | | uint8_t normal_flag=0; |
| | | 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(); |
| | | OpenUWB(); |
| | | 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; |
| | | } |
| | |
| | | void ranging_stop(void) |
| | | { |
| | | ranging_env.enable = 0; |
| | | #ifdef MY_MODE |
| | | fira_uwb_change_to_normal();//变为normal配置的uwb |
| | | #endif |
| | | ranging_monitor_stop(); |
| | | LOG_INFO(TRACE_NO_REPORT_HOST | TRACE_MODULE_APP, "Ranging stop\r\n"); |
| | | } |