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:
There are no prerequisites for this module.
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.
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 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.
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.
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.
The diagram below shows how this module is interconnected within the device.
Several steps are required to properly configure an event chain, so that hardware peripherals can respond to events generated by each other, listed below.
There are no special considerations for this module.
For extra information, see Extra Information for Peripheral Event Controller Driver. This includes:
For a list of examples related to this driver, see Examples for Peripheral Event Controller 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().
enum events_igf_divider |
Input Glitch Filter divider configurations.
Enumerate for the possible division ratios of an Input Glitch Filter.
enum events_igf_edge |
Event Input Glitch Filter edge detection configurations.
|
inlinestatic |
Clear the overrun status of an Event Channel.
[in] | channel_id | Event Channel ID |
|
inlinestatic |
Clear the trigger status of an Event Channel.
[in] | channel_id | Event Channel ID |
void events_ch_configure | ( | struct events_ch_conf *const | config | ) |
Configure an Event Channel.
[in,out] | config | Configuration settings for the Event Channel |
References Assert, events_ch_conf::channel_id, EVENT_CHANNEL_N, EVENT_GENERATOR_N, EVENT_IGF_EDGE_BOTH, EVENT_IGF_EDGE_FALLING, EVENT_IGF_EDGE_NONE, EVENT_IGF_EDGE_RISING, events_ch_disable(), events_ch_conf::generator_id, events_ch_conf::igf_edge, and events_ch_conf::shaper_enable.
Referenced by init_pevc().
|
inlinestatic |
Disable an Event Channel.
[in] | channel_id | Event Channel ID |
Referenced by events_ch_configure().
|
inlinestatic |
Disable the software trigger for an Event Channel.
[in] | channel_id | Event Channel ID |
|
inlinestatic |
|
inlinestatic |
Enable the software trigger for an Event Channel.
[in] | channel_id | Event Channel ID |
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:
[out] | config | Configuration 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_pevc().
|
inlinestatic |
Get the status (enabled or disabled) of an Event Channel.
[in] | channel_id | Event Channel ID |
true | Event Channel is enabled |
false | Event Channel is disabled |
|
inlinestatic |
Get the overrun status of an Event Channel.
[in] | channel_id | Event Channel ID |
true | A channel overrun event has occurred |
false | A channel overrun event has not occurred |
|
inlinestatic |
Get the busy status of an Event Channel.
[in] | channel_id | Event Channel ID |
true | If the Event Channel is ready to be used |
false | If the Event Channel is currently busy |
|
inlinestatic |
Get the trigger status of an Event Channel.
[in] | channel_id | Event Channel ID |
true | A channel event has occurred |
false | A channel event has not occurred |
|
inlinestatic |
Trigger a Software Event for the corresponding Event Channel.
[in] | channel_id | Event Channel ID |
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().
void events_get_config_defaults | ( | struct events_conf *const | config | ) |
Initialize an events configuration structure to defaults.
The default configuration is as follows:
[out] | config | Configuration structure to initialize to default values |
References Assert, EVENT_IGF_DIVIDER_1024, and events_conf::igf_divider.
Referenced by init_pevc().
void events_init | ( | struct events_conf *const | config | ) |
Initialize the events module.
[in] | config | Configuration structure to initialize to default values |
References Assert, events_set_igf_divider(), events_conf::igf_divider, and sysclk_enable_peripheral_clock().
Referenced by init_pevc().
|
inlinestatic |
Set the Input Glitch Filter Divider.
[in] | divider | Input Glitch Filter divider |
Referenced by events_init().