Esp32/Components/driver/include/driver/gpio.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * gpio.h
8  *
9  ****/
10 
13 #pragma once
14 
15 #include <c_types.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <driver/gpio.h>
22 
29 //GPIO FUNCTIONS
30 #define ESP32_LOW 0x0
31 #define ESP32_HIGH 0x1
32 
33 #define ESP32_INPUT 0x01
34 #define ESP32_OUTPUT 0x02
35 #define ESP32_PULLUP 0x04
36 #define ESP32_INPUT_PULLUP 0x05
37 #define ESP32_PULLDOWN 0x08
38 #define ESP32_INPUT_PULLDOWN 0x09
39 #define ESP32_OPEN_DRAIN 0x10
40 #define ESP32_OUTPUT_OPEN_DRAIN 0x12
41 
42 #define ESP32_SPECIAL 0xF0
43 #define ESP32_FUNCTION_1 0x00
44 #define ESP32_FUNCTION_2 0x20
45 #define ESP32_FUNCTION_3 0x40
46 #define ESP32_FUNCTION_4 0x60
47 #define ESP32_FUNCTION_5 0x80
48 #define ESP32_FUNCTION_6 0xA0
49 #define ESP32_ANALOG 0xC0
50 
51 //Interrupt Modes
52 #define ESP32_DISABLED 0x00
53 #define ESP32_RISING 0x01
54 #define ESP32_FALLING 0x02
55 #define ESP32_CHANGE 0x03
56 #define ESP32_ONLOW 0x04
57 #define ESP32_ONHIGH 0x05
58 #define ESP32_ONLOW_WE 0x0C
59 #define ESP32_ONHIGH_WE 0x0D
60 
61 typedef struct {
62  uint8_t reg;
63  int8_t rtc;
64  int8_t adc;
65  int8_t touch;
67 
68 extern const esp32_gpioMux_t esp32_gpioMux[40];
69 extern const int8_t esp32_adc2gpio[20];
70 
71 #define digitalPinIsValid(pin) ((pin) < 40 && esp32_gpioMux[(pin)].reg)
72 #define digitalPinCanOutput(pin) ((pin) < 34 && esp32_gpioMux[(pin)].reg)
73 #define digitalPinToRtcPin(pin) (((pin) < 40) ? esp32_gpioMux[(pin)].rtc : -1)
74 #define digitalPinToAnalogChannel(pin) (((pin) < 40) ? esp32_gpioMux[(pin)].adc : -1)
75 #define digitalPinToTouchChannel(pin) (((pin) < 40) ? esp32_gpioMux[(pin)].touch : -1)
76 #define digitalPinToDacChannel(pin) (((pin) == 25) ? 0 : ((pin) == 26) ? 1 : -1)
77 
80 #ifdef __cplusplus
81 }
82 #endif
const esp32_gpioMux_t esp32_gpioMux[40]
uint8_t reg
Definition: Esp32/Components/driver/include/driver/gpio.h:62
int8_t rtc
Definition: Esp32/Components/driver/include/driver/gpio.h:63
const int8_t esp32_adc2gpio[20]
Definition: Esp32/Components/driver/include/driver/gpio.h:61
int8_t adc
Definition: Esp32/Components/driver/include/driver/gpio.h:64
int8_t touch
Definition: Esp32/Components/driver/include/driver/gpio.h:65