Functions for configuring and using the External Interrupt Controller.
More...
|
typedef enum eic_interrupt_trigger_t | eic_interrupt_trigger_t |
| An enum defining the types of interrupt trigger you wish to scan for.
|
|
typedef void(* | eic_cb_t) (uint8_t channel) |
|
|
enum | eic_interrupt_trigger_t { INTERRUPT_TRIGGER_NONE = 0
, INTERRUPT_TRIGGER_RISING
, INTERRUPT_TRIGGER_FALLING
, INTERRUPT_TRIGGER_BOTH
} |
| An enum defining the types of interrupt trigger you wish to scan for.
|
|
|
void | eic_init (void) |
| Initializes the external interrupt controller, but does not enable it.
|
|
void | eic_enable (void) |
| Enables the external interrupt controller.
|
|
int8_t | eic_configure_pin (const uint8_t pin, eic_interrupt_trigger_t trigger) |
| Configures an external interrupt on one of the external interrupt pins.
|
|
bool | eic_enable_interrupt (const uint8_t pin) |
| Enables an interrupt on the given interrupt channel.
|
|
bool | eic_disable_interrupt (const uint8_t pin) |
| Disables the interrupt on the given interrupt channel.
|
|
bool | eic_enable_event (const uint8_t pin) |
| Enables an interrupt on the given interrupt channel.
|
|
bool | eic_disable_event (const uint8_t pin) |
| Disables the interrupt on the given interrupt channel.
|
|
void | eic_configure_callback (eic_cb_t callback) |
| Configures an external interrupt callback.
|
|
void | eic_disable (void) |
| Disables the external interrupt controller.
|
|
Functions for configuring and using the External Interrupt Controller.
◆ eic_configure_callback()
void eic_configure_callback |
( |
eic_cb_t |
callback | ) |
|
Configures an external interrupt callback.
You only get the one callback, so if you need to handle multiple interrupts, you'll need to check the EIC->INTFLAG register in your callback to determine which interrupt fired.
- Parameters
-
callback | The function that will be called when the interrupt fires. |
- Note
- This function is called from the interrupt handler, so it should be as short as possible.
◆ eic_configure_pin()
Configures an external interrupt on one of the external interrupt pins.
This function configures the interrupt channel with the specified trigger, but it does not set pin direction, mux or pull; you must set up the pin yourself. This function also does not enable an interrupt or event generation. You must call eic_enable_interrupt() or eic_enable_event() to either wake the processor or generate an event for a peripheral.
- Parameters
-
pin | The external interrupt pin you wish to configure — use HAL_GPIO_xxx_PIN() macro. |
trigger | The condition on which you wish to trigger: rising, falling or both. |
- Returns
- 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. Also note that the NMI pin is not currently supported.
FIXME: Should we have macros for this that accept a port / pin?
◆ eic_disable_event()
bool eic_disable_event |
( |
const uint8_t |
pin | ) |
|
Disables the interrupt on the given interrupt channel.
- Parameters
-
pin | The external interrupt pin. |
◆ eic_disable_interrupt()
bool eic_disable_interrupt |
( |
const uint8_t |
pin | ) |
|
Disables the interrupt on the given interrupt channel.
- Parameters
-
pin | The external interrupt pin. |
◆ eic_enable_event()
bool eic_enable_event |
( |
const uint8_t |
pin | ) |
|
Enables an interrupt on the given interrupt channel.
- Parameters
-
pin | The external interrupt pin. |
◆ eic_enable_interrupt()
bool eic_enable_interrupt |
( |
const uint8_t |
pin | ) |
|
Enables an interrupt on the given interrupt channel.
- Parameters
-
pin | The external interrupt pin. |