aboutsummaryrefslogtreecommitdiff
path: root/atmel-samd
diff options
context:
space:
mode:
authorRadomir Dopieralski <deshipu@users.noreply.github.com>2017-10-22 04:39:20 +0200
committerDan Halbert <halbert@halwitz.org>2017-10-21 22:39:20 -0400
commit9bcc1057ca3796e8ba8aa9805cf9d140ee7f51d3 (patch)
tree8f715415852bcb8a7941bee4f7c4905d4e01e36c /atmel-samd
parenta1409d1432ea4280293749b3a2bb5c2278fda609 (diff)
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.
Diffstat (limited to 'atmel-samd')
-rw-r--r--atmel-samd/main.c4
1 files changed, 4 insertions, 0 deletions
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.