4646
4747#define GPIO_IRQ_ALL (0xf)
4848
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-
5549// Open drain behaviour is simulated.
5650#define GPIO_IS_OPEN_DRAIN (id ) (machine_pin_open_drain_mask & (1 << (id)))
5751
@@ -198,13 +192,13 @@ const machine_pin_obj_t *machine_pin_find(mp_obj_t pin) {
198192
199193static void machine_pin_print (const mp_print_t * print , mp_obj_t self_in , mp_print_kind_t kind ) {
200194 machine_pin_obj_t * self = self_in ;
201- uint funcsel = GPIO_GET_FUNCSEL (self -> id );
195+ uint funcsel = gpio_get_function (self -> id );
202196 qstr mode_qst ;
203197 if (!is_ext_pin (self )) {
204198 if (funcsel == GPIO_FUNC_SIO ) {
205199 if (GPIO_IS_OPEN_DRAIN (self -> id )) {
206200 mode_qst = MP_QSTR_OPEN_DRAIN ;
207- } else if (GPIO_IS_OUT (self -> id )) {
201+ } else if (gpio_is_dir_out (self -> id )) {
208202 mode_qst = MP_QSTR_OUT ;
209203 } else {
210204 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
214208 }
215209 mp_printf (print , "Pin(%q, mode=%q" , self -> name , mode_qst );
216210 bool pull_up = false;
217- if (GPIO_IS_PULL_UP (self -> id )) {
211+ if (gpio_is_pulled_up (self -> id )) {
218212 mp_printf (print , ", pull=%q" , MP_QSTR_PULL_UP );
219213 pull_up = true;
220214 }
221- if (GPIO_IS_PULL_DOWN (self -> id )) {
215+ if (gpio_is_pulled_down (self -> id )) {
222216 if (pull_up ) {
223217 mp_printf (print , "|%q" , MP_QSTR_PULL_DOWN );
224218 } else {
@@ -411,7 +405,7 @@ static mp_obj_t machine_pin_toggle(mp_obj_t self_in) {
411405 machine_pin_ext_set (self , self -> last_output_value ^ 1 );
412406 #endif
413407 } else if (GPIO_IS_OPEN_DRAIN (self -> id )) {
414- if (GPIO_IS_OUT (self -> id )) {
408+ if (gpio_is_dir_out (self -> id )) {
415409 gpio_set_dir (self -> id , GPIO_IN );
416410 } else {
417411 gpio_set_dir (self -> id , GPIO_OUT );
0 commit comments