From 9bcc1057ca3796e8ba8aa9805cf9d140ee7f51d3 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Sun, 22 Oct 2017 04:39:20 +0200 Subject: Gracefully reset the gamepad module (#356) If a soft reset happens while the gamepad module is scanning for button presses, there is a moment when the pins get de-initialized, but the gamepad module is still trying to read them, which ends in a crash. We can avoid it by disabling scanning on reset. --- atmel-samd/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'atmel-samd') diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 79b5604e8..7bc4a87ed 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -61,6 +61,7 @@ #include "common-hal/pulseio/PWMOut.h" #include "common-hal/touchio/TouchIn.h" #include "common-hal/usb_hid/__init__.h" +#include "shared-module/gamepad/__init__.h" #include "autoreload.h" #include "flash_api.h" @@ -202,6 +203,9 @@ void reset_samd21(void) { pwmout_reset(); analogin_reset(); +#ifdef CIRCUITPY_GAMEPAD_TICKS + gamepad_reset(); +#endif // TODO: move this to analogout_reset() // Wait for the DAC to sync then reset. -- cgit v1.2.3