nrf: Feed the watchdog from the RTC interrupt
Feeding a watchdog from a periodic interrupt isn't the smartest thing to do (unless you have setup multi-channels) so we also allow us to express to the WDT driver whether we've arrived from an ISR or not.pull/1/head
parent
5f5b7bdb25
commit
b2273b5d22
|
@ -94,15 +94,14 @@ static ubluepy_advertise_data_t m_adv_data_eddystone_url;
|
|||
#endif // BLUETOOTH_WEBBLUETOOTH_REPL
|
||||
|
||||
int mp_hal_stdin_rx_chr(void) {
|
||||
wdt_feed();
|
||||
wdt_feed(false);
|
||||
|
||||
while (!ble_uart_enabled()) {
|
||||
// wait for connection
|
||||
wdt_feed();
|
||||
wdt_feed(false);
|
||||
}
|
||||
while (isBufferEmpty(mp_rx_ring_buffer)) {
|
||||
wdt_feed();
|
||||
;
|
||||
wdt_feed(false);
|
||||
}
|
||||
|
||||
uint8_t byte;
|
||||
|
|
|
@ -76,7 +76,7 @@ void wdt_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
void wdt_feed(void)
|
||||
void wdt_feed(bool isr)
|
||||
{
|
||||
/*
|
||||
* A WDT button allows us to feed the dog from somewhere that would
|
||||
|
@ -86,6 +86,8 @@ void wdt_feed(void)
|
|||
*/
|
||||
#if MICROPY_HW_HAS_WDT_BUTTON
|
||||
if (!button_pressed())
|
||||
#else
|
||||
if (!isr)
|
||||
#endif
|
||||
nrf_wdt_reload_request_set(0);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@
|
|||
#define __MICROPY_INCLUDED_LIB_WDT_H__
|
||||
|
||||
void wdt_init(void);
|
||||
void wdt_feed(void);
|
||||
void wdt_feed(bool isr);
|
||||
|
||||
#endif // __MICROPY_INCLUDED_LIB_WDT_H__
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "rtcounter.h"
|
||||
#include "wdt.h"
|
||||
#include "nrfx_rtc.h"
|
||||
#include "nrf_clock.h"
|
||||
|
||||
|
@ -106,6 +107,7 @@ STATIC void interrupt_handler(size_t instance_id) {
|
|||
uint32_t val = nrfx_rtc_counter_get(self->p_rtc) + config->period;
|
||||
nrfx_rtc_cc_set(self->p_rtc, 0, val, true);
|
||||
}
|
||||
wdt_feed(true);
|
||||
}
|
||||
|
||||
#if !defined(BLUETOOTH_SD)
|
||||
|
|
Loading…
Reference in New Issue