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 "LPCXPRESSO54608"
21 
22 #define BOARD_EXTCLKINRATE (0)
23 
24 /*! @brief The UART to use for debug messages. */
25 /* TODO: rename UART to USART */
26 #define BOARD_DEBUG_UART_TYPE       kSerialPort_Uart
27 #define BOARD_DEBUG_UART_BASEADDR   (uint32_t) USART0
28 #define BOARD_DEBUG_UART_INSTANCE   0U
29 #define BOARD_DEBUG_UART_CLK_FREQ   CLOCK_GetFlexCommClkFreq(0)
30 #define BOARD_DEBUG_UART_CLK_ATTACH kFRO12M_to_FLEXCOMM0
31 #define BOARD_DEBUG_UART_RST        kFC0_RST_SHIFT_RSTn
32 #define BOARD_DEBUG_UART_CLKSRC     kCLOCK_Flexcomm0
33 #define BOARD_UART_IRQ_HANDLER      FLEXCOMM0_IRQHandler
34 #define BOARD_UART_IRQ              FLEXCOMM0_IRQn
35 /* TODO: obsolete */
36 #define BOARD_DEBUG_SPI_CLK_FREQ 12000000
37 
38 #ifndef BOARD_DEBUG_UART_BAUDRATE
39 #define BOARD_DEBUG_UART_BAUDRATE 115200
40 #endif /* BOARD_DEBUG_UART_BAUDRATE */
41 
42 #ifndef BOARD_LED_RED_GPIO
43 #define BOARD_LED_RED_GPIO GPIO
44 #endif
45 #define BOARD_LED_RED_GPIO_PORT 3U
46 #ifndef BOARD_LED_RED_GPIO_PIN
47 #define BOARD_LED_RED_GPIO_PIN 14U
48 #endif
49 #ifndef BOARD_LED_GREEN_GPIO
50 #define BOARD_LED_GREEN_GPIO GPIO
51 #endif
52 #define BOARD_LED_GREEN_GPIO_PORT 2U
53 #ifndef BOARD_LED_GREEN_GPIO_PIN
54 #define BOARD_LED_GREEN_GPIO_PIN 2U
55 #endif
56 #ifndef BOARD_LED_BLUE_GPIO
57 #define BOARD_LED_BLUE_GPIO GPIO
58 #endif
59 #define BOARD_LED_BLUE_GPIO_PORT 3U
60 #ifndef BOARD_LED_BLUE_GPIO_PIN
61 #define BOARD_LED_BLUE_GPIO_PIN 3U
62 #endif
63 
64 /* Board led color mapping */
65 #define LOGIC_LED_ON  0U
66 #define LOGIC_LED_OFF 1U
67 
68 #define LED_RED_INIT(output)                                                          \
69     GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \
70                  &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_RED */
71 #define LED_RED_ON()                                            \
72     GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
73                    1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED_RED */
74 #define LED_RED_OFF()                                         \
75     GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
76                  1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED_RED */
77 #define LED_RED_TOGGLE()                                         \
78     GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \
79                     1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED_RED */
80 
81 #define LED_GREEN_INIT(output)                                                              \
82     GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \
83                  &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_GREEN */
84 #define LED_GREEN_ON()                                              \
85     GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
86                    1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED_GREEN */
87 #define LED_GREEN_OFF()                                           \
88     GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
89                  1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED_GREEN */
90 #define LED_GREEN_TOGGLE()                                           \
91     GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \
92                     1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED_GREEN */
93 
94 #define LED_BLUE_INIT(output)                                                            \
95     GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \
96                  &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED_BLUE */
97 #define LED_BLUE_ON()                                             \
98     GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
99                    1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED_BLUE */
100 #define LED_BLUE_OFF()                                          \
101     GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
102                  1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED_BLUE */
103 #define LED_BLUE_TOGGLE()                                          \
104     GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \
105                     1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED_BLUE */
106 
107 /*! @brief Memory ranges not usable by the ENET DMA. */
108 #ifndef BOARD_ENET_NON_DMA_MEMORY_ARRAY
109 #define BOARD_ENET_NON_DMA_MEMORY_ARRAY                                                     \
110     {                                                                                       \
111         {0x00000000U, 0x0007FFFFU}, {0x10000000U, 0x17FFFFFFU}, {0x80000000U, 0xDFFFFFFFU}, \
112             {0x00000000U, 0x00000000U},                                                     \
113     }
114 #endif /* BOARD_ENET_NON_DMA_MEMORY_ARRAY */
115 
116 #if defined(__cplusplus)
117 extern "C" {
118 #endif /* __cplusplus */
119 
120 /*******************************************************************************
121  * API
122  ******************************************************************************/
123 
124 status_t BOARD_InitDebugConsole(void);
125 
126 #if defined(__cplusplus)
127 }
128 #endif /* __cplusplus */
129 
130 #endif /* _BOARD_H_ */
131