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 /* 98 * We want this pulled for the CONFIG_FLASH_SIZE which sets things in the 99 * CMakeLists.txt 100 * 101 * #define BOARD_FLASH_SIZE (0x1000000U) 102 */ 103 104 /* SKIP_SEMC_INIT can also be defined independently */ 105 #ifdef USE_SDRAM 106 #define SKIP_SEMC_INIT 107 #endif 108 109 /*! @brief The ENET0 PHY address. */ 110 #define BOARD_ENET0_PHY_ADDRESS (0x02U) /* Phy address of enet port 0. */ 111 112 /*! @brief The ENET1 PHY address. */ 113 #define BOARD_ENET1_PHY_ADDRESS (0x01U) /* Phy address of enet port 1. */ 114 115 /*! @brief The EMVSIM SMARTCARD PHY configuration. */ 116 #define BOARD_SMARTCARD_MODULE (EMVSIM1) /*!< SMARTCARD communicational module instance */ 117 #define BOARD_SMARTCARD_MODULE_IRQ (EMVSIM1_IRQn) /*!< SMARTCARD communicational module IRQ handler */ 118 #define BOARD_SMARTCARD_CLOCK_MODULE_CLK_FREQ (CLOCK_GetRootClockFreq(kCLOCK_Root_Emv1)) 119 #define BOARD_SMARTCARD_CLOCK_VALUE (4000000U) /*!< SMARTCARD clock frequency */ 120 121 /* USB PHY condfiguration */ 122 #define BOARD_USB_PHY_D_CAL (0x07U) 123 #define BOARD_USB_PHY_TXCAL45DP (0x06U) 124 #define BOARD_USB_PHY_TXCAL45DM (0x06U) 125 126 #define BOARD_ARDUINO_INT_IRQ (GPIO1_INT3_IRQn) 127 #define BOARD_ARDUINO_I2C_IRQ (LPI2C1_IRQn) 128 #define BOARD_ARDUINO_I2C_INDEX (1) 129 130 #define BOARD_HAS_SDCARD (1U) 131 132 /* @Brief Board accelerator sensor configuration */ 133 #define BOARD_ACCEL_I2C_BASEADDR LPI2C5 134 /* Clock divider for LPI2C clock source */ 135 #define BOARD_ACCEL_I2C_CLOCK_FREQ (CLOCK_GetRootClockFreq(kCLOCK_Root_Lpi2c5)) 136 137 #define BOARD_CODEC_I2C_BASEADDR LPI2C5 138 #define BOARD_CODEC_I2C_INSTANCE 5U 139 #define BOARD_CODEC_I2C_CLOCK_SOURCE_SELECT (0U) 140 #define BOARD_CODEC_I2C_CLOCK_SOURCE_DIVIDER (6U) 141 #define BOARD_CODEC_I2C_CLOCK_FREQ (24000000U) 142 143 /* @Brief Board CAMERA configuration */ 144 #define BOARD_CAMERA_I2C_BASEADDR LPI2C6 145 #define BOARD_CAMERA_I2C_CLOCK_ROOT kCLOCK_Root_Lpi2c6 146 #define BOARD_CAMERA_I2C_CLOCK_SOURCE (1U) /* OSC24M. */ 147 #define BOARD_CAMERA_I2C_CLOCK_DIVIDER (12U) /* Divider = 12, LPI2C clock frequency 2M. */ 148 149 /*! @brief The MIPI panel pins. */ 150 #define BOARD_MIPI_PANEL_RST_GPIO GPIO9 151 #define BOARD_MIPI_PANEL_RST_PIN 1 152 #define BOARD_MIPI_PANEL_POWER_GPIO GPIO11 153 #define BOARD_MIPI_PANEL_POWER_PIN 16 154 /* Back light pin. */ 155 #define BOARD_MIPI_PANEL_BL_GPIO GPIO9 156 #define BOARD_MIPI_PANEL_BL_PIN 29 157 158 /* Touch panel. */ 159 #define BOARD_MIPI_PANEL_TOUCH_I2C_BASEADDR LPI2C5 160 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT kCLOCK_Root_Lpi2c5 161 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_SOURCE (1U) /* OSC24M. */ 162 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_DIVIDER (12U) /* Divider = 12, LPI2C clock frequency 2M. */ 163 #define BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_FREQ CLOCK_GetRootClockFreq(BOARD_MIPI_PANEL_TOUCH_I2C_CLOCK_ROOT) 164 #define BOARD_MIPI_PANEL_TOUCH_RST_GPIO GPIO9 165 #define BOARD_MIPI_PANEL_TOUCH_RST_PIN 0 166 #define BOARD_MIPI_PANEL_TOUCH_INT_GPIO GPIO8 167 #define BOARD_MIPI_PANEL_TOUCH_INT_PIN 31 168 169 /*! @brief The camera pins. */ 170 #define BOARD_CAMERA_PWDN_GPIO GPIO9 171 #define BOARD_CAMERA_PWDN_PIN 25 172 #define BOARD_CAMERA_RST_GPIO GPIO11 173 #define BOARD_CAMERA_RST_PIN 15 174 175 /* SD card detection method when using wifi module. */ 176 #define BOARD_WIFI_SD_DETECT_TYPE kSDMMCHOST_DetectCardByHostDATA3 177 178 #define BOARD_BT_UART_INSTANCE 7 179 #define BOARD_BT_UART_BAUDRATE 3000000 180 #define BOARD_BT_UART_CLK_FREQ CLOCK_GetRootClockFreq(kCLOCK_Root_Lpuart7); 181 #define BOARD_BT_UART_IRQ LPUART7_IRQn 182 #define BOARD_BT_UART_IRQ_HANDLER LPUART7_IRQHandler 183 184 #if defined(__cplusplus) 185 extern "C" { 186 #endif /* __cplusplus */ 187 188 /******************************************************************************* 189 * API 190 ******************************************************************************/ 191 uint32_t BOARD_DebugConsoleSrcFreq(void); 192 193 void BOARD_InitDebugConsole(void); 194 195 void BOARD_ConfigMPU(void); 196 #if defined(SDK_I2C_BASED_COMPONENT_USED) && SDK_I2C_BASED_COMPONENT_USED 197 void BOARD_LPI2C_Init(LPI2C_Type *base, uint32_t clkSrc_Hz); 198 status_t BOARD_LPI2C_Send(LPI2C_Type *base, 199 uint8_t deviceAddress, 200 uint32_t subAddress, 201 uint8_t subaddressSize, 202 uint8_t *txBuff, 203 uint8_t txBuffSize); 204 status_t BOARD_LPI2C_Receive(LPI2C_Type *base, 205 uint8_t deviceAddress, 206 uint32_t subAddress, 207 uint8_t subaddressSize, 208 uint8_t *rxBuff, 209 uint8_t rxBuffSize); 210 status_t BOARD_LPI2C_SendSCCB(LPI2C_Type *base, 211 uint8_t deviceAddress, 212 uint32_t subAddress, 213 uint8_t subaddressSize, 214 uint8_t *txBuff, 215 uint8_t txBuffSize); 216 status_t BOARD_LPI2C_ReceiveSCCB(LPI2C_Type *base, 217 uint8_t deviceAddress, 218 uint32_t subAddress, 219 uint8_t subaddressSize, 220 uint8_t *rxBuff, 221 uint8_t rxBuffSize); 222 void BOARD_Accel_I2C_Init(void); 223 status_t BOARD_Accel_I2C_Send(uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint32_t txBuff); 224 status_t BOARD_Accel_I2C_Receive( 225 uint8_t deviceAddress, uint32_t subAddress, uint8_t subaddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 226 void BOARD_Codec_I2C_Init(void); 227 status_t BOARD_Codec_I2C_Send( 228 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 229 status_t BOARD_Codec_I2C_Receive( 230 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 231 void BOARD_Camera_I2C_Init(void); 232 status_t BOARD_Camera_I2C_Send( 233 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 234 status_t BOARD_Camera_I2C_Receive( 235 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 236 237 status_t BOARD_Camera_I2C_SendSCCB( 238 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 239 status_t BOARD_Camera_I2C_ReceiveSCCB( 240 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 241 242 void BOARD_MIPIPanelTouch_I2C_Init(void); 243 status_t BOARD_MIPIPanelTouch_I2C_Send( 244 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize); 245 status_t BOARD_MIPIPanelTouch_I2C_Receive( 246 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 247 #endif /* SDK_I2C_BASED_COMPONENT_USED */ 248 249 void BOARD_SD_Pin_Config(uint32_t speed, uint32_t strength); 250 void BOARD_MMC_Pin_Config(uint32_t speed, uint32_t strength); 251 252 #if defined(__cplusplus) 253 } 254 #endif /* __cplusplus */ 255 256 #endif /* _BOARD_H_ */ 257