diff --git a/right/src/init_peripherals.c b/right/src/init_peripherals.c index 35f34e2..8294e02 100644 --- a/right/src/init_peripherals.c +++ b/right/src/init_peripherals.c @@ -65,7 +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(I2C_MAIN_BUS_IRQ_ID, 4); NVIC_SetPriority(USB_IRQ_ID, 4); } diff --git a/right/src/key_scanner.c b/right/src/key_scanner.c deleted file mode 100644 index e2d10bd..0000000 --- a/right/src/key_scanner.c +++ /dev/null @@ -1,22 +0,0 @@ -#include "fsl_pit.h" -#include "key_scanner.h" - -uint32_t KeyScannerCounter; - -void PIT_KEY_SCANNER_HANDLER(void) -{ - KeyMatrix_ScanRow(&RightKeyMatrix); - KeyScannerCounter++; - PIT_ClearStatusFlags(PIT, PIT_KEY_SCANNER_CHANNEL, PIT_TFLG_TIF_MASK); -} - -void InitKeyScanner(void) -{ - pit_config_t pitConfig; - PIT_GetDefaultConfig(&pitConfig); - PIT_Init(PIT, &pitConfig); - PIT_SetTimerPeriod(PIT, PIT_KEY_SCANNER_CHANNEL, USEC_TO_COUNT(KEY_SCANNER_INTERVAL_USEC, PIT_SOURCE_CLOCK)); - PIT_EnableInterrupts(PIT, PIT_KEY_SCANNER_CHANNEL, kPIT_TimerInterruptEnable); - EnableIRQ(PIT_KEY_SCANNER_IRQ_ID); - PIT_StartTimer(PIT, PIT_KEY_SCANNER_CHANNEL); -} diff --git a/right/src/key_scanner.h b/right/src/key_scanner.h deleted file mode 100644 index f239818..0000000 --- a/right/src/key_scanner.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __KEY_SCANNER_H__ -#define __KEY_SCANNER_H__ - -// Includes: - - #include "peripherals/pit.h" - #include "right_key_matrix.h" - -// Macros: - - #define KEY_SCANNER_INTERVAL_USEC (1000 / RIGHT_KEY_MATRIX_ROWS_NUM) - -// Variables: - - extern uint32_t KeyScannerCounter; - -// Functions: - - void InitKeyScanner(void); - -#endif diff --git a/right/src/main.c b/right/src/main.c index c8918cf..95c494e 100644 --- a/right/src/main.c +++ b/right/src/main.c @@ -6,7 +6,7 @@ #include "bus_pal_hardware.h" #include "command.h" #include "eeprom.h" -#include "key_scanner.h" +#include "right_key_matrix.h" #include "usb_commands/usb_command_apply_config.h" #include "peripherals/reset_button.h" #include "config_parser/config_globals.h" @@ -44,7 +44,6 @@ int main(void) } else { InitSlaveScheduler(); KeyMatrix_Init(&RightKeyMatrix); - InitKeyScanner(); InitUsb(); while (1) { @@ -52,6 +51,8 @@ int main(void) UsbCommand_ApplyConfig(); IsConfigInitialized = true; } + KeyMatrix_ScanRow(&RightKeyMatrix); + ++MatrixScanCounter; UpdateUsbReports(); __WFI(); } diff --git a/right/src/peripherals/pit.h b/right/src/peripherals/pit.h index 0b22720..e720da8 100644 --- a/right/src/peripherals/pit.h +++ b/right/src/peripherals/pit.h @@ -17,8 +17,4 @@ #define PIT_TIMER_IRQ_ID PIT1_IRQn #define PIT_TIMER_CHANNEL kPIT_Chnl_1 - #define PIT_KEY_SCANNER_HANDLER PIT2_IRQHandler - #define PIT_KEY_SCANNER_IRQ_ID PIT2_IRQn - #define PIT_KEY_SCANNER_CHANNEL kPIT_Chnl_2 - #endif diff --git a/right/src/right_key_matrix.c b/right/src/right_key_matrix.c index e9786b0..4a0fd2f 100644 --- a/right/src/right_key_matrix.c +++ b/right/src/right_key_matrix.c @@ -1,5 +1,7 @@ #include "right_key_matrix.h" +uint32_t MatrixScanCounter; + key_matrix_t RightKeyMatrix = { .colNum = RIGHT_KEY_MATRIX_COLS_NUM, .rowNum = RIGHT_KEY_MATRIX_ROWS_NUM, diff --git a/right/src/right_key_matrix.h b/right/src/right_key_matrix.h index fe4b84d..8fba355 100644 --- a/right/src/right_key_matrix.h +++ b/right/src/right_key_matrix.h @@ -14,5 +14,6 @@ // Variables: extern key_matrix_t RightKeyMatrix; + extern uint32_t MatrixScanCounter; #endif diff --git a/right/src/usb_commands/usb_command_get_debug_buffer.c b/right/src/usb_commands/usb_command_get_debug_buffer.c index 92d0073..2347594 100644 --- a/right/src/usb_commands/usb_command_get_debug_buffer.c +++ b/right/src/usb_commands/usb_command_get_debug_buffer.c @@ -5,7 +5,7 @@ #include "i2c_watchdog.h" #include "buffer.h" #include "timer.h" -#include "key_scanner.h" +#include "right_key_matrix.h" #include "usb_report_updater.h" #include "usb_interfaces/usb_interface_basic_keyboard.h" #include "usb_interfaces/usb_interface_media_keyboard.h" @@ -20,7 +20,7 @@ void UsbCommand_GetDebugBuffer(void) SetDebugBufferUint32(5, I2cSlaveScheduler_Counter); SetDebugBufferUint32(9, I2cWatchdog_WatchCounter); SetDebugBufferUint32(13, I2cWatchdog_RecoveryCounter); - SetDebugBufferUint32(17, KeyScannerCounter); + SetDebugBufferUint32(17, MatrixScanCounter); SetDebugBufferUint32(21, UsbReportUpdateCounter); SetDebugBufferUint32(25, Timer_GetCurrentTime()); SetDebugBufferUint32(29, UsbGenericHidActionCounter);