Skip to content

Commit ae9c853

Browse files
committed
Add API for configuring a GPIO as INPUT_PULLUP.
1 parent a323261 commit ae9c853

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

arduino/cores/esp32/wiring_digital.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ void pinMode(uint32_t pin, uint32_t mode)
3333
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_OUTPUT);
3434
gpio_set_pull_mode((gpio_num_t)pin, GPIO_FLOATING);
3535
break;
36+
37+
case INPUT_PULLUP:
38+
gpio_set_direction((gpio_num_t)pin, GPIO_MODE_INPUT);
39+
gpio_set_pull_mode((gpio_num_t)pin, GPIO_PULLUP_ONLY);
40+
break;
3641
}
3742

3843
PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[pin], PIN_FUNC_GPIO);

arduino/cores/esp32/wiring_digital.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ extern "C" {
2929
#define LOW 0x00
3030
#define HIGH 0x01
3131

32-
#define INPUT 0x00
33-
#define OUTPUT 0x01
32+
#define INPUT 0x00
33+
#define OUTPUT 0x01
34+
#define INPUT_PULLUP 0x02
3435

3536
extern void pinMode(uint32_t pin, uint32_t mode);
3637

0 commit comments

Comments
 (0)