Extract test LED specific code to test_led.[ch]
This commit is contained in:
@@ -2,16 +2,7 @@
|
|||||||
#include "init_clock.h"
|
#include "init_clock.h"
|
||||||
#include "fsl_port.h"
|
#include "fsl_port.h"
|
||||||
#include "key_matrix.h"
|
#include "key_matrix.h"
|
||||||
|
#include "test_led.h"
|
||||||
#define TEST_LED_GPIO GPIOA
|
|
||||||
#define TEST_LED_PORT PORTA
|
|
||||||
#define TEST_LED_CLOCK kCLOCK_PortA
|
|
||||||
#define TEST_LED_PIN 12
|
|
||||||
|
|
||||||
#define TEST_LED_INIT(output) GPIO_PinInit(TEST_LED_GPIO, TEST_LED_PIN, \
|
|
||||||
&(gpio_pin_config_t){kGPIO_DigitalOutput, (output)})
|
|
||||||
#define TEST_LED_ON() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
|
||||||
#define TEST_LED_OFF() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
|
||||||
|
|
||||||
#define KEYBOARD_MATRIX_COLS_NUM 7
|
#define KEYBOARD_MATRIX_COLS_NUM 7
|
||||||
#define KEYBOARD_MATRIX_ROWS_NUM 5
|
#define KEYBOARD_MATRIX_ROWS_NUM 5
|
||||||
@@ -39,9 +30,7 @@ key_matrix_t keyMatrix = {
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
CLOCK_EnableClock(TEST_LED_CLOCK);
|
InitTestLed();
|
||||||
PORT_SetPinMux(TEST_LED_PORT, TEST_LED_PIN, kPORT_MuxAsGpio);
|
|
||||||
TEST_LED_INIT(1);
|
|
||||||
InitClock();
|
InitClock();
|
||||||
|
|
||||||
KeyMatrix_Init(&keyMatrix);
|
KeyMatrix_Init(&keyMatrix);
|
||||||
|
|||||||
9
left/src/test_led.c
Normal file
9
left/src/test_led.c
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "test_led.h"
|
||||||
|
#include "fsl_port.h"
|
||||||
|
|
||||||
|
extern void InitTestLed()
|
||||||
|
{
|
||||||
|
CLOCK_EnableClock(TEST_LED_CLOCK);
|
||||||
|
PORT_SetPinMux(TEST_LED_PORT, TEST_LED_PIN, kPORT_MuxAsGpio);
|
||||||
|
GPIO_PinInit(TEST_LED_GPIO, TEST_LED_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 0});
|
||||||
|
}
|
||||||
26
left/src/test_led.h
Normal file
26
left/src/test_led.h
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#ifndef __TEST_LED_H__
|
||||||
|
#define __TEST_LED_H__
|
||||||
|
|
||||||
|
// Includes:
|
||||||
|
|
||||||
|
#include "fsl_gpio.h"
|
||||||
|
|
||||||
|
// Macros:
|
||||||
|
|
||||||
|
#define LOGIC_LED_ON 0U
|
||||||
|
#define LOGIC_LED_OFF 1U
|
||||||
|
|
||||||
|
#define TEST_LED_GPIO GPIOA
|
||||||
|
#define TEST_LED_PORT PORTA
|
||||||
|
#define TEST_LED_CLOCK kCLOCK_PortA
|
||||||
|
#define TEST_LED_PIN 12
|
||||||
|
|
||||||
|
#define TEST_LED_ON() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||||
|
#define TEST_LED_OFF() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_PIN)
|
||||||
|
#define TEST_LED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||||
|
|
||||||
|
// Functions:
|
||||||
|
|
||||||
|
extern void InitTestLed();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user