8.8.1.1.3 Workflow
- Create an event channel configuration struct, which can be filled out to adjust the configuration of a single event channel.
struct
events_config config;
- Initialize the event channel configuration struct with the module's default values.
events_get_config_defaults(&config);
Note: This should always be performed before using the configuration struct to ensure that all values are initialized to known default settings. - Adjust the configuration struct to request that the channel is to be attached to the specified event generator, that rising edges of the event signal be detected on the channel, and that the synchronous event path is to be used.
config.generator = CONF_EVENT_GENERATOR;
config.edge_detect = EVENTS_EDGE_DETECT_RISING;
config.path = EVENTS_PATH_SYNCHRONOUS;
config.clock_source = GCLK_GENERATOR_0;
- Allocate and configure the channel using the configuration structure.
events_allocate(resource, &config);
Note: The existing configuration struct may be re-used, as long as any values that have been altered from the default settings are taken into account by the user application. - Attach a user to the channel.
events_attach_user(resource, CONF_EVENT_USER);