- Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathesp32-hal-gpio.h
89 lines (73 loc) · 2.93 KB
/
esp32-hal-gpio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2005-2013 Arduino Team. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndefMAIN_ESP32_HAL_GPIO_H_
#defineMAIN_ESP32_HAL_GPIO_H_
#ifdef__cplusplus
extern"C" {
#endif
#include"esp32-hal.h"
#defineLOW 0x0
#defineHIGH 0x1
//GPIO FUNCTIONS
#defineINPUT 0x01
#defineOUTPUT 0x02
#definePULLUP 0x04
#defineINPUT_PULLUP 0x05
#definePULLDOWN 0x08
#defineINPUT_PULLDOWN 0x09
#defineOPEN_DRAIN 0x10
#defineOUTPUT_OPEN_DRAIN 0x12
#defineSPECIAL 0xF0
#defineFUNCTION_1 0x00
#defineFUNCTION_2 0x20
#defineFUNCTION_3 0x40
#defineFUNCTION_4 0x60
#defineFUNCTION_5 0x80
#defineFUNCTION_6 0xA0
#defineANALOG 0xC0
//Interrupt Modes
#defineDISABLED 0x00
#defineRISING 0x01
#defineFALLING 0x02
#defineCHANGE 0x03
#defineONLOW 0x04
#defineONHIGH 0x05
#defineONLOW_WE 0x0C
#defineONHIGH_WE 0x0D
typedefstruct {
uint8_treg; /*!< GPIO register offset from DR_REG_IO_MUX_BASE */
int8_trtc; /*!< RTC GPIO number (-1 if not RTC GPIO pin) */
int8_tadc; /*!< ADC Channel number (-1 if not ADC pin) */
int8_ttouch; /*!< Touch Channel number (-1 if not Touch pin) */
} esp32_gpioMux_t;
externconstesp32_gpioMux_tesp32_gpioMux[40];
externconstint8_tesp32_adc2gpio[20];
#definedigitalPinIsValid(pin) ((pin) < 40 && esp32_gpioMux[(pin)].reg)
#definedigitalPinCanOutput(pin) ((pin) < 34 && esp32_gpioMux[(pin)].reg)
#definedigitalPinToRtcPin(pin) (((pin) < 40)?esp32_gpioMux[(pin)].rtc:-1)
#definedigitalPinToAnalogChannel(pin) (((pin) < 40)?esp32_gpioMux[(pin)].adc:-1)
#definedigitalPinToTouchChannel(pin) (((pin) < 40)?esp32_gpioMux[(pin)].touch:-1)
#definedigitalPinToDacChannel(pin) (((pin) == 25)?0:((pin) == 26)?1:-1)
voidpinMode(uint8_tpin, uint8_tmode);
voiddigitalWrite(uint8_tpin, uint8_tval);
intdigitalRead(uint8_tpin);
voidattachInterrupt(uint8_tpin, void (*)(void), intmode);
voidattachInterruptArg(uint8_tpin, void (*)(void*), void*arg, intmode);
voiddetachInterrupt(uint8_tpin);
#ifdef__cplusplus
}
#endif
#endif/* MAIN_ESP32_HAL_GPIO_H_ */