esp_rom_gpio.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #include <stdint.h>
  11. #include <stdbool.h>
  12. #include "soc/gpio_pins.h" //for GPIO_MATRIX_CONST_ONE_INPUT, GPIO_MATRIX_CONST_ZERO_INPUT
  13. /**
  14. * @brief Configure IO Pad as General Purpose IO,
  15. * so that it can be connected to internal Matrix,
  16. * then combined with one or more peripheral signals.
  17. *
  18. * @param iopad_num IO Pad number
  19. */
  20. void esp_rom_gpio_pad_select_gpio(uint32_t iopad_num);
  21. /**
  22. * @brief Enable internal pull up, and disable internal pull down.
  23. *
  24. * @param iopad_num IO Pad number
  25. */
  26. void esp_rom_gpio_pad_pullup_only(uint32_t iopad_num);
  27. /**
  28. * @brief Unhold the IO Pad.
  29. * @note When the Pad is set to hold, the state is latched at that moment and won't get changed.
  30. *
  31. * @param iopad_num IP Pad number
  32. */
  33. void esp_rom_gpio_pad_unhold(uint32_t gpio_num);
  34. /**
  35. * @brief Set IO Pad current drive capability.
  36. *
  37. * @param iopad_num IO Pad number
  38. * @param drv Numeric to indicate the capability of current drive
  39. * - 0: 5mA
  40. * - 1: 10mA
  41. * - 2: 20mA
  42. * - 3: 40mA
  43. */
  44. void esp_rom_gpio_pad_set_drv(uint32_t iopad_num, uint32_t drv);
  45. /**
  46. * @brief Combine a GPIO input with a peripheral signal, which tagged as input attribute.
  47. *
  48. * @note There's no limitation on the number of signals that a GPIO can combine with.
  49. *
  50. * @param gpio_num GPIO number, especially, `GPIO_MATRIX_CONST_ZERO_INPUT` means connect logic 0 to signal
  51. * `GPIO_MATRIX_CONST_ONE_INPUT` means connect logic 1 to signal
  52. * @param signal_idx Peripheral signal index (tagged as input attribute)
  53. * @param inv Whether the GPIO input to be inverted or not
  54. */
  55. void esp_rom_gpio_connect_in_signal(uint32_t gpio_num, uint32_t signal_idx, bool inv);
  56. /**
  57. * @brief Combine a peripheral signal which tagged as output attribute with a GPIO.
  58. *
  59. * @note There's no limitation on the number of signals that a GPIO can combine with.
  60. *
  61. * @param gpio_num GPIO number
  62. * @param signal_idx Peripheral signal index (tagged as output attribute). Particularly, `SIG_GPIO_OUT_IDX` means disconnect GPIO and other peripherals. Only the GPIO driver can control the output level.
  63. * @param out_inv Whether to signal to be inverted or not
  64. * @param oen_inv Whether the output enable control is inverted or not
  65. */
  66. void esp_rom_gpio_connect_out_signal(uint32_t gpio_num, uint32_t signal_idx, bool out_inv, bool oen_inv);
  67. #ifdef __cplusplus
  68. }
  69. #endif