From 5316ecc492b9121cc8357a5d909fe6d6c6642306 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期二, 15 七月 2025 14:12:50 +0800 Subject: [PATCH] 修改PA驱动引脚为FUN6,成功驱动PA,解决距离远不测距问题 --- keil/uwb_tag_.c | 31 +++++++++++++++++++++++-------- 1 files changed, 23 insertions(+), 8 deletions(-) diff --git a/keil/uwb_tag_.c b/keil/uwb_tag_.c index b1f8e1d..6061cde 100644 --- a/keil/uwb_tag_.c +++ b/keil/uwb_tag_.c @@ -12,7 +12,7 @@ #if defined(MK_SS_TWR_DW_INIT) extern int TagRange(void); - +void Tag_uwb_init(void); /* Ranging period: 1s */ #define RANGING_PERIOD_MS (1000) @@ -228,7 +228,7 @@ return rx_timestamp; } - +int8_t rssi_temp; /* RX done process handler. */ static void rx_int_callback(struct MAC_HW_REPORT_T *rx_report) { @@ -248,6 +248,7 @@ temp_count1=phy_timer_count_get(); //获取发射端时钟偏差 resp_rx_num++; + rssi_temp = rx_report->rssi; freq_offset=phy_freq_offset_get(); // freq_offset_filter=average_filter(freq_offset);//获取频偏 @@ -398,11 +399,11 @@ } uint32_t count_index; int tt=1; -int TagRange(void) +void Tag_uwb_init(void) { - // The following peripherals will be initialized in the uwb_open function + // The following peripherals will be initialized in the uwb_open function // phy/mac/aes/lsp/phy timers initialized - uwb_open(); + uwb_open(); #ifdef STS_MODE // Set STS key and IV phy_sts_key_configure(&sts_iv_key); @@ -435,6 +436,12 @@ #endif ranging_frame_type_set(config.phy_cfg.sts_pkt_cfg); +} + +int sleep_time_step=SLEEP_COUNT; +int TagRange(void) +{ + phy_timer_open(1, IRQ_PRIORITY_HIGH); // Register rx interrupt callback function mac_register_process_handler(tx_int_callback, rx_int_callback); @@ -474,7 +481,15 @@ current_count=phy_timer_count_get();//不断刷新当前计数器值 temp_count2=phy_timer_count_get(); - while(mac_is_busy());//等待接收完成 + while(mac_is_busy())//等待接收完成 + { + IdleTask(); + current_count=phy_timer_count_get(); + if(current_count>end_receive_count&¤t_count<end_receive_count+HALF_SECOND_TIME) + { + break; + } + } temp_count3=phy_timer_count_get(); if(receive_flag==1)//成功接收数据 { @@ -499,7 +514,6 @@ // uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 // while(mac_is_busy()); //break;//成功接收就退出 - } // #ifdef BOXING @@ -507,7 +521,8 @@ // #endif }else if(receive_flag==2){//接收出错 receive_flag=0; - sleep_timer_start(__MS_TO_32K_CNT(sleep_time_count-1));//测试 + sleep_timer_start(__MS_TO_32K_CNT(SLEEP_COUNT-phy_timer_count_get()%30));//测试 + sleep_time_step=SLEEP_COUNT-phy_timer_count_get()%10; tempflag=uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 temp_count3=phy_timer_count_get(); // while(mac_is_busy()); -- Gitblit v1.9.3