diff --git a/peripherals/eic.c b/peripherals/eic.c index 4cb2d6a..a82754f 100644 --- a/peripherals/eic.c +++ b/peripherals/eic.c @@ -96,11 +96,11 @@ void eic_enable(void) { #endif } -bool eic_configure_pin(const uint32_t pin, eic_interrupt_trigger trigger) { +int8_t eic_configure_pin(const uint32_t pin, eic_interrupt_trigger trigger) { uint16_t port = pin >> 8; int8_t channel = _eic_pin_to_channel[port][pin % 32]; if (channel < 0) { - return false; + return -1; } uint8_t config_index = (channel > 7) ? 1 : 0; uint8_t sense_pos = 4 * (channel % 8); @@ -122,7 +122,7 @@ bool eic_configure_pin(const uint32_t pin, eic_interrupt_trigger trigger) { CTRLREG.bit.ENABLE = 1; _eic_sync(); - return true; + return channel; } bool eic_enable_interrupt(const uint8_t pin) { diff --git a/peripherals/eic.h b/peripherals/eic.h index 74657ad..786f90a 100644 --- a/peripherals/eic.h +++ b/peripherals/eic.h @@ -56,10 +56,11 @@ void eic_enable(void); * eic_enable_event() to either wake the processor or generate an event for a peripheral. * @param pin The external interrupt pin you wish to configure * @param trigger The condition on which you wish to trigger: rising, falling or both. + * @return the EIC channel number associated with the pin, or -1 if the pin is not an interrupt pin. * @note Be sure to check your pin multiplexing table to ensure that you do not have multiple pins * assigned to the same interrupt channel. */ -bool eic_configure_pin(const uint32_t pin, eic_interrupt_trigger trigger); +int8_t eic_configure_pin(const uint32_t pin, eic_interrupt_trigger trigger); /** @brief Enables an interrupt on the given interrupt channel. * @param pin The external interrupt pin.