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_INSTANCE 0U
28 #define BOARD_DEBUG_UART_CLK_FREQ CLOCK_GetFlexCommClkFreq(0U)
29 #define BOARD_DEBUG_UART_CLK_ATTACH kFRO12M_to_FLEXCOMM0
30 #define BOARD_DEBUG_UART_RST kFC0_RST_SHIFT_RSTn
31 
32 #define BOARD_DEBUG_SPI_CLK_FREQ 12000000
33 
34 #ifndef BOARD_DEBUG_UART_BAUDRATE
35 #define BOARD_DEBUG_UART_BAUDRATE 115200
36 #endif /* BOARD_DEBUG_UART_BAUDRATE */
37 
38 #ifndef BOARD_LED_RED_GPIO
39 #define BOARD_LED_RED_GPIO GPIO
40 #endif
41 #define BOARD_LED_RED_GPIO_PORT 0U
42 #ifndef BOARD_LED_RED_GPIO_PIN
43 #define BOARD_LED_RED_GPIO_PIN 29U
44 #endif
45 #ifndef BOARD_LED_GREEN_GPIO
46 #define BOARD_LED_GREEN_GPIO GPIO
47 #endif
48 #define BOARD_LED_GREEN_GPIO_PORT 1U
49 #ifndef BOARD_LED_GREEN_GPIO_PIN
50 #define BOARD_LED_GREEN_GPIO_PIN 10U
51 #endif
52 #ifndef BOARD_LED_BLUE_GPIO
53 #define BOARD_LED_BLUE_GPIO GPIO
54 #endif
55 #define BOARD_LED_BLUE_GPIO_PORT 1U
56 #ifndef BOARD_LED_BLUE_GPIO_PIN
57 #define BOARD_LED_BLUE_GPIO_PIN 9U
58 #endif
59 
60 /* Board led color mapping */
61 #define LOGIC_LED_ON 0U
62 #define LOGIC_LED_OFF 1U
63 
64 #define LED_RED_INIT(output)                                                          \
65     GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \
66                  &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_RED */
67 #define LED_RED_ON()                                            \
68     GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
69                    1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */
70 #define LED_RED_OFF()                                         \
71     GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
72                  1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */
73 #define LED_RED_TOGGLE()                                         \
74     GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
75                     1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */
76 
77 #define LED_GREEN_INIT(output)                                                              \
78     GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \
79                  &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_GREEN */
80 #define LED_GREEN_ON()                                              \
81     GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
82                    1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */
83 #define LED_GREEN_OFF()                                           \
84     GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
85                  1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */
86 #define LED_GREEN_TOGGLE()                                           \
87     GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
88                     1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */
89 
90 #define LED_BLUE_INIT(output)                                                            \
91     GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \
92                  &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_BLUE */
93 #define LED_BLUE_ON()                                             \
94     GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
95                    1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */
96 #define LED_BLUE_OFF()                                          \
97     GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
98                  1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */
99 #define LED_BLUE_TOGGLE()                                          \
100     GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
101                     1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */
102 
103 #if defined(__cplusplus)
104 extern "C" {
105 #endif /* __cplusplus */
106 
107 /*******************************************************************************
108  * API
109  ******************************************************************************/
110 
111 status_t BOARD_InitDebugConsole(void);
112 
113 #ifdef SDK_PRIMARY_CORE
114 void BOARD_StartSecondaryCore(void);
115 #endif
116 
117 #if defined(__cplusplus)
118 }
119 #endif /* __cplusplus */
120 
121 #endif /* _BOARD_H_ */
122