From adfc7e798b9cbdd022bf8df971843436912a0fe5 Mon Sep 17 00:00:00 2001 From: chen <15335560115@163.com> Date: 星期日, 20 七月 2025 16:58:30 +0800 Subject: [PATCH] 成功移植g_com_map表逻辑,初步测试能读能写,并且TDOA效果和官方一致 --- keil/include/components/app/src/uwb_trx.c | 43 +++++++++++++++++-------------------------- 1 files changed, 17 insertions(+), 26 deletions(-) diff --git a/keil/include/components/app/src/uwb_trx.c b/keil/include/components/app/src/uwb_trx.c index 9a9ce90..745731f 100644 --- a/keil/include/components/app/src/uwb_trx.c +++ b/keil/include/components/app/src/uwb_trx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2023 Beijing Hanwei Innovation Technology Ltd. Co. and + * Copyright (c) 2019-2025 Beijing Hanwei Innovation Technology Ltd. Co. and * its subsidiaries and affiliates (collectly called MKSEMI). * * All rights reserved. @@ -43,10 +43,6 @@ #include "mk_uwb.h" #include "uwb_trx.h" #include "wsf_msg.h" - -#ifndef RANGING_EN -#define RANGING_EN (0) -#endif #if RANGING_EN || CSI_EN #include "lib_ranging.h" #endif @@ -70,12 +66,6 @@ // register process handler for MAC TX done and RX done mac_register_process_handler(uwb_tx_process, uwb_rx_process); - // which RX ports will be used for AoA/PDoA - phy_rx_ant_mode_set(RX_ANT_PORTS_COMBINATION); - -#if CSI_EN - ranging_aux_out_opt_set(CH_LEN_DEFAULT, 3); -#endif return 0; } @@ -127,8 +117,9 @@ ind->hdr.event = UWB_RX_DONE_MSG; ind->phy_timer_count = rx->timestamp; ind->status = rx->err_code; - ind->rssi = rx->rssi; - ind->snr = rx->snr; + // ind->rssi = rx->rssi; + ind->rssi = correct_rssi(rx->rssi); + ind->snr = correct_snr(rx->snr); if (rx->err_code == UWB_RX_OK) { @@ -144,16 +135,12 @@ } ind->length = rx->pkt_len; -#if RANGING_EN - int64_t timestamp = ranging_rx_time(rx); - ind->timestamp_frac = timestamp & 0x1ff; - ind->timestamp_int = (uint32_t)(timestamp >> 9); - +#if CSI_EN if (ranging_debug_csi_en_get()) { uint8_t frame_idx = 0; debug_csi.frame_idx = frame_idx; - debug_csi.rframe_idx = frame_idx; + debug_csi.frame_idx = frame_idx; uint32_t val = REG_READ(0x40003050); debug_csi.frame[frame_idx].rf_gain = (val & 0x07); @@ -161,15 +148,17 @@ debug_csi.frame[frame_idx].bd_cnt = phy_bd_cnt_get(); debug_csi.frame[frame_idx].sfd_cnt = phy_sfd_cnt_get(); debug_csi.frame[frame_idx].error_code = ind->status; - if (rx->err_code != 0x0830) - { - debug_csi.frame[frame_idx].rssi = ind->rssi; - debug_csi.frame[frame_idx].snr = ind->snr; - dump_preamble_cir(frame_idx, 128); - dump_sts_cir(frame_idx); - } + debug_csi.frame[frame_idx].rssi = ind->rssi; + debug_csi.frame[frame_idx].snr = ind->snr; + debug_csi.frame[frame_idx].channel_power = REG_READ(0x40002064); + debug_csi.frame[frame_idx].noise_power = REG_READ(0x40002078); } +#endif +#if RANGING_EN || CSI_EN + int64_t timestamp = ranging_rx_time(rx); + ind->timestamp_frac = timestamp & 0x1ff; + ind->timestamp_int = (uint32_t)(timestamp >> 9); #endif } @@ -184,10 +173,12 @@ void uwb_tx_process(struct MAC_HW_REPORT_T *tx_report) { + power_off_radio(); uwb_tx_done_ind(tx_report); } void uwb_rx_process(struct MAC_HW_REPORT_T *rx_report) { + power_off_radio(); uwb_rx_done_ind(rx_report); } -- Gitblit v1.9.3