Instead of scanning the keyboard matrix from the main loop and utilizing busy loops, try to use a PIT interrupt handler to do the same thing, scanning one row per interrupt call without busy loops.

For some reason, this makes the movement of the mouse pointer very slow and makes it jump from time to time, so I ended up adding INTERRUPT_KEY_SCANNER and disabling the timer interrupt.
Also double bufferred the mouse report just like the others. Unfortunately this does not affect this issue.
This commit is contained in:
László Monda
2017-11-02 01:11:41 +01:00
parent 024f24f489
commit 00dfd96d55
15 changed files with 157 additions and 43 deletions

View File

@@ -34,6 +34,27 @@ void KeyMatrix_Scan(key_matrix_t *keyMatrix)
}
GPIO_WritePinOutput(rowGpio, rowPin, 0);
for (volatile uint32_t i=0; i<100; i++); // Wait for the new port state to settle. This avoid bogus key state detection.
for (volatile uint32_t i=0; i<100; i++); // Wait for the new port state to settle. This avoids bogus key state detection.
}
}
void KeyMatrix_ScanRow(key_matrix_t *keyMatrix)
{
uint8_t *keyState = keyMatrix->keyStates + keyMatrix->currentRowNum * keyMatrix->colNum;
key_matrix_pin_t *row = keyMatrix->rows + keyMatrix->currentRowNum;
GPIO_Type *rowGpio = row->gpio;
uint32_t rowPin = row->pin;
GPIO_WritePinOutput(rowGpio, rowPin, 1);
key_matrix_pin_t *colEnd = keyMatrix->cols + keyMatrix->colNum;
for (key_matrix_pin_t *col = keyMatrix->cols; col<colEnd; col++) {
*(keyState++) = GPIO_ReadPinInput(col->gpio, col->pin);
}
GPIO_WritePinOutput(rowGpio, rowPin, 0);
if (++keyMatrix->currentRowNum >= keyMatrix->rowNum) {
keyMatrix->currentRowNum = 0;
}
}