1 /* 2 * Copyright 2020, 2023 NXP 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef _BOARD_H_ 8 #define _BOARD_H_ 9 10 #include "clock_config.h" 11 #include "fsl_common.h" 12 #include "fsl_gpio.h" 13 #include "fsl_clock.h" 14 #if defined(CONFIG_BT_LOW_POWER_MODE) && (CONFIG_BT_LOW_POWER_MODE) 15 #if (defined(BUTTON_COUNT) && (BUTTON_COUNT > 0U)) 16 #include "fsl_component_button.h" 17 #endif /* BUTTON_COUNT */ 18 #endif /* CONFIG_BT_LOW_POWER_MODE */ 19 20 /******************************************************************************* 21 * Definitions 22 ******************************************************************************/ 23 /*! @brief The board name */ 24 #define BOARD_NAME "MIMXRT1170-EVK" 25 #ifndef DEBUG_CONSOLE_UART_INDEX 26 #define DEBUG_CONSOLE_UART_INDEX 1 27 #endif 28 29 /* The UART to use for debug messages. */ 30 #define BOARD_DEBUG_UART_TYPE kSerialPort_Uart 31 #define BOARD_DEBUG_UART_CLK_FREQ 24000000 32 33 #if DEBUG_CONSOLE_UART_INDEX == 1 34 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART1 35 #define BOARD_DEBUG_UART_INSTANCE 1U 36 #define BOARD_UART_IRQ LPUART1_IRQn 37 #define BOARD_UART_IRQ_HANDLER LPUART1_IRQHandler 38 #elif DEBUG_CONSOLE_UART_INDEX == 2 39 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART2 40 #define BOARD_DEBUG_UART_INSTANCE 2U 41 #define BOARD_UART_IRQ LPUART2_IRQn 42 #define BOARD_UART_IRQ_HANDLER LPUART2_IRQHandler 43 #elif DEBUG_CONSOLE_UART_INDEX == 12 44 #define BOARD_DEBUG_UART_BASEADDR (uint32_t) LPUART12 45 #define BOARD_DEBUG_UART_INSTANCE 12U 46 #define BOARD_UART_IRQ LPUART12_IRQn 47 #define BOARD_UART_IRQ_HANDLER LPUART12_IRQHandler 48 #else 49 #error "Unsupported UART" 50 #endif 51 52 #ifndef BOARD_DEBUG_UART_BAUDRATE 53 #define BOARD_DEBUG_UART_BAUDRATE (115200U) 54 #endif /* BOARD_DEBUG_UART_BAUDRATE */ 55 56 /* Definitions for eRPC MU transport layer */ 57 #if defined(FSL_FEATURE_MU_SIDE_A) 58 #define MU_BASE MUA 59 #define MU_IRQ MUA_IRQn 60 #define MU_IRQ_HANDLER MUA_IRQHandler 61 #endif 62 #if defined(FSL_FEATURE_MU_SIDE_B) 63 #define MU_BASE MUB 64 #define MU_IRQ MUB_IRQn 65 #define MU_IRQ_HANDLER MUB_IRQHandler 66 #endif 67 #define MU_IRQ_PRIORITY (2) 68 69 /*! @brief The USER_LED used for board */ 70 #define LOGIC_LED_ON (0U) 71 #define LOGIC_LED_OFF (1U) 72 #ifndef BOARD_USER_LED_GPIO 73 #define BOARD_USER_LED_GPIO GPIO9 74 #endif 75 #ifndef BOARD_USER_LED_GPIO_PIN 76 #define BOARD_USER_LED_GPIO_PIN (3U) 77 #endif 78 79 #define USER_LED_INIT(output) \ 80 GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, output); \ 81 BOARD_USER_LED_GPIO->GDIR |= (1U << BOARD_USER_LED_GPIO_PIN) /*!< Enable target USER_LED */ 82 #define USER_LED_OFF() \ 83 GPIO_PortClear(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!< Turn off target USER_LED */ 84 #define USER_LED_ON() GPIO_PortSet(BOARD_USER_LED_GPIO, 1U << BOARD_USER_LED_GPIO_PIN) /*!<Turn on target USER_LED*/ 85 #define USER_LED_TOGGLE() \ 86 GPIO_PinWrite(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN, \ 87 0x1 ^ GPIO_PinRead(BOARD_USER_LED_GPIO, BOARD_USER_LED_GPIO_PIN)) /*!< Toggle target USER_LED */ 88 89 /*! @brief Define the port interrupt number for the board switches */ 90 #ifndef BOARD_USER_BUTTON_GPIO 91 #define BOARD_USER_BUTTON_GPIO GPIO13 92 #endif 93 #ifndef BOARD_USER_BUTTON_GPIO_PIN 94 #define BOARD_USER_BUTTON_GPIO_PIN (0U) 95 #endif 96 #define BOARD_USER_BUTTON_IRQ GPIO13_Combined_0_31_IRQn 97 #define BOARD_USER_BUTTON_IRQ_HANDLER GPIO13_Combined_0_31_IRQHandler 98 #define BOARD_USER_BUTTON_NAME "SW7" 99 100 #if defined(CONFIG_BT_LOW_POWER_MODE) && (CONFIG_BT_LOW_POWER_MODE) 101 #ifndef BUTTON_COUNT 102 #define BUTTON_COUNT 1 103 #endif 104 #if (defined(BUTTON_COUNT) && (BUTTON_COUNT > 0U)) 105 #define APP_WAKEUP_BUTTON BOARD_USER_BUTTON_GPIO 106 #define APP_WAKEUP_BUTTON_GPIO 13 107 #define APP_WAKEUP_BUTTON_GPIO_PIN BOARD_USER_BUTTON_GPIO_PIN 108 #define APP_WAKEUP_BUTTON_DEFAULT_VALUE 1 109 #define APP_WAKEUP_BUTTON_IRQ BOARD_USER_BUTTON_IRQ 110 #define APP_WAKEUP_BUTTON_IRQ_HANDLER BOARD_USER_BUTTON_IRQ_HANDLER 111 #define APP_WAKEUP_BUTTON_NAME BOARD_USER_BUTTON_NAME 112 113 extern button_config_t g_buttonConfig[]; 114 #endif /* BUTTON_COUNT */ 115 #endif /* CONFIG_BT_LOW_POWER_MODE */ 116 117 /*! @brief The board flash size */ 118 #define BOARD_FLASH_SIZE (0x1000000U) 119 120 /* SKIP_SEMC_INIT can also be defined independently */ 121 #ifdef USE_SDRAM 122 #define SKIP_SEMC_INIT 123 #endif 124 125 /*! @brief The ENET0 PHY address. */ 126 #define BOARD_ENET0_PHY_ADDRESS (0x02U) /* Phy address of enet port 0. */ 127 128 /*! @brief The ENET1 PHY address. */ 129 #define BOARD_ENET1_PHY_ADDRESS (0x01U) /* Phy address of enet port 1. */ 130 131 /*! @brief The ENET PHY used for board. */ 132 #ifndef BOARD_ENET_PHY0_RESET_GPIO 133 #define BOARD_ENET_PHY0_RESET_GPIO GPIO12 134 #endif 135 #ifndef BOARD_ENET_PHY0_RESET_GPIO_PIN 136 #define BOARD_ENET_PHY0_RESET_GPIO_PIN (12U) 137 #endif 138 139 #define BOARD_ENET_PHY0_RESET \ 140 GPIO_WritePinOutput(BOARD_ENET_PHY0_RESET_GPIO, BOARD_ENET_PHY0_RESET_GPIO_PIN, 0); \ 141 SDK_DelayAtLeastUs(10000, CLOCK_GetFreq(kCLOCK_CpuClk)); \ 142 GPIO_WritePinOutput(BOARD_ENET_PHY0_RESET_GPIO, BOARD_ENET_PHY0_RESET_GPIO_PIN, 1); \ 143 SDK_DelayAtLeastUs(100, CLOCK_GetFreq(kCLOCK_CpuClk)) 144 145 #ifndef BOARD_ENET_PHY1_RESET_GPIO 146 #define BOARD_ENET_PHY1_RESET_GPIO GPIO11 147 #endif 148 #ifndef BOARD_ENET_PHY1_RESET_GPIO_PIN 149 #define BOARD_ENET_PHY1_RESET_GPIO_PIN (14U) 150 #endif 151 152 /* For a complete PHY reset of RTL8211FDI-CG, this pin must be asserted low for at least 10ms. And 153 * wait for a further 30ms(for internal circuits settling time) before accessing the PHY register */ 154 #define BOARD_ENET_PHY1_RESET \ 155 GPIO_WritePinOutput(BOARD_ENET_PHY1_RESET_GPIO, BOARD_ENET_PHY1_RESET_GPIO_PIN, 0); \ 156 SDK_DelayAtLeastUs(10000, CLOCK_GetFreq(kCLOCK_CpuClk)); \ 157 GPIO_WritePinOutput(BOARD_ENET_PHY1_RESET_GPIO, BOARD_ENET_PHY1_RESET_GPIO_PIN, 1); \ 158 SDK_DelayAtLeastUs(30000, CLOCK_GetFreq(kCLOCK_CpuClk)) 159 160 /*! @brief The EMVSIM SMARTCARD PHY configuration. */ 161 #define BOARD_SMARTCARD_MODULE (EMVSIM1) /*!< SMARTCARD communicational module instance */ 162 #define BOARD_SMARTCARD_MODULE_IRQ (EMVSIM1_IRQn) /*!< SMARTCARD communicational module IRQ handler */ 163 #define BOARD_SMARTCARD_CLOCK_MODULE_CLK_FREQ (CLOCK_GetRootClockFreq(kCLOCK_Root_Emv1)) 164 #define BOARD_SMARTCARD_CLOCK_VALUE (4000000U) /*!< SMARTCARD clock frequency */ 165 166 /* USB PHY condfiguration */ 167 #define BOARD_USB_PHY_D_CAL (0x07U) 168 #define BOARD_USB_PHY_TXCAL45DP (0x06U) 169 #define BOARD_USB_PHY_TXCAL45DM (0x06U) 170 171 #define BOARD_ARDUINO_INT_IRQ (GPIO1_INT3_IRQn) 172 #define BOARD_ARDUINO_I2C_IRQ (LPI2C1_IRQn) 173 #define BOARD_ARDUINO_I2C_INDEX (1) 174 175 #define BOARD_HAS_SDCARD (1U) 176 177 /* @Brief Board accelerator sensor configuration */ 178 #define BOARD_ACCEL_I2C_BASEADDR LPI2C5 179 /* Clock divider for LPI2C clock source */ 180 #define BOARD_ACCEL_I2C_CLOCK_FREQ (CLOCK_GetRootClockFreq(kCLOCK_Root_Lpi2c5)) 181 182 #define BOARD_CODEC_I2C_BASEADDR LPI2C5 183 #define BOARD_CODEC_I2C_INSTANCE 5U 184 #define BOARD_CODEC_I2C_CLOCK_SOURCE_SELECT (0U) 185 #define BOARD_CODEC_I2C_CLOCK_SOURCE_DIVIDER (6U) 186 #define BOARD_CODEC_I2C_CLOCK_FREQ (24000000U) 187 188 /* @Brief Board CAMERA configuration */ 189 #define BOARD_CAMERA_I2C_BASEADDR LPI2C6 190 #define BOARD_CAMERA_I2C_CLOCK_ROOT kCLOCK_Root_Lpi2c6 191 #define BOARD_CAMERA_I2C_CLOCK_SOURCE (1U) /* OSC24M. */ 192 #define BOARD_CAMERA_I2C_CLOCK_DIVIDER (12U) /* Divider = 12, LPI2C clock frequency 2M. */ 193 194 /*! @brief The MIPI panel pins. */ 195 #define BOARD_MIPI_PANEL_RST_GPIO GPIO9 196 #define BOARD_MIPI_PANEL_RST_PIN 1 197 #define BOARD_MIPI_PANEL_POWER_GPIO GPIO11 198 #define BOARD_MIPI_PANEL_POWER_PIN 16 199 /* Back light pin. */ 200 #define BOARD_MIPI_PANEL_BL_GPIO GPIO9 201 #define BOARD_MIPI_PANEL_BL_PIN 29 202 203 /* Touch panel. */ 204 #define BOARD_MIPI_PANEL_TOUCH_I2C_BASEADDR LPI2C5 205 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT kCLOCK_Root_Lpi2c5 206 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_SOURCE (1U) /* OSC24M. */ 207 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_DIVIDER (12U) /* Divider = 12, LPI2C clock frequency 2M. */ 208 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_FREQ CLOCK_GetRootClockFreq(BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT) 209 #define BOARD_MIPI_PANEL_TOUCH_RST_GPIO GPIO9 210 #define BOARD_MIPI_PANEL_TOUCH_RST_PIN 0 211 #define BOARD_MIPI_PANEL_TOUCH_INT_GPIO GPIO8 212 #define BOARD_MIPI_PANEL_TOUCH_INT_PIN 31 213 214 /*! @brief The camera pins. */ 215 #define BOARD_CAMERA_PWDN_GPIO GPIO9 216 #define BOARD_CAMERA_PWDN_PIN 25 217 #define BOARD_CAMERA_RST_GPIO GPIO11 218 #define BOARD_CAMERA_RST_PIN 15 219 220 /* SD card detection method when using wifi module. */ 221 #define BOARD_WIFI_SD_DETECT_TYPE kSDMMCHOST_DetectCardByHostDATA3 222 223 #define BOARD_BT_UART_INSTANCE 7 224 #define BOARD_BT_UART_BASEADDR (uint32_t) LPUART7 225 #define BOARD_BT_UART_BAUDRATE 3000000 226 #define BOARD_BT_UART_CLK_FREQ CLOCK_GetRootClockFreq(kCLOCK_Root_Lpuart7); 227 #define BOARD_BT_UART_IRQ LPUART7_IRQn 228 #define BOARD_BT_UART_IRQ_HANDLER LPUART7_IRQHandler 229 230 /*! @brief The Ethernet port used by network examples, default use 1G port. */ 231 /* Below comment is for test script to easily define which port to be used, please don't delete. */ 232 /* @TEST_ANCHOR */ 233 #ifndef BOARD_NETWORK_USE_100M_ENET_PORT 234 #define BOARD_NETWORK_USE_100M_ENET_PORT (0U) 235 #endif 236 237 /* Timer Manager definition. */ 238 #define BOARD_TM_INSTANCE 1 239 #define BOARD_TM_CLOCK_ROOT kCLOCK_Root_Gpt1 240 241 #if defined(__cplusplus) 242 extern "C" { 243 #endif /* __cplusplus */ 244 245 /******************************************************************************* 246 * API 247 ******************************************************************************/ 248 uint32_t BOARD_DebugConsoleSrcFreq(void); 249 250 void BOARD_InitDebugConsole(void); 251 252 void BOARD_ConfigMPU(void); 253 #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED 254 void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz); 255 status_t BOARD_LPI2C_Send(LPI2C_Type *base, 256 uint8_t deviceAddress, 257 uint32_t subAddress, 258 uint8_t subaddressSize, 259 uint8_t *txBuff, 260 uint8_t txBuffSize); 261 status_t BOARD_LPI2C_Receive(LPI2C_Type *base, 262 uint8_t deviceAddress, 263 uint32_t subAddress, 264 uint8_t subaddressSize, 265 uint8_t *rxBuff, 266 uint8_t rxBuffSize); 267 status_t BOARD_LPI2C_SendSCCB(LPI2C_Type *base, 268 uint8_t deviceAddress, 269 uint32_t subAddress, 270 uint8_t subaddressSize, 271 uint8_t *txBuff, 272 uint8_t txBuffSize); 273 status_t BOARD_LPI2C_ReceiveSCCB(LPI2C_Type *base, 274 uint8_t deviceAddress, 275 uint32_t subAddress, 276 uint8_t subaddressSize, 277 uint8_t *rxBuff, 278 uint8_t rxBuffSize); 279 void BOARD_Accel_I2C_Init(void); 280 status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff); 281 status_t BOARD_Accel_I2C_Receive( 282 uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 283 void BOARD_Codec_I2C_Init(void); 284 status_t BOARD_Codec_I2C_Send( 285 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 286 status_t BOARD_Codec_I2C_Receive( 287 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 288 void BOARD_Camera_I2C_Init(void); 289 status_t BOARD_Camera_I2C_Send( 290 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 291 status_t BOARD_Camera_I2C_Receive( 292 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 293 294 status_t BOARD_Camera_I2C_SendSCCB( 295 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 296 status_t BOARD_Camera_I2C_ReceiveSCCB( 297 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 298 299 void BOARD_MIPIPanelTouch_I2C_Init(void); 300 status_t BOARD_MIPIPanelTouch_I2C_Send( 301 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 302 status_t BOARD_MIPIPanelTouch_I2C_Receive( 303 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 304 #endif /* SDK_I2C_BASED_COMPONENT_USED */ 305 306 void BOARD_SD_Pin_Config(uint32_t speed, uint32_t strength); 307 void BOARD_MMC_Pin_Config(uint32_t speed, uint32_t strength); 308 309 #if defined(__cplusplus) 310 } 311 #endif /* __cplusplus */ 312 313 #endif /* _BOARD_H_ */ 314