Skip to content

Commit d1f0cb3

Browse files
authored
Merge pull request #3 from ppibburr/patch-1
add IO modes and pullups
2 parents e765b5b + 06d9b0a commit d1f0cb3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/gpio.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66
#include "driver/adc.h"
77

88
#define GPIO_MODE_DEF_PULLUP (BIT3)
9+
#define GPIO_MODE_DEF_PULLDOWN (BIT3)
910
#define GPIO_MODE_INPUT_PULLUP ((GPIO_MODE_INPUT)|(GPIO_MODE_DEF_PULLUP))
11+
#define GPIO_MODE_INPUT_PULLDOWN ((GPIO_MODE_INPUT)|(GPIO_MODE_DEF_PULLDOWN))
12+
#define GPIO_MODE_OUTPUT (GPIO_MODE_DEF_OUTPUT)
13+
#define GPIO_MODE_OUTPUT_OD ((GPIO_MODE_DEF_OUTPUT)|(GPIO_MODE_DEF_OD))
14+
#define GPIO_MODE_INPUT_OUTPUT_OD ((GPIO_MODE_DEF_INPUT)|(GPIO_MODE_DEF_OUTPUT)|(GPIO_MODE_DEF_OD))
15+
#define GPIO_MODE_INPUT_OUTPUT ((GPIO_MODE_DEF_INPUT)|(GPIO_MODE_DEF_OUTPUT))
1016

1117
static mrb_value
1218
mrb_esp32_gpio_pin_mode(mrb_state *mrb, mrb_value self) {
@@ -173,9 +179,12 @@ mrb_mruby_esp32_gpio_gem_init(mrb_state* mrb)
173179
mrb_define_const(mrb, constants, "LOW", mrb_fixnum_value(0));
174180
mrb_define_const(mrb, constants, "HIGH", mrb_fixnum_value(1));
175181

176-
mrb_define_const(mrb, constants, "INPUT", mrb_fixnum_value(GPIO_MODE_INPUT));
177-
mrb_define_const(mrb, constants, "INPUT_PULLUP", mrb_fixnum_value(GPIO_MODE_INPUT_PULLUP));
178-
mrb_define_const(mrb, constants, "OUTPUT", mrb_fixnum_value(GPIO_MODE_OUTPUT));
182+
mrb_define_const(mrb, constants, "INPUT", mrb_fixnum_value(GPIO_MODE_INPUT));
183+
mrb_define_const(mrb, constants, "INPUT_OUTPUT", mrb_fixnum_value(GPIO_MODE_INPUT_OUTPUT));
184+
mrb_define_const(mrb, constants, "OUTPUT", mrb_fixnum_value(GPIO_MODE_OUTPUT));
185+
mrb_define_const(mrb, constants, "INPUT_PULLUP", mrb_fixnum_value(GPIO_MODE_INPUT_PULLUP));
186+
mrb_define_const(mrb, constants, "INPUT_PULLDOWN", mrb_fixnum_value(GPIO_MODE_INPUT_PULLDOWN));
187+
179188
}
180189

181190
void

0 commit comments

Comments
 (0)