1 /* 2 * Copyright 2019 NXP 3 * All rights reserved. 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 "LPC845BREAKOUT" 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_UART_IRQ USART0_IRQn 31 #define BOARD_UART_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 /* LED_GREEN */ 42 #ifndef BOARD_LED_GREEN_GPIO 43 #define BOARD_LED_GREEN_GPIO GPIO 44 #endif 45 #define BOARD_LED_GREEN_GPIO_PORT 1U 46 #ifndef BOARD_LED_GREEN_GPIO_PIN 47 #define BOARD_LED_GREEN_GPIO_PIN 0U 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 #define LED_GREEN_OFF() \ 58 GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 59 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */ 60 #define LED_GREEN_TOGGLE() \ 61 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 62 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */ 63 64 /* LED_BLUE */ 65 #ifndef BOARD_LED_BLUE_GPIO 66 #define BOARD_LED_BLUE_GPIO GPIO 67 #endif 68 #define BOARD_LED_BLUE_GPIO_PORT 1U 69 #ifndef BOARD_LED_BLUE_GPIO_PIN 70 #define BOARD_LED_BLUE_GPIO_PIN 1U 71 #endif 72 73 #ifndef BOARD_K3_GPIO 74 #define BOARD_K3_GPIO GPIO 75 #endif 76 #define BOARD_K3_GPIO_PORT 0U 77 #ifndef BOARD_K3_GPIO_PIN 78 #define BOARD_K3_GPIO_PIN 4U 79 #endif 80 #define BOARD_K3_NAME "K3" 81 #define BOARD_K3_IRQ PIN_INT0_IRQn 82 #define BOARD_K3_IRQ_HANDLER PIN_INT0_IRQHandler 83 84 #define LED_BLUE_INIT(output) \ 85 GPIO_PortInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT); \ 86 GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \ 87 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED_GREEN */ 88 #define LED_BLUE_ON() \ 89 GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 90 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */ 91 #define LED_BLUE_OFF() \ 92 GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 93 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */ 94 #define LED_BLUE_TOGGLE() \ 95 GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 96 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */ 97 98 /* LED_RED */ 99 #ifndef BOARD_LED_RED_GPIO 100 #define BOARD_LED_RED_GPIO GPIO 101 #endif 102 #define BOARD_LED_RED_GPIO_PORT 1U 103 #ifndef BOARD_LED_RED_GPIO_PIN 104 #define BOARD_LED_RED_GPIO_PIN 2U 105 #endif 106 107 #define LED_RED_INIT(output) \ 108 GPIO_PortInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT); \ 109 GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \ 110 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED_GREEN */ 111 #define LED_RED_ON() \ 112 GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 113 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */ 114 #define LED_RED_OFF() \ 115 GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 116 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */ 117 #define LED_RED_TOGGLE() \ 118 GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 119 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */ 120 121 #if defined(__cplusplus) 122 extern "C" { 123 #endif /* __cplusplus */ 124 125 /******************************************************************************* 126 * API 127 ******************************************************************************/ 128 129 status_t BOARD_InitDebugConsole(void); 130 131 #if defined(__cplusplus) 132 } 133 #endif /* __cplusplus */ 134 135 #endif /* _BOARD_H_ */ 136