1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17 /** 18 * @file iot_gpio_ex.h 19 * 20 * @brief Declares the extended GPIO interface functions. 21 * 22 * These functions are used for settings GPIO pulls and driver strength. \n 23 * 24 * @since 1.0 25 * @version 1.0 26 */ 27 28 #ifndef IOT_GPIO_EX_H 29 #define IOT_GPIO_EX_H 30 31 32 /** 33 * @brief Enumerates the functions of GPIO hardware pin 0. 34 */ 35 typedef enum { 36 /** GPIO0 function */ 37 IOT_GPIO_FUNC_GPIO_0_GPIO, 38 /** Functions of UART1 TXD */ 39 IOT_GPIO_FUNC_GPIO_0_UART1_TXD = 2, 40 /** SPI1 CK function */ 41 IOT_GPIO_FUNC_GPIO_0_SPI1_CK, 42 /** Functions of JTAG TD0 */ 43 IOT_GPIO_FUNC_GPIO_0_JTAG_TDO, 44 /** PWM3 OUT function */ 45 IOT_GPIO_FUNC_GPIO_0_PWM3_OUT, 46 /** I2C1 SDA function */ 47 IOT_GPIO_FUNC_GPIO_0_I2C1_SDA, 48 } WifiIotIoFuncGpio0; 49 50 /** 51 * @brief Enumerates the functions of GPIO hardware pin 1. 52 */ 53 typedef enum { 54 /** GPIO1 function */ 55 IOT_GPIO_FUNC_GPIO_1_GPIO, 56 /** UART1 RXD function */ 57 IOT_GPIO_FUNC_GPIO_1_UART1_RXD = 2, 58 /** SPI1 RXD function */ 59 IOT_GPIO_FUNC_GPIO_1_SPI1_RXD, 60 /** JTAG TCKfunction */ 61 IOT_GPIO_FUNC_GPIO_1_JTAG_TCK, 62 /** PWM4 OUT function */ 63 IOT_GPIO_FUNC_GPIO_1_PWM4_OUT, 64 /** I2C1 SCL function */ 65 IOT_GPIO_FUNC_GPIO_1_I2C1_SCL, 66 /** BT FREQ function */ 67 IOT_GPIO_FUNC_GPIO_1_BT_FREQ, 68 } WifiiIotIoFuncGpio1; 69 70 /** 71 * @brief Enumerates the functions of GPIO hardware pin 2. 72 */ 73 typedef enum { 74 /** GPIO2 function */ 75 IOT_GPIO_FUNC_GPIO_2_GPIO, 76 /** UART1 RTS function */ 77 IOT_GPIO_FUNC_GPIO_2_UART1_RTS_N = 2, 78 /** SPI1 TXD function */ 79 IOT_GPIO_FUNC_GPIO_2_SPI1_TXD, 80 /** JTAG TRSTN function */ 81 IOT_GPIO_FUNC_GPIO_2_JTAG_TRSTN, 82 /** PWM2 OUT function */ 83 IOT_GPIO_FUNC_GPIO_2_PWM2_OUT, 84 /** SSI CLK function */ 85 IOT_GPIO_FUNC_GPIO_2_SSI_CLK = 7, 86 } WifiIotIoFuncGpio2; 87 88 /** 89 * @brief Enumerates the functions of GPIO hardware pin 3. 90 */ 91 typedef enum { 92 /** GPIO3 function */ 93 IOT_GPIO_FUNC_GPIO_3_GPIO, 94 /** UART0 TXD function */ 95 IOT_GPIO_FUNC_GPIO_3_UART0_TXD, 96 /** UART1 CTS function */ 97 IOT_GPIO_FUNC_GPIO_3_UART1_CTS_N, 98 /** SPI CSN function */ 99 IOT_GPIO_FUNC_GPIO_3_SPI1_CSN, 100 /** JTAG TDI function */ 101 IOT_GPIO_FUNC_GPIO_3_JTAG_TDI, 102 /** PWM5 OUT function */ 103 IOT_GPIO_FUNC_GPIO_3_PWM5_OUT, 104 /** I2C1 SDA function */ 105 IOT_GPIO_FUNC_GPIO_3_I2C1_SDA, 106 /** SSI DATA function */ 107 IOT_GPIO_FUNC_GPIO_3_SSI_DATA, 108 } WifiIotIoFuncGpio3; 109 110 /** 111 * @brief Enumerates the functions of GPIO hardware pin 4. 112 */ 113 typedef enum { 114 /** GPIO4 function */ 115 IOT_GPIO_FUNC_GPIO_4_GPIO, 116 /** UART0 RXD function */ 117 IOT_GPIO_FUNC_GPIO_4_UART0_RXD = 2, 118 /** JTAG TMS function */ 119 IOT_GPIO_FUNC_GPIO_4_JTAG_TMS = 4, 120 /** PWM1 OUT function */ 121 IOT_GPIO_FUNC_GPIO_4_PWM1_OUT, 122 /** I2C1 SCL function */ 123 IOT_GPIO_FUNC_GPIO_4_I2C1_SCL, 124 } WifiIotIoFuncGpio4; 125 126 /** 127 * @brief Enumerates the functions of GPIO hardware pin 5. 128 */ 129 typedef enum { 130 /** GPIO5 function */ 131 IOT_GPIO_FUNC_GPIO_5_GPIO, 132 /** UART1 RXD function */ 133 IOT_GPIO_FUNC_GPIO_5_UART1_RXD = 2, 134 /** SPI0 CSN function */ 135 IOT_GPIO_FUNC_GPIO_5_SPI0_CSN, 136 /** PWM2 OUT function */ 137 IOT_GPIO_FUNC_GPIO_5_PWM2_OUT = 5, 138 /** I2C0 MCLK function */ 139 IOT_GPIO_FUNC_GPIO_5_I2S0_MCLK, 140 /** BT STATUS function */ 141 IOT_GPIO_FUNC_GPIO_5_BT_STATUS, 142 } WifiIotIoFuncGpio5; 143 144 /** 145 * @brief Enumerates the functions of GPIO hardware pin 6. 146 */ 147 typedef enum { 148 /** GPIO6 function */ 149 IOT_GPIO_FUNC_GPIO_6_GPIO, 150 /** UART1 TXD function */ 151 IOT_GPIO_FUNC_GPIO_6_UART1_TXD = 2, 152 /** SPI0 CK function */ 153 IOT_GPIO_FUNC_GPIO_6_SPI0_CK, 154 /** PWM3 OUT function */ 155 IOT_GPIO_FUNC_GPIO_6_PWM3_OUT = 5, 156 /** I2S0 TX function */ 157 IOT_GPIO_FUNC_GPIO_6_I2S0_TX, 158 /** COEX switch function */ 159 IOT_GPIO_FUNC_GPIO_6_COEX_SWITCH, 160 } WifiIotIoFuncGpio6; 161 162 /** 163 * @brief Enumerates the functions of GPIO hardware pin 7. 164 */ 165 typedef enum { 166 /** GPIO7 function */ 167 IOT_GPIO_FUNC_GPIO_7_GPIO, 168 /** UART1 CTS function */ 169 IOT_GPIO_FUNC_GPIO_7_UART1_CTS_N = 2, 170 /** SPI0 RXD function */ 171 IOT_GPIO_FUNC_GPIO_7_SPI0_RXD, 172 /** PWM0 OUT function */ 173 IOT_GPIO_FUNC_GPIO_7_PWM0_OUT = 5, 174 /** I2S0 BCLK function */ 175 IOT_GPIO_FUNC_GPIO_7_I2S0_BCLK, 176 /** BT ACTIVE function */ 177 IOT_GPIO_FUNC_GPIO_7_BT_ACTIVE, 178 } WifiIotIoFuncGpio7; 179 180 /** 181 * @brief Enumerates the functions of GPIO hardware pin 8. 182 */ 183 typedef enum { 184 /** GPIO8 function */ 185 IOT_GPIO_FUNC_GPIO_8_GPIO, 186 /** UART1 RTS function */ 187 IOT_GPIO_FUNC_GPIO_8_UART1_RTS_N = 2, 188 /** SPI0 TXD function */ 189 IOT_GPIO_FUNC_GPIO_8_SPI0_TXD, 190 /** PWM1 OUT function */ 191 IOT_GPIO_FUNC_GPIO_8_PWM1_OUT = 5, 192 /** I2S0 WS function */ 193 IOT_GPIO_FUNC_GPIO_8_I2S0_WS, 194 /** WLAN ACTIVE function */ 195 IOT_GPIO_FUNC_GPIO_8_WLAN_ACTIVE, 196 } WifiIotIoFuncGpio8; 197 198 /** 199 * @brief Enumerates the functions of GPIO hardware pin 9. 200 */ 201 typedef enum { 202 /** GPIO9 function */ 203 IOT_GPIO_FUNC_GPIO_9_GPIO, 204 /** I2C0 SCL function */ 205 IOT_GPIO_FUNC_GPIO_9_I2C0_SCL, 206 /** UART2 RTS function */ 207 IOT_GPIO_FUNC_GPIO_9_UART2_RTS_N, 208 /** SDIO D2 function */ 209 IOT_GPIO_FUNC_GPIO_9_SDIO_D2, 210 /** SPI0 TXD function */ 211 IOT_GPIO_FUNC_GPIO_9_SPI0_TXD, 212 /** PWM0 OUT function */ 213 IOT_GPIO_FUNC_GPIO_9_PWM0_OUT, 214 /** I2S0 MCLK function */ 215 IOT_GPIO_FUNC_GPIO_9_I2S0_MCLK = 7, 216 } WifiIotIoFuncGpio9; 217 218 /** 219 * @brief Enumerates the functions of GPIO hardware pin 10. 220 */ 221 typedef enum { 222 /** GPIO10 function */ 223 IOT_GPIO_FUNC_GPIO_10_GPIO, 224 /** I2C0 SDA function */ 225 IOT_GPIO_FUNC_GPIO_10_I2C0_SDA, 226 /** UART2 CTS function */ 227 IOT_GPIO_FUNC_GPIO_10_UART2_CTS_N, 228 /** SDIO D3 function */ 229 IOT_GPIO_FUNC_GPIO_10_SDIO_D3, 230 /** SPI0 CK function */ 231 IOT_GPIO_FUNC_GPIO_10_SPI0_CK, 232 /** PWM1 OUT function */ 233 IOT_GPIO_FUNC_GPIO_10_PWM1_OUT, 234 /** I2S0 TX function */ 235 IOT_GPIO_FUNC_GPIO_10_I2S0_TX = 7, 236 } WifiIotIoFuncGpio10; 237 238 /** 239 * @brief Enumerates the functions of GPIO hardware pin 11. 240 */ 241 typedef enum { 242 /** GPIO11 function */ 243 IOT_GPIO_FUNC_GPIO_11_GPIO, 244 /** UART2 TXD function */ 245 IOT_GPIO_FUNC_GPIO_11_UART2_TXD = 2, 246 /** SDIO CMD function */ 247 IOT_GPIO_FUNC_GPIO_11_SDIO_CMD, 248 /** SDIO RXD function */ 249 IOT_GPIO_FUNC_GPIO_11_SPI0_RXD, 250 /** PWM2 OUT function */ 251 IOT_GPIO_FUNC_GPIO_11_PWM2_OUT, 252 /** RF TX_EN_EXT function */ 253 IOT_GPIO_FUNC_GPIO_11_RF_TX_EN_EXT, 254 /** I2S0 RX function */ 255 IOT_GPIO_FUNC_GPIO_11_I2S0_RX, 256 } WifiIotIoFuncGpio11; 257 258 /** 259 * @brief Enumerates the functions of GPIO hardware pin 12. 260 */ 261 typedef enum { 262 /** GPIO12 function */ 263 IOT_GPIO_FUNC_GPIO_12_GPIO, 264 /** SUART2 RXD function */ 265 IOT_GPIO_FUNC_GPIO_12_UART2_RXD = 2, 266 /** SDIO CLK function */ 267 IOT_GPIO_FUNC_GPIO_12_SDIO_CLK, 268 /** SDIO CSN function */ 269 IOT_GPIO_FUNC_GPIO_12_SPI0_CSN, 270 /** PWM3 OUT function */ 271 IOT_GPIO_FUNC_GPIO_12_PWM3_OUT, 272 /** RF RX_EN_EXT function */ 273 IOT_GPIO_FUNC_GPIO_12_RF_RX_EN_EXT, 274 /** I2S0 BCLK function */ 275 IOT_GPIO_FUNC_GPIO_12_I2S0_BCLK, 276 } WifiIotIoFuncGpio12; 277 278 /** 279 * @brief Enumerates the functions of GPIO hardware pin 13. 280 */ 281 typedef enum { 282 /** SSI DATA function */ 283 IOT_GPIO_FUNC_GPIO_13_SSI_DATA, 284 /** UART0 TXD function */ 285 IOT_GPIO_FUNC_GPIO_13_UART0_TXD, 286 /** UART2 RTS function */ 287 IOT_GPIO_FUNC_GPIO_13_UART2_RTS_N, 288 /** SDIO D0 function */ 289 IOT_GPIO_FUNC_GPIO_13_SDIO_D0, 290 /** GPIO13 function */ 291 IOT_GPIO_FUNC_GPIO_13_GPIO, 292 /** PWM4 OUT function */ 293 IOT_GPIO_FUNC_GPIO_13_PWM4_OUT, 294 /** I2C0 SDA function */ 295 IOT_GPIO_FUNC_GPIO_13_I2C0_SDA, 296 /** I2S0 WS function */ 297 IOT_GPIO_FUNC_GPIO_13_I2S0_WS, 298 } WifiIotIoFuncGpio13; 299 300 /** 301 * @brief Enumerates the functions of GPIO hardware pin 14. 302 */ 303 typedef enum { 304 /** SSI CLK function */ 305 IOT_GPIO_FUNC_GPIO_14_SSI_CLK, 306 /** UART0 RXD function */ 307 IOT_GPIO_FUNC_GPIO_14_UART0_RXD, 308 /** UART2 CTS function */ 309 IOT_GPIO_FUNC_GPIO_14_UART2_CTS_N, 310 /** SDIO D1 function */ 311 IOT_GPIO_FUNC_GPIO_14_SDIO_D1, 312 /** GPIO14 function */ 313 IOT_GPIO_FUNC_GPIO_14_GPIO, 314 /** PWM5 OUT function */ 315 IOT_GPIO_FUNC_GPIO_14_PWM5_OUT, 316 /** I2C0 SCL function */ 317 IOT_GPIO_FUNC_GPIO_14_I2C0_SCL, 318 } WifiIotIoFuncGpio14; 319 320 /** 321 * @brief Enumerates GPIO pull-up or pull-down settings. 322 */ 323 typedef enum { 324 /** No pull */ 325 IOT_GPIO_PULL_NONE, 326 /** Pull-up */ 327 IOT_GPIO_PULL_UP, 328 /** Pull-down */ 329 IOT_GPIO_PULL_DOWN, 330 /** Maximum value */ 331 IOT_GPIO_PULL_MAX, 332 } IotGpioPull; 333 334 335 unsigned int IoTGpioSetFunc(unsigned int id, unsigned char val); 336 337 unsigned int IoTGpioSetPull(unsigned int id, IotGpioPull val); 338 339 #endif 340 /** @} */