File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#include "driver/gpio.h"
5
5
6
+ #define GPIO_MODE_DEF_PULLUP (BIT3)
7
+ #define GPIO_MODE_INPUT_PULLUP ((GPIO_MODE_INPUT)|(GPIO_MODE_DEF_PULLUP))
8
+
6
9
static mrb_value
7
10
mrb_esp32_gpio_pin_mode (mrb_state * mrb , mrb_value self ) {
8
11
mrb_value pin , dir ;
@@ -13,7 +16,12 @@ mrb_esp32_gpio_pin_mode(mrb_state *mrb, mrb_value self) {
13
16
return mrb_nil_value ();
14
17
}
15
18
16
- gpio_set_direction (mrb_fixnum (pin ), mrb_fixnum (dir ));
19
+ gpio_pad_select_gpio (mrb_fixnum (pin ));
20
+ gpio_set_direction (mrb_fixnum (pin ), mrb_fixnum (dir ) & ~GPIO_MODE_DEF_PULLUP );
21
+
22
+ if (mrb_fixnum (dir ) & GPIO_MODE_DEF_PULLUP ) {
23
+ gpio_set_pull_mode (mrb_fixnum (pin ), GPIO_PULLUP_ONLY );
24
+ }
17
25
18
26
return self ;
19
27
}
@@ -108,6 +116,7 @@ mrb_mruby_esp32_gpio_gem_init(mrb_state* mrb)
108
116
mrb_define_const (mrb , constants , "HIGH" , mrb_fixnum_value (1 ));
109
117
110
118
mrb_define_const (mrb , constants , "INPUT" , mrb_fixnum_value (GPIO_MODE_INPUT ));
119
+ mrb_define_const (mrb , constants , "INPUT_PULLUP" , mrb_fixnum_value (GPIO_MODE_INPUT_PULLUP ));
111
120
mrb_define_const (mrb , constants , "OUTPUT" , mrb_fixnum_value (GPIO_MODE_OUTPUT ));
112
121
}
113
122
You can’t perform that action at this time.
0 commit comments