1 /** 2 3 ****************************************************************************** 4 5 * @file bl602_gpio.h 6 7 * @version V1.2 8 9 * @date 2019-12-14 10 11 * @brief This file is the description of.IP register 12 13 ****************************************************************************** 14 15 * @attention 16 17 * 18 19 * <h2><center>© COPYRIGHT(c) 2019 Bouffalo Lab</center></h2> 20 21 * 22 23 * Redistribution and use in source and binary forms, with or without modification, 24 25 * are permitted provided that the following conditions are met: 26 27 * 1. Redistributions of source code must retain the above copyright notice, 28 29 * this list of conditions and the following disclaimer. 30 31 * 2. Redistributions in binary form must reproduce the above copyright notice, 32 33 * this list of conditions and the following disclaimer in the documentation 34 35 * and/or other materials provided with the distribution. 36 37 * 3. Neither the name of Bouffalo Lab nor the names of its contributors 38 39 * may be used to endorse or promote products derived from this software 40 41 * without specific prior written permission. 42 43 * 44 45 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 46 47 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 48 49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 50 51 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 52 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 56 57 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 58 59 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 60 61 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 62 63 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 64 65 * 66 67 ****************************************************************************** 68 69 */ 70 71 #ifndef __BL602_GPIO_H__ 72 #define __BL602_GPIO_H__ 73 74 typedef enum { 75 GLB_GPIO_PIN_0 = 0, 76 GLB_GPIO_PIN_1, 77 GLB_GPIO_PIN_2, 78 GLB_GPIO_PIN_3, 79 GLB_GPIO_PIN_4, 80 GLB_GPIO_PIN_5, 81 GLB_GPIO_PIN_6, 82 GLB_GPIO_PIN_7, 83 GLB_GPIO_PIN_8, 84 GLB_GPIO_PIN_9, 85 GLB_GPIO_PIN_10, 86 GLB_GPIO_PIN_11, 87 GLB_GPIO_PIN_12, 88 GLB_GPIO_PIN_13, 89 GLB_GPIO_PIN_14, 90 GLB_GPIO_PIN_15, 91 GLB_GPIO_PIN_16, 92 GLB_GPIO_PIN_17, 93 GLB_GPIO_PIN_18, 94 GLB_GPIO_PIN_19, 95 GLB_GPIO_PIN_20, 96 GLB_GPIO_PIN_21, 97 GLB_GPIO_PIN_22, 98 GLB_GPIO_PIN_MAX, 99 } GLB_GPIO_Type; 100 101 #define GPIO_MODE_INPUT ((uint32_t)0x00000000U) /*!< Input Floating Mode */ 102 #define GPIO_MODE_OUTPUT ((uint32_t)0x00000001U) /*!< Output Push Pull Mode */ 103 #define GPIO_MODE_AF ((uint32_t)0x00000002U) /*!< Alternate function */ 104 #define GPIO_MODE_ANALOG ((uint32_t)0x00000003U) /*!< Analog function */ 105 #define GPIO_PULL_UP ((uint32_t)0x00000000U) /*!< GPIO pull up */ 106 #define GPIO_PULL_DOWN ((uint32_t)0x00000001U) /*!< GPIO pull down */ 107 #define GPIO_PULL_NONE ((uint32_t)0x00000002U) /*!< GPIO no pull up or down */ 108 109 typedef enum { 110 GPIO_FUN_SDIO = 1, 111 GPIO_FUN_FLASH = 2, 112 GPIO_FUN_SPI = 4, 113 GPIO_FUN_I2C = 6, 114 GPIO_FUN_UART = 7, 115 GPIO_FUN_PWM = 8, 116 GPIO_FUN_EXT_PA = 9, 117 GPIO_FUN_ANALOG = 10, 118 GPIO_FUN_SWGPIO = 11, 119 GPIO_FUN_GPIO = 11, 120 GPIO_FUN_JTAG = 14, 121 GPIO_FUN_UART0_RTS = 0x70, 122 GPIO_FUN_UART0_CTS = 0x71, 123 GPIO_FUN_UART0_TX = 0x72, 124 GPIO_FUN_UART0_RX = 0x73, 125 GPIO_FUN_UART1_RTS = 0x74, 126 GPIO_FUN_UART1_CTS = 0x75, 127 GPIO_FUN_UART1_TX = 0x76, 128 GPIO_FUN_UART1_RX = 0x77, 129 GPIO_FUN_GPIO_OUTPUT = 0x80, 130 GPIO_FUN_GPIO_INPUT = 0x81, 131 GPIO_FUN_UNUSED = 255, 132 } GLB_GPIO_FUNC_Type; 133 134 typedef struct 135 { 136 uint8_t gpioPin; 137 uint8_t gpioFun; 138 uint8_t gpioMode; 139 uint8_t pullType; 140 uint8_t drive; 141 uint8_t smtCtrl; 142 } GLB_GPIO_Cfg_Type; 143 144 /* GPIO0 function definition */ 145 #define GPIO0_FUN_SDIO_CLK 1 146 #define GPIO0_FUN_SF_D1 2 147 #define GPIO0_FUN_UNUSED3 3 148 #define GPIO0_FUN_SPI_MOSI_SPI_MISO 4 149 #define GPIO0_FUN_UNUSED5 5 150 #define GPIO0_FUN_I2C_SCL 6 151 #define GPIO0_FUN_UART_SIG0 7 152 #define GPIO0_FUN_PWM_CH0 8 153 #define GPIO0_FUN_FEM_GPIO_0 9 154 #define GPIO0_FUN_ATEST_IN 10 155 #define GPIO0_FUN_SWGPIO_0 11 156 #define GPIO0_FUN_E21_TMS 14 157 /* GPIO1 function definition */ 158 #define GPIO1_FUN_SDIO_CMD 1 159 #define GPIO1_FUN_SF_D2 2 160 #define GPIO1_FUN_UNUSED3 3 161 #define GPIO1_FUN_SPI_MISO_SPI_MOSI 4 162 #define GPIO1_FUN_UNUSED5 5 163 #define GPIO1_FUN_I2C_SDA 6 164 #define GPIO1_FUN_UART_SIG1 7 165 #define GPIO1_FUN_PWM_CH1 8 166 #define GPIO1_FUN_FEM_GPIO_1 9 167 #define GPIO1_FUN_ATEST_IP 10 168 #define GPIO1_FUN_SWGPIO_1 11 169 #define GPIO1_FUN_E21_TDI 14 170 /* GPIO2 function definition */ 171 #define GPIO2_FUN_SDIO_DAT0 1 172 #define GPIO2_FUN_SF_D3 2 173 #define GPIO2_FUN_UNUSED3 3 174 #define GPIO2_FUN_SPI_SS 4 175 #define GPIO2_FUN_UNUSED5 5 176 #define GPIO2_FUN_I2C_SCL 6 177 #define GPIO2_FUN_UART_SIG2 7 178 #define GPIO2_FUN_PWM_CH2 8 179 #define GPIO2_FUN_FEM_GPIO_2 9 180 #define GPIO2_FUN_ATEST_QN 10 181 #define GPIO2_FUN_SWGPIO_2 11 182 #define GPIO2_FUN_E21_TCK 14 183 /* GPIO3 function definition */ 184 #define GPIO3_FUN_SDIO_DAT1 1 185 #define GPIO3_FUN_UNUSED2 2 186 #define GPIO3_FUN_UNUSED3 3 187 #define GPIO3_FUN_SPI_SCLK 4 188 #define GPIO3_FUN_UNUSED5 5 189 #define GPIO3_FUN_I2C_SDA 6 190 #define GPIO3_FUN_UART_SIG3 7 191 #define GPIO3_FUN_PWM_CH3 8 192 #define GPIO3_FUN_FEM_GPIO_3 9 193 #define GPIO3_FUN_ATEST_QP 10 194 #define GPIO3_FUN_SWGPIO_3 11 195 #define GPIO3_FUN_E21_TDO 14 196 /* GPIO4 function definition */ 197 #define GPIO4_FUN_SDIO_DAT2 1 198 #define GPIO4_FUN_UNUSED2 2 199 #define GPIO4_FUN_UNUSED3 3 200 #define GPIO4_FUN_SPI_MOSI_SPI_MISO 4 201 #define GPIO4_FUN_UNUSED5 5 202 #define GPIO4_FUN_I2C_SCL 6 203 #define GPIO4_FUN_UART_SIG4 7 204 #define GPIO4_FUN_PWM_CH4 8 205 #define GPIO4_FUN_FEM_GPIO_0 9 206 #define GPIO4_FUN_GPIP_CH1 10 207 #define GPIO4_FUN_SWGPIO_4 11 208 #define GPIO4_FUN_E21_TMS 14 209 /* GPIO5 function definition */ 210 #define GPIO5_FUN_SDIO_DAT3 1 211 #define GPIO5_FUN_UNUSED2 2 212 #define GPIO5_FUN_UNUSED3 3 213 #define GPIO5_FUN_SPI_MISO_SPI_MOSI 4 214 #define GPIO5_FUN_UNUSED5 5 215 #define GPIO5_FUN_I2C_SDA 6 216 #define GPIO5_FUN_UART_SIG5 7 217 #define GPIO5_FUN_PWM_CH0 8 218 #define GPIO5_FUN_FEM_GPIO_1 9 219 #define GPIO5_FUN_GPIP_CH4 10 220 #define GPIO5_FUN_SWGPIO_5 11 221 #define GPIO5_FUN_E21_TDI 14 222 /* GPIO6 function definition */ 223 #define GPIO6_FUN_UNUSED1 1 224 #define GPIO6_FUN_UNUSED2 2 225 #define GPIO6_FUN_UNUSED3 3 226 #define GPIO6_FUN_SPI_SS 4 227 #define GPIO6_FUN_UNUSED5 5 228 #define GPIO6_FUN_I2C_SCL 6 229 #define GPIO6_FUN_UART_SIG6 7 230 #define GPIO6_FUN_PWM_CH1 8 231 #define GPIO6_FUN_FEM_GPIO_2 9 232 #define GPIO6_FUN_GPIP_CH5 10 233 #define GPIO6_FUN_SWGPIO_6 11 234 #define GPIO6_FUN_E21_TCK 14 235 /* GPIO7 function definition */ 236 #define GPIO7_FUN_UNUSED1 1 237 #define GPIO7_FUN_UNUSED2 2 238 #define GPIO7_FUN_UNUSED3 3 239 #define GPIO7_FUN_SPI_SCLK 4 240 #define GPIO7_FUN_UNUSED5 5 241 #define GPIO7_FUN_I2C_SDA 6 242 #define GPIO7_FUN_UART_SIG7 7 243 #define GPIO7_FUN_PWM_CH2 8 244 #define GPIO7_FUN_FEM_GPIO_3 9 245 #define GPIO7_FUN_UNUSED10 10 246 #define GPIO7_FUN_SWGPIO_7 11 247 #define GPIO7_FUN_E21_TDO 14 248 /* GPIO8 function definition */ 249 #define GPIO8_FUN_UNUSED1 1 250 #define GPIO8_FUN_UNUSED2 2 251 #define GPIO8_FUN_UNUSED3 3 252 #define GPIO8_FUN_SPI_MOSI_SPI_MISO 4 253 #define GPIO8_FUN_UNUSED5 5 254 #define GPIO8_FUN_I2C_SCL 6 255 #define GPIO8_FUN_UART_SIG0 7 256 #define GPIO8_FUN_PWM_CH3 8 257 #define GPIO8_FUN_FEM_GPIO_0 9 258 #define GPIO8_FUN_UNUSED10 10 259 #define GPIO8_FUN_SWGPIO_8 11 260 #define GPIO8_FUN_E21_TMS 14 261 /* GPIO9 function definition */ 262 #define GPIO9_FUN_UNUSED1 1 263 #define GPIO9_FUN_UNUSED2 2 264 #define GPIO9_FUN_UNUSED3 3 265 #define GPIO9_FUN_SPI_MISO_SPI_MOSI 4 266 #define GPIO9_FUN_UNUSED5 5 267 #define GPIO9_FUN_I2C_SDA 6 268 #define GPIO9_FUN_UART_SIG1 7 269 #define GPIO9_FUN_PWM_CH4 8 270 #define GPIO9_FUN_FEM_GPIO_1 9 271 #define GPIO9_FUN_GPIP_CH6_GPIP_CH7 10 272 #define GPIO9_FUN_SWGPIO_9 11 273 #define GPIO9_FUN_E21_TDI 14 274 /* GPIO10 function definition */ 275 #define GPIO10_FUN_UNUSED1 1 276 #define GPIO10_FUN_UNUSED2 2 277 #define GPIO10_FUN_UNUSED3 3 278 #define GPIO10_FUN_SPI_SS 4 279 #define GPIO10_FUN_UNUSED5 5 280 #define GPIO10_FUN_I2C_SCL 6 281 #define GPIO10_FUN_UART_SIG2 7 282 #define GPIO10_FUN_PWM_CH0 8 283 #define GPIO10_FUN_FEM_GPIO_2 9 284 #define GPIO10_FUN_MICBIAS_GPIP_CH8_GPIP_CH9 10 285 #define GPIO10_FUN_SWGPIO_10 11 286 #define GPIO10_FUN_E21_TCK 14 287 /* GPIO11 function definition */ 288 #define GPIO11_FUN_UNUSED1 1 289 #define GPIO11_FUN_UNUSED2 2 290 #define GPIO11_FUN_UNUSED3 3 291 #define GPIO11_FUN_SPI_SCLK 4 292 #define GPIO11_FUN_UNUSED5 5 293 #define GPIO11_FUN_I2C_SDA 6 294 #define GPIO11_FUN_UART_SIG3 7 295 #define GPIO11_FUN_PWM_CH1 8 296 #define GPIO11_FUN_FEM_GPIO_3 9 297 #define GPIO11_FUN_IRLED_OUT_GPIP_CH10 10 298 #define GPIO11_FUN_SWGPIO_11 11 299 #define GPIO11_FUN_E21_TDO 14 300 /* GPIO12 function definition */ 301 #define GPIO12_FUN_UNUSED1 1 302 #define GPIO12_FUN_UNUSED2 2 303 #define GPIO12_FUN_UNUSED3 3 304 #define GPIO12_FUN_SPI_MOSI_SPI_MISO 4 305 #define GPIO12_FUN_UNUSED5 5 306 #define GPIO12_FUN_I2C_SCL 6 307 #define GPIO12_FUN_UART_SIG4 7 308 #define GPIO12_FUN_PWM_CH2 8 309 #define GPIO12_FUN_FEM_GPIO_0 9 310 #define GPIO12_FUN_GPIP_CH0_GPADC_VREF_EXT 10 311 #define GPIO12_FUN_SWGPIO_12 11 312 #define GPIO12_FUN_E21_TMS 14 313 /* GPIO13 function definition */ 314 #define GPIO13_FUN_UNUSED1 1 315 #define GPIO13_FUN_UNUSED2 2 316 #define GPIO13_FUN_UNUSED3 3 317 #define GPIO13_FUN_SPI_MISO_SPI_MOSI 4 318 #define GPIO13_FUN_UNUSED5 5 319 #define GPIO13_FUN_I2C_SDA 6 320 #define GPIO13_FUN_UART_SIG5 7 321 #define GPIO13_FUN_PWM_CH3 8 322 #define GPIO13_FUN_FEM_GPIO_1 9 323 #define GPIO13_FUN_GPIP_CH3 10 324 #define GPIO13_FUN_SWGPIO_13 11 325 #define GPIO13_FUN_E21_TDI 14 326 /* GPIO14 function definition */ 327 #define GPIO14_FUN_UNUSED1 1 328 #define GPIO14_FUN_UNUSED2 2 329 #define GPIO14_FUN_UNUSED3 3 330 #define GPIO14_FUN_SPI_SS 4 331 #define GPIO14_FUN_UNUSED5 5 332 #define GPIO14_FUN_I2C_SCL 6 333 #define GPIO14_FUN_UART_SIG6 7 334 #define GPIO14_FUN_PWM_CH4 8 335 #define GPIO14_FUN_FEM_GPIO_2 9 336 #define GPIO14_FUN_GPIP_CH2 10 337 #define GPIO14_FUN_SWGPIO_14 11 338 #define GPIO14_FUN_E21_TCK 14 339 /* GPIO15 function definition */ 340 #define GPIO15_FUN_UNUSED1 1 341 #define GPIO15_FUN_UNUSED2 2 342 #define GPIO15_FUN_UNUSED3 3 343 #define GPIO15_FUN_SPI_SCLK 4 344 #define GPIO15_FUN_UNUSED5 5 345 #define GPIO15_FUN_I2C_SDA 6 346 #define GPIO15_FUN_UART_SIG7 7 347 #define GPIO15_FUN_PWM_CH0 8 348 #define GPIO15_FUN_FEM_GPIO_3 9 349 #define GPIO15_FUN_PSW_IRRCV_OUT_GPIP_CH11 10 350 #define GPIO15_FUN_SWGPIO_15 11 351 #define GPIO15_FUN_E21_TDO 14 352 /* GPIO16 function definition */ 353 #define GPIO16_FUN_UNUSED1 1 354 #define GPIO16_FUN_UNUSED2 2 355 #define GPIO16_FUN_UNUSED3 3 356 #define GPIO16_FUN_SPI_MOSI_SPI_MISO 4 357 #define GPIO16_FUN_UNUSED5 5 358 #define GPIO16_FUN_I2C_SCL 6 359 #define GPIO16_FUN_UART_SIG0 7 360 #define GPIO16_FUN_PWM_CH1 8 361 #define GPIO16_FUN_FEM_GPIO_0 9 362 #define GPIO16_FUN_UNUSED10 10 363 #define GPIO16_FUN_SWGPIO_16 11 364 #define GPIO16_FUN_E21_TMS 14 365 /* GPIO17 function definition */ 366 #define GPIO17_FUN_UNUSED1 1 367 #define GPIO17_FUN_SF_D3 2 368 #define GPIO17_FUN_UNUSED3 3 369 #define GPIO17_FUN_SPI_MISO_SPI_MOSI 4 370 #define GPIO17_FUN_UNUSED5 5 371 #define GPIO17_FUN_I2C_SDA 6 372 #define GPIO17_FUN_UART_SIG1 7 373 #define GPIO17_FUN_PWM_CH2 8 374 #define GPIO17_FUN_FEM_GPIO_1 9 375 #define GPIO17_FUN_PMIP_DC_TP_OUT 10 376 #define GPIO17_FUN_SWGPIO_17 11 377 #define GPIO17_FUN_E21_TDI 14 378 /* GPIO18 function definition */ 379 #define GPIO18_FUN_UNUSED1 1 380 #define GPIO18_FUN_SF_D2 2 381 #define GPIO18_FUN_UNUSED3 3 382 #define GPIO18_FUN_SPI_SS 4 383 #define GPIO18_FUN_UNUSED5 5 384 #define GPIO18_FUN_I2C_SCL 6 385 #define GPIO18_FUN_UART_SIG2 7 386 #define GPIO18_FUN_PWM_CH3 8 387 #define GPIO18_FUN_FEM_GPIO_2 9 388 #define GPIO18_FUN_UNUSED10 10 389 #define GPIO18_FUN_SWGPIO_18 11 390 #define GPIO18_FUN_E21_TCK 14 391 /* GPIO19 function definition */ 392 #define GPIO19_FUN_UNUSED1 1 393 #define GPIO19_FUN_SF_D1 2 394 #define GPIO19_FUN_UNUSED3 3 395 #define GPIO19_FUN_SPI_SCLK 4 396 #define GPIO19_FUN_UNUSED5 5 397 #define GPIO19_FUN_I2C_SDA 6 398 #define GPIO19_FUN_UART_SIG3 7 399 #define GPIO19_FUN_PWM_CH4 8 400 #define GPIO19_FUN_FEM_GPIO_3 9 401 #define GPIO19_FUN_UNUSED10 10 402 #define GPIO19_FUN_SWGPIO_19 11 403 #define GPIO19_FUN_E21_TDO 14 404 /* GPIO20 function definition */ 405 #define GPIO20_FUN_UNUSED1 1 406 #define GPIO20_FUN_SF_D0 2 407 #define GPIO20_FUN_UNUSED3 3 408 #define GPIO20_FUN_SPI_MOSI_SPI_MISO 4 409 #define GPIO20_FUN_UNUSED5 5 410 #define GPIO20_FUN_I2C_SCL 6 411 #define GPIO20_FUN_UART_SIG4 7 412 #define GPIO20_FUN_PWM_CH0 8 413 #define GPIO20_FUN_FEM_GPIO_0 9 414 #define GPIO20_FUN_UNUSED10 10 415 #define GPIO20_FUN_SWGPIO_20 11 416 #define GPIO20_FUN_E21_TMS 14 417 /* GPIO21 function definition */ 418 #define GPIO21_FUN_UNUSED1 1 419 #define GPIO21_FUN_SF_CS 2 420 #define GPIO21_FUN_UNUSED3 3 421 #define GPIO21_FUN_SPI_MISO_SPI_MOSI 4 422 #define GPIO21_FUN_UNUSED5 5 423 #define GPIO21_FUN_I2C_SDA 6 424 #define GPIO21_FUN_UART_SIG5 7 425 #define GPIO21_FUN_PWM_CH1 8 426 #define GPIO21_FUN_FEM_GPIO_1 9 427 #define GPIO21_FUN_UNUSED10 10 428 #define GPIO21_FUN_SWGPIO_21 11 429 #define GPIO21_FUN_E21_TDI 14 430 /* GPIO22 function definition */ 431 #define GPIO22_FUN_UNUSED1 1 432 #define GPIO22_FUN_SF_CLK_OUT 2 433 #define GPIO22_FUN_UNUSED3 3 434 #define GPIO22_FUN_SPI_SS 4 435 #define GPIO22_FUN_UNUSED5 5 436 #define GPIO22_FUN_I2C_SCL 6 437 #define GPIO22_FUN_UART_SIG6 7 438 #define GPIO22_FUN_PWM_CH2 8 439 #define GPIO22_FUN_FEM_GPIO_2 9 440 #define GPIO22_FUN_UNUSED10 10 441 #define GPIO22_FUN_SWGPIO_22 11 442 #define GPIO22_FUN_E21_TCK 14 443 444 #endif /*__BL602_GPIO_H__ */ 445