8000 Add workaround for CHANGE interrupt to work · sparkfun/mbed-os-ambiq-apollo3@3d69e97 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d69e97

Browse files
committed
Add workaround for CHANGE interrupt to work
1 parent 5572f0a commit 3d69e97

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/device/gpio_irq_api.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ extern "C"
1111
uint32_t ap3_gpio_enable_interrupts(uint32_t ui32Pin, am_hal_gpio_intdir_e eIntDir);
1212
/** GPIO IRQ HAL structure. gpio_irq_s is declared in the target's HAL
1313
*/
14-
typedef struct gpio_irq_s gpio_irq_t;
14+
n // typedef struct gpio_irq_s gpio_irq_t;
1515

16-
typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
16+
// typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
1717
extern void am_gpio_isr(void);
1818
static ap3_gpio_irq_control_t gpio_irq_control[AP3_GPIO_MAX_PADS];
1919

@@ -78,7 +78,14 @@ extern "C"
7878
{
7979
am_hal_gpio_interrupt_clear(AM_HAL_GPIO_BIT(pinNum));
8080
ap3_gpio_irq_control_t irq_ctrl = gpio_irq_control[pinNum];
81-
((gpio_irq_handler)irq_ctrl.handler)(irq_ctrl.id, irq_ctrl.events);
81+
uint8_t enabledEvents = irq_ctrl.events;
82+
//Can't check if a rise or a fall caused the interrupt, must assume source from what is enabled
83+
if(enabledEvents == (IRQ_RISE | IRQ_FALL))
84+
{
85+
//if both are enabled we have to just assume it game from the rise, its the best we can do
86+
enabledEvents = IRQ_RISE;
87+
}
88+
((gpio_irq_handler)irq_ctrl.handler)(irq_ctrl.id, enabledEvents);
8289
}
8390
gpio_int_mask >>= 1;
8491
pinNum++;

0 commit comments

Comments
 (0)
0