From fe36f37716c6962356c16842a382b8593c71fddb Mon Sep 17 00:00:00 2001 From: schneider <schneider@blinkenlichts.net> Date: Fri, 30 Oct 2020 23:15:54 +0100 Subject: [PATCH] fix(usb): Reset the watchdog while perfoming MSC operations The MSC interrupts can come in back to back, effectively blocking the FreeRTOS timer task which resets the watchdog. This simple fix simply resets the watchdog when performing an MSC read or write. --- epicardium/modules/usb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/epicardium/modules/usb.c b/epicardium/modules/usb.c index 1e23c99cf..a58e7d270 100644 --- a/epicardium/modules/usb.c +++ b/epicardium/modules/usb.c @@ -24,6 +24,9 @@ #include "mx25lba.h" #include "msc.h" +#include "mxc_sys.h" +#include "wdt.h" + /* memory access callbacks for the mass storage (FLASH) device */ static int mscmem_init(); static uint32_t mscmem_size(void); @@ -96,6 +99,9 @@ static uint32_t mscmem_size(void) static int mscmem_read(uint32_t lba, uint8_t *buffer) { + /* Reset the watchdog as this interrupt might be + * firing back to back for a few seconds. */ + WDT_ResetTimer(MXC_WDT0); return mx25_read(lba, buffer); } @@ -105,6 +111,9 @@ static int mscmem_write(uint32_t lba, uint8_t *buffer) //bootloader_dirty(); } dirty = 2; + /* Reset the watchdog as this interrupt might be + * firing back to back for a few seconds. */ + WDT_ResetTimer(MXC_WDT0); return mx25_write(lba, buffer); } -- GitLab