File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -386,10 +386,21 @@ ExecStatus port_begin_cmd(PortData *p) {
386
386
u8 mode = (p -> arg [0 ] >> 4 ) & 0x07 ;
387
387
388
388
if (port_pin_supports_interrupt (p , pin )) {
389
- eic_config ( p -> port -> gpio [ pin ], mode );
389
+ // If we are setting an interrupt
390
390
if (mode != 0 ) {
391
+ // Ensure the pin is configured as an external interrupt
391
392
pin_mux_eic (p -> port -> gpio [pin ]);
393
+ // Set the type of interrupt we need (ie low, fall, etc.)
394
+ eic_config (p -> port -> gpio [pin ], mode );
395
+ // If we are removing interrupts
392
396
} else {
397
+ // First disable the interrupts
398
+ eic_config (p -> port -> gpio [pin ], mode );
399
+ // Then set the pin back as GPIO
400
+ // It is important to do this in the above order to avoid
401
+ // the case where the interrupt is disabled and pin set as
402
+ // GPIO in one call, and the interrupt enabled in the next
403
+ // (which could immediately fire depending on GPIO state)
393
404
pin_gpio (p -> port -> gpio [pin ]);
394
405
}
395
406
}
You can’t perform that action at this time.
0 commit comments