chen
2025-07-11 bf236e83ebac73ddc076ddee4c541da9d469b95e
keil/dw_app.c
@@ -28,6 +28,12 @@
int32_t tof_i;
uint32_t tof_i_ui;
double tof_f;
struct mk_uwb_configure
{
    uint8_t phy_work_mode; /* PHY_TX / PHY_RX / PHT_TX|PHY_RX */
    struct UWB_CONFIG_T phy_cfg;
};
extern struct mk_uwb_configure config;
extern int32_t freq_offset,freq_offset_filter; 
void SetANCTimestap(uint8_t i,uint8_t* pollrx,uint8_t* resptx,uint32_t resprx,uint8_t* distoffset,int32_t anc_clockoffset_from_MK,uint32_t polltx)  //写入时间戳信息
{
@@ -67,7 +73,7 @@
}
// ts_a - ts_b
int64_t ranging_timestamp_diff(int64_t ts_a, int64_t ts_b)
int64_t ranging_timestamp_diff1(int64_t ts_a, int64_t ts_b)
{
    if (ts_a < ts_b)
    {
@@ -88,7 +94,7 @@
         //temp_freq_offset=freq_offset_filter;//测试
         memcpy(&resp_tx_timestamp,&anc_resptx[i],4);
         memcpy(&poll_rx_timestamp,&anc_pollrx[i],4);
         treply = ranging_timestamp_diff(resp_tx_timestamp, poll_rx_timestamp);
         treply = ranging_timestamp_diff1(resp_tx_timestamp, poll_rx_timestamp);
         //基站
//    // correct antenna delay
//    treply += ranging_ant_delays_get((uint8_t)(RX_MAIN_ANT_PORT));
@@ -101,14 +107,14 @@
         memcpy(&poll_tx_timestamp,&tag_polltx[i],4);
         memcpy(&resp_rx_timestamp,&tag_resprx[i],4);
         
         tround=ranging_timestamp_diff(resp_rx_timestamp, poll_tx_timestamp);
         tround=ranging_timestamp_diff1(resp_rx_timestamp, poll_tx_timestamp);
            tround_temp=tround;
            treply_temp=treply;
            //标签
         // correct antenna delay
//    tround -= ranging_ant_delays_get(uwb_app_config.ppdu_params.rx_ant_id);
         // corrected by frequency offset
         tround = (int64_t)((double)tround * (1 - (double)anc_clockoffset[i] / ch_center_freq_map[UWB_CH_NUM]));
         tround = (int64_t)((double)tround * (1 - (double)anc_clockoffset[i] /  uwb_ch_freq_table[config.phy_cfg.ch_num]));//此处有修改
         tround_temp=tround;
         treply_temp=treply;
         tof_i = (int32_t)(tround - treply) / 2;