From 07d3633e5d6905272d19da645c767b7267f27a8f Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 27 二月 2025 14:04:06 +0800 Subject: [PATCH] 2.14,加入假休眠机制,休眠时功耗100-200ua --- Src/application/dw_app.c | 35 ++++++++++++++++++++++++++++++----- 1 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Src/application/dw_app.c b/Src/application/dw_app.c index 226c813..5a40c87 100644 --- a/Src/application/dw_app.c +++ b/Src/application/dw_app.c @@ -81,7 +81,7 @@ SINGLEPOLL, }tag_state=STARTPOLL; dwt_config_t config = { - 2, /* Channel number. */ + 5, /* Channel number. */ DWT_PRF_64M, /* Pulse repetition frequency. */ DWT_PLEN_128, /* Preamble length. */ DWT_PAC8, /* Preamble acquisition chunk size. Used in RX only. */ @@ -189,6 +189,29 @@ /* 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. */ //设置接收超时时间 +} +uint8_t uwb_onflag=1; +void UWB_RXON() +{ + if(!g_com_map[MODBUS_MODE]) + { + Dw1000_Init(); + uwb_onflag=1; + g_com_map[UWB_ONFLAG]=uwb_onflag; + save_com_map_to_flash(); + } +} +void UWB_RXOFF() +{ + if(!g_com_map[MODBUS_MODE]) + { + 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(); + uwb_onflag=0; + g_com_map[UWB_ONFLAG]=uwb_onflag; + save_com_map_to_flash(); + } } void Dw1000_App_Init(void) { @@ -1218,10 +1241,10 @@ IdleTask(); }; - if(status_reg==0xffffffff) - { - NVIC_SystemReset(); - } +// if(status_reg==0xffffffff) +// { +// NVIC_SystemReset(); +// } if (status_reg & SYS_STATUS_RXFCG)//如果成功接收 { dwt_write32bitreg(SYS_STATUS_ID, SYS_STATUS_RXFCG | SYS_STATUS_TXFRS);//清楚寄存器标志位 @@ -1270,6 +1293,7 @@ } u32 id,error_times=0; extern float Height; +extern IWDG_HandleTypeDef hiwdg; void Tag_App(void)//发送模式(TAG标签) { @@ -1291,6 +1315,7 @@ // } Dw1000_Init(); error_times = 0; + HAL_IWDG_Refresh(&hiwdg); switch(tag_state) { case REGPOLL: -- Gitblit v1.9.3