3.11. exti — External interrupts

Source code: src/drivers/exti.h, src/drivers/exti.c

Test code: tst/drivers/exti/main.c


Defines

EXTI_TRIGGER_BOTH_EDGES EXTI_PORT_TRIGGER_BOTH_EDGES

Trigger an interrupt on both rising and falling edges.

EXTI_TRIGGER_FALLING_EDGE EXTI_PORT_TRIGGER_FALLING_EDGE

Trigger an interrupt on falling edges.

EXTI_TRIGGER_RISING_EDGE EXTI_PORT_TRIGGER_RISING_EDGE

Trigger an interrupt on both rising edges.

Functions

int exti_module_init(void)

Initialize the external interrupt (EXTI) module. This function must be called before calling any other function in this module.

The module will only be initialized once even if this function is called multiple times.

Return
zero(0) or negative error code.

int exti_init(struct exti_driver_t *self_p, struct exti_device_t *dev_p, int trigger, void (*on_interrupt)(void *arg_p), void *arg_p, )

Initialize given driver object.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to be initialized.
  • dev_p: Device to use.
  • trigger: One of EXTI_TRIGGER_BOTH_EDGES, EXTI_TRIGGER_FALLING_EDGE or EXTI_TRIGGER_RISING_EDGE.
  • on_interrupt: Function callback called when an interrupt occurs.
  • arg_p: Fucntion callback argument.

int exti_start(struct exti_driver_t *self_p)

Starts the EXTI device using given driver object.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int exti_stop(struct exti_driver_t *self_p)

Stops the EXTI device referenced by given driver object.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

int exti_clear(struct exti_driver_t *self_p)

Clear the interrupt flag.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object.

Variables

struct exti_device_t exti_device[EXTI_DEVICE_MAX]