Skip to content

Commit

Permalink
EIC: pass channel number back to caller
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycastillo committed Jul 16, 2024
1 parent 91c50d3 commit 5feadac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions peripherals/eic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion peripherals/eic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5feadac

Please sign in to comment.