Adding left/key_scanner.[ch] which I totally forgot.

This commit is contained in:
László Monda
2017-11-14 03:43:51 +01:00
parent 4c97238999
commit f63f2f9b96
2 changed files with 39 additions and 0 deletions

21
left/src/key_scanner.c Normal file
View File

@@ -0,0 +1,21 @@
#include "fsl_lptmr.h"
#include "key_scanner.h"
#include "main.h"
void KEY_SCANNER_HANDLER(void)
{
KeyMatrix_ScanRow(&keyMatrix);
LPTMR_ClearStatusFlags(KEY_SCANNER_LPTMR_BASEADDR, kLPTMR_TimerCompareFlag);
}
void InitKeyScanner(void)
{
lptmr_config_t lptmrConfig;
LPTMR_GetDefaultConfig(&lptmrConfig);
LPTMR_Init(KEY_SCANNER_LPTMR_BASEADDR, &lptmrConfig);
LPTMR_SetTimerPeriod(KEY_SCANNER_LPTMR_BASEADDR, MSEC_TO_COUNT(KEY_SCANNER_INTERVAL_MSEC, LPTMR_SOURCE_CLOCK));
LPTMR_EnableInterrupts(KEY_SCANNER_LPTMR_BASEADDR, kLPTMR_TimerInterruptEnable);
EnableIRQ(KEY_SCANNER_LPTMR_IRQ_ID);
LPTMR_StartTimer(KEY_SCANNER_LPTMR_BASEADDR);
}

18
left/src/key_scanner.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef __KEY_SCANNER_H__
#define __KEY_SCANNER_H__
// Macros:
#define LPTMR_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_LpoClk)
#define KEY_SCANNER_LPTMR_BASEADDR LPTMR0
#define KEY_SCANNER_LPTMR_IRQ_ID LPTMR0_IRQn
#define KEY_SCANNER_HANDLER LPTMR0_IRQHandler
#define KEY_SCANNER_INTERVAL_MSEC 1
// Functions:
void InitKeyScanner(void);
#endif