zhyinch
2019-11-29 00485199097d2314a18da9f69fb7422a489064d6
Ô´Âë/ºËÐİå/Src/application/dw_app.c
@@ -336,7 +336,9 @@
         while(neartimout_timer<timeout&&recbase_num<nearbase_num+1)
         {
               while (!((status_reg = dwt_read32bitreg(SYS_STATUS_ID)) & (SYS_STATUS_RXFCG | SYS_STATUS_ALL_RX_ERR)))//不断查询芯片状态直到成功接收或者发生错误
               {
               {
                   if(neartimout_timer>timeout)
                        break;
               };
               if(status_reg==0xffffffff)
               {
@@ -347,6 +349,8 @@
                     dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_RXFCG | SYS_STATUS_TXFRS);//清楚寄存器标志位
                     frame_len = dwt_read32bitreg(RX_FINFO_ID) & RX_FINFO_RXFLEN_MASK;   //获得接收到的数据长度
                     dwt_readrxdata(rx_buffer, frame_len, 0);   //读取接收数据
                     dwt_setrxtimeout(DELAY_BETWEEN_TWO_FRAME_UUS+100);//设定接收超时时间,0位没有超时时间
                     dwt_rxenable(0);//打开接收
                     if (rx_buffer[MESSAGE_TYPE_IDX] == NEAR_RESPONSE&&!memcmp(&rx_buffer[TAG_ID_IDX],&dev_id,2)) //判断接收到的数据是否是response数据
                     {   u16 rec_nearbaseid,rec_nearbasepos;
                        poll_tx_ts = get_tx_timestamp_u64();                              //获得POLL发送时间T1
@@ -385,23 +389,25 @@
                           result=dwt_starttx(DWT_START_TX_DELAYED);//设定为延迟发送         
                        }else{
                           rec_nearbasepos=FindNearBasePos(rec_nearbaseid);
                           final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+rec_nearbasepos*4], resp_rx_ts);
                           final_msg_set_ts(&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos+1)*4], resp_rx_ts);
                           memcpy(&nearbase_distlist[rec_nearbasepos],&rx_buffer[DIST_IDX],4);
                           dwt_writetxdata(sizeof(tx_near_msg), tx_near_msg, 0);//将发送数据写入DW1000
                           dwt_writetxdata(28+nearbase_num*4, tx_near_msg, 0);//将发送数据写入DW1000
                           dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度
                           //dwt_writetxdata(4,&tx_near_msg[FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos+1)*4], FINAL_MSG_RESP_RX_NEARBASE_IDX+(rec_nearbasepos+1)*4);//将发送数据写入DW1000
                        }                        
                     }
                  }         
         }
            if(result==0)
         {while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))//不断查询芯片状态直到发送完成
         { };
   }
   else
   {
   dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR);
      random_delay_tim = DFT_RAND_DLY_TIM_MS;
   }
            dwt_forcetrxoff();
//            if(result==0)
//         {while (!(dwt_read32bitreg(SYS_STATUS_ID) & SYS_STATUS_TXFRS))//不断查询芯片状态直到发送完成
//         { };
//
//   }
//   else
//   {
//   dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_ALL_RX_ERR);
//   }
}
void NearAncSelect(void)
@@ -583,7 +589,7 @@
         }
}
void Anchor_RecNearPoll(u8 ancrec_nearbasepos)
void Anchor_RecNearPoll(u8 ancrec_nearbasepos) //0 mainbase  1 first near_base
{
         tmp_time=TIM3->CNT;
         memcpy(&tx_near_msg[ANCTIMEMS],&sync_timer,2);
@@ -599,8 +605,8 @@
         memcpy(&tx_near_msg[DIST_IDX], &tagdist_list[taglist_pos], 4);
         tx_near_msg[MESSAGE_TYPE_IDX]=NEAR_RESPONSE;
         dwt_writetxdata(24, tx_near_msg, 0);//写入发送数据
         dwt_writetxfctrl(24, 0);//设定发送长度
         dwt_writetxdata(17, tx_near_msg, 0);//写入发送数据
         dwt_writetxfctrl(17, 0);//设定发送长度
         result = dwt_starttx(DWT_START_TX_DELAYED | DWT_RESPONSE_EXPECTED);//延迟发送,等待接收
         battary = rx_buffer[BATTARY_IDX];
@@ -669,7 +675,7 @@
}
void Anchor_App(void)
{
   u8 send_len,nearbase_num,i;
   u8 send_len,i;
   u16 tempid;
   dwt_setrxtimeout(0);//设定接收超时时间,0位没有超时时间
   dwt_rxenable(0);//打开接收