zhyinch
2022-09-21 0fa736d6e3dc2e086b9f75ba1985e6d6ca000d2a
Src/application/dw_app.c
@@ -48,7 +48,7 @@
#define POLL_TX_TO_RESP_RX_DLY_UUS 150
/* This is the delay from Frame RX timestamp to TX reply timestamp used for calculating/setting the DW1000's delayed TX function. This includes the
 * frame length of approximately 2.66 ms with above configuration. */
#define RESP_RX_TO_FINAL_TX_DLY_UUS 410
#define RESP_RX_TO_FINAL_TX_DLY_UUS 2410
/* Receive response timeout. See NOTE 5 below. */
#define RESP_RX_TIMEOUT_UUS 600
@@ -78,7 +78,7 @@
   NEARPOLL,
}tag_state=GETNEARMSG;
static dwt_config_t config = {
   5,               /* Channel number. */
   2,               /* Channel number. */
   DWT_PRF_64M,     /* Pulse repetition frequency. */
   DWT_PLEN_128,    /* Preamble length. */
   DWT_PAC8,        /* Preamble acquisition chunk size. Used in RX only. */
@@ -297,6 +297,27 @@
int16_t offset=2700;
extern int16_t g_commap_antdelay;
u8 motor_state,rec_remotepara_state,rec_remotepara[80];
 double firstpath_power,firstpath_power2, rx_power,rec_firstpath_power;
  double f1, f2, r1, r2;
uint16_t F1,F2,F3,N,C;
double B = 131072;
double A = 121.74;
double min_power;
 dwt_rxdiag_t d1;
double LOS(dwt_rxdiag_t *dia) {
     F1 = dia->firstPathAmp1;
     F2 = dia->firstPathAmp2;
     F3 = dia->firstPathAmp3;
     N = dia->rxPreamCount;
     C = dia->maxGrowthCIR;
    firstpath_power=10* log10((F1*F1+F2*F2+F3*F3)/(N*N))-A;
    rx_power=10*log10(C*B/(N*N))-A;
 //   min_power =  - 10 * log10((F1 *F1 + F2 * F2 + F3 * F3) / (C *B));
    return min_power;
  }
void NearPoll(void)
{
   
@@ -438,7 +459,9 @@
                           dwt_writetxfctrl(28+nearbase_num*4, 0);//设定发送数据长度
                           flag_getresponse=1;
                           memcpy(&rec_tagpos_binary,&rx_buffer[NEARMSG_EMPTYSLOTPOS_INDEX],4);
                           dwt_readdiagnostics(&d1);
                                    LOS(&d1);
                                    tx_near_msg[TAGRXPOWER_IDX] = -(int)firstpath_power;
                        
                           //时间同步
                           ancsync_time=((sync_timer)*1000+tmp_time);