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