diff --git a/right/src/init_peripherals.c b/right/src/init_peripherals.c index bd84feb..53e1d16 100644 --- a/right/src/init_peripherals.c +++ b/right/src/init_peripherals.c @@ -14,6 +14,7 @@ #include "eeprom.h" #include "microseconds/microseconds_pit.c" #include "timer.h" +#include "key_debouncer.h" void InitInterruptPriorities(void) { @@ -122,6 +123,7 @@ void InitPeripherals(void) #ifdef I2C_WATCHDOG InitI2cWatchdog(); #endif + InitKeyDebouncer(); EEPROM_Init(); //microseconds_init(); } diff --git a/right/src/key_debouncer.c b/right/src/key_debouncer.c new file mode 100644 index 0000000..8a85eb3 --- /dev/null +++ b/right/src/key_debouncer.c @@ -0,0 +1,32 @@ +#include "key_debouncer.h" +#include "fsl_pit.h" +#include "slot.h" +#include "module.h" +#include "key_states.h" +#include "peripherals/test_led.h" + +void PIT_KEY_DEBOUNCER_HANDLER(void) +{ + TEST_LED_TOGGLE(); + for (uint8_t slotId=0; slotIddebounceCounter < KEY_DEBOUNCER_TIMEOUT_MSEC) { + keyState->current = keyState->previous; + } else if (!keyState->previous && keyState->current) { + keyState->debounceCounter = 0; + } + if (keyState->current) { if (suppressKeys) { keyState->suppressed = true;