esp_rom_gpio.h 2.9 KB

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