APPLICATION NOTE. AT06863: SAM4L Peripheral Event Controller (PEVC) SAM4L Peripheral Event Controller (PEVC) ASF PROGRAMMERS MANUAL

Similar documents
SAM4 Reset Controller (RSTC)

AT11512: SAM L Brown Out Detector (BOD) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AT03262: SAM D/R/L/C System Pin Multiplexer (SYSTEM PINMUX) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel AT03261: SAM D20 System Interrupt Driver (SYSTEM INTERRUPT) SAM D20 System Interrupt Driver (SYSTEM INTERRUPT)

SAM4L Asynchronous Timer (AST)

AT10942: SAM Configurable Custom Logic (CCL) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

APPLICATION NOTE. AT05567: TC Capture on External Interrupt with the Event System on SAM D20. Preface ASF PROJECT DOCUMENTATION

AT07942: SAM4L Asynchronous Timer (AST) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

SAM4L Liquid Crystal Display (LCDCA)

AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Features. Introduction. AVR 8-bit Microcontrollers APPLICATION NOTE

AT03975: Getting Started with SAM L21. Descripton. Features. SMART ARM-Based Microcontroller APPLICATION NOTE

USER GUIDE EDBG. Description

AVR42789: Writing to Flash on the New tinyavr Platform Using Assembly

OLED display with pixels resolution Ambient light sensor CPU load Analog filter Quadrature Encoder with push button Digital I/O

Atmel AVR32847: Migration from/to the UC3L0 64/32/16 from/to the UC3L0 256/ bit Atmel Microcontrollers. Application Note.

APPLICATION NOTE. AT6486: Using DIVAS on SAMC Microcontroller. SMART ARM-Based Microcontroller. Introduction. Features

AT60142H/HT. Rad-Hard 512Kx8 Very Low Power CMOS SRAM ERRATA-SHEET. Active Errata List. Errata History. Abbreviations. 1.

AVR42772: Data Logger Demo Application on XMEGA A1U Xplained Pro. Introduction. Features. AVR XMEGA Microcontrollers APPLICATION NOTE

APPLICATION NOTE. Atmel AT02260: Driving AT42QT1085. Atmel QTouch. Features. Description

EDBG. Description. Programmers and Debuggers USER GUIDE

APPLICATION NOTE. Atmel AVR1638: XMEGA RTC Calibration. 8-bit Atmel Microcontrollers. Features. Introduction

AT06467: Getting started with SAM D09/D10/D11. Features. Description. SMART ARM-based Microcontrollers APPLICATION NOTE

AVR1303: Use and configuration of IR communication module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Native route discovery algorithm

AVR1518: XMEGA-A1 Xplained Training - XMEGA Clock System. 8-bit Atmel Microcontrollers. Application Note. Prerequisites.

APPLICATION NOTE. Atmel AVR3009: Driving QTouch Device with I 2 C Interface. Atmel QTouch. Introduction

ATECC108/ATSHA204 USER GUIDE. Atmel Firmware Library. Features. Introduction

ATAES132A Firmware Development Library. Introduction. Features. Atmel CryptoAuthentication USER GUIDE

AT09381: SAM D - Debugging Watchdog Timer Reset. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

APPLICATION NOTE. AT11008: Migration from ATxmega16D4/32D4 Revision E to Revision I. Atmel AVR XMEGA. Introduction. Features

AVR1501: Xplain training XMEGA Timer/Counter 8-bit Microcontrollers Application Note Prerequisites 1 Introduction

Hardware Prerequisites Atmel Xplained Pro Evaluation Kit Atmel WINC1500 extension USB Micro Cable (TypeA / MicroB)

APPLICATION NOTE. Atmel AT03160: Migrating Bootloader from ATxmega128A1 to other Atmel XMEGA Devices. Atmel AVR XMEGA. Features.

AVR1503: Xplain training - XMEGA Programmable Multi Interrupt Controller 8-bit Microcontrollers Application Note Prerequisites

SAMA5D2 Quad SPI (QSPI) Performance. Introduction. SMART ARM-based Microprocessor APPLICATION NOTE

USER GUIDE. Atmel QT1 Xplained Pro. Preface

APPLICATION NOTE. Atmel AT03304: SAM D20 I 2 C Slave Bootloader SAM D20. Description. Features

AVR1315: Accessing the XMEGA EEPROM. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Ethernet1 Xplained Pro

USER GUIDE. Atmel OLED1 Xplained Pro. Preface

APPLICATION NOTE. Atmel AT01080: XMEGA E Schematic Checklist. Atmel AVR XMEGA E. Features. Introduction

APPLICATION NOTE. Atmel AT03782: Using Low Power Modes in SAM4N Microcontroller. Atmel 32-bit Microcontroller. Features.

AT21CS Series Reset and Discovery. Introduction. Serial EEPROM APPLICATION NOTE

AVR32752: Using the AVR32 UC3 Static Memory Controller. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel AVR057: Internal RC Oscillator Calibration for ATtiny4/5/9/10/20/40. 8-bit Atmel Microcontrollers. Features.

QT3 Xplained Pro. Preface. Atmel QTouch USER GUIDE

Section 5 SERCOM. Tasks SPI. In this section you will learn:

APPLICATION NOTE. AT03324: Atmel REB212BSMA-EK Quick Start Guide. Atmel MCU Wireless. Introduction

USER GUIDE. Atmel QT6 Xplained Pro. Preface

USER GUIDE. Atmel Segment LCD1 Xplained Pro. Preface

APPLICATION NOTE. Atmel QT4 Xplained Pro User Guide ATAN0114. Preface

AT03255: SAM D/R/L/C Serial Peripheral Interface (SERCOM SPI) Driver. Introduction. SMART ARM-based Microcontrollers APPLICATION NOTE

AVR1508: Xplain training - XMEGA DAC 8-bit Microcontrollers Application Note Features 1 Introduction

QT2 Xplained Pro. Preface. Atmel QTouch USER GUIDE

Atmel AVR1619: XMEGA-B1 Xplained Demonstration. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

Intel Stress Bitstreams and Encoder (Intel SBE) 2017 AVS2 Release Notes (Version 2.3)

USER GUIDE. ZigBit USB Stick User Guide. Introduction

AVR32917: picopower Board getting started. 32-bit Microcontrollers. Application Note. Preliminary. Features. 1 Introduction

APPLICATION NOTE. AT04470: Differences between SAM D21 Variants A, B, and L. 32-bit Microcontroller. Introduction

Atmel QT600 Quick Start Guide Touch Solutions

Atmel ATMXT143E touchscreen controller Capacitive touch ITO 320 x 240 pixel LCD display with SPI interface LED backlight

USER GUIDE. Atmel PROTO1 Xplained Pro. Preface

OLED display Sensors readout. Light sensor Temperature sensor

This user guide describes how to run the Atmel ATWINC3400 Bluetooth Low Energy (BLE) Provisioning demo from out-of-box conditions.

APPLICATION NOTE. 3-lead CONTACT Package Usage. ATSHA204A, ATECC108A, and ATECC508A. Introduction. 3-lead CONTACT Package

APPLICATION NOTE. How to Securely Switch Atmel s LIN Transceiver ATA6662/ATA6662C to Sleep Mode ATA6662/ATA6662C. Concerning Atmel ATA6662

a clock signal and a bi-directional data signal (SCL, SDA)

HALCoGen TMS570LS31x Help: example_sci_uart_9600.c

Atmel AVR1926: XMEGA-B1 Xplained Getting Started Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

M3H Group(2) Application Note 12-bit Analog to Digital Converter (ADC-A)

Open Source Used In TSP

Smart RF Device Family - Getting Started Guide. Features. Description. References ATAN0115 APPLICATION NOTE

Ecma International Policy on Submission, Inclusion and Licensing of Software

AVR32 UC3 Software Framework... User Manual

USER GUIDE. ATWINC1500 Xplained Pro. Preface

Atmel and the use of Verilator to create uc Device Models

USER GUIDE. ATmega168 Xplained Mini User Guide. Introduction

ATECC508A Public Key Validation. Introduction. Atmel CryptoAuthentication APPLICATION NOTE

AVR1922: Xplain Board Controller Firmware 8-bit Microcontrollers Application Note Features 1 Introduction

M3H Group(2) Application Note Asynchronous Serial Communication Circuit (UART-C)

DGILib USER GUIDE Atmel-42771A-DGILib_User Guide-09/2016

AVR4018: Inertial Two (ATAVRSBIN2) Hardware User's Guide. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Ecma International Policy on Submission, Inclusion and Licensing of Software

Atmel AVR1924: XMEGA-A1 Xplained Hardware User's Guide. 8-bit Atmel Microcontrollers. Application Note. Preliminary. Features.

Atmel AVR ATxmega384C3 microcontroller OLED display with 128x32 pixels resolution Analog sensors. Ambient light sensor Temperature sensor

APPLICATION NOTE. Atmel AVR536: Migration from ATmega644 to ATmega644A. 8-bit Atmel Microcontrollers. Introduction

APPLICATION NOTE. Generating Random Secrets. ATSHA204A, ATECC108A, and ATECC508A. Description. Topics

AVR532: Migration from ATmega48/88/168 to ATmega48A/88A/168A. 8-bit Microcontrollers. Application Note. 1 Introduction

APPLICATION NOTE. Atmel AVR2131: Lightweight Mesh Getting Started Guide. Atmel MCU Wireless. Features. Description

ATtiny817 QTouch Moisture Demo User Guide. Description. Features. AVR 8-bit Microcontrollers USER GUIDE

AVR097: Migration between ATmega128 and ATmega1281/ATmega bit Microcontrollers. Application Note. Features. 1 Introduction

SBAT90USB162 Atmel. SBAT90USB162 Development Board User s Manual

APPLICATION NOTE. Atmel AVR116: Wear Leveling on DataFlash. 32-bit Atmel Microcontrollers. Features. Description. Wear leveling

Atmel AT697F. Rad-Hard 32-bit SPARC v8 Processor ERRATA SHEET. Active Errata List

LBAT90USB162 Atmel. LBAT90USB162 Development Board User s Manual

USER GUIDE. Wireless Production Test Reference Protocol Specification Document. Atmel MCU Wireless. Description

Atmel LF-RFID Kit Comparison Chart. Application Note. Atmel LF-RFID Kit Comparison Chart. 1. Description

APPLICATION NOTE. Scope. Reference Documents. Software Ethernet Bridge on SAMA5D3/D4. Atmel SMART SAMA5D3/D4 Series

AT697E. Application Note. Checking AT697E Code for Occurrence of LDF/FPOPd Instructions Sequence with a dependency on an Odd-Numbered Register

64K (8K x 8) Battery-Voltage Parallel EEPROM with Page Write and Software Data Protection AT28BV64B

Transcription:

APPLICATION NOTE AT06863: SAM4L Peripheral Event Controller (PEVC) ASF PROGRAMMERS MANUAL SAM4L Peripheral Event Controller (PEVC) This driver provides a unified interface for the configuration and management of the event channels within the SAM4L device. 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. The outline of this documentation is as follows: Prerequisites Module Overview Special Considerations Extra Information Examples API Overview

Table of Contents SAM4L Peripheral Event Controller (PEVC)... 1 Software License... 4 1. Prerequisites... 5 2. Module Overview... 6 2.1. Event Channels... 6 2.2. Event Users... 6 2.3. Event Shaper (EVS)... 6 2.3.1. Input Glitch Filter (IGF)... 7 2.4. Physical Connection... 7 2.5. Configuring Events... 7 2.5.1. Source Peripheral... 7 2.5.2. Event System... 7 2.5.3. Destination Peripheral... 7 3. Special Considerations... 8 4. Extra Information... 9 5. Examples... 10 6. API Overview... 11 6.1. Structure Definitions... 11 6.1.1. Struct events_ch_conf... 11 6.1.2. Struct events_conf... 11 6.2. Macro Definitions... 11 6.2.1. Macro EVENT_CHANNEL_N... 11 6.2.2. Macro EVENT_GENERATOR_N... 11 6.3. Function Definitions... 11 6.3.1. Function events_ch_clear_overrun_status()... 11 6.3.2. Function events_ch_clear_trigger_status()... 12 6.3.3. Function events_ch_configure()... 12 6.3.4. Function events_ch_disable()... 12 6.3.5. Function events_ch_disable_software_trigger()... 12 6.3.6. Function events_ch_enable()... 13 6.3.7. Function events_ch_enable_software_trigger()... 13 6.3.8. Function events_ch_get_config_defaults()... 13 6.3.9. Function events_ch_is_enabled()... 14 6.3.10. Function events_ch_is_overrun()... 14 6.3.11. Function events_ch_is_ready()... 14 6.3.12. Function events_ch_is_triggered()... 15 6.3.13. Function events_ch_software_trigger()... 15 6.3.14. Function events_disable()... 15 6.3.15. Function events_enable()... 15 6.3.16. Function events_get_config_defaults()... 16 6.3.17. Function events_init()... 16 6.3.18. Function events_set_igf_divider()... 16 6.4. Enumeration Definitions... 17 6.4.1. Enum events_igf_divider... 17 6.4.2. Enum events_igf_edge... 17 7. Extra Information for Peripheral Event Controller Driver... 18 7.1. Acronyms... 18 7.2. Dependencies... 18 7.3. Errata... 18 7.4. Module History... 18 2

8. Examples for Peripheral Event Controller Driver... 19 8.1. Quick Start Guide for the Peripheral Event Controller Driver... 19 8.1.1. Use Cases... 19 8.1.2. Basic Use Case... 19 8.1.3. Setup Steps... 19 8.1.4. Basic Usage... 20 8.2. Example for the Peripheral Event System - AST/PDCA... 20 8.2.1. Introduction... 20 8.2.2. Main Files... 20 8.2.3. Compilation Information... 21 8.2.4. Device Information... 21 8.2.5. Configuration Information... 21 8.3. Example for the Peripheral Event System - GPIO/PDCA... 21 8.3.1. Introduction... 21 8.3.2. Main Files... 21 8.3.3. Compilation Information... 21 8.3.4. Device Information... 21 8.3.5. Configuration Information... 21 Index... 23 Document Revision History... 24 3

Software License Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of Atmel may not be used to endorse or promote products derived from this software without specific prior written permission. 4. This software may only be redistributed and used in connection with an Atmel microcontroller product. THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4

1. Prerequisites There are no prerequisites for this module. 5

2. 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 fixedfunction Event Users, connected to peripherals within the device, can then subscribe to an Event Channel in a oneto-many relationship in order to receive events as they are generated. An overview of the event system chain is shown in Figure 2-1: Module Overview on page 6. Figure 2-1. Module Overview User Generator Generator Peripheral Event System User/ Generator 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. 2.1 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. 2.2 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. 2.3 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. 6

2.3.1 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. 2.4 Physical Connection Figure 2-2: Physical Connection on page 7 shows how this module is interconnected within the device. Figure 2-2. Physical Connection Source Peripherals Source MUXs PEVC Event Channels Channel MUXs PEVC Event Users Destination Peripherals 2.5 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. 2.5.1 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. 2.5.2 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. 2.5.3 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. 7

3. Special Considerations There are no special considerations for this module. 8

4. Extra Information For extra information, see Extra Information for Peripheral Event Controller Driver. This includes: Acronyms Dependencies Errata Module History 9

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

6. API Overview 6.1 Structure Definitions 6.1.1 Struct events_ch_conf Configuration structure for an Event Channel. Table 6-1. Members Type Name Description uint32_t channel_id Channel to configure (user). uint32_t generator_id Event generator to connect to the channel. enum events_igf_edge igf_edge Edge detection for Event Channels. bool shaper_enable Enable Event Shaper (EVS) or not. 6.1.2 Struct events_conf Configuration structure for event module. Table 6-2. Members Type Name Description enum events_igf_divider igf_divider Input Glitch Filter divider. 6.2 Macro Definitions 6.2.1 Macro EVENT_CHANNEL_N #define EVENT_CHANNEL_N Maximum number for Event Channels (users). 6.2.2 Macro EVENT_GENERATOR_N #define EVENT_GENERATOR_N Maximum number for event generator. 6.3 Function Definitions 6.3.1 Function events_ch_clear_overrun_status() Clear the overrun status of an Event Channel. void events_ch_clear_overrun_status( 11

uint32_t channel_id) Table 6-3. Parameters [in] channel_id Event Channel ID 6.3.2 Function events_ch_clear_trigger_status() Clear the trigger status of an Event Channel. void events_ch_clear_trigger_status( uint32_t channel_id) Table 6-4. Parameters [in] channel_id Event Channel ID 6.3.3 Function events_ch_configure() Configure an Event Channel. void events_ch_configure( struct events_ch_conf *const config) Table 6-5. Parameters [in, out] config Configuration settings for the Event Channel 6.3.4 Function events_ch_disable() Disable an Event Channel. void events_ch_disable( uint32_t channel_id) Table 6-6. Parameters [in] channel_id Event Channel ID 6.3.5 Function events_ch_disable_software_trigger() Disable the software trigger for an Event Channel. void events_ch_disable_software_trigger( uint32_t channel_id) 12

Table 6-7. Parameters [in] channel_id Event Channel ID 6.3.6 Function events_ch_enable() Enable an Event Channel. void events_ch_enable( uint32_t channel_id) Table 6-8. Parameters [in] channel_id Event Channel ID 6.3.7 Function events_ch_enable_software_trigger() Enable the software trigger for an Event Channel. void events_ch_enable_software_trigger( uint32_t channel_id) Table 6-9. Parameters [in] channel_id Event Channel ID 6.3.8 Function events_ch_get_config_defaults() Initialize an event channel configuration structure to defaults. void events_ch_get_config_defaults( struct events_ch_conf *const config) 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 Table 6-10. Parameters [out] config Configuration structure to initialize to default values 13

6.3.9 Function events_ch_is_enabled() Get the status (enabled or disabled) of an Event Channel. bool events_ch_is_enabled( uint32_t channel_id) Table 6-11. Parameters [in] channel_id Event Channel ID Returns The Event Channel enabled/disabled status. Table 6-12. Return Values Return value true false Description Event Channel is enabled Event Channel is disabled 6.3.10 Function events_ch_is_overrun() Get the overrun status of an Event Channel. bool events_ch_is_overrun( uint32_t channel_id) Table 6-13. Parameters [in] channel_id Event Channel ID Returns The Event Channel overrun status. Table 6-14. Return Values Return value true false Description A channel overrun event has occurred A channel overrun event has not occurred 6.3.11 Function events_ch_is_ready() Get the busy status of an Event Channel. bool events_ch_is_ready( uint32_t channel_id) Table 6-15. Parameters [in] channel_id Event Channel ID 14

Returns The Event Channel busy status. Table 6-16. Return Values Return value true false Description If the Event Channel is ready to be used If the Event Channel is currently busy 6.3.12 Function events_ch_is_triggered() Get the trigger status of an Event Channel. bool events_ch_is_triggered( uint32_t channel_id) Table 6-17. Parameters [in] channel_id Event Channel ID Returns The Event Channel trigger status. Table 6-18. Return Values Return value true false Description A channel event has occurred A channel event has not occurred 6.3.13 Function events_ch_software_trigger() Trigger a Software Event for the corresponding Event Channel. void events_ch_software_trigger( uint32_t channel_id) Table 6-19. Parameters [in] channel_id Event Channel ID 6.3.14 Function events_disable() Disable the events module. void events_disable(void) 6.3.15 Function events_enable() 15

Enable the events module. void events_enable(void) 6.3.16 Function events_get_config_defaults() Initialize an events configuration structure to defaults. void events_get_config_defaults( struct events_conf *const config) The default configuration is as follows: Input Glitch Filter Divider is set to EVENT_IGF_DIVIDER_1024 on page 17 Table 6-20. Parameters [out] config Configuration structure to initialize to default values 6.3.17 Function events_init() Initialize the events module. void events_init( struct events_conf *const config) Table 6-21. Parameters [in] config Configuration structure to initialize to default values 6.3.18 Function events_set_igf_divider() Set the Input Glitch Filter Divider. void events_set_igf_divider( enum events_igf_divider divider) Table 6-22. Parameters [in] divider Input Glitch Filter divider Note As stated in the datasheet, there is one divider value for all Event Shaper (EVS) instances. 16

6.4 Enumeration Definitions 6.4.1 Enum events_igf_divider Enumerate for the possible division ratios of an Input Glitch Filter. Table 6-23. Members Enum value Description 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. 6.4.2 Enum events_igf_edge Table 6-24. Members Enum value EVENT_IGF_EDGE_NONE EVENT_IGF_EDGE_RISING EVENT_IGF_EDGE_FALLING EVENT_IGF_EDGE_BOTH Description Input Glitch Filter is disabled. Event detection through Input Glitch Filter on rising edge. Event detection through Input Glitch Filter on falling edge. Event detection through Input Glitch Filter on both edges. 17

7. Extra Information for Peripheral Event Controller Driver 7.1 Acronyms Below is a table listing the acronyms used in this module, along with their intended meanings. Acronym ADC AST EVS IGF PDCA Definition Analog to Digital Converter Asynchronous Timer Event Shaper Input Glitch Filter Peripheral DMA Controller 7.2 Dependencies This driver has the following dependencies: None 7.3 Errata There are no errata related to this driver. 7.4 Module History An overview of the module history is presented in the table below, with details on the enhancements and fixes made to the module since its first release. The current version of this corresponds to the newest version in the table. Changelog Initial document release 18

8. Examples for Peripheral Event Controller Driver This is a list of the available Quick Start Guides (QSGs) and example applications for SAM4L Peripheral Event Controller (PEVC). QSGs are simple examples with step-by-step instructions to configure and use this driver in a selection of use cases. Note that QSGs can be compiled as a standalone application or be added to the user application. Quick Start Guide for the Peripheral Event Controller Driver Example for the Peripheral Event System - AST/PDCA Example for the Peripheral Event System - GPIO/PDCA 8.1 Quick Start Guide for the Peripheral Event Controller Driver This is the quick start guide for the SAM4L Peripheral Event Controller (PEVC), with step-by-step instructions on how to configure and use the driver for a specific use case. The use cases contain several code fragments. The code fragments in the steps for setup can be copied into a custom initialization function, while the steps for usage can be copied into, e.g., the main application function. 8.1.1 Use Cases Basic Use Case 8.1.2 Basic Use Case This use case will demonstrate how to use the Peripheral Event Controller on SAM4L_EK. In this use case, one event channel is configured as: Configure AST periodic event 0 as a generator Configure PDCA channel 0 as a user to transfer one word Enable the event shaper for the generator 8.1.3 Setup Steps 8.1.3.1 Prerequisites This module requires the following service: clk_group 8.1.3.2 Code Example Copy-paste the following setup code to your application: static void init_events(void) { struct events_conf events_config; struct events_ch_conf ch_config; /* Initialize event module */ events_get_config_defaults(&events_config); events_init(&events_config); events_enable(); /* * Configure an event channel * - AST periodic event 0 --- Generator * - PDCA channel 0 --- User */ 19

events_ch_get_config_defaults(&ch_config); ch_config.channel_id = PEVC_ID_USER_PDCA_0; ch_config.generator_id = PEVC_ID_GEN_AST_2; ch_config.shaper_enable = true; ch_config.igf_edge = EVENT_IGF_EDGE_NONE; events_ch_configure(&ch_config); } /* Enable the channel */ events_ch_enable(pevc_id_user_pdca_0); Add this to the main loop or a setup function: /* Initialize AST as event generator. */ init_ast(); /* Initialise events for this example. */ init_events(); /* Initialize the PDCA as event user */ init_pdca(); 8.1.3.3 Workflow 1. Initialize AST to generate periodic event 0. see sam/drivers/events/example1 for more detail: init_ast(); 2. Initialize the event module and enable it: init_events(); 3. Initialize PDCA channel 0 to transfer data to USART. see sam/drivers/events/example1 for more detail: init_pdca(); 8.1.4 Basic Usage After the channel is configured correctly and enabled, each time a new event from AST occurs, a character is sent to the USART via PDCA without the use of the CPU. 8.2 Example for the Peripheral Event System - AST/PDCA 8.2.1 Introduction This example shows how to use the Peripheral Event Controller. In the example, the AST generates a periodic event which is transmitted to the PDCA. Each time a new event occurs, a character is sent to the USART without the use of the CPU. The main loop of the function is a delay 500ms and toggle a LED continuously to show CPU activity. 8.2.2 Main Files events.c: Events driver events.h: Events driver header file events_example1.c: Events example 1 application 20

8.2.3 Compilation Information This software is written for GNU GCC and IAR Embedded Workbench for Atmel. Other compilers may or may not work. 8.2.4 Device Information SAM4L device can be used. 8.2.5 Configuration Information This example has been tested with the following configuration: PC terminal settings: 115200 baud 8 data bits no parity bit 1 stop bit no flow control 8.3 Example for the Peripheral Event System - GPIO/PDCA 8.3.1 Introduction This example shows how to use the Peripheral Event Controller. In the example, an I/O pin is configured to trigger a GPIO event when detecting a falling edge. Each time a new event occurs, it will trigger the PDCA to send a character to the USART without CPU usage. 8.3.2 Main Files events.c: Events driver events.h: Events driver header file events_example2.c: Events example 2 application 8.3.3 Compilation Information This software is written for GNU GCC and IAR Embedded Workbench for Atmel. Other compilers may or may not work. 8.3.4 Device Information SAM4L device can be used. 8.3.5 Configuration Information This example has been tested with the following configuration: PC terminal settings: 115200 baud 8 data bits no parity bit 1 stop bit 21

no flow control 22

Index E Enumeration Definitions events_igf_divider, 17 events_igf_edge, 17 F Function Definitions events_ch_clear_overrun_status, 11 events_ch_clear_trigger_status, 12 events_ch_configure, 12 events_ch_disable, 12 events_ch_disable_software_trigger, 12 events_ch_enable, 13 events_ch_enable_software_trigger, 13 events_ch_get_config_defaults, 13 events_ch_is_enabled, 14 events_ch_is_overrun, 14 events_ch_is_ready, 14 events_ch_is_triggered, 15 events_ch_software_trigger, 15 events_disable, 15 events_enable, 15 events_get_config_defaults, 16 events_init, 16 events_set_igf_divider, 16 M Macro Definitions EVENT_CHANNEL_N, 11 EVENT_GENERATOR_N, 11 S Structure Definitions events_ch_conf, 11 events_conf, 11 23

Document Revision History Doc. Rev. Date Comments 42312A 05/2014 Initial document release 24

Atmel Corporation 1600 Technology Drive, San Jose, CA 95110 USA T: (+1)(408) 441.0311 F: (+1)(408) 436.4200 www.atmel.com 2014 Atmel Corporation. All rights reserved. / Rev.: Atmel, Atmel logo and combinations thereof, Enabling Unlimited Possibilities, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others. Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.