Fix both edge bug in gpio_irq_api.c

Fixes #22
pull/17/head
Matthew Else 2013-07-26 09:41:20 +01:00
parent ddbb67a996
commit 3172fd97ca
1 changed files with 11 additions and 8 deletions

View File

@ -37,17 +37,20 @@ static inline void handle_interrupt_in(uint32_t channel) {
uint8_t pin_num = (pin_names[channel] & (0x0f << PIN_SHIFT)) >> PIN_SHIFT;
uint8_t trigger_event = trigger_events[channel];
if (trigger_event == 1) {
// Rising edge.
if (trigger_event == 1)
irq_handler(channel_ids[channel], IRQ_RISE);
}
else if (trigger_event == 2) {
// Low, therefore falling edge...
else if (trigger_event == 2)
irq_handler(channel_ids[channel], IRQ_FALL);
}
else {
// This is supposed to be triggered by both cases...
// In order to get an idea of which kind of event it is,
// We need to read the logic level of the pin...
uint8_t logic = (port_reg->DATA & (1 << pin_num)) >> pin_num;
if (logic == 1)
irq_handler(channel_ids[channel], IRQ_RISE);
else
irq_handler(channel_ids[channel], IRQ_FALL);
}
// Clear the interrupt...