From 65d6ddb1de4064ba058cd718873a73115735211a Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期三, 04 十二月 2024 15:53:25 +0800 Subject: [PATCH] 不丢包版本,加入接收窗口退出机制,抢占问题未解决 --- keil/uwb_tag_.c | 27 ++++++++++++++++++++------- 1 files changed, 20 insertions(+), 7 deletions(-) diff --git a/keil/uwb_tag_.c b/keil/uwb_tag_.c index 8cb31a8..1345310 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) @@ -398,11 +398,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 +435,10 @@ #endif ranging_frame_type_set(config.phy_cfg.sts_pkt_cfg); +} +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); @@ -460,7 +464,8 @@ start_receive_count=phy_timer_count_get(); - poll_timeout=nearbase_num*US_TO_PHY_TIMER_COUNT(DELAY_BETWEEN_TWO_FRAME_UUS)+US_TO_PHY_TIMER_COUNT(RESP_RX_TIMEOUT_US);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss + //poll_timeout=nearbase_num*US_TO_PHY_TIMER_COUNT(DELAY_BETWEEN_TWO_FRAME_UUS)+US_TO_PHY_TIMER_COUNT(RESP_RX_TIMEOUT_US);//多一个多0.4ms默认0.4ms计算为0.125*4*100000,默认开启1mss + poll_timeout=US_TO_PHY_TIMER_COUNT(RESP_RX_TIMEOUT_US); end_receive_count=start_receive_count+poll_timeout; if(end_receive_count>=UINT32_MAX) @@ -473,7 +478,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)//成功接收数据 { @@ -498,7 +511,6 @@ // uwb_rx(0, 0, RESP_RX_TIMEOUT_US);//立即开启接受并设置0超时 // while(mac_is_busy()); //break;//成功接收就退出 - } // #ifdef BOXING @@ -506,6 +518,7 @@ // #endif }else if(receive_flag==2){//接收出错 receive_flag=0; + sleep_timer_start(__MS_TO_32K_CNT(sleep_time_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