1 /* 2 * Copyright 2017-2018 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_reset.h" 14 #include "fsl_gpio.h" 15 #include "fsl_iocon.h" 16 17 /******************************************************************************* 18 * Definitions 19 ******************************************************************************/ 20 /*! @brief The board name */ 21 #define BOARD_NAME "LPCXpresso55S69" 22 23 /*! @brief The UART to use for debug messages. */ 24 /* TODO: rename UART to USART */ 25 #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart 26 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) USART0 27 #define BOARD_DEBUG_UART_INSTANCE 0U 28 #define BOARD_DEBUG_UART_CLK_FREQ 12000000U 29 #define BOARD_DEBUG_UART_CLK_ATTACH kFRO12M_to_FLEXCOMM0 30 #define BOARD_DEBUG_UART_RST kFC0_RST_SHIFT_RSTn 31 #define BOARD_DEBUG_UART_CLKSRC kCLOCK_Flexcomm0 32 #define BOARD_UART_IRQ_HANDLER FLEXCOMM0_IRQHandler 33 #define BOARD_UART_IRQ FLEXCOMM0_IRQn 34 35 #define BOARD_ACCEL_I2C_BASEADDR I2C4 36 #define BOARD_ACCEL_I2C_CLOCK_FREQ 12000000 37 38 #define BOARD_DEBUG_UART_TYPE_CORE1 kSerialPort_Uart 39 #define BOARD_DEBUG_UART_BASEADDR_CORE1 (uint32_t) USART1 40 #define BOARD_DEBUG_UART_INSTANCE_CORE1 1U 41 #define BOARD_DEBUG_UART_CLK_FREQ_CORE1 12000000U 42 #define BOARD_DEBUG_UART_CLK_ATTACH_CORE1 kFRO12M_to_FLEXCOMM1 43 #define BOARD_DEBUG_UART_RST_CORE1 kFC1_RST_SHIFT_RSTn 44 #define BOARD_DEBUG_UART_CLKSRC_CORE1 kCLOCK_Flexcomm1 45 #define BOARD_UART_IRQ_HANDLER_CORE1 FLEXCOMM1_IRQHandler 46 #define BOARD_UART_IRQ_CORE1 FLEXCOMM1_IRQn 47 48 #ifndef BOARD_DEBUG_UART_BAUDRATE 49 #define BOARD_DEBUG_UART_BAUDRATE 115200U 50 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 51 52 #ifndef BOARD_DEBUG_UART_BAUDRATE_CORE1 53 #define BOARD_DEBUG_UART_BAUDRATE_CORE1 115200U 54 #endif /* BOARD_DEBUG_UART_BAUDRATE_CORE1 */ 55 56 #define BOARD_CODEC_I2C_BASEADDR I2C4 57 #define BOARD_CODEC_I2C_CLOCK_FREQ 12000000 58 #define BOARD_CODEC_I2C_INSTANCE 4 59 #ifndef BOARD_LED_RED_GPIO 60 #define BOARD_LED_RED_GPIO GPIO 61 #endif 62 #define BOARD_LED_RED_GPIO_PORT 1U 63 #ifndef BOARD_LED_RED_GPIO_PIN 64 #define BOARD_LED_RED_GPIO_PIN 6U 65 #endif 66 67 #ifndef BOARD_LED_BLUE_GPIO 68 #define BOARD_LED_BLUE_GPIO GPIO 69 #endif 70 #define BOARD_LED_BLUE_GPIO_PORT 1U 71 #ifndef BOARD_LED_BLUE_GPIO_PIN 72 #define BOARD_LED_BLUE_GPIO_PIN 4U 73 #endif 74 75 #ifndef BOARD_LED_GREEN_GPIO 76 #define BOARD_LED_GREEN_GPIO GPIO 77 #endif 78 #define BOARD_LED_GREEN_GPIO_PORT 1U 79 #ifndef BOARD_LED_GREEN_GPIO_PIN 80 #define BOARD_LED_GREEN_GPIO_PIN 7U 81 #endif 82 83 #ifndef BOARD_SW1_GPIO 84 #define BOARD_SW1_GPIO GPIO 85 #endif 86 #define BOARD_SW1_GPIO_PORT 0U 87 #ifndef BOARD_SW1_GPIO_PIN 88 #define BOARD_SW1_GPIO_PIN 5U 89 #endif 90 #define BOARD_SW1_NAME "SW1" 91 #define BOARD_SW1_IRQ PIN_INT0_IRQn 92 #define BOARD_SW1_IRQ_HANDLER PIN_INT0_IRQHandler 93 94 #ifndef BOARD_SW2_GPIO 95 #define BOARD_SW2_GPIO GPIO 96 #endif 97 #define BOARD_SW2_GPIO_PORT 1U 98 #ifndef BOARD_SW2_GPIO_PIN 99 #define BOARD_SW2_GPIO_PIN 18U 100 #endif 101 #define BOARD_SW2_NAME "SW2" 102 #define BOARD_SW2_IRQ PIN_INT1_IRQn 103 #define BOARD_SW2_IRQ_HANDLER PIN_INT1_IRQHandler 104 #define BOARD_SW2_GPIO_PININT_INDEX 1 105 106 #ifndef BOARD_SW3_GPIO 107 #define BOARD_SW3_GPIO GPIO 108 #endif 109 #define BOARD_SW3_GPIO_PORT 1U 110 #ifndef BOARD_SW3_GPIO_PIN 111 #define BOARD_SW3_GPIO_PIN 9U 112 #endif 113 #define BOARD_SW3_NAME "SW3" 114 #define BOARD_SW3_IRQ PIN_INT1_IRQn 115 #define BOARD_SW3_IRQ_HANDLER PIN_INT1_IRQHandler 116 #define BOARD_SW3_GPIO_PININT_INDEX 1 117 118 /* USB PHY condfiguration */ 119 #define BOARD_USB_PHY_D_CAL (0x05U) 120 #define BOARD_USB_PHY_TXCAL45DP (0x0AU) 121 #define BOARD_USB_PHY_TXCAL45DM (0x0AU) 122 123 /* Board led color mapping */ 124 #define LOGIC_LED_ON 0U 125 #define LOGIC_LED_OFF 1U 126 127 #define LED_RED_INIT(output) \ 128 { \ 129 IOCON_PinMuxSet(IOCON, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, IOCON_DIGITAL_EN); \ 130 GPIO_PinInit(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, BOARD_LED_RED_GPIO_PIN, \ 131 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED1 */ \ 132 } 133 #define LED_RED_ON() \ 134 GPIO_PortClear(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 135 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn on target LED1 */ 136 #define LED_RED_OFF() \ 137 GPIO_PortSet(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 138 1U << BOARD_LED_RED_GPIO_PIN) /*!< Turn off target LED1 \ \ \ \ \ \ \ \ \ \ \ 139 */ 140 #define LED_RED_TOGGLE() \ 141 GPIO_PortToggle(BOARD_LED_RED_GPIO, BOARD_LED_RED_GPIO_PORT, \ 142 1U << BOARD_LED_RED_GPIO_PIN) /*!< Toggle on target LED1 */ 143 144 #define LED_BLUE_INIT(output) \ 145 { \ 146 IOCON_PinMuxSet(IOCON, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, IOCON_DIGITAL_EN); \ 147 GPIO_PinInit(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, BOARD_LED_BLUE_GPIO_PIN, \ 148 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}); /*!< Enable target LED1 */ \ 149 } 150 #define LED_BLUE_ON() \ 151 GPIO_PortClear(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 152 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn on target LED1 */ 153 #define LED_BLUE_OFF() \ 154 GPIO_PortSet(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 155 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Turn off target LED1 */ 156 #define LED_BLUE_TOGGLE() \ 157 GPIO_PortToggle(BOARD_LED_BLUE_GPIO, BOARD_LED_BLUE_GPIO_PORT, \ 158 1U << BOARD_LED_BLUE_GPIO_PIN) /*!< Toggle on target LED1 */ 159 160 #define LED_GREEN_INIT(output) \ 161 GPIO_PinInit(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, BOARD_LED_GREEN_GPIO_PIN, \ 162 &(gpio_pin_config_t){kGPIO_DigitalOutput, (output)}) /*!< Enable target LED1 */ 163 #define LED_GREEN_ON() \ 164 GPIO_PortClear(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 165 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn on target LED1 */ 166 #define LED_GREEN_OFF() \ 167 GPIO_PortSet(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 168 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Turn off target LED1 */ 169 #define LED_GREEN_TOGGLE() \ 170 GPIO_PortToggle(BOARD_LED_GREEN_GPIO, BOARD_LED_GREEN_GPIO_PORT, \ 171 1U << BOARD_LED_GREEN_GPIO_PIN) /*!< Toggle on target LED1 */ 172 173 /* Display. */ 174 #define BOARD_LCD_DC_GPIO GPIO 175 #define BOARD_LCD_DC_GPIO_PORT 1U 176 #define BOARD_LCD_DC_GPIO_PIN 5U 177 178 /* Serial MWM WIFI */ 179 #define BOARD_SERIAL_MWM_PORT_CLK_FREQ CLOCK_GetFlexCommClkFreq(2) 180 #define BOARD_SERIAL_MWM_PORT USART2 181 #define BOARD_SERIAL_MWM_PORT_IRQn FLEXCOMM2_IRQn 182 #define BOARD_SERIAL_MWM_RST_WRITE(output) 183 184 #if defined(__cplusplus) 185 extern "C" { 186 #endif /* __cplusplus */ 187 188 /******************************************************************************* 189 * API 190 ******************************************************************************/ 191 192 void BOARD_InitDebugConsole(void); 193 void BOARD_InitDebugConsole_Core1(void); 194 #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED 195 void BOARD_I2C_Init(I2C_Type *base, uint32_t clkSrc_Hz); 196 status_t BOARD_I2C_Send(I2C_Type *base, 197 uint8_t deviceAddress, 198 uint32_t subAddress, 199 uint8_t subaddressSize, 200 uint8_t *txBuff, 201 uint8_t txBuffSize); 202 status_t BOARD_I2C_Receive(I2C_Type *base, 203 uint8_t deviceAddress, 204 uint32_t subAddress, 205 uint8_t subaddressSize, 206 uint8_t *rxBuff, 207 uint8_t rxBuffSize); 208 void BOARD_Accel_I2C_Init(void); 209 status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff); 210 status_t BOARD_Accel_I2C_Receive( 211 uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 212 void BOARD_Codec_I2C_Init(void); 213 status_t BOARD_Codec_I2C_Send( 214 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 215 status_t BOARD_Codec_I2C_Receive( 216 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 217 #endif /* SDK_I2C_BASED_COMPONENT_USED */ 218 219 #if defined(__cplusplus) 220 } 221 #endif /* __cplusplus */ 222 223 #endif /* _BOARD_H_ */ 224