gpio.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. GPIO & RTC GPIO
  2. ===============
  3. :link_to_translation:`zh_CN:[中文]`
  4. GPIO Summary
  5. ------------
  6. .. include:: gpio/{IDF_TARGET_PATH_NAME}.inc
  7. :start-after: gpio-summary
  8. :end-before: ---
  9. .. only:: SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
  10. There is also separate "RTC GPIO" support, which functions when GPIOs are routed to the "RTC" low-power and analog subsystem. These pin functions can be used when:
  11. .. list::
  12. - In Deep-sleep mode
  13. :SOC_ULP_SUPPORTED: - The :doc:`Ultra Low Power co-processor <../../api-reference/system/ulp>` is running
  14. - Analog functions such as ADC/DAC/etc are in use.
  15. .. only:: SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER or SOC_GPIO_FLEX_GLITCH_FILTER_NUM
  16. GPIO Glitch Filter
  17. ------------------
  18. The {IDF_TARGET_NAME} chip features hardware filters to remove unwanted glitch pulses from the input GPIO, which can help reduce false triggering of the interrupt and prevent a noise being routed to the peripheral side.
  19. .. only:: SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER
  20. Each GPIO can be configured with a glitch filter, which can be used to filter out pulses shorter than **two** sample clock cycles. The duration of the filter is not configurable. The sample clock is the clock source of the IO_MUX. In the driver, we call this kind of filter as ``pin glitch filter``. You can create the filter handle by calling :cpp:func:`gpio_new_pin_glitch_filter`. All the configurations for a pin glitch filter are listed in the :cpp:type:`gpio_pin_glitch_filter_config_t` structure.
  21. - :cpp:member:`gpio_pin_glitch_filter_config_t::gpio_num` sets the GPIO number to enable the glitch filter.
  22. .. only:: SOC_GPIO_FLEX_GLITCH_FILTER_NUM
  23. {IDF_TARGET_FLEX_GLITCH_FILTER_NUM:default="8"}
  24. {IDF_TARGET_NAME} provides {IDF_TARGET_FLEX_GLITCH_FILTER_NUM} flexible glitch filters, whose duration is configurable. We refer to this kind of filter as ``flex flitch filter``. Each of them can be applied to any input GPIO. However, applying multiple filters to the same GPIO doesn't make difference from one. You can create the filter handle by calling :cpp:func:`gpio_new_flex_glitch_filter`. All the configurations for a flexible glitch filter are listed in the :cpp:type:`gpio_flex_glitch_filter_config_t` structure.
  25. - :cpp:member:`gpio_flex_glitch_filter_config_t::gpio_num` sets the GPIO that will be applied to the flex glitch filter.
  26. - :cpp:member:`gpio_flex_glitch_filter_config_t::window_width_ns` and :cpp:member:`gpio_flex_glitch_filter_config_t::window_thres_ns` are the key parameters of the glitch filter. During :cpp:member:`gpio_flex_glitch_filter_config_t::window_width_ns`, any pulse whose width is shorter than :cpp:member:`gpio_flex_glitch_filter_config_t::window_thres_ns` will be discarded. Please note that, you can't set :cpp:member:`gpio_flex_glitch_filter_config_t::window_thres_ns` bigger than :cpp:member:`gpio_flex_glitch_filter_config_t::window_width_ns`.
  27. .. only:: SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER and SOC_GPIO_FLEX_GLITCH_FILTER_NUM
  28. Please note, the ``pin glitch filter`` and ``flex glitch filter`` are independent. You can enable both of them for the same GPIO.
  29. The glitch filter is disabled by default, and can be enabled by calling :cpp:func:`gpio_glitch_filter_enable`. To recycle the filter, you can call :cpp:func:`gpio_del_glitch_filter`. Please note, before deleting the filter, you should disable it first by calling :cpp:func:`gpio_glitch_filter_disable`.
  30. Application Example
  31. -------------------
  32. * GPIO output and input interrupt example: :example:`peripherals/gpio/generic_gpio`.
  33. API Reference - Normal GPIO
  34. ---------------------------
  35. .. include-build-file:: inc/gpio.inc
  36. .. include-build-file:: inc/gpio_types.inc
  37. .. only:: SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
  38. API Reference - RTC GPIO
  39. ------------------------
  40. .. include-build-file:: inc/rtc_io.inc
  41. .. include-build-file:: inc/rtc_io_types.inc
  42. .. only:: SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER or SOC_GPIO_FLEX_GLITCH_FILTER_NUM
  43. API Reference - GPIO Glitch Filter
  44. ----------------------------------
  45. .. include-build-file:: inc/gpio_filter.inc