summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDaniel Campora <daniel@wipy.io>2015-05-17 13:42:15 +0200
committerDaniel Campora <daniel@wipy.io>2015-05-17 13:42:15 +0200
commitfb9e4cf4634ce62479e5d40659a19ba84a59bbb4 (patch)
tree75ee80dfacacf375f7803c60416e9014f4510330
parent8e611e841476d98eb829978a7e73ce92ff822ca8 (diff)
downloadmicropython-fb9e4cf4634ce62479e5d40659a19ba84a59bbb4.tar.gz
micropython-fb9e4cf4634ce62479e5d40659a19ba84a59bbb4.zip
cc3200: Make sure to handle all pending pin interrupts.
When entering the interrupt handler of a given GPIO port, more than one pin could have pending interrupts, therefore care must be taken to service each interrupt one by one before leaving.
-rw-r--r--cc3200/mods/pybpin.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/cc3200/mods/pybpin.c b/cc3200/mods/pybpin.c
index c9454de337..76545525df 100644
--- a/cc3200/mods/pybpin.c
+++ b/cc3200/mods/pybpin.c
@@ -712,7 +712,6 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_INT_RISING_FALLING), MP_OBJ_NEW_SMALL_INT(GPIO_BOTH_EDGES) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_INT_LOW_LEVEL), MP_OBJ_NEW_SMALL_INT(GPIO_LOW_LEVEL) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_INT_HIGH_LEVEL), MP_OBJ_NEW_SMALL_INT(GPIO_HIGH_LEVEL) },
-
{ MP_OBJ_NEW_QSTR(MP_QSTR_S2MA), MP_OBJ_NEW_SMALL_INT(PIN_STRENGTH_2MA) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_S4MA), MP_OBJ_NEW_SMALL_INT(PIN_STRENGTH_4MA) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_S6MA), MP_OBJ_NEW_SMALL_INT(PIN_STRENGTH_6MA) },
@@ -752,12 +751,18 @@ STATIC void GPIOA3IntHandler (void) {
// common interrupt handler
STATIC void EXTI_Handler(uint port) {
- uint32_t bit = MAP_GPIOIntStatus(port, true);
- MAP_GPIOIntClear(port, bit);
-
- // TODO: loop through all the active bits before exiting
- pin_obj_t *self = (pin_obj_t *)pin_find_pin_by_port_bit(&pin_cpu_pins_locals_dict, port, bit);
- mp_obj_t _callback = mpcallback_find(self);
- mpcallback_handler(_callback);
+ uint32_t bits = MAP_GPIOIntStatus(port, true);
+ MAP_GPIOIntClear(port, bits);
+
+ // might be that we have more than one Pin interrupt triggered at the same time
+ // therefore we must loop through all the 8 possible bits
+ for (int i = 0; i < 8; i++) {
+ uint32_t bit = (1 << i);
+ if (bit & bits) {
+ pin_obj_t *self = (pin_obj_t *)pin_find_pin_by_port_bit(&pin_cpu_pins_locals_dict, port, bit);
+ mp_obj_t _callback = mpcallback_find(self);
+ mpcallback_handler(_callback);
+ }
+ }
}