除了 ESP32 GPIO API 外,還提供了結構件(Structures)、巨集(Marco)、 泛型型別定義(Type Definitions)和枚舉(Enumerations)。
1. Structure:
1.1. struct gpio_config_t:
Configuration parameters of GPIO pad for gpio_config function.
Public Members
|
Description
|
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
|
2. Macros:
Macros
|
Description
|
GPIO_SEL_0
|
Pin 0 selected
|
GPIO_SEL_1
|
Pin 1 selected
|
GPIO_SEL_2
|
Pin 2 selected
|
GPIO_IS_VALID_GPIO(gpio_num)
|
Check whether it is a valid GPIO number
|
GPIO_IS_VALID_OUTPUT_GPIO(gpio_num)
|
Check whether it can be a valid GPIO number of output mode
|
Note: There are more macros like that up to pin 39, excluding
pins 20, 24 and 28..31. They are not shown here to reduce redundant
information.
3. Type Definitions:
Type Definitions
|
Description
|
typedef void
(*gpio_isr_t)(void *)
|
|
typedef
intr_handle_t gpio_isr_handle_t
|
4. Enumerations:
4.1. enum gpio_num_t:
Enumeration
|
Description
|
GPIO_NUM_0 = 0
|
GPIO0, input and output
|
GPIO_NUM_1 = 1
|
GPIO1, input and output
|
GPIO_NUM_2 = 2
|
GPIO2, input and output
|
Note: There are more enumerations like that up
to GPIO39, excluding GPIO20, GPIO24 and GPIO28..31. They are not shown here to
reduce redundant information.
Note: GPIO34..39 are input mode only.
4.2. enum gpio_int_type_t:
Enumeration
|
Description
|
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
|
4.3. enum gpio_mode_t:
Enumeration
|
Description
|
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
|
4.4. enum gpio_pullup_t:
Enumeration
|
Description
|
GPIO_PULLUP_DISABLE
= 0x0
|
Disable GPIO pull-up resistor
|
GPIO_PULLUP_ENABLE
= 0x1
|
Enable GPIO pull-up resistor
|
4.5. enum gpio_pulldown_t:
Enumeration
|
Description
|
GPIO_PULLDOWN_DISABLE
= 0x0
|
Disable GPIO pull-down resistor
|
GPIO_PULLDOWN_ENABLE
= 0x1
|
Enable GPIO pull-down resistor
|
4.6. enum gpio_pull_mode_t:
Enumeration
|
Description
|
GPIO_PULLUP_ONLY
|
Pad pull up
|
GPIO_PULLDOWN_ONLY
|
Pad pull down
|
GPIO_PULLUP_PULLDOWN
|
Pad pull up + pull down
|
GPIO_FLOATING
|
Pad floating
|
4.7. enum gpio_drive_cap_t:
Enumeration
|
Description
|
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: default value
|
GPIO_DRIVE_CAP_DEFAULT
= 2
|
Pad drive capability: default value
|
GPIO_DRIVE_CAP_3
= 3
|
Pad drive capability: strongest
|
GPIO_DRIVE_CAP_MAX
|
相關網址:
※ DIY – ESP32:ESP32 GPIO 功能資源(九)
※ DIY - ESP32:ESP32 GPIO API 應用程式接口函數(三十)
※ DIY - ESP32:ESP32 常用 GPIO 應用程式接口函數(三十二)
請問如何設定為 open-drain mode,3Q
回覆刪除