Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM4L Peripheral Event Controller (PEVC) Driver

This driver for Atmel® | SMART ARM®-based microcontrollers provides a unified interface for the configuration and management of the Event Channels.

The peripheral event generators and users are interconnected by a network known as the Peripheral Event System.

The Peripheral Event System allows low latency peripheral-to-peripheral signaling without CPU intervention, and without consuming system resources such as bus or RAM bandwidth. This offloads the CPU and system resources compared to a traditional interrupt-based software driven system.

Devices from the following series can use this module:

The outline of this documentation is as follows:

Prerequisites

There are no prerequisites for this module.

Module Overview

Peripherals within the SAM4L device are capable of generating two types of actions in response to a given stimulus; they can set a register flag for later intervention by the CPU (using interrupt or polling methods), or they can generate event signals which can be internally routed directly to other peripherals within the device. The use of events allows for direct actions to be performed in one peripheral in response to a stimulus in another without CPU intervention. This can lower the overall power consumption of the system if the CPU is able to remain in sleep modes for longer periods, and lowers the latency of the system response.

The Peripheral Event System is comprised of a number of freely configurable Event Channels, plus a number of fixed Event Users. Each Event Channel can be configured to select the input peripheral that will generate the events on the channel, as well as the Event Shaper (EVS) and Input Glitch Filter (IGF) operating modes. The fixed-function Event Users, connected to peripherals within the device, can then subscribe to an Event Channel in a one-to-many relationship in order to receive events as they are generated. An overview of the event system chain is shown in the figure below.

There are many different events that can be routed in the device, which can then trigger many different actions. For example, an Analog Comparator module could be configured to generate an event when the input signal rises above the compare threshold, which then triggers a Timer Counter module to capture the current count value for later use.

Event Channels

The Peripheral Event Controller module in the SAM4L device consists of several channels, which can be freely linked to an Event Generator (i.e. a peripheral within the device that is capable of generating events). Each channel can be individually configured to select the generator peripheral, signal path, Event Shaper (EVS), and Input Glitch Filter (IGF) applied to the input event signal, before being passed to any event user(s).

Event Channels can support multiple users within the device in a standardized manner; when an Event User is linked to an Event Channel, the channel will automatically handshake with all attached users to ensure that all modules correctly receive and acknowledge the event.

Event Users

Event Users are able to subscribe to an Event Channel, once it has been configured. Each Event User consists of a fixed connection to one of the peripherals within the device (for example, an ADC module or Timer module) and is capable of being connected to a single Event Channel.

Event Shaper (EVS)

The Peripheral Event Controller module contains Event Shapers (EVS) for external inputs and general purpose waveforms (i.e. timer outputs or Generic Clocks) that require synchronisation and/or edge detection prior to peripheral event propagation.

Each Event Shaper is responsible for shaping one generator input prior to it going through an Event Channel.

Refer to the module configuration section at the end of the Peripheral Event Controller (PEVC) section in the device datasheet for the specific configuration of Event Shapers and Input Glitch Filters.

Input Glitch Filter (IGF)

The Peripheral Event Controller module contains Input Glitch Filters (IGF) specifically to allow I/O inputs to be sampled periodically. Input Glitch Filtering can be turned on or off in the Event Shaper associated with the Event Channel.

Physical Connection

The diagram below shows how this module is interconnected within the device.

Configuring Events

Several steps are required to properly configure an event chain, so that hardware peripherals can respond to events generated by each other, listed below.

Source Peripheral

  1. The source peripheral (that will generate events) must be configured and enabled.
  2. The source peripheral (that will generate events) must have an output event enabled.

Event System

  1. The event system channel must be configured and enabled, with the correct source peripheral selected as the channel's Event Generator.
  2. The event system user must be configured and enabled, with the correct source Event Channel selected as the source.

Destination Peripheral

  1. The destination peripheral (that will receive events) must be configured and enabled.
  2. The destination peripheral (that will receive events) must have an input event enabled.

Special Considerations

There are no special considerations for this module.

Extra Information

For extra information, see Extra Information for Peripheral Event Controller Driver. This includes:

Examples

For a list of examples related to this driver, see Examples for Peripheral Event Controller Driver.

API Overview

Modules

 
 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the SAM4L Peripheral Event Controller (PEVC) Driver.
 

Data Structures

struct  events_ch_conf
 Event Channel configuration structure. More...
 
struct  events_conf
 Event configuration structure. More...
 

Macros

#define EVENT_CHANNEL_N   PEVC_TRIGOUT_BITS
 Maximum number for Event Channels (users). More...
 
#define EVENT_GENERATOR_N   PEVC_EVIN_BITS
 Maximum number for event generator. More...
 

Enumerations

enum  events_igf_divider {
  EVENT_IGF_DIVIDER_1 = 0,
  EVENT_IGF_DIVIDER_2 = 1,
  EVENT_IGF_DIVIDER_4 = 2,
  EVENT_IGF_DIVIDER_8 = 3,
  EVENT_IGF_DIVIDER_16 = 4,
  EVENT_IGF_DIVIDER_32 = 5,
  EVENT_IGF_DIVIDER_64 = 6,
  EVENT_IGF_DIVIDER_128 = 7,
  EVENT_IGF_DIVIDER_256 = 8,
  EVENT_IGF_DIVIDER_512 = 9,
  EVENT_IGF_DIVIDER_1024 = 10,
  EVENT_IGF_DIVIDER_2048 = 11,
  EVENT_IGF_DIVIDER_4096 = 12,
  EVENT_IGF_DIVIDER_8192 = 13,
  EVENT_IGF_DIVIDER_16384 = 14,
  EVENT_IGF_DIVIDER_32768 = 15
}
 Input Glitch Filter divider configurations. More...
 
enum  events_igf_edge {
  EVENT_IGF_EDGE_NONE = 0,
  EVENT_IGF_EDGE_RISING = 1,
  EVENT_IGF_EDGE_FALLING = 2,
  EVENT_IGF_EDGE_BOTH = 3
}
 Event Input Glitch Filter edge detection configurations. More...
 

Functions

static void events_ch_clear_overrun_status (uint32_t channel_id)
 Clear the overrun status of an Event Channel. More...
 
static void events_ch_clear_trigger_status (uint32_t channel_id)
 Clear the trigger status of an Event Channel. More...
 
void events_ch_configure (struct events_ch_conf *const config)
 Configure an Event Channel. More...
 
static void events_ch_disable (uint32_t channel_id)
 Disable an Event Channel. More...
 
static void events_ch_disable_software_trigger (uint32_t channel_id)
 Disable the software trigger for an Event Channel. More...
 
static void events_ch_enable (uint32_t channel_id)
 Enable an Event Channel. More...
 
static void events_ch_enable_software_trigger (uint32_t channel_id)
 Enable the software trigger for an Event Channel. More...
 
void events_ch_get_config_defaults (struct events_ch_conf *const config)
 Initialize an Event Channel configuration structure to defaults. More...
 
static bool events_ch_is_enabled (uint32_t channel_id)
 Get the status (enabled or disabled) of an Event Channel. More...
 
static bool events_ch_is_overrun (uint32_t channel_id)
 Get the overrun status of an Event Channel. More...
 
static bool events_ch_is_ready (uint32_t channel_id)
 Get the busy status of an Event Channel. More...
 
static bool events_ch_is_triggered (uint32_t channel_id)
 Get the trigger status of an Event Channel. More...
 
static void events_ch_software_trigger (uint32_t channel_id)
 Trigger a Software Event for the corresponding Event Channel. More...
 
void events_disable (void)
 Disable the events module. More...
 
void events_enable (void)
 Enable the events module. More...
 
void events_get_config_defaults (struct events_conf *const config)
 Initialize an events configuration structure to defaults. More...
 
void events_init (struct events_conf *const config)
 Initialize the events module. More...
 
static void events_set_igf_divider (enum events_igf_divider divider)
 Set the Input Glitch Filter Divider. More...
 

#define EVENT_CHANNEL_N   PEVC_TRIGOUT_BITS

Maximum number for Event Channels (users).

Referenced by events_ch_configure(), and events_ch_get_config_defaults().

#define EVENT_GENERATOR_N   PEVC_EVIN_BITS

Maximum number for event generator.

Referenced by events_ch_configure(), and events_ch_get_config_defaults().

Input Glitch Filter divider configurations.

Enumerate for the possible division ratios of an Input Glitch Filter.

Enumerator
EVENT_IGF_DIVIDER_1 

Select a prescaler division ratio of 1.

EVENT_IGF_DIVIDER_2 

Select a prescaler division ratio of 2.

EVENT_IGF_DIVIDER_4 

Select a prescaler division ratio of 4.

EVENT_IGF_DIVIDER_8 

Select a prescaler division ratio of 8.

EVENT_IGF_DIVIDER_16 

Select a prescaler division ratio of 16.

EVENT_IGF_DIVIDER_32 

Select a prescaler division ratio of 32.

EVENT_IGF_DIVIDER_64 

Select a prescaler division ratio of 64.

EVENT_IGF_DIVIDER_128 

Select a prescaler division ratio of 128.

EVENT_IGF_DIVIDER_256 

Select a prescaler division ratio of 256.

EVENT_IGF_DIVIDER_512 

Select a prescaler division ratio of 512.

EVENT_IGF_DIVIDER_1024 

Select a prescaler division ratio of 1024.

EVENT_IGF_DIVIDER_2048 

Select a prescaler division ratio of 2048.

EVENT_IGF_DIVIDER_4096 

Select a prescaler division ratio of 4096.

EVENT_IGF_DIVIDER_8192 

Select a prescaler division ratio of 8192.

EVENT_IGF_DIVIDER_16384 

Select a prescaler division ratio of 16384.

EVENT_IGF_DIVIDER_32768 

Select a prescaler division ratio of 32768.

Event Input Glitch Filter edge detection configurations.

Enumerator
EVENT_IGF_EDGE_NONE 

Input Glitch Filter is disabled.

EVENT_IGF_EDGE_RISING 

Event detection through Input Glitch Filter on rising edge.

EVENT_IGF_EDGE_FALLING 

Event detection through Input Glitch Filter on falling edge.

EVENT_IGF_EDGE_BOTH 

Event detection through Input Glitch Filter on both edges.

static void events_ch_clear_overrun_status ( uint32_t  channel_id)
inlinestatic

Clear the overrun status of an Event Channel.

Parameters
[in]channel_idEvent Channel ID
static void events_ch_clear_trigger_status ( uint32_t  channel_id)
inlinestatic

Clear the trigger status of an Event Channel.

Parameters
[in]channel_idEvent Channel ID

Referenced by run_events_ast_test(), and run_events_software_test().

void events_ch_configure ( struct events_ch_conf *const  config)
static void events_ch_disable ( uint32_t  channel_id)
inlinestatic

Disable an Event Channel.

Parameters
[in]channel_idEvent Channel ID

Referenced by events_ch_configure().

static void events_ch_disable_software_trigger ( uint32_t  channel_id)
inlinestatic

Disable the software trigger for an Event Channel.

Parameters
[in]channel_idEvent Channel ID
static void events_ch_enable ( uint32_t  channel_id)
inlinestatic

Enable an Event Channel.

Parameters
[in]channel_idEvent Channel ID

Referenced by init_events(), init_pevc(), and run_events_ast_test().

static void events_ch_enable_software_trigger ( uint32_t  channel_id)
inlinestatic

Enable the software trigger for an Event Channel.

Parameters
[in]channel_idEvent Channel ID

Referenced by run_events_software_test().

void events_ch_get_config_defaults ( struct events_ch_conf *const  config)

Initialize an Event Channel configuration structure to defaults.

The default configuration is as follows:

  • Channel ID is initialized to invalid number
  • Generator ID is initialized to invalid number
  • Event shaper is disabled
  • Event Input Glitch Filter is disabled
Parameters
[out]configConfiguration structure to initialize to default values

References Assert, events_ch_conf::channel_id, EVENT_CHANNEL_N, EVENT_GENERATOR_N, EVENT_IGF_EDGE_NONE, events_ch_conf::generator_id, events_ch_conf::igf_edge, and events_ch_conf::shaper_enable.

Referenced by init_events(), init_pevc(), and run_events_ast_test().

static bool events_ch_is_enabled ( uint32_t  channel_id)
inlinestatic

Get the status (enabled or disabled) of an Event Channel.

Parameters
[in]channel_idEvent Channel ID
Returns
The Event Channel enabled/disabled status.
Return values
trueEvent Channel is enabled
falseEvent Channel is disabled
static bool events_ch_is_overrun ( uint32_t  channel_id)
inlinestatic

Get the overrun status of an Event Channel.

Parameters
[in]channel_idEvent Channel ID
Returns
The Event Channel overrun status.
Return values
trueA channel overrun event has occurred
falseA channel overrun event has not occurred
static bool events_ch_is_ready ( uint32_t  channel_id)
inlinestatic

Get the busy status of an Event Channel.

Parameters
[in]channel_idEvent Channel ID
Returns
The Event Channel busy status.
Return values
trueIf the Event Channel is ready to be used
falseIf the Event Channel is currently busy
static bool events_ch_is_triggered ( uint32_t  channel_id)
inlinestatic

Get the trigger status of an Event Channel.

Parameters
[in]channel_idEvent Channel ID
Returns
The Event Channel trigger status.
Return values
trueA channel event has occurred
falseA channel event has not occurred

Referenced by run_events_ast_test(), and run_events_software_test().

static void events_ch_software_trigger ( uint32_t  channel_id)
inlinestatic

Trigger a Software Event for the corresponding Event Channel.

Parameters
[in]channel_idEvent Channel ID

Referenced by run_events_software_test().

void events_disable ( void  )

Disable the events module.

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

void events_enable ( void  )

Enable the events module.

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

Referenced by init_events(), and run_events_ast_test().

void events_get_config_defaults ( struct events_conf *const  config)

Initialize an events configuration structure to defaults.

The default configuration is as follows:

Parameters
[out]configConfiguration structure to initialize to default values

References Assert, EVENT_IGF_DIVIDER_1024, and events_conf::igf_divider.

Referenced by init_events(), init_pevc(), and run_events_ast_test().

void events_init ( struct events_conf *const  config)

Initialize the events module.

Parameters
[in]configConfiguration structure to initialize to default values

References Assert, events_set_igf_divider(), events_conf::igf_divider, and sysclk_enable_peripheral_clock().

Referenced by init_events(), init_pevc(), and run_events_ast_test().

static void events_set_igf_divider ( enum events_igf_divider  divider)
inlinestatic

Set the Input Glitch Filter Divider.

Parameters
[in]dividerInput Glitch Filter divider
Note
As stated in the datasheet, there is one divider value for all Event Shaper (EVS) instances.

Referenced by events_init().