@@ -63,10 +63,23 @@ void gpio_mode(gpio_t *obj, PinMode mode)
63
63
return ;
64
64
}
65
65
66
+ uint32_t pin_index = NU_PININDEX (obj -> pin );
67
+ uint32_t port_index = NU_PINPORT (obj -> pin );
68
+ GPIO_T * gpio_base = NU_PORT_BASE (port_index );
69
+
66
70
switch (mode ) {
67
71
case PullNone :
72
+ if (mode == PullNone ) {
73
+ GPIO_SetPullCtl (gpio_base , 1 << pin_index , GPIO_PUSEL_DISABLE );
74
+ }
68
75
case PullDown :
76
+ if (mode == PullDown ) {
77
+ GPIO_SetPullCtl (gpio_base , 1 << pin_index , GPIO_PUSEL_PULL_DOWN );
78
+ }
69
79
case PullUp :
80
+ if (mode == PullUp ) {
81
+ GPIO_SetPullCtl (gpio_base , 1 << pin_index , GPIO_PUSEL_PULL_UP );
82
+ }
70
83
/* H/W doesn't support separate configuration for input pull mode/direction.
71
84
* We translate to input-only/push-pull output I/O mode dependent on direction. */
72
85
obj -> mode = (obj -> direction == PIN_INPUT ) ? InputOnly : PushPullOutput ;
@@ -111,10 +124,23 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
111
124
112
125
obj -> direction = direction ;
113
126
127
+ uint32_t pin_index = NU_PININDEX (obj -> pin );
128
+ uint32_t port_index = NU_PINPORT (obj -> pin );
129
+ GPIO_T * gpio_base = NU_PORT_BASE (port_index );
130
+
114
131
switch (obj -> mode ) {
115
132
case PullNone :
133
+ if (obj -> mode == PullNone ) {
134
+ GPIO_SetPullCtl (gpio_base , 1 << pin_index , GPIO_PUSEL_DISABLE );
135
+ }
116
136
case PullDown :
137
+ if (obj -> mode == PullDown ) {
138
+ GPIO_SetPullCtl (gpio_base , 1 << pin_index , GPIO_PUSEL_PULL_DOWN );
139
+ }
117
140
case PullUp :
141
+ if (obj -> mode == PullUp ) {
142
+ GPIO_SetPullCtl (gpio_base , 1 << pin_index , GPIO_PUSEL_PULL_UP );
143
+ }
118
144
/* H/W doesn't support separate configuration for input pull mode/direction.
119
145
* We translate to input-only/push-pull output I/O mode dependent on direction. */
120
146
obj -> mode = (obj -> direction == PIN_INPUT ) ? InputOnly : PushPullOutput ;
0 commit comments