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