gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
Event System

Functions for configuring the Event System. More...

Functions

void evsys_init (void)
 Initializes the Event System.
 
void evsys_configure_channel (uint8_t channel, uint8_t generator, evsys_path_t path, evsys_edge_t edge, generic_clock_generator_t clocksource)
 Configures an event channel with a generator and path settings.
 
void evsys_connect_user (uint8_t user, uint8_t channel)
 Connects an event user to an event channel.
 
void evsys_disconnect_user (uint8_t user)
 Disconnects an event user from its channel.
 
void evsys_software_event (uint8_t channel)
 Triggers a software event on the specified channel.
 
void evsys_enable_interrupt (uint8_t channel)
 Enables the event-detected interrupt for a channel.
 
void evsys_disable_interrupt (uint8_t channel)
 Disables the event-detected interrupt for a channel.
 
bool evsys_get_and_clear_interrupt (uint8_t channel)
 Checks and clears a channel's event-detected interrupt flag.
 

Detailed Description

Functions for configuring the Event System.

The Event System routes events between peripherals without CPU intervention. Event generators (sources) are connected to event users (destinations) through configurable event channels.

Generator and user IDs are chip-specific. Use the EVSYS_ID_GEN_* and EVSYS_ID_USER_* defines from your chip's headers. For example, EVSYS_ID_GEN_RTC_OVF for the RTC overflow generator, or EVSYS_ID_USER_DMAC_CH_0 for DMA channel 0's event input.

Function Documentation

◆ evsys_configure_channel()

void evsys_configure_channel ( uint8_t channel,
uint8_t generator,
evsys_path_t path,
evsys_edge_t edge,
generic_clock_generator_t clocksource )

Configures an event channel with a generator and path settings.

Parameters
channelThe event channel number (0 to EVSYS_CHANNELS-1).
generatorThe event generator ID. Use the EVSYS_ID_GEN_* defines from your chip's instance header (e.g. EVSYS_ID_GEN_RTC_OVF).
pathThe event propagation path. Use EVSYS_PATH_ASYNCHRONOUS for lowest latency without edge detection, EVSYS_PATH_SYNCHRONOUS when generator and channel share a clock, or EVSYS_PATH_RESYNCHRONIZED when they do not.
edgeEdge detection mode. Must be EVSYS_EDGE_NONE for asynchronous paths. Must be EVSYS_EDGE_RISING, EVSYS_EDGE_FALLING, or EVSYS_EDGE_BOTH for synchronous or resynchronized paths.
clocksourceThe generic clock source for edge detection and event propagation. Ignored when path is EVSYS_PATH_ASYNCHRONOUS.
Note
SAM D51 erratum DS80000748F ยง2.21.1: TCC event inputs are not compatible with EVSYS channels in synchronous or resynchronized mode on the D51. Use an asynchronous channel path for any event routed to a TCC.

◆ evsys_connect_user()

void evsys_connect_user ( uint8_t user,
uint8_t channel )

Connects an event user to an event channel.

The channel must be configured first with evsys_configure_channel(). Multiple users can be connected to the same channel.

Parameters
userThe event user ID. Use the EVSYS_ID_USER_* defines from your chip's instance header (e.g. EVSYS_ID_USER_DMAC_CH_0).
channelThe event channel number to connect to.

◆ evsys_disable_interrupt()

void evsys_disable_interrupt ( uint8_t channel)

Disables the event-detected interrupt for a channel.

Parameters
channelThe channel to disable the interrupt for.

◆ evsys_disconnect_user()

void evsys_disconnect_user ( uint8_t user)

Disconnects an event user from its channel.

Parameters
userThe event user ID to disconnect.

◆ evsys_enable_interrupt()

void evsys_enable_interrupt ( uint8_t channel)

Enables the event-detected interrupt for a channel.

Define irq_handler_evsys in your application; from it, call evsys_get_and_clear_interrupt() to identify which channel fired. On the SAM D51 only channels 0-11 can generate interrupts.

Parameters
channelThe channel to enable the interrupt for.

◆ evsys_get_and_clear_interrupt()

bool evsys_get_and_clear_interrupt ( uint8_t channel)

Checks and clears a channel's event-detected interrupt flag.

Parameters
channelThe channel to check.
Returns
true if the channel's event-detected flag was set (now cleared).

◆ evsys_init()

void evsys_init ( void )

Initializes the Event System.

Enables the EVSYS bus clock. Call once at boot before configuring any event channels.

◆ evsys_software_event()

void evsys_software_event ( uint8_t channel)

Triggers a software event on the specified channel.

The software event behaves like an event from a generator. For synchronous or resynchronized paths, the channel must be configured with edge detection enabled.

Parameters
channelThe event channel number.