Skip to content

Commit

Permalink
Fix both edge bug in gpio_irq_api.c
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelse committed Jul 26, 2013
1 parent ddbb67a commit 3172fd9
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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...
irq_handler(channel_ids[channel], IRQ_RISE);
// 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...
Expand Down

0 comments on commit 3172fd9

Please sign in to comment.