Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM4L External Interrupt Controller (EIC) Driver

This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's on-chip External Interrupt Controller (EIC).

Devices from the following series can use this module:

The outline of this documentation is as follows:

Module Overview

The External Interrupt Controller (EIC) allows pins to be configured as external interrupts. Each external interrupt has its own interrupt request and can be individually masked. Each external interrupt can generate an interrupt on rising or falling edge, or high or low level. Every interrupt input has a configurable filter to remove spikes from the interrupt source. Every interrupt pin can also be configured to be asynchronous, in order to wake-up the part from sleep modes where the CLK_SYNC clock has been disabled.

An additional Non-Maskable Interrupt (NMI) pin is also supported. This has the same properties as the other external interrupts, but is connected to the NMI request of the CPU, enabling it to interrupt any other interrupt mode.

Special Considerations

Prerequisites

Extra Information

For extra information, see Extra Information for EIC. This includes:

Examples

For a list of examples related to this driver, see

API Overview

Data Structures

struct  eic_line_config
 Configuration parameters of the EIC module. More...
 

Macros

#define EIC_NUMBER_OF_LINES   9
 Number of available EIC lines, device dependent. More...
 

Typedefs

typedef void(* eic_callback_t )(void)
 Callback definition. More...
 

Functions

void eic_disable (Eic *eic)
 Disable the EIC module. More...
 
void eic_enable (Eic *eic)
 Enable the EIC module. More...
 
static void eic_line_clear_interrupt (Eic *eic, uint8_t line_number)
 Clear the interrupt flag of specified pin. More...
 
static void eic_line_disable (Eic *eic, uint8_t line_number)
 Disable the external interrupt on specified line. More...
 
static void eic_line_disable_interrupt (Eic *eic, uint8_t line_number)
 Disables the propagation from the EIC to the interrupt controller of the external interrupt on a specified line. More...
 
static void eic_line_enable (Eic *eic, uint8_t line_number)
 Enable the external interrupt on specified line. More...
 
static void eic_line_enable_interrupt (Eic *eic, uint8_t line_number)
 Enables the propagation from the EIC to the interrupt controller of the external interrupt on a specified line. More...
 
static bool eic_line_interrupt_is_enabled (Eic *eic, uint8_t line_number)
 Tells whether an EIC interrupt line is enabled. More...
 
static bool eic_line_interrupt_is_pending (Eic *eic, uint8_t line_number)
 Tells whether an EIC interrupt line is pending. More...
 
static bool eic_line_is_enabled (Eic *eic, uint8_t line_number)
 Tells whether an EIC line is enabled. More...
 
void eic_line_set_callback (Eic *eic, uint8_t line_number, eic_callback_t callback, uint8_t irq_line, uint8_t irq_level)
 Set callback for given EIC line. More...
 
void eic_line_set_config (Eic *eic, uint8_t line_number, struct eic_line_config *eic_line_conf)
 Program the EIC hardware with the specified configuration. More...
 

External Interrupt lines

#define EXT_NMI   0
 Non-Maskable Interrupt. More...
 
#define EXT_INT1   1
 External Interrupt 1. More...
 
#define EXT_INT2   2
 External Interrupt 2. More...
 
#define EXT_INT3   3
 External Interrupt 3. More...
 
#define EXT_INT4   4
 External Interrupt 4. More...
 
#define EXT_INT5   5
 External Interrupt 5. More...
 
#define EXT_INT6   6
 External Interrupt 6. More...
 
#define EXT_INT7   7
 External Interrupt 7. More...
 
#define EXT_INT8   8
 External Interrupt 8. More...
 

Mode Trigger Options

#define EIC_MODE_EDGE_TRIGGERED   0
 The interrupt is edge triggered. More...
 
#define EIC_MODE_LEVEL_TRIGGERED   1
 The interrupt is level triggered. More...
 

Edge level Options

#define EIC_EDGE_FALLING_EDGE   0
 The interrupt triggers on falling edge. More...
 
#define EIC_EDGE_RISING_EDGE   1
 The interrupt triggers on rising edge. More...
 

Level Options

#define EIC_LEVEL_LOW_LEVEL   0
 The interrupt triggers on low level. More...
 
#define EIC_LEVEL_HIGH_LEVEL   1
 The interrupt triggers on high level. More...
 

Filter Options

#define EIC_FILTER_ENABLED   1
 The interrupt is filtered. More...
 
#define EIC_FILTER_DISABLED   0
 The interrupt is not filtered. More...
 

Synch Mode Options

#define EIC_SYNCH_MODE   0
 The interrupt is synchronized to CLK_SYNC. More...
 
#define EIC_ASYNCH_MODE   1
 The interrupt is asynchronous. More...
 

#define EIC_ASYNCH_MODE   1

The interrupt is asynchronous.

Referenced by eic_line_change_config(), and eic_line_set_config().

#define EIC_EDGE_FALLING_EDGE   0

The interrupt triggers on falling edge.

#define EIC_EDGE_RISING_EDGE   1

The interrupt triggers on rising edge.

Referenced by eic_line_set_config().

#define EIC_FILTER_DISABLED   0

The interrupt is not filtered.

Referenced by eic_line_change_config().

#define EIC_FILTER_ENABLED   1

The interrupt is filtered.

Referenced by eic_line_set_config().

#define EIC_LEVEL_HIGH_LEVEL   1

The interrupt triggers on high level.

Referenced by eic_line_change_config(), and eic_line_set_config().

#define EIC_LEVEL_LOW_LEVEL   0

The interrupt triggers on low level.

Referenced by eic_line_change_config().

#define EIC_MODE_EDGE_TRIGGERED   0

The interrupt is edge triggered.

#define EIC_MODE_LEVEL_TRIGGERED   1

The interrupt is level triggered.

Referenced by eic_line_change_config(), and eic_line_set_config().

#define EIC_NUMBER_OF_LINES   9

Number of available EIC lines, device dependent.

#define EIC_SYNCH_MODE   0

The interrupt is synchronized to CLK_SYNC.

#define EXT_INT1   1

External Interrupt 1.

#define EXT_INT2   2

External Interrupt 2.

#define EXT_INT3   3

External Interrupt 3.

#define EXT_INT4   4

External Interrupt 4.

#define EXT_INT5   5

External Interrupt 5.

#define EXT_INT6   6

External Interrupt 6.

#define EXT_INT7   7

External Interrupt 7.

#define EXT_INT8   8

External Interrupt 8.

#define EXT_NMI   0

Non-Maskable Interrupt.

typedef void(* eic_callback_t)(void)

Callback definition.

void eic_disable ( Eic *  eic)

Disable the EIC module.

Parameters
[in]eicBase address of the EIC module

References SLEEPMGR_BACKUP, sleepmgr_unlock_mode(), and sysclk_disable_peripheral_clock().

void eic_enable ( Eic *  eic)

Enable the EIC module.

Parameters
[in]eicBase address of the EIC module

References SLEEPMGR_BACKUP, sleepmgr_lock_mode(), and sysclk_enable_peripheral_clock().

static void eic_line_clear_interrupt ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Clear the interrupt flag of specified pin.

     Call this function once you have handled the interrupt.
Parameters
[in]eicBase address of the EIC (i.e. EIC)
[in]line_numberLine number to clear

Referenced by eic_pad_init().

static void eic_line_disable ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Disable the external interrupt on specified line.

Parameters
[in]eicBase address of the EIC module
[in]line_numberLine number to disable

Referenced by eic_pad_init().

static void eic_line_disable_interrupt ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Disables the propagation from the EIC to the interrupt controller of the external interrupt on a specified line.

Parameters
[in]eicBase address of the EIC (i.e. EIC)
[in]line_numberLine number of interrupt to disable

Referenced by eic_pad_init().

static void eic_line_enable ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Enable the external interrupt on specified line.

Parameters
[in]eicBase address of the EIC module
[in]line_numberThe line number to enable

Referenced by eic_pad_init().

static void eic_line_enable_interrupt ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Enables the propagation from the EIC to the interrupt controller of the external interrupt on a specified line.

Parameters
[in]eicBase address of the EIC module
[in]line_numberLine number of interrupt to enable

Referenced by eic_line_set_callback(), and eic_pad_init().

static bool eic_line_interrupt_is_enabled ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Tells whether an EIC interrupt line is enabled.

Parameters
[in]eicBase address of the EIC module
[in]line_numberLine number to test
Return values
trueEIC interrupt line is enabled
falseEIC interrupt line is not enabled
static bool eic_line_interrupt_is_pending ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Tells whether an EIC interrupt line is pending.

Parameters
[in]eicBase address of the EIC module
[in]line_numberLine number to test
Return values
trueEIC interrupt line is pending
falseEIC interrupt line is not pending
static bool eic_line_is_enabled ( Eic *  eic,
uint8_t  line_number 
)
inlinestatic

Tells whether an EIC line is enabled.

Parameters
[in]eicBase address of the EIC module
[in]line_numberLine number to test
Return values
trueEIC line is enabled
falseEIC line is not enabled
void eic_line_set_callback ( Eic *  eic,
uint8_t  line_number,
eic_callback_t  callback,
uint8_t  irq_line,
uint8_t  irq_level 
)

Set callback for given EIC line.

Parameters
[in]eicBase address of the EIC module
[in]line_numberNumber of line
[in]callbackCallback function pointer
[in]irq_lineInterrupt line number (EIC_1_IRQn to EIC_8_IRQn)
[in]irq_levelInterrupt level (the priority of the interrupt request)

References callback, eic_line_enable_interrupt(), and irq_register_handler.

Referenced by eic_pad_init().

void eic_line_set_config ( Eic *  eic,
uint8_t  line_number,
struct eic_line_config eic_line_conf 
)

Program the EIC hardware with the specified configuration.

Parameters
[in]eicBase address of the EIC module
[in]line_numberNumber of line to configure
[in]eic_line_confConfiguration parameters for the EIC module (see eic_line_config)

References eic_line_config::eic_async, EIC_ASYNCH_MODE, eic_line_config::eic_edge, EIC_EDGE_RISING_EDGE, eic_line_config::eic_filter, EIC_FILTER_ENABLED, eic_line_config::eic_level, EIC_LEVEL_HIGH_LEVEL, eic_line_config::eic_mode, and EIC_MODE_LEVEL_TRIGGERED.

Referenced by eic_line_change_config().