40 #include "nrf_bootloader_wdt.h"
42 #include "nrf_bootloader_dfu_timers.h"
43 #include "nrf_log_ctrl.h"
45 #define NRF_LOG_MODULE_NAME nrf_bootloader_wdt
50 static void wdt_feed(
void)
52 if (nrf_wdt_started())
54 for (nrf_wdt_rr_register_t i = NRF_WDT_RR0; i < NRF_WDT_RR7; i++)
56 if (nrf_wdt_reload_request_is_enabled(i))
58 nrf_wdt_reload_request_set(i);
65 static void wdt_feed_timer_handler(
void)
67 NRF_LOG_INFO(
"Internal feed");
74 nrf_wdt_event_clear(NRF_WDT_EVENT_TIMEOUT);
75 NRF_LOG_FINAL_FLUSH();
78 #define MAX_FLASH_OP_TIME_TICKS 3200
82 static bool initialized =
false;
89 if (nrf_wdt_started())
91 uint32_t wdt_ticks = nrf_wdt_reload_value_get();
93 NRF_LOG_INFO(
"WDT enabled CRV:%d ticks", wdt_ticks);
97 NRF_BOOTLOADER_MIN_TIMEOUT_TICKS);
100 reduced_timeout_ticks = (reduced_timeout_ticks > (1<<20))? (1<<20) : reduced_timeout_ticks;
101 NRF_LOG_INFO(
"Starting a timer (%d ticks) for feeding watchdog.", reduced_timeout_ticks);
102 nrf_bootloader_wdt_feed_timer_start(reduced_timeout_ticks, wdt_feed_timer_handler);
108 NVIC_EnableIRQ(WDT_IRQn);
112 NRF_LOG_INFO(
"WDT is not enabled");
120 if (nrf_wdt_started())
void WDT_IRQHandler(void)
void nrf_bootloader_wdt_init(void)
void nrf_bootloader_wdt_feed(void)
#define MAX_FLASH_OP_TIME_TICKS
NRF_LOG_MODULE_REGISTER()