From e3a121f0d8add629f014b2eef5032cb0574d43ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Fri, 10 Nov 2017 23:42:45 +0100 Subject: [PATCH] Make pressing the reset button revert to the factory preset. --- right/src/peripherals/reset_button.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/right/src/peripherals/reset_button.c b/right/src/peripherals/reset_button.c index ba12259..d9e3a87 100644 --- a/right/src/peripherals/reset_button.c +++ b/right/src/peripherals/reset_button.c @@ -1,9 +1,19 @@ #include "reset_button.h" #include "fsl_port.h" +#include "bootloader/wormhole.h" + +void RESET_BUTTON_IRQ_HANDLER(void) +{ + Wormhole.magicNumber = WORMHOLE_MAGIC_NUMBER; + Wormhole.enumerationMode = EnumerationMode_NormalKeyboard; + NVIC_SystemReset(); +} void InitResetButton(void) { CLOCK_EnableClock(RESET_BUTTON_CLOCK); + PORT_SetPinInterruptConfig(RESET_BUTTON_PORT, RESET_BUTTON_PIN, kPORT_InterruptFallingEdge); + EnableIRQ(RESET_BUTTON_IRQ); PORT_SetPinConfig(RESET_BUTTON_PORT, RESET_BUTTON_PIN, &(port_pin_config_t){.pullSelect=kPORT_PullUp, .mux=kPORT_MuxAsGpio}); }