46
46
47
47
#define GPIO_IRQ_ALL (0xf)
48
48
49
- // Macros to access the state of the hardware.
50
- #define GPIO_GET_FUNCSEL (id ) ((iobank0_hw->io[(id)].ctrl & IO_BANK0_GPIO0_CTRL_FUNCSEL_BITS) >> IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB)
51
- #define GPIO_IS_OUT (id ) (sio_hw->gpio_oe & (1 << (id)))
52
- #define GPIO_IS_PULL_UP (id ) (padsbank0_hw->io[(id)] & PADS_BANK0_GPIO0_PUE_BITS)
53
- #define GPIO_IS_PULL_DOWN (id ) (padsbank0_hw->io[(id)] & PADS_BANK0_GPIO0_PDE_BITS)
54
-
55
49
// Open drain behaviour is simulated.
56
50
#define GPIO_IS_OPEN_DRAIN (id ) (machine_pin_open_drain_mask & (1 << (id)))
57
51
@@ -198,13 +192,13 @@ const machine_pin_obj_t *machine_pin_find(mp_obj_t pin) {
198
192
199
193
static void machine_pin_print (const mp_print_t * print , mp_obj_t self_in , mp_print_kind_t kind ) {
200
194
machine_pin_obj_t * self = self_in ;
201
- uint funcsel = GPIO_GET_FUNCSEL (self -> id );
195
+ uint funcsel = gpio_get_function (self -> id );
202
196
qstr mode_qst ;
203
197
if (!is_ext_pin (self )) {
204
198
if (funcsel == GPIO_FUNC_SIO ) {
205
199
if (GPIO_IS_OPEN_DRAIN (self -> id )) {
206
200
mode_qst = MP_QSTR_OPEN_DRAIN ;
207
- } else if (GPIO_IS_OUT (self -> id )) {
201
+ } else if (gpio_is_dir_out (self -> id )) {
208
202
mode_qst = MP_QSTR_OUT ;
209
203
} else {
210
204
mode_qst = MP_QSTR_IN ;
@@ -214,11 +208,11 @@ static void machine_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_prin
214
208
}
215
209
mp_printf (print , "Pin(%q, mode=%q" , self -> name , mode_qst );
216
210
bool pull_up = false;
217
- if (GPIO_IS_PULL_UP (self -> id )) {
211
+ if (gpio_is_pulled_up (self -> id )) {
218
212
mp_printf (print , ", pull=%q" , MP_QSTR_PULL_UP );
219
213
pull_up = true;
220
214
}
221
- if (GPIO_IS_PULL_DOWN (self -> id )) {
215
+ if (gpio_is_pulled_down (self -> id )) {
222
216
if (pull_up ) {
223
217
mp_printf (print , "|%q" , MP_QSTR_PULL_DOWN );
224
218
} else {
@@ -411,7 +405,7 @@ static mp_obj_t machine_pin_toggle(mp_obj_t self_in) {
411
405
machine_pin_ext_set (self , self -> last_output_value ^ 1 );
412
406
#endif
413
407
} else if (GPIO_IS_OPEN_DRAIN (self -> id )) {
414
- if (GPIO_IS_OUT (self -> id )) {
408
+ if (gpio_is_dir_out (self -> id )) {
415
409
gpio_set_dir (self -> id , GPIO_IN );
416
410
} else {
417
411
gpio_set_dir (self -> id , GPIO_OUT );
0 commit comments