1 /* 2 * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 * Copyright 2016-2017 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef _BOARD_H_ 10 #define _BOARD_H_ 11 12 #include "clock_config.h" 13 #include "fsl_common.h" 14 #include "fsl_gpio.h" 15 16 /******************************************************************************* 17 * Definitions 18 ******************************************************************************/ 19 /*! @brief The board name */ 20 #define BOARD_NAME "LPCXPRESSO54114" 21 22 #define BOARD_EXTCLKINRATE (0) 23 24 /*! @brief The UART to use for debug messages. */ 25 #define BOARD_DEBUG_UART_TYPE DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 26 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) USART0 27 #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetFreq(kCLOCK_Flexcomm0) 28 #define BOARD_DEBUG_UART_CLK_ATTACH kFRO12M_to_FLEXCOMM0 29 #define BOARD_DEBUG_UART_RST kFC0_RST_SHIFT_RSTn 30 31 #define BOARD_DEBUG_SPI_CLK_FREQ 12000000 32 33 #ifndef BOARD_DEBUG_UART_BAUDRATE 34 #define BOARD_DEBUG_UART_BAUDRATE 115200 35 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 36 37 #define BOARD_LED_RED_GPIO GPIO 38 #define BOARD_LED_RED_GPIO_PORT 0U 39 #define BOARD_LED_RED_GPIO_PIN 29U 40 #define BOARD_LED_GREEN_GPIO GPIO 41 #define BOARD_LED_GREEN_GPIO_PORT 1U 42 #define BOARD_LED_GREEN_GPIO_PIN 10U 43 #define BOARD_LED_BLUE_GPIO GPIO 44 #define BOARD_LED_BLUE_GPIO_PORT 1U 45 #define BOARD_LED_BLUE_GPIO_PIN 9U 46 47 #define BOARD_SW1_GPIO GPIO 48 #define BOARD_SW1_GPIO_PORT 0U 49 #define BOARD_SW1_GPIO_PIN 24U 50 #define BOARD_SW1_NAME "SW1" 51 #define BOARD_SW3_IRQ PIN_INT0_IRQn 52 #define BOARD_SW3_IRQ_HANDLER PIN_INT0_IRQHandler 53 54 #define BOARD_SW2_GPIO GPIO 55 #define BOARD_SW2_GPIO_PORT 0U 56 #define BOARD_SW2_GPIO_PIN 31U 57 #define BOARD_SW2_NAME "SW2" 58 #define BOARD_SW3_IRQ PIN_INT0_IRQn 59 #define BOARD_SW3_IRQ_HANDLER PIN_INT0_IRQHandler 60 61 #define BOARD_SW3_GPIO GPIO 62 #define BOARD_SW3_GPIO_PORT 0U 63 #define BOARD_SW3_GPIO_PIN 4U 64 #define BOARD_SW3_NAME "SW3" 65 #define BOARD_SW3_IRQ PIN_INT0_IRQn 66 #define BOARD_SW3_IRQ_HANDLER PIN_INT0_IRQHandler 67 #define BOARD_SW3_GPIO_PININT_INDEX 0 68 69 /* Board led color mapping */ 70 #define LOGIC_LED_ON 0U 71 #define LOGIC_LED_OFF 1U 72 73 #define LED_RED_INIT(output) \ 74 GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \ 75 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_RED */ 76 #define LED_RED_ON() \ 77 GPIO_ClearPinsOutput(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 78 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */ 79 #define LED_RED_OFF() \ 80 GPIO_SetPinsOutput(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 81 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */ 82 #define LED_RED_TOGGLE() \ 83 GPIO_TogglePinsOutput(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 84 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ 85 86 #define LED_GREEN_INIT(output) \ 87 GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \ 88 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_GREEN */ 89 #define LED_GREEN_ON() \ 90 GPIO_ClearPinsOutput(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 91 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */ 92 #define LED_GREEN_OFF() \ 93 GPIO_SetPinsOutput(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 94 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */ 95 #define LED_GREEN_TOGGLE() \ 96 GPIO_TogglePinsOutput(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 97 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 98 99 #define LED_BLUE_INIT(output) \ 100 GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \ 101 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_BLUE */ 102 #define LED_BLUE_ON() \ 103 GPIO_ClearPinsOutput(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 104 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */ 105 #define LED_BLUE_OFF() \ 106 GPIO_SetPinsOutput(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 107 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */ 108 #define LED_BLUE_TOGGLE() \ 109 GPIO_TogglePinsOutput(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 110 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 111 112 #if defined(__cplusplus) 113 extern "C" { 114 #endif /* __cplusplus */ 115 116 /******************************************************************************* 117 * API 118 ******************************************************************************/ 119 120 status_t BOARD_InitDebugConsole(void); 121 122 #if defined(__cplusplus) 123 } 124 #endif /* __cplusplus */ 125 126 #endif /* _BOARD_H_ */ 127