3.1.7. pcint — Pin change interrupts

This module adds support for external pin change interrupts, with triggers on rising and/or falling edges.


Source code: src/drivers/basic/pcint.h, src/drivers/basic/pcint.c

Test code: tst/drivers/hardware/basic/pcint/main.c


Defines

PCINT_TRIGGER_BOTH_EDGES

Trigger an interrupt on both rising and falling edges.

PCINT_TRIGGER_FALLING_EDGE

Trigger an interrupt on falling edges.

PCINT_TRIGGER_RISING_EDGE

Trigger an interrupt on rising edges.

Functions

int pcint_module_init(void)

Initialize the external change interrupt 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 pcint_init(struct pcint_driver_t *self_p, struct pcint_device_t *dev_p, int trigger, void (*on_interrupt)(void *arg_p), void *arg_p, )

Initialize given change interrupt 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 PCINT_TRIGGER_BOTH_EDGES, PCINT_TRIGGER_FALLING_EDGE or PCINT_TRIGGER_RISING_EDGE.
  • on_interrupt: Function callback called when an interrupt occurs.
  • arg_p: Function callback argument.

int pcint_start(struct pcint_driver_t *self_p)

Starts the pin change interrupt device using given driver object.

Enables interrupts for given pin change interrupt driver.

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

int pcint_stop(struct pcint_driver_t *self_p)

Stops the pin change interrupt device referenced by given driver object.

Disables interrupts for given pin change interrupt driver.

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

Variables

struct pcint_device_t pcint_device[PCINT_DEVICE_MAX]