From df800c357dd4680da31bb89b6394c455daaaaf11 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Mon, 22 Jan 2024 15:55:22 +0800 Subject: [PATCH] wdt ok --- app/app.uvoptx | 96 +++++++++++++++++++++++++++---------------------- app/app.uvprojx | 10 ++++++ app/config/sdk_config.h | 4 +-- app/main.c | 12 +++---- app/src/board.c | 16 ++++++++- app/src/board.h | 5 ++- 6 files changed, 90 insertions(+), 53 deletions(-) diff --git a/app/app.uvoptx b/app/app.uvoptx index b13ae18..ce98612 100644 --- a/app/app.uvoptx +++ b/app/app.uvoptx @@ -835,6 +835,18 @@ 0 0 + + 7 + 36 + 1 + 0 + 0 + 0 + ..\sdk\modules\nrfx\drivers\src\nrfx_wdt.c + nrfx_wdt.c + 0 + 0 + @@ -845,7 +857,7 @@ 0 8 - 36 + 37 1 0 0 @@ -857,7 +869,7 @@ 8 - 37 + 38 1 0 0 @@ -869,7 +881,7 @@ 8 - 38 + 39 1 0 0 @@ -881,7 +893,7 @@ 8 - 39 + 40 1 0 0 @@ -893,7 +905,7 @@ 8 - 40 + 41 1 0 0 @@ -905,7 +917,7 @@ 8 - 41 + 42 1 0 0 @@ -917,7 +929,7 @@ 8 - 42 + 43 1 0 0 @@ -929,7 +941,7 @@ 8 - 43 + 44 1 0 0 @@ -941,7 +953,7 @@ 8 - 44 + 45 1 0 0 @@ -953,7 +965,7 @@ 8 - 45 + 46 1 0 0 @@ -965,7 +977,7 @@ 8 - 46 + 47 1 0 0 @@ -977,7 +989,7 @@ 8 - 47 + 48 1 0 0 @@ -989,7 +1001,7 @@ 8 - 48 + 49 1 0 0 @@ -1001,7 +1013,7 @@ 8 - 49 + 50 1 0 0 @@ -1013,7 +1025,7 @@ 8 - 50 + 51 1 0 0 @@ -1025,7 +1037,7 @@ 8 - 51 + 52 1 0 0 @@ -1037,7 +1049,7 @@ 8 - 52 + 53 1 0 0 @@ -1049,7 +1061,7 @@ 8 - 53 + 54 1 0 0 @@ -1061,7 +1073,7 @@ 8 - 54 + 55 1 0 0 @@ -1073,7 +1085,7 @@ 8 - 55 + 56 1 0 0 @@ -1085,7 +1097,7 @@ 8 - 56 + 57 1 0 0 @@ -1097,7 +1109,7 @@ 8 - 57 + 58 1 0 0 @@ -1109,7 +1121,7 @@ 8 - 58 + 59 1 0 0 @@ -1121,7 +1133,7 @@ 8 - 59 + 60 1 0 0 @@ -1133,7 +1145,7 @@ 8 - 60 + 61 1 0 0 @@ -1145,7 +1157,7 @@ 8 - 61 + 62 1 0 0 @@ -1157,7 +1169,7 @@ 8 - 62 + 63 1 0 0 @@ -1177,7 +1189,7 @@ 0 9 - 63 + 64 1 0 0 @@ -1189,7 +1201,7 @@ 9 - 64 + 65 1 0 0 @@ -1201,7 +1213,7 @@ 9 - 65 + 66 1 0 0 @@ -1213,7 +1225,7 @@ 9 - 66 + 67 1 0 0 @@ -1225,7 +1237,7 @@ 9 - 67 + 68 1 0 0 @@ -1237,7 +1249,7 @@ 9 - 68 + 69 1 0 0 @@ -1257,7 +1269,7 @@ 0 10 - 69 + 70 1 0 0 @@ -1269,7 +1281,7 @@ 10 - 70 + 71 1 0 0 @@ -1281,7 +1293,7 @@ 10 - 71 + 72 1 0 0 @@ -1301,7 +1313,7 @@ 0 11 - 72 + 73 1 0 0 @@ -1313,7 +1325,7 @@ 11 - 73 + 74 1 0 0 @@ -1325,7 +1337,7 @@ 11 - 74 + 75 1 0 0 @@ -1345,7 +1357,7 @@ 0 12 - 75 + 76 1 0 0 @@ -1365,7 +1377,7 @@ 0 13 - 76 + 77 1 0 0 @@ -1377,7 +1389,7 @@ 13 - 77 + 78 1 0 0 diff --git a/app/app.uvprojx b/app/app.uvprojx index 17b1940..445f198 100644 --- a/app/app.uvprojx +++ b/app/app.uvprojx @@ -1659,6 +1659,11 @@ 1 ..\sdk\modules\nrfx\drivers\src\nrfx_pwm.c + + nrfx_wdt.c + 1 + ..\sdk\modules\nrfx\drivers\src\nrfx_wdt.c + @@ -5398,6 +5403,11 @@ 1 ..\sdk\modules\nrfx\drivers\src\nrfx_pwm.c + + nrfx_wdt.c + 1 + ..\sdk\modules\nrfx\drivers\src\nrfx_wdt.c + diff --git a/app/config/sdk_config.h b/app/config/sdk_config.h index 883d8c1..5da286a 100644 --- a/app/config/sdk_config.h +++ b/app/config/sdk_config.h @@ -6113,7 +6113,7 @@ // WDT_ENABLED - nrf_drv_wdt - WDT peripheral driver - legacy layer //========================================================== #ifndef WDT_ENABLED -#define WDT_ENABLED 0 +#define WDT_ENABLED 1 #endif // WDT_CONFIG_BEHAVIOUR - WDT behavior in CPU SLEEP or HALT mode @@ -6130,7 +6130,7 @@ #ifndef WDT_CONFIG_RELOAD_VALUE -#define WDT_CONFIG_RELOAD_VALUE 2000 +#define WDT_CONFIG_RELOAD_VALUE 5000 #endif // WDT_CONFIG_IRQ_PRIORITY - Interrupt priority diff --git a/app/main.c b/app/main.c index f845f4a..411910d 100644 --- a/app/main.c +++ b/app/main.c @@ -1,5 +1,8 @@ #if 1 #include "board.h" +#include "diskio_blkdev.h" +#include "ff.h" +#include "nrf_block_dev_sdc.h" #include "nrf_delay.h" #include "project_cfg.h" #include "sys.h" @@ -7,10 +10,6 @@ #include "zble_module.h" #include "zdatachannel_service.h" -#include "ff.h" -#include "diskio_blkdev.h" -#include "nrf_block_dev_sdc.h" - #if 0 void qingfengboard_test(void) { // 测试LED @@ -92,8 +91,6 @@ static void board_init() { // board_i2c_init(); } - - int main(void) { zsys_init(); NRF_LOG_INFO("compile time :%s", __TIME__); @@ -114,7 +111,8 @@ int main(void) { // ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL)); // fatfs_test_write(); - pwm_trigger(); + // pwm_trigger(); + wd_init(); zble_module_start_adv(); zsys_loop(); diff --git a/app/src/board.c b/app/src/board.c index 03f79d4..57b550a 100644 --- a/app/src/board.c +++ b/app/src/board.c @@ -8,6 +8,7 @@ #include "ff.h" #include "nrf_block_dev_sdc.h" #include "nrf_drv_pwm.h" +#include "nrf_drv_wdt.h" static int16_t adc_channel_read_val(uint16_t channel) { nrf_saadc_value_t value; @@ -330,4 +331,17 @@ void fatfs_test_write() { (void)f_close(&file); return; -} \ No newline at end of file +} +nrf_drv_wdt_channel_id m_channel_id; + +void wd_init() { + //WDT_CONFIG_RELOAD_VALUE 修改这个数值修改喂狗周期,单位ms + nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; + config.reload_value = WDT_CONFIG_RELOAD_VALUE; + ret_code_t err_code = nrf_drv_wdt_init(&config, NULL); + ZERROR_CHECK(err_code); + err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); + ZERROR_CHECK(err_code); + nrf_drv_wdt_enable(); +} +void wd_feed() { nrfx_wdt_feed(); } \ No newline at end of file diff --git a/app/src/board.h b/app/src/board.h index 331f855..e36e8fb 100644 --- a/app/src/board.h +++ b/app/src/board.h @@ -61,4 +61,7 @@ void screen_spi_translate_onebyte(); *******************************************************************************/ void fatfs_init(); void fatfs_test_write(); -void pwm_trigger(); \ No newline at end of file +void pwm_trigger(); + +void wd_init(); +void wd_feed(); \ No newline at end of file