Extract test LED macros to test_led.h
This commit is contained in:
@@ -225,6 +225,11 @@
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/slot.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>sources/test_led.h</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/test_led.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>sources/usb_api.h</name>
|
||||
<type>1</type>
|
||||
|
||||
@@ -31,36 +31,12 @@
|
||||
#ifndef _BOARD_H_
|
||||
#define _BOARD_H_
|
||||
|
||||
#include "clock_config.h"
|
||||
#include "fsl_gpio.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Define the port interrupt number for the board switches */
|
||||
|
||||
#define BOARD_SW2_GPIO GPIOC
|
||||
#define BOARD_SW2_PORT PORTC
|
||||
#define BOARD_SW2_GPIO_PIN 1
|
||||
#define BOARD_SW2_IRQ PORTC_IRQn
|
||||
#define BOARD_SW2_IRQ_HANDLER PORTC_IRQHandler
|
||||
|
||||
/* Board led color mapping */
|
||||
#define LOGIC_LED_ON 0U
|
||||
#define LOGIC_LED_OFF 1U
|
||||
#define BOARD_LED_RED_GPIO GPIOD
|
||||
#define BOARD_LED_RED_GPIO_PORT PORTD
|
||||
#define BOARD_LED_RED_GPIO_PIN 7U
|
||||
|
||||
#define LED_RED_INIT(output) \
|
||||
GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PIN, \
|
||||
&(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_RED */
|
||||
#define LED_RED_ON() \
|
||||
GPIO_ClearPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */
|
||||
#define LED_RED_OFF() \
|
||||
GPIO_SetPinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */
|
||||
#define LED_RED_TOGGLE() \
|
||||
GPIO_TogglePinsOutput(BOARD_LED_RED_GPIO, 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */
|
||||
|
||||
#endif /* _BOARD_H_ */
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "fsl_common.h"
|
||||
#include "fsl_port.h"
|
||||
#include "board.h"
|
||||
#include "test_led.h"
|
||||
|
||||
void BOARD_InitPins(void)
|
||||
{
|
||||
@@ -54,11 +55,11 @@ void BOARD_InitPins(void)
|
||||
|
||||
// Initialize LEDs.
|
||||
|
||||
PORT_SetPinMux(BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, kPORT_MuxAsGpio);
|
||||
PORT_SetPinMux(TEST_LED_GPIO_PORT, TEST_LED_GPIO_PIN, kPORT_MuxAsGpio);
|
||||
|
||||
LED_RED_INIT(LOGIC_LED_ON);
|
||||
TEST_RED_INIT(LOGIC_LED_ON);
|
||||
|
||||
GPIO_SetPinsOutput(BOARD_LED_RED_GPIO, 1 << BOARD_LED_RED_GPIO_PIN);
|
||||
GPIO_SetPinsOutput(TEST_LED_GPIO, 1 << TEST_LED_GPIO_PIN);
|
||||
|
||||
// Initialize I2C.
|
||||
|
||||
|
||||
23
right/test_led.h
Normal file
23
right/test_led.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#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 GPIOD
|
||||
#define TEST_LED_GPIO_PORT PORTD
|
||||
#define TEST_LED_GPIO_PIN 7U
|
||||
|
||||
#define TEST_RED_INIT(output) GPIO_PinInit(TEST_LED_GPIO, TEST_LED_GPIO_PIN, \
|
||||
&(gpio_pin_config_t){kGPIO_DigitalOutput, (output)})
|
||||
#define TEST_RED_ON() GPIO_ClearPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
#define TEST_RED_OFF() GPIO_SetPinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
#define TEST_RED_TOGGLE() GPIO_TogglePinsOutput(TEST_LED_GPIO, 1U << TEST_LED_GPIO_PIN)
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "include/board/board.h"
|
||||
#include "usb_composite_device.h"
|
||||
#include "usb_interface_generic_hid.h"
|
||||
#include "test_led.h"
|
||||
|
||||
static usb_device_endpoint_struct_t UsbGenericHidEndpoints[USB_GENERIC_HID_ENDPOINT_COUNT] =
|
||||
{
|
||||
@@ -66,10 +67,10 @@ usb_status_t UsbGenericHidCallback(class_handle_t handle, uint32_t event, void *
|
||||
|
||||
switch (command) {
|
||||
case '0':
|
||||
LED_RED_ON();
|
||||
TEST_RED_ON();
|
||||
break;
|
||||
case '1':
|
||||
LED_RED_OFF();
|
||||
TEST_RED_OFF();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user