4545#include "rom_map.h"
4646#include "pin.h"
4747#include "gpio.h"
48- #include "pybgpio .h"
48+ #include "pybpin .h"
4949#include "pybextint.h"
5050#include "mpexception.h"
5151#include "interrupt.h"
5555/// \moduleref pyb
5656/// \class ExtInt - configure I/O pins to interrupt on external events
5757///
58- /// There are a maximum of 25 GPIO interrupt lines.
58+ /// There are a maximum of 25 gpio interrupt lines.
5959///
6060/// Example callback:
6161///
7272/// See: http://www.eng.utah.edu/~cs5780/debouncing.pdf for a detailed
7373/// explanation, along with various techniques for debouncing.
7474///
75- /// All gpio objects go through the gpio mapper to come up with one of the
75+ /// All pin objects go through the pin mapper to come up with one of the
7676/// gpio pins.
7777///
78- /// extint = pyb.ExtInt(gpio , mode, pull, callback)
78+ /// extint = pyb.ExtInt(pin , mode, pull, callback)
7979///
8080/// There is also a C API, so that drivers which require EXTI interrupt lines
8181/// can also use this code. See pybextint.h for the available functions.
@@ -149,7 +149,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
149149/// \classmethod \constructor(pin, mode, pull, callback)
150150/// Create an ExtInt object:
151151///
152- /// - `gpio ` is the gpio on which to enable the interrupt (can be a gpio object or any valid gpio name).
152+ /// - `pin ` is the pin on which to enable the interrupt (can be a pin object or any valid pin name).
153153/// - `mode` can be one of:
154154/// - `ExtInt.IRQ_RISING` - trigger on a rising edge;
155155/// - `ExtInt.IRQ_FALLING` - trigger on a falling edge;
@@ -162,7 +162,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(extint_obj_swint_obj, extint_obj_swint);
162162/// callback function must accept exactly 1 argument, which is the line that
163163/// triggered the interrupt.
164164STATIC const mp_arg_t pyb_extint_make_new_args [] = {
165- { MP_QSTR_gpio , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
165+ { MP_QSTR_pin , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
166166 { MP_QSTR_mode , MP_ARG_REQUIRED | MP_ARG_INT , {.u_int = 0 } },
167167 { MP_QSTR_pull , MP_ARG_REQUIRED | MP_ARG_INT , {.u_int = 0 } },
168168 { MP_QSTR_callback , MP_ARG_REQUIRED | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
@@ -271,12 +271,12 @@ void extint_init0(void) {
271271}
272272
273273extint_obj_t * extint_register (mp_obj_t pin_obj , uint32_t intmode , uint32_t pull , mp_obj_t callback ) {
274- const gpio_obj_t * gpio = NULL ;
274+ const pin_obj_t * pin = NULL ;
275275 extint_obj_t * self ;
276276 void * handler ;
277277 uint32_t intnum ;
278278
279- gpio = gpio_find (pin_obj );
279+ pin = pin_find (pin_obj );
280280
281281 if (intmode != GPIO_FALLING_EDGE &&
282282 intmode != GPIO_RISING_EDGE &&
@@ -294,8 +294,8 @@ extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull,
294294 nlr_raise (mp_obj_new_exception_msg (& mp_type_OSError , mpexception_value_invalid_arguments ));
295295 }
296296
297- if (NULL == (self = extint_find (gpio -> port , gpio -> bit ))) {
298- self = extint_add (gpio -> pin_num , gpio -> port , gpio -> bit );
297+ if (NULL == (self = extint_find (pin -> port , pin -> bit ))) {
298+ self = extint_add (pin -> pin_num , pin -> port , pin -> bit );
299299 }
300300 else {
301301 // we need to update the callback atomically, so we disable the line
@@ -307,10 +307,10 @@ extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull,
307307 self -> callback = NULL ;
308308
309309 // before enabling the interrupt, configure the gpio pin
310- gpio_config ( gpio , PIN_MODE_0 , GPIO_DIR_MODE_IN , pull , PIN_STRENGTH_4MA );
310+ pin_config ( pin , PIN_MODE_0 , GPIO_DIR_MODE_IN , pull , PIN_STRENGTH_4MA );
311311
312- MAP_GPIOIntTypeSet (gpio -> port , gpio -> bit , intmode );
313- switch (gpio -> port ) {
312+ MAP_GPIOIntTypeSet (pin -> port , pin -> bit , intmode );
313+ switch (pin -> port ) {
314314 case GPIOA0_BASE :
315315 handler = GPIOA0IntHandler ;
316316 intnum = INT_GPIOA0 ;
@@ -330,7 +330,7 @@ extint_obj_t* extint_register(mp_obj_t pin_obj, uint32_t intmode, uint32_t pull,
330330 break ;
331331 }
332332
333- MAP_GPIOIntRegister (gpio -> port , handler );
333+ MAP_GPIOIntRegister (pin -> port , handler );
334334 // set the interrupt to the lowest priority, to make sure that no ther
335335 // isr will be preemted by this one
336336 MAP_IntPrioritySet (intnum , INT_PRIORITY_LVL_7 );
0 commit comments