1 /* 2 * Copyright 2020 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 #include "fsl_clock.h" 15 16 /******************************************************************************* 17 * Definitions 18 ******************************************************************************/ 19 /*! @brief The board name */ 20 #define BOARD_NAME "MIMXRT1170-EVK" 21 #ifndef DEBUG_CONSOLE_UART_INDEX 22 #define DEBUG_CONSOLE_UART_INDEX 1 23 #endif 24 25 /* The UART to use for debug messages. */ 26 #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart 27 #define BOARD_DEBUG_UART_CLK_FREQ 24000000 28 29 #if DEBUG_CONSOLE_UART_INDEX == 1 30 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART1 31 #define BOARD_DEBUG_UART_INSTANCE 1U 32 #define BOARD_UART_IRQ LPUART1_IRQn 33 #define BOARD_UART_IRQ_HANDLER LPUART1_IRQHandler 34 #elif DEBUG_CONSOLE_UART_INDEX == 2 35 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART2 36 #define BOARD_DEBUG_UART_INSTANCE 2U 37 #define BOARD_UART_IRQ LPUART2_IRQn 38 #define BOARD_UART_IRQ_HANDLER LPUART2_IRQHandler 39 #elif DEBUG_CONSOLE_UART_INDEX == 12 40 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART12 41 #define BOARD_DEBUG_UART_INSTANCE 12U 42 #define BOARD_UART_IRQ LPUART12_IRQn 43 #define BOARD_UART_IRQ_HANDLER LPUART12_IRQHandler 44 #else 45 #error "Unsupported UART" 46 #endif 47 48 #ifndef BOARD_DEBUG_UART_BAUDRATE 49 #define BOARD_DEBUG_UART_BAUDRATE (115200U) 50 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 51 52 /* Definitions for eRPC MU transport layer */ 53 #if defined(FSL_FEATURE_MU_SIDE_A) 54 #define MU_BASE MUA 55 #define MU_IRQ MUA_IRQn 56 #define MU_IRQ_HANDLER MUA_IRQHandler 57 #endif 58 #if defined(FSL_FEATURE_MU_SIDE_B) 59 #define MU_BASE MUB 60 #define MU_IRQ MUB_IRQn 61 #define MU_IRQ_HANDLER MUB_IRQHandler 62 #endif 63 #define MU_IRQ_PRIORITY (2) 64 65 /*! @brief The USER_LED used for board */ 66 #define LOGIC_LED_ON (0U) 67 #define LOGIC_LED_OFF (1U) 68 #ifndef BOARD_USER_LED_GPIO 69 #define BOARD_USER_LED_GPIO GPIO9 70 #endif 71 #ifndef BOARD_USER_LED_GPIO_PIN 72 #define BOARD_USER_LED_GPIO_PIN (3U) 73 #endif 74 75 #define USER_LED_INIT(output) \ 76 GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, output); \ 77 BOARD_USER_LED_GPIO->GDIR |= (1U << BOARD_USER_LED_GPIO_PIN) /*!< Enable target USER_LED */ 78 #define USER_LED_OFF() \ 79 GPIO_PortClear(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!< Turn off target USER_LED */ 80 #define USER_LED_ON() GPIO_PortSet(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!<Turn on target USER_LED*/ 81 #define USER_LED_TOGGLE() \ 82 GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, \ 83 0x1 ^ GPIO_PinRead(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN)) /*!< Toggle target USER_LED */ 84 85 /*! @brief Define the port interrupt number for the board switches */ 86 #ifndef BOARD_USER_BUTTON_GPIO 87 #define BOARD_USER_BUTTON_GPIO GPIO13 88 #endif 89 #ifndef BOARD_USER_BUTTON_GPIO_PIN 90 #define BOARD_USER_BUTTON_GPIO_PIN (0U) 91 #endif 92 #define BOARD_USER_BUTTON_IRQ GPIO13_Combined_0_31_IRQn 93 #define BOARD_USER_BUTTON_IRQ_HANDLER GPIO13_Combined_0_31_IRQHandler 94 #define BOARD_USER_BUTTON_NAME "SW7" 95 96 /*! @brief The board flash size */ 97 #define BOARD_FLASH_SIZE (0x1000000U) 98 99 /* SKIP_SEMC_INIT can also be defined independently */ 100 #ifdef USE_SDRAM 101 #define SKIP_SEMC_INIT 102 #endif 103 104 /*! @brief The ENET0 PHY address. */ 105 #define BOARD_ENET0_PHY_ADDRESS (0x02U) /* Phy address of enet port 0. */ 106 107 /*! @brief The ENET1 PHY address. */ 108 #define BOARD_ENET1_PHY_ADDRESS (0x01U) /* Phy address of enet port 1. */ 109 110 /*! @brief The EMVSIM SMARTCARD PHY configuration. */ 111 #define BOARD_SMARTCARD_MODULE (EMVSIM1) /*!< SMARTCARD communicational module instance */ 112 #define BOARD_SMARTCARD_MODULE_IRQ (EMVSIM1_IRQn) /*!< SMARTCARD communicational module IRQ handler */ 113 #define BOARD_SMARTCARD_CLOCK_MODULE_CLK_FREQ (CLOCK_GetRootClockFreq(kCLOCK_Root_Emv1)) 114 #define BOARD_SMARTCARD_CLOCK_VALUE (4000000U) /*!< SMARTCARD clock frequency */ 115 116 /* USB PHY condfiguration */ 117 #define BOARD_USB_PHY_D_CAL (0x07U) 118 #define BOARD_USB_PHY_TXCAL45DP (0x06U) 119 #define BOARD_USB_PHY_TXCAL45DM (0x06U) 120 121 #define BOARD_ARDUINO_INT_IRQ (GPIO1_INT3_IRQn) 122 #define BOARD_ARDUINO_I2C_IRQ (LPI2C1_IRQn) 123 #define BOARD_ARDUINO_I2C_INDEX (1) 124 125 #define BOARD_HAS_SDCARD (1U) 126 127 /*! @brief The WIFI-QCA shield pin. */ 128 #define BOARD_INITGT202SHIELD_PWRON_GPIO GPIO1 /*!< GPIO device name: GPIO */ 129 #define BOARD_INITGT202SHIELD_PWRON_PORT 1U /*!< PORT device index: 1 */ 130 #define BOARD_INITGT202SHIELD_PWRON_GPIO_PIN 3U /*!< PIO4 pin index: 3 */ 131 #define BOARD_INITGT202SHIELD_PWRON_PIN_NAME GPIO1_3 /*!< Pin name */ 132 #define BOARD_INITGT202SHIELD_PWRON_LABEL "PWRON" /*!< Label */ 133 #define BOARD_INITGT202SHIELD_PWRON_NAME "PWRON" /*!< Identifier name */ 134 #define BOARD_INITGT202SHIELD_PWRON_DIRECTION kGPIO_DigitalOutput /*!< Direction */ 135 136 #define BOARD_INITGT202SHIELD_IRQ_GPIO GPIO1 /*!< GPIO device name: GPIO */ 137 #define BOARD_INITGT202SHIELD_IRQ_PORT 1U /*!< PORT device index: 1 */ 138 #define BOARD_INITGT202SHIELD_IRQ_GPIO_PIN 19U /*!< PIO1 pin index: 19 */ 139 #define BOARD_INITGT202SHIELD_IRQ_PIN_NAME GPIO1_19 /*!< Pin name */ 140 #define BOARD_INITGT202SHIELD_IRQ_LABEL "IRQ" /*!< Label */ 141 #define BOARD_INITGT202SHIELD_IRQ_NAME "IRQ" /*!< Identifier name */ 142 #define BOARD_INITGT202SHIELD_IRQ_DIRECTION kGPIO_DigitalInput /*!< Direction */ 143 144 #define BOARD_INITSILEX2401SHIELD_PWRON_GPIO GPIO1 /*!< GPIO device name: GPIO */ 145 #define BOARD_INITSILEX2401SHIELD_PWRON_PORT 1U /*!< PORT device index: 1 */ 146 #define BOARD_INITSILEX2401SHIELD_PWRON_GPIO_PIN 9U /*!< PIO4 pin index: 9 */ 147 #define BOARD_INITSILEX2401SHIELD_PWRON_PIN_NAME GPIO1_9 /*!< Pin name */ 148 #define BOARD_INITSILEX2401SHIELD_PWRON_LABEL "PWRON" /*!< Label */ 149 #define BOARD_INITSILEX2401SHIELD_PWRON_NAME "PWRON" /*!< Identifier name */ 150 #define BOARD_INITSILEX2401SHIELD_PWRON_DIRECTION kGPIO_DigitalOutput /*!< Direction */ 151 152 #define BOARD_INITSILEX2401SHIELD_IRQ_GPIO GPIO1 /*!< GPIO device name: GPIO */ 153 #define BOARD_INITSILEX2401SHIELD_IRQ_PORT 1U /*!< PORT device index: 1 */ 154 #define BOARD_INITSILEX2401SHIELD_IRQ_GPIO_PIN 11U /*!< PIO1 pin index: 11 */ 155 #define BOARD_INITSILEX2401SHIELD_IRQ_PIN_NAME GPIO1_11 /*!< Pin name */ 156 #define BOARD_INITSILEX2401SHIELD_IRQ_LABEL "IRQ" /*!< Label */ 157 #define BOARD_INITSILEX2401SHIELD_IRQ_NAME "IRQ" /*!< Identifier name */ 158 #define BOARD_INITSILEX2401SHIELD_IRQ_DIRECTION kGPIO_DigitalInput /*!< Direction */ 159 160 /* @Brief Board accelerator sensor configuration */ 161 #define BOARD_ACCEL_I2C_BASEADDR LPI2C5 162 /* Clock divider for LPI2C clock source */ 163 #define BOARD_ACCEL_I2C_CLOCK_FREQ (CLOCK_GetRootClockFreq(kCLOCK_Root_Lpi2c5)) 164 165 #define BOARD_CODEC_I2C_BASEADDR LPI2C5 166 #define BOARD_CODEC_I2C_INSTANCE 5U 167 #define BOARD_CODEC_I2C_CLOCK_SOURCE_SELECT (0U) 168 #define BOARD_CODEC_I2C_CLOCK_SOURCE_DIVIDER (6U) 169 #define BOARD_CODEC_I2C_CLOCK_FREQ (24000000U) 170 171 /* @Brief Board CAMERA configuration */ 172 #define BOARD_CAMERA_I2C_BASEADDR LPI2C6 173 #define BOARD_CAMERA_I2C_CLOCK_ROOT kCLOCK_Root_Lpi2c6 174 #define BOARD_CAMERA_I2C_CLOCK_SOURCE (1U) /* OSC24M. */ 175 #define BOARD_CAMERA_I2C_CLOCK_DIVIDER (12U) /* Divider = 12, LPI2C clock frequency 2M. */ 176 177 /*! @brief The MIPI panel pins. */ 178 #define BOARD_MIPI_PANEL_RST_GPIO GPIO9 179 #define BOARD_MIPI_PANEL_RST_PIN 1 180 #define BOARD_MIPI_PANEL_POWER_GPIO GPIO11 181 #define BOARD_MIPI_PANEL_POWER_PIN 16 182 /* Back light pin. */ 183 #define BOARD_MIPI_PANEL_BL_GPIO GPIO9 184 #define BOARD_MIPI_PANEL_BL_PIN 29 185 186 /* Touch panel. */ 187 #define BOARD_MIPI_PANEL_TOUCH_I2C_BASEADDR LPI2C5 188 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT kCLOCK_Root_Lpi2c5 189 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_SOURCE (1U) /* OSC24M. */ 190 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_DIVIDER (12U) /* Divider = 12, LPI2C clock frequency 2M. */ 191 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_FREQ CLOCK_GetRootClockFreq(BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT) 192 #define BOARD_MIPI_PANEL_TOUCH_RST_GPIO GPIO9 193 #define BOARD_MIPI_PANEL_TOUCH_RST_PIN 0 194 #define BOARD_MIPI_PANEL_TOUCH_INT_GPIO GPIO8 195 #define BOARD_MIPI_PANEL_TOUCH_INT_PIN 31 196 197 /*! @brief The camera pins. */ 198 #define BOARD_CAMERA_PWDN_GPIO GPIO9 199 #define BOARD_CAMERA_PWDN_PIN 25 200 #define BOARD_CAMERA_RST_GPIO GPIO11 201 #define BOARD_CAMERA_RST_PIN 15 202 203 /* SD card detection method when using wifi module. */ 204 #define BOARD_WIFI_SD_DETECT_TYPE kSDMMCHOST_DetectCardByHostDATA3 205 206 #define BOARD_BT_UART_INSTANCE 7 207 #define BOARD_BT_UART_BAUDRATE 3000000 208 #define BOARD_BT_UART_CLK_FREQ CLOCK_GetRootClockFreq(kCLOCK_Root_Lpuart7); 209 #define BOARD_BT_UART_IRQ LPUART7_IRQn 210 #define BOARD_BT_UART_IRQ_HANDLER LPUART7_IRQHandler 211 212 #if defined(__cplusplus) 213 extern "C" { 214 #endif /* __cplusplus */ 215 216 /******************************************************************************* 217 * API 218 ******************************************************************************/ 219 uint32_t BOARD_DebugConsoleSrcFreq(void); 220 221 void BOARD_InitDebugConsole(void); 222 223 void BOARD_ConfigMPU(void); 224 #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED 225 void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz); 226 status_t BOARD_LPI2C_Send(LPI2C_Type *base, 227 uint8_t deviceAddress, 228 uint32_t subAddress, 229 uint8_t subaddressSize, 230 uint8_t *txBuff, 231 uint8_t txBuffSize); 232 status_t BOARD_LPI2C_Receive(LPI2C_Type *base, 233 uint8_t deviceAddress, 234 uint32_t subAddress, 235 uint8_t subaddressSize, 236 uint8_t *rxBuff, 237 uint8_t rxBuffSize); 238 status_t BOARD_LPI2C_SendSCCB(LPI2C_Type *base, 239 uint8_t deviceAddress, 240 uint32_t subAddress, 241 uint8_t subaddressSize, 242 uint8_t *txBuff, 243 uint8_t txBuffSize); 244 status_t BOARD_LPI2C_ReceiveSCCB(LPI2C_Type *base, 245 uint8_t deviceAddress, 246 uint32_t subAddress, 247 uint8_t subaddressSize, 248 uint8_t *rxBuff, 249 uint8_t rxBuffSize); 250 void BOARD_Accel_I2C_Init(void); 251 status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff); 252 status_t BOARD_Accel_I2C_Receive( 253 uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 254 void BOARD_Codec_I2C_Init(void); 255 status_t BOARD_Codec_I2C_Send( 256 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 257 status_t BOARD_Codec_I2C_Receive( 258 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 259 void BOARD_Camera_I2C_Init(void); 260 status_t BOARD_Camera_I2C_Send( 261 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 262 status_t BOARD_Camera_I2C_Receive( 263 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 264 265 status_t BOARD_Camera_I2C_SendSCCB( 266 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 267 status_t BOARD_Camera_I2C_ReceiveSCCB( 268 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 269 270 void BOARD_MIPIPanelTouch_I2C_Init(void); 271 status_t BOARD_MIPIPanelTouch_I2C_Send( 272 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 273 status_t BOARD_MIPIPanelTouch_I2C_Receive( 274 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 275 #endif /* SDK_I2C_BASED_COMPONENT_USED */ 276 277 void BOARD_SD_Pin_Config(uint32_t speed, uint32_t strength); 278 void BOARD_MMC_Pin_Config(uint32_t speed, uint32_t strength); 279 280 #if defined(__cplusplus) 281 } 282 #endif /* __cplusplus */ 283 284 #endif /* _BOARD_H_ */ 285