From 76dfec4622c64f983570f33588e81e63187fd809 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期五, 15 十一月 2024 15:16:15 +0800 Subject: [PATCH] 增加了uwb_app配置 --- keil/uwb_app.c | 63 +++++++++++++++++++++++++++---- 1 files changed, 55 insertions(+), 8 deletions(-) diff --git a/keil/uwb_app.c b/keil/uwb_app.c index 2be8e51..2144422 100644 --- a/keil/uwb_app.c +++ b/keil/uwb_app.c @@ -13,6 +13,7 @@ extern int simple_main(void); extern int temp_main(void); +void Calibration_Time(void); void TagListUpdate(void); extern void IO_LED_control_change(uint8_t data); extern void IO_control_init(void); @@ -51,8 +52,12 @@ uint32_t temp_count2=0; uint32_t temp_count3=0; uint32_t temp_internal=0; +int16_t elevation = 0; +int16_t azimuth = 0; +uint8_t fom = 0; int32_t distance; uint8_t taglist_num; +float *sts_rssi=NULL; extern uint8_t recev_error_num; extern Operation_step UWB_work_state; @@ -241,7 +246,7 @@ /* RX done process handler. */ int8_t rssi; static void rx_int_callback(struct MAC_HW_REPORT_T *rx_report) -{ +{ uint8_t valid_sts=0; // Power off radio power_off_radio(); @@ -259,7 +264,19 @@ poll_rx_num++; rssi = rx_report->rssi; receive_flag=1; - + valid_sts= sts_valid_check(); + if (valid_sts) + { + aoa_calculate(&elevation, &azimuth); + aoa_fom_get(NULL, &fom); +// float pdoa[3]; +// pdoa[0] = pdoa_select_get(0, 3); +// pdoa[1] = pdoa_select_get(1, 3); +// pdoa[2] = pdoa_select_get(2, 3); +// LOG_INFO(TRACE_MODULE_APP, "PDOA: %f %f %f\r\n", pdoa[0], pdoa[1], pdoa[2]); + + sts_rssi = sts_rssi_output_get(); + } } else { @@ -405,11 +422,40 @@ uint16_t uwb_searchcount; uint8_t flag_recsuccess; uint8_t flag_temp2,flag_temp1; - uint8_t valid_sts = 0; -int16_t elevation = 0; -int16_t azimuth = 0; -uint8_t fom = 0; +uint32_t start_receive_count_calibration; +uint32_t current_count_calibration; +uint8_t secondtask_search_count,secondtask_search_flag; extern uint8_t g_start_send_flag,search_open_flag = 1,link_success_flag,flag_secondtask; +void Calibration_Time(void) +{ + current_count_calibration=phy_timer_count_get(); + if((current_count_calibration-start_receive_count_calibration>=MS_TO_PHY_TIMER_COUNT(500)||current_count_calibration+(UINT32_MAX-start_receive_count_calibration)>=MS_TO_PHY_TIMER_COUNT(500)) + &&!((end_receive_count-current_count_calibration<=MS_TO_PHY_TIMER_COUNT(200))||(end_receive_count+(UINT32_MAX-current_count_calibration)<=MS_TO_PHY_TIMER_COUNT(200)))) + { + start_receive_count_calibration=current_count_calibration;//更新开始时间 +// MotorPoll(); + + if(secondtask_search_count++%2==0) + { + secondtask_search_flag = 1; + }else{ + secondtask_search_flag = 0; + } + if(secondtask_search_flag)//更新S时间TICK + { + HIDO_TimerTick(); + TagListUpdate(); +// GPS_Poll(); +// if(nomove_count<=g_com_map[NOMOVESLEEP_TIME])//防止溢出 +// nomove_count++; +// else{ +// nomove_count=g_com_map[NOMOVESLEEP_TIME]+1; +// } + } +// update_led_power_state();//更新等状态防止震动卡死在搜索 + } +} + int UwbRange(void) { uint8_t i; @@ -457,6 +503,7 @@ current_count=phy_timer_count_get(); while(mac_is_busy()) { + Calibration_Time(); IdleTask(); current_count=phy_timer_count_get(); if(current_count>end_receive_count&¤t_count<end_receive_count+HALF_SECOND_TIME) @@ -505,7 +552,7 @@ } recev_error_num=0; range_timeout_us=5000;//恢复为5000进入range后 - LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度:%d.\r\n",g_com_map[BIND_DEV_ID],distance,rssi); + LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度ANT0:%d,信号强度ANT2:%d\r\n",g_com_map[BIND_DEV_ID],distance,sts_rssi[0],sts_rssi[2]); gpio_pin_clr(SCL_PIN); break; } @@ -641,7 +688,7 @@ } gpio_pin_clr(SCL_PIN);//测试 - LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度:%d.\r\n",g_com_map[BIND_DEV_ID],distance,rssi); + LOG_INFO(TRACE_MODULE_APP,"标签ID:%X,距离: %d 信号强度ANT0:%d,信号强度ANT2:%d\r\n",g_com_map[BIND_DEV_ID],distance,sts_rssi[0],sts_rssi[2]); return 1;//返回发送成功标志 } -- Gitblit v1.9.3