From 6e5211bf6d6279e343cf0f8fca0341b78a29de9e Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期四, 15 五月 2025 18:04:17 +0800 Subject: [PATCH] 初步能连接上,但是直接停止无任何测距版本 --- keil/include/main/main.c | 104 +++++++++++++++++++++++++++------------------------ 1 files changed, 55 insertions(+), 49 deletions(-) diff --git a/keil/include/main/main.c b/keil/include/main/main.c index f98589e..c9a34a8 100644 --- a/keil/include/main/main.c +++ b/keil/include/main/main.c @@ -109,7 +109,7 @@ // //***************************************************************************** #define WSF_BUF_POOLS 5 -void Fira_Ranging_Task(void); +void Fira_Change_Task(void); // Default pool descriptor. static wsfBufPoolDesc_t poolDescriptors[WSF_BUF_POOLS] = { {32, 26}, {64, 24}, {128, 4}, {256 + 32, 4}, {1024 + 32, 2}, @@ -191,55 +191,11 @@ break; } } -wsfHandlerId_t handlerId; -void Fira_Ranging_Task(void) + +void Fira_Change_Task(void) { - // - // Create app task - // - handlerId = WsfOsSetNextHandler(app_handler); - app_init(handlerId); - - // - // Create ranging task or test task - // - handlerId = WsfOsSetNextHandler(ranging_handler); - ranging_init(handlerId); - -#ifdef UWB_UCI_TEST_EN - // Create test task - handlerId = WsfOsSetNextHandler(uwb_test_handler); - uwb_test_init(handlerId); -#endif - - 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); - - // 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); } +extern uint8_t normal_flag; int main(void) { // Initialize MCU system @@ -270,9 +226,53 @@ { LOG_INFO(TRACE_MODULE_APP, "Memory pool is not enough %d\r\n", wsfBufMemLen - FREE_MEM_SIZE); } +// + // Create app task + // + wsfHandlerId_t handlerId = WsfOsSetNextHandler(app_handler); + app_init(handlerId); - + // + // Create ranging task or test task + // + handlerId = WsfOsSetNextHandler(ranging_handler); + ranging_init(handlerId); +#ifdef UWB_UCI_TEST_EN + // Create test task + handlerId = WsfOsSetNextHandler(uwb_test_handler); + uwb_test_init(handlerId); +#endif + + 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); + +// // 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); + Uwb_init();//默认为我们测距配置 + OpenUWB(); // // Create UCI transmission layer task // @@ -295,6 +295,12 @@ while (1) { wsfOsDispatcher(); + if(normal_flag) + { + + uwb_app_poll();//我们的测距逻辑 + IdleTask(); + } power_manage(); } -- Gitblit v1.9.3