yincheng.zhong
2023-06-25 06629026df255b22a5fdc7aae1d926bc67e941b3
Src/application/dw_app.c
@@ -80,7 +80,7 @@
   NEARPOLL,
    SINGLEPOLL,
}tag_state=STARTPOLL;
static dwt_config_t config = {
 dwt_config_t config = {
   2,               /* Channel number. */
   DWT_PRF_64M,     /* Pulse repetition frequency. */
   DWT_PLEN_128,    /* Preamble length. */
@@ -185,7 +185,6 @@
    /* Apply default antenna delay value. See NOTE 1 below. */
    dwt_setrxantennadelay(RX_ANT_DLY);      //设置接收天线延迟
    dwt_settxantennadelay(TX_ANT_DLY);      //设置发射天线延迟
    /* Set expected response's delay and timeout. See NOTE 4 and 5 below.
     * As this example only handles one incoming frame with always the same delay and timeout, those values can be set here once for all. */
            //设置接收超时时间
@@ -1268,22 +1267,23 @@
void Tag_App(void)//发送模式(TAG标签)
{
   
   //LED0_ON;
   SPIx_CS_GPIO->BRR = SPIx_CS;
   delay_us(700);
   SPIx_CS_GPIO->BSRR = SPIx_CS;
   id =  dwt_readdevid() ;
       while (DWT_DEVICE_ID != id)
    {
      //   Dw1000_Init();
         id =  dwt_readdevid() ;
        IdleTask();
        if(error_times++>20)
        {
            printf("DW ID ERROR.\r\n");
            SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader
        }
    }
//   //LED0_ON;
//   SPIx_CS_GPIO->BRR = SPIx_CS;
//   delay_us(700);
//   SPIx_CS_GPIO->BSRR = SPIx_CS;
//   id =  dwt_readdevid() ;
//       while (DWT_DEVICE_ID != id)
//    {
//      //   Dw1000_Init();
//         id =  dwt_readdevid() ;
//        IdleTask();
//        if(error_times++>20)
//        {
//            printf("DW ID ERROR.\r\n");
//            SCB->AIRCR = 0X05FA0000|(unsigned int)0x04; //软复位回到bootloader
//        }
//    }
    Dw1000_Init();
    error_times = 0;
   switch(tag_state)
   {
@@ -1317,5 +1317,9 @@
            break;
   }
     userkey_state = !GET_USERKEY;
   dwt_entersleep();
           dwt_forcetrxoff();
       dwt_setinterrupt(  DWT_INT_RFCG | (DWT_INT_ARFE | DWT_INT_RFSL | DWT_INT_SFDT | DWT_INT_RPHE | DWT_INT_RFCE | DWT_INT_RFTO | DWT_INT_RXPTO), 1);
      dwt_setrxtimeout(0);//设定接收超时时间,0位没有超时时间
        dwt_rxenable(0);
   //dwt_entersleep();
}