// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include "soc/gpio_periph.h" #include "soc/gpio_caps.h" #ifdef __cplusplus extern "C" { #endif typedef int gpio_num_t; typedef enum { GPIO_INTR_DISABLE = 0, /*!< Disable GPIO interrupt */ GPIO_INTR_POSEDGE = 1, /*!< GPIO interrupt type : rising edge */ GPIO_INTR_NEGEDGE = 2, /*!< GPIO interrupt type : falling edge */ GPIO_INTR_ANYEDGE = 3, /*!< GPIO interrupt type : both rising and falling edge */ GPIO_INTR_LOW_LEVEL = 4, /*!< GPIO interrupt type : input low level trigger */ GPIO_INTR_HIGH_LEVEL = 5, /*!< GPIO interrupt type : input high level trigger */ GPIO_INTR_MAX, } gpio_int_type_t; typedef enum { GPIO_MODE_DISABLE = GPIO_MODE_DEF_DISABLE, /*!< GPIO mode : disable input and output */ GPIO_MODE_INPUT = GPIO_MODE_DEF_INPUT, /*!< GPIO mode : input only */ GPIO_MODE_OUTPUT = GPIO_MODE_DEF_OUTPUT, /*!< GPIO mode : output only mode */ GPIO_MODE_OUTPUT_OD = ((GPIO_MODE_DEF_OUTPUT) | (GPIO_MODE_DEF_OD)), /*!< GPIO mode : output only with open-drain mode */ 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*/ GPIO_MODE_INPUT_OUTPUT = ((GPIO_MODE_DEF_INPUT) | (GPIO_MODE_DEF_OUTPUT)), /*!< GPIO mode : output and input mode */ } gpio_mode_t; typedef enum { GPIO_PULLUP_DISABLE = 0x0, /*!< Disable GPIO pull-up resistor */ GPIO_PULLUP_ENABLE = 0x1, /*!< Enable GPIO pull-up resistor */ } gpio_pullup_t; typedef enum { GPIO_PULLDOWN_DISABLE = 0x0, /*!< Disable GPIO pull-down resistor */ GPIO_PULLDOWN_ENABLE = 0x1, /*!< Enable GPIO pull-down resistor */ } gpio_pulldown_t; /** * @brief Configuration parameters of GPIO pad for gpio_config function */ typedef struct { uint64_t pin_bit_mask; /*!< GPIO pin: set with bit mask, each bit maps to a GPIO */ gpio_mode_t mode; /*!< GPIO mode: set input/output mode */ gpio_pullup_t pull_up_en; /*!< GPIO pull-up */ gpio_pulldown_t pull_down_en; /*!< GPIO pull-down */ gpio_int_type_t intr_type; /*!< GPIO interrupt type */ } gpio_config_t; typedef enum { GPIO_PULLUP_ONLY, /*!< Pad pull up */ GPIO_PULLDOWN_ONLY, /*!< Pad pull down */ GPIO_PULLUP_PULLDOWN, /*!< Pad pull up + pull down*/ GPIO_FLOATING, /*!< Pad floating */ } gpio_pull_mode_t; typedef enum { GPIO_DRIVE_CAP_0 = 0, /*!< Pad drive capability: weak */ GPIO_DRIVE_CAP_1 = 1, /*!< Pad drive capability: stronger */ GPIO_DRIVE_CAP_2 = 2, /*!< Pad drive capability: medium */ GPIO_DRIVE_CAP_DEFAULT = 2, /*!< Pad drive capability: medium */ GPIO_DRIVE_CAP_3 = 3, /*!< Pad drive capability: strongest */ GPIO_DRIVE_CAP_MAX, } gpio_drive_cap_t; typedef void (*gpio_isr_t)(void *); #ifdef __cplusplus } #endif