Microchip® Advanced Software Framework

Quickstart guide for SAM EIC driver

This is the quickstart guide for the SAM4L External Interrupt Controller (EIC) Driver, with step-by-step instructions on how to configure and use the driver in a selection of use cases.

The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function.

Basic Use Case

In this basic use case, the EIC module and single line are configured for:

  • Falling edge trigger and async mode
  • Interrupt-based handling
  • GPIO_PUSH_BUTTON_EIC_IRQ as input

Prerequisites

System Clock Management (Sysclock).

Setup Steps

Example Code

Add to application C-file:

static void eic_callback(void)
{
/* Check if EIC push button line interrupt line is pending. */
bToggle = 1;
}
}
static void eic_setup(void)
{
eic_enable(EIC);
struct eic_line_config eic_line_conf;
eic_line_conf.eic_edge = EIC_EDGE_FALLING_EDGE;
eic_line_conf.eic_level = EIC_LEVEL_LOW_LEVEL;
eic_line_conf.eic_filter = EIC_FILTER_DISABLED;
eic_line_conf.eic_async = EIC_ASYNCH_MODE;
}

Workflow

Define the interrupt callback function in the application:

static void eic_callback(void)
{
/* Check if EIC push button line interrupt line is pending. */
bToggle = 1;
}
}

Enable EIC module:

eic_enable(EIC);
Note
Including enable module clock and lock sleep mode.

Configure EIC line with specified mode:

Set the EIC callback function and enable EIC interrupt.

Enable EIC line: