From 114944d512d07f1fdbfcaa13d582944e49b8961d Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期二, 24 九月 2024 15:28:16 +0800 Subject: [PATCH] 1.31,修复不能测距的bug。 --- Src/application/dw_app.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c index a2e7737..ca2246a 100644 --- a/Src/application/dw_app.c +++ b/Src/application/dw_app.c @@ -132,16 +132,18 @@ u16 tag_time_recv[TAG_NUM_IN_SYS]; u8 usart_send[300]={0x55,0xAA}; u8 battary,button; +extern uint8_t uwb_errorflag; extern uint8_t g_pairstart; void tag_sleep_configuraion(void) { dwt_configuresleep(0x940, 0x7); dwt_entersleep(); } -extern u32 id; +u32 id; void UWB_Wkup(void) { - + if(!uwb_errorflag) + { SPIx_CS_GPIO->BRR = SPIx_CS; delay_us(600); SPIx_CS_GPIO->BSRR = SPIx_CS; @@ -152,8 +154,54 @@ id = dwt_readdevid() ; if(iderror_count++>100) { - printf("UWB芯片ID错误"); +// printf("UWB芯片ID错误"); break; } } +} +} +extern u8 uwb_rx_remaintime_ms,gps_chafenlingqi; +uint8_t uwb_state; +void UWB_RXStart(u8 tims_ms) +{ + if(!uwb_errorflag) + { +// if(!HAL_GPIO_ReadPin( RADIO_NSS_GPIO_Port, RADIO_NSS_Pin)) +// { +// gps_chafenlingqi++; +// return; +// } + UWB_Wkup(); + 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), 0); + uwb_rx_remaintime_ms = tims_ms; + + 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(tims_ms*1000);//设定接收超时时间,0位没有超时时间 + dwt_rxenable(0); + uwb_state=1; + } +} +void UWB_RXON() +{ + if(!uwb_errorflag) + { + UWB_Wkup(); + 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), 0); + + + 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); + } +} +void UWB_RXOFF() +{ + if(!uwb_errorflag) + { + 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), 0); + dwt_forcetrxoff(); + dwt_entersleep(); + } } \ No newline at end of file -- Gitblit v1.9.3