1 /*
2  * SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include <stdint.h>
14 #include <stdbool.h>
15 #include "soc/gpio_pins.h"  //for GPIO_MATRIX_CONST_ONE_INPUT, GPIO_MATRIX_CONST_ZERO_INPUT
16 
17 /**
18  * @brief Configure IO Pad as General Purpose IO,
19  *        so that it can be connected to internal Matrix,
20  *        then combined with one or more peripheral signals.
21  *
22  * @param iopad_num IO Pad number
23  */
24 void esp_rom_gpio_pad_select_gpio(uint32_t iopad_num);
25 
26 /**
27  * @brief Enable internal pull up, and disable internal pull down.
28  *
29  * @param iopad_num IO Pad number
30  */
31 void esp_rom_gpio_pad_pullup_only(uint32_t iopad_num);
32 
33 /**
34  * @brief Unhold the IO Pad.
35  * @note When the Pad is set to hold, the state is latched at that moment and won't get changed.
36  *
37  * @param iopad_num IP Pad number
38  */
39 void esp_rom_gpio_pad_unhold(uint32_t gpio_num);
40 
41 /**
42  * @brief Set IO Pad current drive capability.
43  *
44  * @param iopad_num IO Pad number
45  * @param drv Numeric to indicate the capability of current drive
46  *      - 0: 5mA
47  *      - 1: 10mA
48  *      - 2: 20mA
49  *      - 3: 40mA
50  */
51 void esp_rom_gpio_pad_set_drv(uint32_t iopad_num, uint32_t drv);
52 
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 /**
66  * @brief Combine a peripheral signal which tagged as output attribute with a GPIO.
67  *
68  * @note There's no limitation on the number of signals that a GPIO can combine with.
69  * @note Internally, the signal will be connected first, then output will be enabled on the pad.
70  *
71  * @param gpio_num GPIO number
72  * @param signal_idx Peripheral signal index (tagged as output attribute)
73  * @param out_inv Whether to signal to be inverted or not
74  * @param oen_inv Whether the output enable control is inverted or not
75  */
76 void esp_rom_gpio_connect_out_signal(uint32_t gpio_num, uint32_t signal_idx, bool out_inv, bool oen_inv);
77 
78 #ifdef __cplusplus
79 }
80 #endif
81