1 /* 2 * Copyright (c) 2016, Freescale Semiconductor, Inc. 3 * Copyright 2016-2018 NXP 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 #ifndef _BOARD_H_ 9 #define _BOARD_H_ 10 11 #include "clock_config.h" 12 #include "fsl_common.h" 13 #include "fsl_gpio.h" 14 15 /******************************************************************************* 16 * Definitions 17 ******************************************************************************/ 18 /*! @brief The board name */ 19 #define BOARD_NAME "LPCXPRESSO804" 20 21 #define BOARD_EXTCLKINRATE (0) 22 23 /*! @brief The UART to use for debug messages. */ 24 #define BOARD_DEBUG_USART_TYPE kSerialPort_Uart 25 #define BOARD_DEBUG_USART_BASEADDR (uint32_t) USART0 26 #define BOARD_DEBUG_USART_INSTANCE 0U 27 #define BOARD_DEBUG_USART_CLK_FREQ CLOCK_GetMainClkFreq() 28 #define BOARD_DEBUG_USART_CLK_ATTACH kUART0_Clk_From_MainClk 29 #define BOARD_DEBUG_USART_RST kUART0_RST_N_SHIFT_RSTn 30 #define BOARD_USART_IRQ USART0_IRQn 31 #define BOARD_USART_IRQ_HANDLER USART0_IRQHandler 32 33 #ifndef BOARD_DEBUG_USART_BAUDRATE 34 #define BOARD_DEBUG_USART_BAUDRATE 9600 35 #endif /* BOARD_DEBUG_USART_BAUDRATE */ 36 37 /*! @brief Board led mapping */ 38 #define LOGIC_LED_ON 0U 39 #define LOGIC_LED_OFF 1U 40 41 /* LED_GREEN */ 42 #ifndef BOARD_LED_GREEN_GPIO 43 #define BOARD_LED_GREEN_GPIO GPIO 44 #endif 45 #define BOARD_LED_GREEN_GPIO_PORT 0U 46 #ifndef BOARD_LED_GREEN_GPIO_PIN 47 #define BOARD_LED_GREEN_GPIO_PIN 12U 48 #endif 49 50 #define LED_GREEN_INIT(output) \ 51 GPIO_PortInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT); \ 52 GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \ 53 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED_GREEN */ 54 #define LED_GREEN_ON() \ 55 GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 56 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN \ \ \ \ \ \ \ 57 */ 58 #define LED_GREEN_OFF() \ 59 GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 60 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN \ \ \ \ \ \ \ 61 */ 62 #define LED_GREEN_TOGGLE() \ 63 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 64 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 65 66 /* LED_BLUE */ 67 #ifndef BOARD_LED_BLUE_GPIO 68 #define BOARD_LED_BLUE_GPIO GPIO 69 #endif 70 #define BOARD_LED_BLUE_GPIO_PORT 0U 71 #ifndef BOARD_LED_BLUE_GPIO_PIN 72 #define BOARD_LED_BLUE_GPIO_PIN 11U 73 #endif 74 75 #ifndef BOARD_S1_GPIO 76 #define BOARD_S1_GPIO GPIO 77 #endif 78 #define BOARD_S1_GPIO_PORT 0U 79 #ifndef BOARD_S1_GPIO_PIN 80 #define BOARD_S1_GPIO_PIN 13U 81 #endif 82 #define BOARD_S1_NAME "S1" 83 #define BOARD_S1_IRQ PIN_INT0_IRQn 84 #define BOARD_S1_IRQ_HANDLER PIN_INT0_IRQHandler 85 86 #define LED_BLUE_INIT(output) \ 87 GPIO_PortInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT); \ 88 GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \ 89 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED_GREEN */ 90 #define LED_BLUE_ON() \ 91 GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 92 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE \ \ \ \ \ \ \ 93 */ 94 #define LED_BLUE_OFF() \ 95 GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 96 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE \ \ \ \ \ \ \ 97 */ 98 #define LED_BLUE_TOGGLE() \ 99 GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 100 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 101 102 /* LED_RED */ 103 #ifndef BOARD_LED_RED_GPIO 104 #define BOARD_LED_RED_GPIO GPIO 105 #endif 106 #define BOARD_LED_RED_GPIO_PORT 0U 107 #ifndef BOARD_LED_RED_GPIO_PIN 108 #define BOARD_LED_RED_GPIO_PIN 13U 109 #endif 110 111 #define LED_RED_INIT(output) \ 112 GPIO_PortInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT); \ 113 GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \ 114 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED_GREEN */ 115 #define LED_RED_ON() \ 116 GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 117 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED \ \ \ \ \ \ \ 118 */ 119 #define LED_RED_OFF() \ 120 GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 121 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED \ \ \ \ \ \ \ 122 */ 123 #define LED_RED_TOGGLE() \ 124 GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 125 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ 126 127 #ifndef BOARD_SW1_GPIO 128 #define BOARD_SW1_GPIO GPIO 129 #endif 130 #define BOARD_SW1_GPIO_PORT 0U 131 #ifndef BOARD_SW1_GPIO_PIN 132 #define BOARD_SW1_GPIO_PIN 13U 133 #endif 134 #define BOARD_SW1_NAME "SW1" 135 #define BOARD_SW1_IRQ PIN_INT0_IRQn 136 #define BOARD_SW1_IRQ_HANDLER PIN_INT0_IRQHandler 137 138 #if defined(__cplusplus) 139 extern "C" { 140 #endif /* __cplusplus */ 141 142 /******************************************************************************* 143 * API 144 ******************************************************************************/ 145 146 status_t BOARD_InitDebugConsole(void); 147 148 #if defined(__cplusplus) 149 } 150 #endif /* __cplusplus */ 151 152 #endif /* _BOARD_H_ */ 153