From 06982df5ea44131c7ec9d108da31ad6e4ead13da Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 20 Nov 2018 15:07:42 -0800 Subject: [PATCH] Hint to GCC that a few functions are critical path Signed-off-by: Jesse Vincent --- src/kaleidoscope/hardware/ATMegaKeyboard.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp index 2feaa996..f71c2fc5 100644 --- a/src/kaleidoscope/hardware/ATMegaKeyboard.cpp +++ b/src/kaleidoscope/hardware/ATMegaKeyboard.cpp @@ -59,7 +59,7 @@ void ATMegaKeyboard::attachToHost() { UDCON &= ~_BV(DETACH); } -void ATMegaKeyboard::readMatrix(void) { +void __attribute__((optimize(3))) ATMegaKeyboard::readMatrix(void) { for (uint8_t current_row = 0; current_row < KeyboardHardware.matrix_rows; current_row++) { uint16_t mask, cols; @@ -68,6 +68,7 @@ void ATMegaKeyboard::readMatrix(void) { mask = KeyboardHardware.debounceMaskForRow(current_row); OUTPUT_TOGGLE(KeyboardHardware.matrix_row_pins[current_row]); + asm volatile("nop"); cols = (KeyboardHardware.readCols() & mask) | (KeyboardHardware.keyState_[current_row] & ~mask); OUTPUT_TOGGLE(KeyboardHardware.matrix_row_pins[current_row]); KeyboardHardware.debounceRow(cols ^ KeyboardHardware.keyState_[current_row], current_row); @@ -95,7 +96,7 @@ bool ATMegaKeyboard::isKeyswitchPressed(uint8_t keyIndex) { keyIndex % KeyboardHardware.matrix_columns); } -void ATMegaKeyboard::actOnMatrixScan() { +void __attribute__((optimize(3))) ATMegaKeyboard::actOnMatrixScan() { for (byte row = 0; row < KeyboardHardware.matrix_rows; row++) { for (byte col = 0; col < KeyboardHardware.matrix_columns; col++) { uint8_t keyState = (bitRead(KeyboardHardware.previousKeyState_[row], col) << 0) |