diff --git a/lib/agent b/lib/agent index 15df8d7..32d9635 160000 --- a/lib/agent +++ b/lib/agent @@ -1 +1 @@ -Subproject commit 15df8d71299e0547d953874d1a8d21e9147a396f +Subproject commit 32d9635b340e4dfbb12fdcfc909ec89e488ce56a diff --git a/right/src/init_peripherals.c b/right/src/init_peripherals.c index 7efcb20..8294e02 100644 --- a/right/src/init_peripherals.c +++ b/right/src/init_peripherals.c @@ -12,7 +12,6 @@ #include "init_peripherals.h" #include "eeprom.h" #include "timer.h" -#include "key_debouncer.h" #include "usb_api.h" #include "slave_scheduler.h" #include "bootloader/wormhole.h" @@ -66,8 +65,6 @@ static void initInterruptPriorities(void) NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1); NVIC_SetPriority(I2C_EEPROM_BUS_IRQ_ID, 0); NVIC_SetPriority(PIT_TIMER_IRQ_ID, 3); - NVIC_SetPriority(PIT_KEY_SCANNER_IRQ_ID, 4); - NVIC_SetPriority(PIT_KEY_DEBOUNCER_IRQ_ID, 4); NVIC_SetPriority(I2C_MAIN_BUS_IRQ_ID, 4); NVIC_SetPriority(USB_IRQ_ID, 4); } @@ -159,6 +156,5 @@ void InitPeripherals(void) TestLed_Init(); LedPwm_Init(); InitI2cWatchdog(); - InitKeyDebouncer(); EEPROM_Init(); } diff --git a/right/src/key_debouncer.c b/right/src/key_debouncer.c deleted file mode 100644 index 0ec19e7..0000000 --- a/right/src/key_debouncer.c +++ /dev/null @@ -1,32 +0,0 @@ -#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) -{ - TestLed_Toggle(); - for (uint8_t slotId=0; slotIddebounceCounter) { - keyState->current = keyState->previous; + if (keyState->debouncing) { + if ((uint8_t)(Timer_GetCurrentTime() - keyState->timestamp) > KEY_BOUNCE_TIME_MSEC) { + keyState->debouncing = false; + } else { + keyState->current = keyState->previous; + } } else if (!keyState->previous && keyState->current) { - keyState->debounceCounter = KEY_DEBOUNCER_TIMEOUT_MSEC + 1; + keyState->timestamp = Timer_GetCurrentTime(); + keyState->debouncing = true; } if (keyState->current) { diff --git a/shared/key_matrix.h b/shared/key_matrix.h index e58e12c..abe221b 100644 --- a/shared/key_matrix.h +++ b/shared/key_matrix.h @@ -9,6 +9,7 @@ // Macros: #define MAX_KEYS_IN_MATRIX 100 + #define KEY_BOUNCE_TIME_MSEC 100 // Typedefs: