Call KeyMatrix_ScanRow() from an LPTMR interrupt for the left half. Remove KeyMatrix_Scan()
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
#include "test_led.h"
|
#include "test_led.h"
|
||||||
#include "init_peripherals.h"
|
#include "init_peripherals.h"
|
||||||
|
|
||||||
static uint32_t prevWatchdogCounter = 0;
|
//static uint32_t prevWatchdogCounter = 0;
|
||||||
uint32_t I2cWatchdog_RecoveryCounter;
|
uint32_t I2cWatchdog_RecoveryCounter;
|
||||||
volatile uint32_t I2cWatchdog_WatchCounter;
|
volatile uint32_t I2cWatchdog_WatchCounter;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ void InitI2cWatchdog(void)
|
|||||||
EnableIRQ(LPTMR0_IRQn);
|
EnableIRQ(LPTMR0_IRQn);
|
||||||
LPTMR_StartTimer(LPTMR0);
|
LPTMR_StartTimer(LPTMR0);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
void I2C_WATCHDOG_LPTMR_HANDLER(void)
|
void I2C_WATCHDOG_LPTMR_HANDLER(void)
|
||||||
{
|
{
|
||||||
TEST_LED_TOGGLE();
|
TEST_LED_TOGGLE();
|
||||||
@@ -35,3 +35,4 @@ void I2C_WATCHDOG_LPTMR_HANDLER(void)
|
|||||||
|
|
||||||
LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
|
LPTMR_ClearStatusFlags(LPTMR0, kLPTMR_TimerCompareFlag);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "slave_protocol_handler.h"
|
#include "slave_protocol_handler.h"
|
||||||
#include "i2c_watchdog.h"
|
#include "i2c_watchdog.h"
|
||||||
#include "debug_over_spi.h"
|
#include "debug_over_spi.h"
|
||||||
|
#include "key_scanner.h"
|
||||||
|
|
||||||
i2c_slave_config_t slaveConfig;
|
i2c_slave_config_t slaveConfig;
|
||||||
i2c_slave_handle_t slaveHandle;
|
i2c_slave_handle_t slaveHandle;
|
||||||
@@ -82,6 +83,7 @@ void InitLedDriver(void)
|
|||||||
void InitPeripherals(void)
|
void InitPeripherals(void)
|
||||||
{
|
{
|
||||||
InitInterruptPriorities();
|
InitInterruptPriorities();
|
||||||
|
InitKeyScanner();
|
||||||
InitLedDriver();
|
InitLedDriver();
|
||||||
InitTestLed();
|
InitTestLed();
|
||||||
LedPwm_Init();
|
LedPwm_Init();
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ int main(void)
|
|||||||
KeyMatrix_Init(&keyMatrix);
|
KeyMatrix_Init(&keyMatrix);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
KeyMatrix_Scan(&keyMatrix);
|
// KeyMatrix_Scan(&keyMatrix);
|
||||||
__WFI();
|
__WFI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,26 +18,6 @@ void KeyMatrix_Init(key_matrix_t *keyMatrix)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyMatrix_Scan(key_matrix_t *keyMatrix)
|
|
||||||
{
|
|
||||||
uint8_t *keyState = keyMatrix->keyStates;
|
|
||||||
|
|
||||||
key_matrix_pin_t *rowEnd = keyMatrix->rows + keyMatrix->rowNum;
|
|
||||||
for (key_matrix_pin_t *row = keyMatrix->rows; row<rowEnd; row++) {
|
|
||||||
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);
|
|
||||||
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)
|
void KeyMatrix_ScanRow(key_matrix_t *keyMatrix)
|
||||||
{
|
{
|
||||||
uint8_t *keyState = keyMatrix->keyStates + keyMatrix->currentRowNum * keyMatrix->colNum;
|
uint8_t *keyState = keyMatrix->keyStates + keyMatrix->currentRowNum * keyMatrix->colNum;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
void KeyMatrix_Init(key_matrix_t *keyMatrix);
|
void KeyMatrix_Init(key_matrix_t *keyMatrix);
|
||||||
void KeyMatrix_Scan(key_matrix_t *keyMatrix);
|
|
||||||
void KeyMatrix_ScanRow(key_matrix_t *keyMatrix);
|
void KeyMatrix_ScanRow(key_matrix_t *keyMatrix);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user