1 // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD 2 // 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 #pragma once 16 17 #include "soc/gpio_periph.h" 18 #include "soc/soc_caps.h" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 typedef enum { 25 GPIO_PORT_0 = 0, 26 GPIO_PORT_MAX, 27 } gpio_port_t; 28 29 #define GPIO_SEL_0 (BIT(0)) /*!< Pin 0 selected */ 30 #define GPIO_SEL_1 (BIT(1)) /*!< Pin 1 selected */ 31 #define GPIO_SEL_2 (BIT(2)) /*!< Pin 2 selected */ 32 #define GPIO_SEL_3 (BIT(3)) /*!< Pin 3 selected */ 33 #define GPIO_SEL_4 (BIT(4)) /*!< Pin 4 selected */ 34 #define GPIO_SEL_5 (BIT(5)) /*!< Pin 5 selected */ 35 #define GPIO_SEL_6 (BIT(6)) /*!< Pin 6 selected */ 36 #define GPIO_SEL_7 (BIT(7)) /*!< Pin 7 selected */ 37 #define GPIO_SEL_8 (BIT(8)) /*!< Pin 8 selected */ 38 #define GPIO_SEL_9 (BIT(9)) /*!< Pin 9 selected */ 39 #define GPIO_SEL_10 (BIT(10)) /*!< Pin 10 selected */ 40 #define GPIO_SEL_11 (BIT(11)) /*!< Pin 11 selected */ 41 #define GPIO_SEL_12 (BIT(12)) /*!< Pin 12 selected */ 42 #define GPIO_SEL_13 (BIT(13)) /*!< Pin 13 selected */ 43 #define GPIO_SEL_14 (BIT(14)) /*!< Pin 14 selected */ 44 #define GPIO_SEL_15 (BIT(15)) /*!< Pin 15 selected */ 45 #define GPIO_SEL_16 (BIT(16)) /*!< Pin 16 selected */ 46 #define GPIO_SEL_17 (BIT(17)) /*!< Pin 17 selected */ 47 #define GPIO_SEL_18 (BIT(18)) /*!< Pin 18 selected */ 48 #define GPIO_SEL_19 (BIT(19)) /*!< Pin 19 selected */ 49 #define GPIO_SEL_20 (BIT(20)) /*!< Pin 20 selected */ 50 #define GPIO_SEL_21 (BIT(21)) /*!< Pin 21 selected */ 51 #if CONFIG_IDF_TARGET_ESP32 52 #define GPIO_SEL_22 (BIT(22)) /*!< Pin 22 selected */ 53 #define GPIO_SEL_23 (BIT(23)) /*!< Pin 23 selected */ 54 55 #define GPIO_SEL_25 (BIT(25)) /*!< Pin 25 selected */ 56 #endif 57 #define GPIO_SEL_26 (BIT(26)) /*!< Pin 26 selected */ 58 #define GPIO_SEL_27 (BIT(27)) /*!< Pin 27 selected */ 59 #define GPIO_SEL_28 (BIT(28)) /*!< Pin 28 selected */ 60 #define GPIO_SEL_29 (BIT(29)) /*!< Pin 29 selected */ 61 #define GPIO_SEL_30 (BIT(30)) /*!< Pin 30 selected */ 62 #define GPIO_SEL_31 (BIT(31)) /*!< Pin 31 selected */ 63 #define GPIO_SEL_32 ((uint64_t)(((uint64_t)1)<<32)) /*!< Pin 32 selected */ 64 #define GPIO_SEL_33 ((uint64_t)(((uint64_t)1)<<33)) /*!< Pin 33 selected */ 65 #define GPIO_SEL_34 ((uint64_t)(((uint64_t)1)<<34)) /*!< Pin 34 selected */ 66 #define GPIO_SEL_35 ((uint64_t)(((uint64_t)1)<<35)) /*!< Pin 35 selected */ 67 #define GPIO_SEL_36 ((uint64_t)(((uint64_t)1)<<36)) /*!< Pin 36 selected */ 68 #define GPIO_SEL_37 ((uint64_t)(((uint64_t)1)<<37)) /*!< Pin 37 selected */ 69 #define GPIO_SEL_38 ((uint64_t)(((uint64_t)1)<<38)) /*!< Pin 38 selected */ 70 #define GPIO_SEL_39 ((uint64_t)(((uint64_t)1)<<39)) /*!< Pin 39 selected */ 71 #if SOC_GPIO_PIN_COUNT > 40 72 #define GPIO_SEL_40 ((uint64_t)(((uint64_t)1)<<40)) /*!< Pin 40 selected */ 73 #define GPIO_SEL_41 ((uint64_t)(((uint64_t)1)<<41)) /*!< Pin 41 selected */ 74 #define GPIO_SEL_42 ((uint64_t)(((uint64_t)1)<<42)) /*!< Pin 42 selected */ 75 #define GPIO_SEL_43 ((uint64_t)(((uint64_t)1)<<43)) /*!< Pin 43 selected */ 76 #define GPIO_SEL_44 ((uint64_t)(((uint64_t)1)<<44)) /*!< Pin 44 selected */ 77 #define GPIO_SEL_45 ((uint64_t)(((uint64_t)1)<<45)) /*!< Pin 45 selected */ 78 #define GPIO_SEL_46 ((uint64_t)(((uint64_t)1)<<46)) /*!< Pin 46 selected */ 79 #if CONFIG_IDF_TARGET_ESP32S3 80 #define GPIO_SEL_47 ((uint64_t)(((uint64_t)1)<<47)) /*!< Pin 47 selected */ 81 #define GPIO_SEL_48 ((uint64_t)(((uint64_t)1)<<48)) /*!< Pin 48 selected */ 82 #endif 83 #endif 84 85 #define GPIO_PIN_REG_0 IO_MUX_GPIO0_REG 86 #define GPIO_PIN_REG_1 IO_MUX_GPIO1_REG 87 #define GPIO_PIN_REG_2 IO_MUX_GPIO2_REG 88 #define GPIO_PIN_REG_3 IO_MUX_GPIO3_REG 89 #define GPIO_PIN_REG_4 IO_MUX_GPIO4_REG 90 #define GPIO_PIN_REG_5 IO_MUX_GPIO5_REG 91 #define GPIO_PIN_REG_6 IO_MUX_GPIO6_REG 92 #define GPIO_PIN_REG_7 IO_MUX_GPIO7_REG 93 #define GPIO_PIN_REG_8 IO_MUX_GPIO8_REG 94 #define GPIO_PIN_REG_9 IO_MUX_GPIO9_REG 95 #define GPIO_PIN_REG_10 IO_MUX_GPIO10_REG 96 #define GPIO_PIN_REG_11 IO_MUX_GPIO11_REG 97 #define GPIO_PIN_REG_12 IO_MUX_GPIO12_REG 98 #define GPIO_PIN_REG_13 IO_MUX_GPIO13_REG 99 #define GPIO_PIN_REG_14 IO_MUX_GPIO14_REG 100 #define GPIO_PIN_REG_15 IO_MUX_GPIO15_REG 101 #define GPIO_PIN_REG_16 IO_MUX_GPIO16_REG 102 #define GPIO_PIN_REG_17 IO_MUX_GPIO17_REG 103 #define GPIO_PIN_REG_18 IO_MUX_GPIO18_REG 104 #define GPIO_PIN_REG_19 IO_MUX_GPIO19_REG 105 #define GPIO_PIN_REG_20 IO_MUX_GPIO20_REG 106 #define GPIO_PIN_REG_21 IO_MUX_GPIO21_REG 107 #define GPIO_PIN_REG_22 IO_MUX_GPIO22_REG 108 #define GPIO_PIN_REG_23 IO_MUX_GPIO23_REG 109 #define GPIO_PIN_REG_24 IO_MUX_GPIO24_REG 110 #define GPIO_PIN_REG_25 IO_MUX_GPIO25_REG 111 #define GPIO_PIN_REG_26 IO_MUX_GPIO26_REG 112 #define GPIO_PIN_REG_27 IO_MUX_GPIO27_REG 113 #define GPIO_PIN_REG_28 IO_MUX_GPIO28_REG 114 #define GPIO_PIN_REG_29 IO_MUX_GPIO29_REG 115 #define GPIO_PIN_REG_30 IO_MUX_GPIO30_REG 116 #define GPIO_PIN_REG_31 IO_MUX_GPIO31_REG 117 #define GPIO_PIN_REG_32 IO_MUX_GPIO32_REG 118 #define GPIO_PIN_REG_33 IO_MUX_GPIO33_REG 119 #define GPIO_PIN_REG_34 IO_MUX_GPIO34_REG 120 #define GPIO_PIN_REG_35 IO_MUX_GPIO35_REG 121 #define GPIO_PIN_REG_36 IO_MUX_GPIO36_REG 122 #define GPIO_PIN_REG_37 IO_MUX_GPIO37_REG 123 #define GPIO_PIN_REG_38 IO_MUX_GPIO38_REG 124 #define GPIO_PIN_REG_39 IO_MUX_GPIO39_REG 125 #define GPIO_PIN_REG_40 IO_MUX_GPIO40_REG 126 #define GPIO_PIN_REG_41 IO_MUX_GPIO41_REG 127 #define GPIO_PIN_REG_42 IO_MUX_GPIO42_REG 128 #define GPIO_PIN_REG_43 IO_MUX_GPIO43_REG 129 #define GPIO_PIN_REG_44 IO_MUX_GPIO44_REG 130 #define GPIO_PIN_REG_45 IO_MUX_GPIO45_REG 131 #define GPIO_PIN_REG_46 IO_MUX_GPIO46_REG 132 #define GPIO_PIN_REG_47 IO_MUX_GPIO47_REG 133 #define GPIO_PIN_REG_48 IO_MUX_GPIO48_REG 134 135 #if CONFIG_IDF_TARGET_ESP32 136 typedef enum { 137 GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */ 138 GPIO_NUM_0 = 0, /*!< GPIO0, input and output */ 139 GPIO_NUM_1 = 1, /*!< GPIO1, input and output */ 140 GPIO_NUM_2 = 2, /*!< GPIO2, input and output */ 141 GPIO_NUM_3 = 3, /*!< GPIO3, input and output */ 142 GPIO_NUM_4 = 4, /*!< GPIO4, input and output */ 143 GPIO_NUM_5 = 5, /*!< GPIO5, input and output */ 144 GPIO_NUM_6 = 6, /*!< GPIO6, input and output */ 145 GPIO_NUM_7 = 7, /*!< GPIO7, input and output */ 146 GPIO_NUM_8 = 8, /*!< GPIO8, input and output */ 147 GPIO_NUM_9 = 9, /*!< GPIO9, input and output */ 148 GPIO_NUM_10 = 10, /*!< GPIO10, input and output */ 149 GPIO_NUM_11 = 11, /*!< GPIO11, input and output */ 150 GPIO_NUM_12 = 12, /*!< GPIO12, input and output */ 151 GPIO_NUM_13 = 13, /*!< GPIO13, input and output */ 152 GPIO_NUM_14 = 14, /*!< GPIO14, input and output */ 153 GPIO_NUM_15 = 15, /*!< GPIO15, input and output */ 154 GPIO_NUM_16 = 16, /*!< GPIO16, input and output */ 155 GPIO_NUM_17 = 17, /*!< GPIO17, input and output */ 156 GPIO_NUM_18 = 18, /*!< GPIO18, input and output */ 157 GPIO_NUM_19 = 19, /*!< GPIO19, input and output */ 158 GPIO_NUM_20 = 20, /*!< GPIO20, input and output */ 159 GPIO_NUM_21 = 21, /*!< GPIO21, input and output */ 160 GPIO_NUM_22 = 22, /*!< GPIO22, input and output */ 161 GPIO_NUM_23 = 23, /*!< GPIO23, input and output */ 162 GPIO_NUM_25 = 25, /*!< GPIO25, input and output */ 163 GPIO_NUM_26 = 26, /*!< GPIO26, input and output */ 164 GPIO_NUM_27 = 27, /*!< GPIO27, input and output */ 165 GPIO_NUM_28 = 28, /*!< GPIO28, input and output */ 166 GPIO_NUM_29 = 29, /*!< GPIO29, input and output */ 167 GPIO_NUM_30 = 30, /*!< GPIO30, input and output */ 168 GPIO_NUM_31 = 31, /*!< GPIO31, input and output */ 169 GPIO_NUM_32 = 32, /*!< GPIO32, input and output */ 170 GPIO_NUM_33 = 33, /*!< GPIO33, input and output */ 171 GPIO_NUM_34 = 34, /*!< GPIO34, input mode only */ 172 GPIO_NUM_35 = 35, /*!< GPIO35, input mode only */ 173 GPIO_NUM_36 = 36, /*!< GPIO36, input mode only */ 174 GPIO_NUM_37 = 37, /*!< GPIO37, input mode only */ 175 GPIO_NUM_38 = 38, /*!< GPIO38, input mode only */ 176 GPIO_NUM_39 = 39, /*!< GPIO39, input mode only */ 177 GPIO_NUM_MAX, 178 /** @endcond */ 179 } gpio_num_t; 180 #elif CONFIG_IDF_TARGET_ESP32S2 181 typedef enum { 182 GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */ 183 GPIO_NUM_0 = 0, /*!< GPIO0, input and output */ 184 GPIO_NUM_1 = 1, /*!< GPIO1, input and output */ 185 GPIO_NUM_2 = 2, /*!< GPIO2, input and output */ 186 GPIO_NUM_3 = 3, /*!< GPIO3, input and output */ 187 GPIO_NUM_4 = 4, /*!< GPIO4, input and output */ 188 GPIO_NUM_5 = 5, /*!< GPIO5, input and output */ 189 GPIO_NUM_6 = 6, /*!< GPIO6, input and output */ 190 GPIO_NUM_7 = 7, /*!< GPIO7, input and output */ 191 GPIO_NUM_8 = 8, /*!< GPIO8, input and output */ 192 GPIO_NUM_9 = 9, /*!< GPIO9, input and output */ 193 GPIO_NUM_10 = 10, /*!< GPIO10, input and output */ 194 GPIO_NUM_11 = 11, /*!< GPIO11, input and output */ 195 GPIO_NUM_12 = 12, /*!< GPIO12, input and output */ 196 GPIO_NUM_13 = 13, /*!< GPIO13, input and output */ 197 GPIO_NUM_14 = 14, /*!< GPIO14, input and output */ 198 GPIO_NUM_15 = 15, /*!< GPIO15, input and output */ 199 GPIO_NUM_16 = 16, /*!< GPIO16, input and output */ 200 GPIO_NUM_17 = 17, /*!< GPIO17, input and output */ 201 GPIO_NUM_18 = 18, /*!< GPIO18, input and output */ 202 GPIO_NUM_19 = 19, /*!< GPIO19, input and output */ 203 GPIO_NUM_20 = 20, /*!< GPIO20, input and output */ 204 GPIO_NUM_21 = 21, /*!< GPIO21, input and output */ 205 GPIO_NUM_26 = 26, /*!< GPIO26, input and output */ 206 GPIO_NUM_27 = 27, /*!< GPIO27, input and output */ 207 GPIO_NUM_28 = 28, /*!< GPIO28, input and output */ 208 GPIO_NUM_29 = 29, /*!< GPIO29, input and output */ 209 GPIO_NUM_30 = 30, /*!< GPIO30, input and output */ 210 GPIO_NUM_31 = 31, /*!< GPIO31, input and output */ 211 GPIO_NUM_32 = 32, /*!< GPIO32, input and output */ 212 GPIO_NUM_33 = 33, /*!< GPIO33, input and output */ 213 GPIO_NUM_34 = 34, /*!< GPIO34, input and output */ 214 GPIO_NUM_35 = 35, /*!< GPIO35, input and output */ 215 GPIO_NUM_36 = 36, /*!< GPIO36, input and output */ 216 GPIO_NUM_37 = 37, /*!< GPIO37, input and output */ 217 GPIO_NUM_38 = 38, /*!< GPIO38, input and output */ 218 GPIO_NUM_39 = 39, /*!< GPIO39, input and output */ 219 GPIO_NUM_40 = 40, /*!< GPIO40, input and output */ 220 GPIO_NUM_41 = 41, /*!< GPIO41, input and output */ 221 GPIO_NUM_42 = 42, /*!< GPIO42, input and output */ 222 GPIO_NUM_43 = 43, /*!< GPIO43, input and output */ 223 GPIO_NUM_44 = 44, /*!< GPIO44, input and output */ 224 GPIO_NUM_45 = 45, /*!< GPIO45, input and output */ 225 GPIO_NUM_46 = 46, /*!< GPIO46, input mode only */ 226 GPIO_NUM_MAX, 227 /** @endcond */ 228 } gpio_num_t; 229 #elif CONFIG_IDF_TARGET_ESP32S3 230 typedef enum { 231 GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */ 232 GPIO_NUM_0 = 0, /*!< GPIO0, input and output */ 233 GPIO_NUM_1 = 1, /*!< GPIO1, input and output */ 234 GPIO_NUM_2 = 2, /*!< GPIO2, input and output */ 235 GPIO_NUM_3 = 3, /*!< GPIO3, input and output */ 236 GPIO_NUM_4 = 4, /*!< GPIO4, input and output */ 237 GPIO_NUM_5 = 5, /*!< GPIO5, input and output */ 238 GPIO_NUM_6 = 6, /*!< GPIO6, input and output */ 239 GPIO_NUM_7 = 7, /*!< GPIO7, input and output */ 240 GPIO_NUM_8 = 8, /*!< GPIO8, input and output */ 241 GPIO_NUM_9 = 9, /*!< GPIO9, input and output */ 242 GPIO_NUM_10 = 10, /*!< GPIO10, input and output */ 243 GPIO_NUM_11 = 11, /*!< GPIO11, input and output */ 244 GPIO_NUM_12 = 12, /*!< GPIO12, input and output */ 245 GPIO_NUM_13 = 13, /*!< GPIO13, input and output */ 246 GPIO_NUM_14 = 14, /*!< GPIO14, input and output */ 247 GPIO_NUM_15 = 15, /*!< GPIO15, input and output */ 248 GPIO_NUM_16 = 16, /*!< GPIO16, input and output */ 249 GPIO_NUM_17 = 17, /*!< GPIO17, input and output */ 250 GPIO_NUM_18 = 18, /*!< GPIO18, input and output */ 251 GPIO_NUM_19 = 19, /*!< GPIO19, input and output */ 252 GPIO_NUM_20 = 20, /*!< GPIO20, input and output */ 253 GPIO_NUM_21 = 21, /*!< GPIO21, input and output */ 254 GPIO_NUM_26 = 26, /*!< GPIO26, input and output */ 255 GPIO_NUM_27 = 27, /*!< GPIO27, input and output */ 256 GPIO_NUM_28 = 28, /*!< GPIO28, input and output */ 257 GPIO_NUM_29 = 29, /*!< GPIO29, input and output */ 258 GPIO_NUM_30 = 30, /*!< GPIO30, input and output */ 259 GPIO_NUM_31 = 31, /*!< GPIO31, input and output */ 260 GPIO_NUM_32 = 32, /*!< GPIO32, input and output */ 261 GPIO_NUM_33 = 33, /*!< GPIO33, input and output */ 262 GPIO_NUM_34 = 34, /*!< GPIO34, input and output */ 263 GPIO_NUM_35 = 35, /*!< GPIO35, input and output */ 264 GPIO_NUM_36 = 36, /*!< GPIO36, input and output */ 265 GPIO_NUM_37 = 37, /*!< GPIO37, input and output */ 266 GPIO_NUM_38 = 38, /*!< GPIO38, input and output */ 267 GPIO_NUM_39 = 39, /*!< GPIO39, input and output */ 268 GPIO_NUM_40 = 40, /*!< GPIO40, input and output */ 269 GPIO_NUM_41 = 41, /*!< GPIO41, input and output */ 270 GPIO_NUM_42 = 42, /*!< GPIO42, input and output */ 271 GPIO_NUM_43 = 43, /*!< GPIO43, input and output */ 272 GPIO_NUM_44 = 44, /*!< GPIO44, input and output */ 273 GPIO_NUM_45 = 45, /*!< GPIO45, input and output */ 274 GPIO_NUM_46 = 46, /*!< GPIO46, input and output */ 275 GPIO_NUM_47 = 47, /*!< GPIO47, input and output */ 276 GPIO_NUM_48 = 48, /*!< GPIO48, input and output */ 277 GPIO_NUM_MAX, 278 /** @endcond */ 279 } gpio_num_t; 280 #elif CONFIG_IDF_TARGET_ESP32C3 281 typedef enum { 282 GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */ 283 GPIO_NUM_0 = 0, /*!< GPIO0, input and output */ 284 GPIO_NUM_1 = 1, /*!< GPIO1, input and output */ 285 GPIO_NUM_2 = 2, /*!< GPIO2, input and output */ 286 GPIO_NUM_3 = 3, /*!< GPIO3, input and output */ 287 GPIO_NUM_4 = 4, /*!< GPIO4, input and output */ 288 GPIO_NUM_5 = 5, /*!< GPIO5, input and output */ 289 GPIO_NUM_6 = 6, /*!< GPIO6, input and output */ 290 GPIO_NUM_7 = 7, /*!< GPIO7, input and output */ 291 GPIO_NUM_8 = 8, /*!< GPIO8, input and output */ 292 GPIO_NUM_9 = 9, /*!< GPIO9, input and output */ 293 GPIO_NUM_10 = 10, /*!< GPIO10, input and output */ 294 GPIO_NUM_11 = 11, /*!< GPIO11, input and output */ 295 GPIO_NUM_12 = 12, /*!< GPIO12, input and output */ 296 GPIO_NUM_13 = 13, /*!< GPIO13, input and output */ 297 GPIO_NUM_14 = 14, /*!< GPIO14, input and output */ 298 GPIO_NUM_15 = 15, /*!< GPIO15, input and output */ 299 GPIO_NUM_16 = 16, /*!< GPIO16, input and output */ 300 GPIO_NUM_17 = 17, /*!< GPIO17, input and output */ 301 GPIO_NUM_18 = 18, /*!< GPIO18, input and output */ 302 GPIO_NUM_19 = 19, /*!< GPIO19, input and output */ 303 GPIO_NUM_20 = 20, /*!< GPIO20, input and output */ 304 GPIO_NUM_21 = 21, /*!< GPIO21, input and output */ 305 GPIO_NUM_MAX, 306 /** @endcond */ 307 } gpio_num_t; 308 #elif CONFIG_IDF_TARGET_ESP32H2 309 typedef enum { 310 GPIO_NUM_NC = -1, /*!< Use to signal not connected to S/W */ 311 GPIO_NUM_0 = 0, /*!< GPIO0, input and output */ 312 GPIO_NUM_1 = 1, /*!< GPIO1, input and output */ 313 GPIO_NUM_2 = 2, /*!< GPIO2, input and output */ 314 GPIO_NUM_3 = 3, /*!< GPIO3, input and output */ 315 GPIO_NUM_4 = 4, /*!< GPIO4, input and output */ 316 GPIO_NUM_5 = 5, /*!< GPIO5, input and output */ 317 GPIO_NUM_6 = 6, /*!< GPIO6, input and output */ 318 GPIO_NUM_7 = 7, /*!< GPIO7, input and output */ 319 GPIO_NUM_8 = 8, /*!< GPIO8, input and output */ 320 GPIO_NUM_9 = 9, /*!< GPIO9, input and output */ 321 GPIO_NUM_10 = 10, /*!< GPIO10, input and output */ 322 GPIO_NUM_11 = 11, /*!< GPIO11, input and output */ 323 GPIO_NUM_12 = 12, /*!< GPIO12, input and output */ 324 GPIO_NUM_13 = 13, /*!< GPIO13, input and output */ 325 GPIO_NUM_14 = 14, /*!< GPIO14, input and output */ 326 GPIO_NUM_15 = 15, /*!< GPIO15, input and output */ 327 GPIO_NUM_16 = 16, /*!< GPIO16, input and output */ 328 GPIO_NUM_17 = 17, /*!< GPIO17, input and output */ 329 GPIO_NUM_18 = 18, /*!< GPIO18, input and output */ 330 GPIO_NUM_19 = 19, /*!< GPIO19, input and output */ 331 GPIO_NUM_20 = 20, /*!< GPIO20, input and output */ 332 GPIO_NUM_21 = 21, /*!< GPIO21, input and output */ 333 GPIO_NUM_22 = 22, /*!< GPIO22, input and output */ 334 GPIO_NUM_26 = 26, /*!< GPIO26, input and output */ 335 GPIO_NUM_27 = 27, /*!< GPIO27, input and output */ 336 GPIO_NUM_28 = 28, /*!< GPIO28, input and output */ 337 GPIO_NUM_29 = 29, /*!< GPIO29, input and output */ 338 GPIO_NUM_30 = 30, /*!< GPIO30, input and output */ 339 GPIO_NUM_31 = 31, /*!< GPIO31, input and output */ 340 GPIO_NUM_32 = 32, /*!< GPIO32, input and output */ 341 GPIO_NUM_33 = 33, /*!< GPIO33, input and output */ 342 GPIO_NUM_34 = 34, /*!< GPIO34, input and output */ 343 GPIO_NUM_35 = 35, /*!< GPIO35, input and output */ 344 GPIO_NUM_36 = 36, /*!< GPIO36, input and output */ 345 GPIO_NUM_37 = 37, /*!< GPIO37, input and output */ 346 GPIO_NUM_38 = 38, /*!< GPIO38, input and output */ 347 GPIO_NUM_39 = 39, /*!< GPIO39, input and output */ 348 GPIO_NUM_40 = 40, /*!< GPIO40, input and output */ 349 GPIO_NUM_MAX, 350 /** @endcond */ 351 } gpio_num_t; 352 #endif 353 354 typedef enum { 355 GPIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */ 356 GPIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */ 357 GPIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */ 358 GPIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */ 359 GPIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */ 360 GPIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */ 361 GPIO_INTR_MAX, 362 } gpio_int_type_t; 363 364 /** @cond */ 365 #define GPIO_MODE_DEF_DISABLE (0) 366 #define GPIO_MODE_DEF_INPUT (BIT0) ///< bit mask for input 367 #define GPIO_MODE_DEF_OUTPUT (BIT1) ///< bit mask for output 368 #define GPIO_MODE_DEF_OD (BIT2) ///< bit mask for OD mode 369 /** @endcond */ 370 371 typedef enum { 372 GPIO_MODE_DISABLE = GPIO_MODE_DEF_DISABLE, /*!< GPIO mode : disable input and output */ 373 GPIO_MODE_INPUT = GPIO_MODE_DEF_INPUT, /*!< GPIO mode : input only */ 374 GPIO_MODE_OUTPUT = GPIO_MODE_DEF_OUTPUT, /*!< GPIO mode : output only mode */ 375 GPIO_MODE_OUTPUT_OD = ((GPIO_MODE_DEF_OUTPUT) | (GPIO_MODE_DEF_OD)), /*!< GPIO mode : output only with open-drain mode */ 376 GPIO_MODE_INPUT_OUTPUT_OD = ((GPIO_MODE_DEF_INPUT) | (GPIO_MODE_DEF_OUTPUT) | (GPIO_MODE_DEF_OD)), /*!< GPIO mode : output and input with open-drain mode*/ 377 GPIO_MODE_INPUT_OUTPUT = ((GPIO_MODE_DEF_INPUT) | (GPIO_MODE_DEF_OUTPUT)), /*!< GPIO mode : output and input mode */ 378 } gpio_mode_t; 379 380 typedef enum { 381 GPIO_PULLUP_DISABLE = 0x0, /*!< Disable GPIO pull-up resistor */ 382 GPIO_PULLUP_ENABLE = 0x1, /*!< Enable GPIO pull-up resistor */ 383 } gpio_pullup_t; 384 385 typedef enum { 386 GPIO_PULLDOWN_DISABLE = 0x0, /*!< Disable GPIO pull-down resistor */ 387 GPIO_PULLDOWN_ENABLE = 0x1, /*!< Enable GPIO pull-down resistor */ 388 } gpio_pulldown_t; 389 390 /** 391 * @brief Configuration parameters of GPIO pad for gpio_config function 392 */ 393 typedef struct { 394 uint64_t pin_bit_mask; /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */ 395 gpio_mode_t mode; /*!< GPIO mode: set input/output mode */ 396 gpio_pullup_t pull_up_en; /*!< GPIO pull-up */ 397 gpio_pulldown_t pull_down_en; /*!< GPIO pull-down */ 398 gpio_int_type_t intr_type; /*!< GPIO interrupt type */ 399 } gpio_config_t; 400 401 typedef enum { 402 GPIO_PULLUP_ONLY, /*!< Pad pull up */ 403 GPIO_PULLDOWN_ONLY, /*!< Pad pull down */ 404 GPIO_PULLUP_PULLDOWN, /*!< Pad pull up + pull down*/ 405 GPIO_FLOATING, /*!< Pad floating */ 406 } gpio_pull_mode_t; 407 408 typedef enum { 409 GPIO_DRIVE_CAP_0 = 0, /*!< Pad drive capability: weak */ 410 GPIO_DRIVE_CAP_1 = 1, /*!< Pad drive capability: stronger */ 411 GPIO_DRIVE_CAP_2 = 2, /*!< Pad drive capability: medium */ 412 GPIO_DRIVE_CAP_DEFAULT = 2, /*!< Pad drive capability: medium */ 413 GPIO_DRIVE_CAP_3 = 3, /*!< Pad drive capability: strongest */ 414 GPIO_DRIVE_CAP_MAX, 415 } gpio_drive_cap_t; 416 417 typedef void (*gpio_isr_t)(void *); 418 419 #ifdef __cplusplus 420 } 421 #endif 422