8.8.1.1.2 Code
Add to the main application source file, before any functions, according to the kit used:
- SAM D20 Xplained Pro.
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU - SAM D21 Xplained Pro.
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU - SAM R21 Xplained Pro.
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU - SAM D11 Xplained Pro.
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC2_MCX_0#define CONF_EVENT_USER EVSYS_ID_USER_TC1_EVU - SAM L21 Xplained Pro
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_NONE#define CONF_EVENT_USER EVSYS_ID_USER_PORT_EV_0 - SAM L22 Xplained Pro
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_NONE#define CONF_EVENT_USER EVSYS_ID_USER_PORT_EV_0 - SAM DA1 Xplained Pro.
#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_TC4_MCX_0#define CONF_EVENT_USER EVSYS_ID_USER_TC3_EVU - SAM C21 Xplained Pro
Copy-paste the following setup code to your user application:#define CONF_EVENT_GENERATOR EVSYS_ID_GEN_NONE#define CONF_EVENT_USER EVSYS_ID_USER_PORT_EV_0
Create an event resource struct and add to user application (typically the start of main()):staticvoidconfigure_event_channel(structevents_resource *resource){structevents_config config;events_get_config_defaults(&config);config.generator = CONF_EVENT_GENERATOR;config.edge_detect = EVENTS_EDGE_DETECT_RISING;config.path = EVENTS_PATH_SYNCHRONOUS;config.clock_source = GCLK_GENERATOR_0;events_allocate(resource, &config);}staticvoidconfigure_event_user(structevents_resource *resource){events_attach_user(resource, CONF_EVENT_USER);}
Add to user application initialization (typically the start of main()):structevents_resource example_event;configure_event_channel(&example_event);configure_event_user(&example_event);
