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 "LPCXPRESSO824MAX" 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_UART_BAUDRATE */ 36 37 /*! @brief Board led mapping */ 38 #define LOGIC_LED_ON 0U 39 #define LOGIC_LED_OFF 1U 40 41 #ifndef BOARD_SW1_GPIO 42 #define BOARD_SW1_GPIO GPIO 43 #endif 44 #define BOARD_SW1_GPIO_PORT 0U 45 #ifndef BOARD_SW1_GPIO_PIN 46 #define BOARD_SW1_GPIO_PIN 4U 47 #endif 48 #define BOARD_SW1_NAME "SW1" 49 #define BOARD_SW1_IRQ PIN_INT0_IRQn 50 #define BOARD_SW1_IRQ_HANDLER PIN_INT0_IRQHandler 51 52 /* LED_GREEN */ 53 #ifndef BOARD_LED_GREEN_GPIO 54 #define BOARD_LED_GREEN_GPIO GPIO 55 #endif 56 #define BOARD_LED_GREEN_GPIO_PORT 0U 57 #ifndef BOARD_LED_GREEN_GPIO_PIN 58 #define BOARD_LED_GREEN_GPIO_PIN 16U 59 #endif 60 61 #define LED_GREEN_INIT(output) \ 62 GPIO_PortInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT); \ 63 GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \ 64 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED_GREEN */ 65 #define LED_GREEN_ON() \ 66 GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 67 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN \ \ \ \ 68 */ 69 #define LED_GREEN_OFF() \ 70 GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 71 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN \ \ \ \ 72 */ 73 #define LED_GREEN_TOGGLE() \ 74 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 75 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 76 77 /* LED_BLUE */ 78 #ifndef BOARD_LED_BLUE_GPIO 79 #define BOARD_LED_BLUE_GPIO GPIO 80 #endif 81 #define BOARD_LED_BLUE_GPIO_PORT 0U 82 #ifndef BOARD_LED_BLUE_GPIO_PIN 83 #define BOARD_LED_BLUE_GPIO_PIN 27U 84 #endif 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 12U 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 #if defined(__cplusplus) 128 extern "C" { 129 #endif /* __cplusplus */ 130 131 /******************************************************************************* 132 * API 133 ******************************************************************************/ 134 135 status_t BOARD_InitDebugConsole(void); 136 137 #if defined(__cplusplus) 138 } 139 #endif /* __cplusplus */ 140 141 #endif /* _BOARD_H_ */ 142