mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Child:
592:a274ee790e56
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

Full URL: https://github.com/mbedmicro/mbed/commit/d5b4d2ab9c47edb4dc5776e7177b0c2263459081/

Initial version of drivers for SAMR21

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 579:53297373a894 1 /**
mbed_official 579:53297373a894 2 * \file
mbed_official 579:53297373a894 3 *
mbed_official 579:53297373a894 4 * \brief SAM TC - Timer Counter Driver
mbed_official 579:53297373a894 5 *
mbed_official 579:53297373a894 6 * Copyright (C) 2013-2014 Atmel Corporation. All rights reserved.
mbed_official 579:53297373a894 7 *
mbed_official 579:53297373a894 8 * \asf_license_start
mbed_official 579:53297373a894 9 *
mbed_official 579:53297373a894 10 * \page License
mbed_official 579:53297373a894 11 *
mbed_official 579:53297373a894 12 * Redistribution and use in source and binary forms, with or without
mbed_official 579:53297373a894 13 * modification, are permitted provided that the following conditions are met:
mbed_official 579:53297373a894 14 *
mbed_official 579:53297373a894 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 579:53297373a894 16 * this list of conditions and the following disclaimer.
mbed_official 579:53297373a894 17 *
mbed_official 579:53297373a894 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 579:53297373a894 19 * this list of conditions and the following disclaimer in the documentation
mbed_official 579:53297373a894 20 * and/or other materials provided with the distribution.
mbed_official 579:53297373a894 21 *
mbed_official 579:53297373a894 22 * 3. The name of Atmel may not be used to endorse or promote products derived
mbed_official 579:53297373a894 23 * from this software without specific prior written permission.
mbed_official 579:53297373a894 24 *
mbed_official 579:53297373a894 25 * 4. This software may only be redistributed and used in connection with an
mbed_official 579:53297373a894 26 * Atmel microcontroller product.
mbed_official 579:53297373a894 27 *
mbed_official 579:53297373a894 28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
mbed_official 579:53297373a894 29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
mbed_official 579:53297373a894 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
mbed_official 579:53297373a894 31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
mbed_official 579:53297373a894 32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 579:53297373a894 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
mbed_official 579:53297373a894 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
mbed_official 579:53297373a894 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
mbed_official 579:53297373a894 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
mbed_official 579:53297373a894 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
mbed_official 579:53297373a894 38 * POSSIBILITY OF SUCH DAMAGE.
mbed_official 579:53297373a894 39 *
mbed_official 579:53297373a894 40 * \asf_license_stop
mbed_official 579:53297373a894 41 *
mbed_official 579:53297373a894 42 */
mbed_official 579:53297373a894 43 /**
mbed_official 579:53297373a894 44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
mbed_official 579:53297373a894 45 */
mbed_official 579:53297373a894 46
mbed_official 579:53297373a894 47 #ifndef TC_H_INCLUDED
mbed_official 579:53297373a894 48 #define TC_H_INCLUDED
mbed_official 579:53297373a894 49
mbed_official 579:53297373a894 50 /**
mbed_official 579:53297373a894 51 * \defgroup asfdoc_sam0_tc_group SAM Timer/Counter Driver (TC)
mbed_official 579:53297373a894 52 *
mbed_official 579:53297373a894 53 * This driver for Atmel庐 | SMART SAM devices provides an interface for the configuration
mbed_official 579:53297373a894 54 * and management of the timer modules within the device, for waveform
mbed_official 579:53297373a894 55 * generation and timing operations. The following driver API modes are covered
mbed_official 579:53297373a894 56 * by this manual:
mbed_official 579:53297373a894 57 *
mbed_official 579:53297373a894 58 * - Polled APIs
mbed_official 579:53297373a894 59 * \if TC_CALLBACK_MODE
mbed_official 579:53297373a894 60 * - Callback APIs
mbed_official 579:53297373a894 61 * \endif
mbed_official 579:53297373a894 62 *
mbed_official 579:53297373a894 63 *
mbed_official 579:53297373a894 64 * The following peripherals are used by this module:
mbed_official 579:53297373a894 65 * - TC (Timer/Counter)
mbed_official 579:53297373a894 66 *
mbed_official 579:53297373a894 67 * The following devices can use this module:
mbed_official 579:53297373a894 68 * - Atmel | SMART SAM D20/D21
mbed_official 579:53297373a894 69 * - Atmel | SMART SAM R21
mbed_official 579:53297373a894 70 * - Atmel | SMART SAM D10/D11
mbed_official 579:53297373a894 71 * - Atmel | SMART SAM L21
mbed_official 579:53297373a894 72 *
mbed_official 579:53297373a894 73 * The outline of this documentation is as follows:
mbed_official 579:53297373a894 74 * - \ref asfdoc_sam0_tc_prerequisites
mbed_official 579:53297373a894 75 * - \ref asfdoc_sam0_tc_module_overview
mbed_official 579:53297373a894 76 * - \ref asfdoc_sam0_tc_special_considerations
mbed_official 579:53297373a894 77 * - \ref asfdoc_sam0_tc_extra_info
mbed_official 579:53297373a894 78 * - \ref asfdoc_sam0_tc_examples
mbed_official 579:53297373a894 79 * - \ref asfdoc_sam0_tc_api_overview
mbed_official 579:53297373a894 80 *
mbed_official 579:53297373a894 81 *
mbed_official 579:53297373a894 82 * \section asfdoc_sam0_tc_prerequisites Prerequisites
mbed_official 579:53297373a894 83 *
mbed_official 579:53297373a894 84 * There are no prerequisites for this module.
mbed_official 579:53297373a894 85 *
mbed_official 579:53297373a894 86 *
mbed_official 579:53297373a894 87 * \section asfdoc_sam0_tc_module_overview Module Overview
mbed_official 579:53297373a894 88 *
mbed_official 579:53297373a894 89 * The Timer/Counter (TC) module provides a set of timing and counting related
mbed_official 579:53297373a894 90 * functionality, such as the generation of periodic waveforms, the capturing
mbed_official 579:53297373a894 91 * of a periodic waveform's frequency/duty cycle, and software timekeeping for
mbed_official 579:53297373a894 92 * periodic operations. TC modules can be configured to use an 8-, 16-, or
mbed_official 579:53297373a894 93 * 32-bit counter size.
mbed_official 579:53297373a894 94 *
mbed_official 579:53297373a894 95 * This TC module for the SAM is capable of the following functions:
mbed_official 579:53297373a894 96 *
mbed_official 579:53297373a894 97 * - Generation of PWM signals
mbed_official 579:53297373a894 98 * - Generation of timestamps for events
mbed_official 579:53297373a894 99 * - General time counting
mbed_official 579:53297373a894 100 * - Waveform period capture
mbed_official 579:53297373a894 101 * - Waveform frequency capture
mbed_official 579:53297373a894 102 *
mbed_official 579:53297373a894 103 * \ref asfdoc_sam0_tc_block_diagram "The diagram below" shows the overview
mbed_official 579:53297373a894 104 * of the TC module design.
mbed_official 579:53297373a894 105 *
mbed_official 579:53297373a894 106 * \anchor asfdoc_sam0_tc_block_diagram
mbed_official 579:53297373a894 107 * \image html overview.svg "Basic Overview of the TC Module"
mbed_official 579:53297373a894 108 *
mbed_official 579:53297373a894 109 *
mbed_official 579:53297373a894 110 * \subsection asfdoc_sam0_tc_features Driver Feature Macro Definition
mbed_official 579:53297373a894 111 * <table>
mbed_official 579:53297373a894 112 * <tr>
mbed_official 579:53297373a894 113 * <th>Driver Feature Macro</th>
mbed_official 579:53297373a894 114 * <th>Supported devices</th>
mbed_official 579:53297373a894 115 * </tr>
mbed_official 579:53297373a894 116 * <tr>
mbed_official 579:53297373a894 117 * <td>FEATURE_TC_DOUBLE_BUFFERED</td>
mbed_official 579:53297373a894 118 * <td>SAML21</td>
mbed_official 579:53297373a894 119 * </tr>
mbed_official 579:53297373a894 120 * <tr>
mbed_official 579:53297373a894 121 * <td>FEATURE_TC_SYNCBUSY_SCHEME_VERSION_2</td>
mbed_official 579:53297373a894 122 * <td>SAML21</td>
mbed_official 579:53297373a894 123 * </tr>
mbed_official 579:53297373a894 124 * <tr>
mbed_official 579:53297373a894 125 * <td>FEATURE_TC_STAMP_PW_CAPTURE</td>
mbed_official 579:53297373a894 126 * <td>SAML21</td>
mbed_official 579:53297373a894 127 * </tr>
mbed_official 579:53297373a894 128 * <tr>
mbed_official 579:53297373a894 129 * <td>FEATURE_TC_READ_SYNC</td>
mbed_official 579:53297373a894 130 * <td>SAML21</td>
mbed_official 579:53297373a894 131 * </tr>
mbed_official 579:53297373a894 132 * <tr>
mbed_official 579:53297373a894 133 * <td>FEATURE_TC_IO_CAPTURE</td>
mbed_official 579:53297373a894 134 * <td>SAML21</td>
mbed_official 579:53297373a894 135 * </tr>
mbed_official 579:53297373a894 136 * </table>
mbed_official 579:53297373a894 137 * \note The specific features are only available in the driver when the
mbed_official 579:53297373a894 138 * selected device supports those features.
mbed_official 579:53297373a894 139 *
mbed_official 579:53297373a894 140 * \subsection asfdoc_sam0_tc_module_overview_func_desc Functional Description
mbed_official 579:53297373a894 141 * Independent of the configured counter size, each TC module can be set up
mbed_official 579:53297373a894 142 * in one of two different modes; capture and compare.
mbed_official 579:53297373a894 143 *
mbed_official 579:53297373a894 144 * In capture mode, the counter value is stored when a configurable event
mbed_official 579:53297373a894 145 * occurs. This mode can be used to generate timestamps used in event capture,
mbed_official 579:53297373a894 146 * or it can be used for the measurement of a periodic input signal's
mbed_official 579:53297373a894 147 * frequency/duty cycle.
mbed_official 579:53297373a894 148 *
mbed_official 579:53297373a894 149 * In compare mode, the counter value is compared against one or more of the
mbed_official 579:53297373a894 150 * configured channel compare values. When the counter value coincides with a
mbed_official 579:53297373a894 151 * compare value an action can be taken automatically by the module, such as
mbed_official 579:53297373a894 152 * generating an output event or toggling a pin when used for frequency or PWM
mbed_official 579:53297373a894 153 * signal generation.
mbed_official 579:53297373a894 154 *
mbed_official 579:53297373a894 155 * \note The connection of events between modules requires the use of the
mbed_official 579:53297373a894 156 * \ref asfdoc_sam0_events_group "SAM Event System Driver (EVENTS)"
mbed_official 579:53297373a894 157 * to route output event of one module to the the input event of another.
mbed_official 579:53297373a894 158 * For more information on event routing, refer to the event driver
mbed_official 579:53297373a894 159 * documentation.
mbed_official 579:53297373a894 160 *
mbed_official 579:53297373a894 161 * \subsection asfdoc_sam0_tc_module_overview_tc_size Timer/Counter Size
mbed_official 579:53297373a894 162 * Each timer module can be configured in one of three different counter
mbed_official 579:53297373a894 163 * sizes; 8-, 16-, and 32-bit. The size of the counter determines the maximum
mbed_official 579:53297373a894 164 * value it can count to before an overflow occurs and the count is reset back
mbed_official 579:53297373a894 165 * to zero. \ref asfdoc_sam0_tc_count_size_vs_top "The table below" shows the
mbed_official 579:53297373a894 166 * maximum values for each of the possible counter sizes.
mbed_official 579:53297373a894 167 *
mbed_official 579:53297373a894 168 * \anchor asfdoc_sam0_tc_count_size_vs_top
mbed_official 579:53297373a894 169 * <table>
mbed_official 579:53297373a894 170 * <caption>Timer Counter Sizes and Their Maximum Count Values</caption>
mbed_official 579:53297373a894 171 * <tr>
mbed_official 579:53297373a894 172 * <th>Counter size</th>
mbed_official 579:53297373a894 173 * <th>Max. (hexadecimal)</th>
mbed_official 579:53297373a894 174 * <th>Max. (decimal)</th>
mbed_official 579:53297373a894 175 * </tr>
mbed_official 579:53297373a894 176 * <tr>
mbed_official 579:53297373a894 177 * <td>8-bit</td>
mbed_official 579:53297373a894 178 * <td>0xFF</td>
mbed_official 579:53297373a894 179 * <td>255</td>
mbed_official 579:53297373a894 180 * </tr>
mbed_official 579:53297373a894 181 * <tr>
mbed_official 579:53297373a894 182 * <td>16-bit</td>
mbed_official 579:53297373a894 183 * <td>0xFFFF</td>
mbed_official 579:53297373a894 184 * <td>65,535</td>
mbed_official 579:53297373a894 185 * </tr>
mbed_official 579:53297373a894 186 * <tr>
mbed_official 579:53297373a894 187 * <td>32-bit</td>
mbed_official 579:53297373a894 188 * <td>0xFFFFFFFF</td>
mbed_official 579:53297373a894 189 * <td>4,294,967,295</td>
mbed_official 579:53297373a894 190 * </tr>
mbed_official 579:53297373a894 191 * </table>
mbed_official 579:53297373a894 192 *
mbed_official 579:53297373a894 193 * When using the counter in 16- or 32-bit count mode, Compare Capture
mbed_official 579:53297373a894 194 * register 0 (CC0) is used to store the period value when running in PWM
mbed_official 579:53297373a894 195 * generation match mode.
mbed_official 579:53297373a894 196 *
mbed_official 579:53297373a894 197 * When using 32-bit counter size, two 16-bit counters are chained together
mbed_official 579:53297373a894 198 * in a cascade formation. Except in SAM D10/D11, Even numbered TC modules
mbed_official 579:53297373a894 199 * (e.g. TC0, TC2) can be configured as 32-bit counters. The odd numbered
mbed_official 579:53297373a894 200 * counters will act as slaves to the even numbered masters, and will not
mbed_official 579:53297373a894 201 * be reconfigurable until the master timer is disabled. The pairing of timer
mbed_official 579:53297373a894 202 * modules for 32-bit mode is shown in \ref asfdoc_sam0_tc_module_ms_pairs
mbed_official 579:53297373a894 203 * "the table below".
mbed_official 579:53297373a894 204 *
mbed_official 579:53297373a894 205 * \anchor asfdoc_sam0_tc_module_ms_pairs
mbed_official 579:53297373a894 206 * <table>
mbed_official 579:53297373a894 207 * <caption>TC Master and Slave Module Pairings</caption>
mbed_official 579:53297373a894 208 * <tr>
mbed_official 579:53297373a894 209 * <th>Master TC Module</th>
mbed_official 579:53297373a894 210 * <th>Slave TC Module</th>
mbed_official 579:53297373a894 211 * </tr>
mbed_official 579:53297373a894 212 * <tr>
mbed_official 579:53297373a894 213 * <td>TC0</td>
mbed_official 579:53297373a894 214 * <td>TC1</td>
mbed_official 579:53297373a894 215 * </tr>
mbed_official 579:53297373a894 216 * <tr>
mbed_official 579:53297373a894 217 * <td>TC2</td>
mbed_official 579:53297373a894 218 * <td>TC3</td>
mbed_official 579:53297373a894 219 * </tr>
mbed_official 579:53297373a894 220 * <tr>
mbed_official 579:53297373a894 221 * <td>...</td>
mbed_official 579:53297373a894 222 * <td>...</td>
mbed_official 579:53297373a894 223 * </tr>
mbed_official 579:53297373a894 224 * <tr>
mbed_official 579:53297373a894 225 * <td>TCn-1</td>
mbed_official 579:53297373a894 226 * <td>TCn</td>
mbed_official 579:53297373a894 227 * </tr>
mbed_official 579:53297373a894 228 * </table>
mbed_official 579:53297373a894 229 *
mbed_official 579:53297373a894 230 * In SAMD10/D11, odd numbered TC modules (e.g. TC1) can be configured as 32-bit
mbed_official 579:53297373a894 231 * counters. The even numbered(e.g. TC2) counters will act as slaves to the odd
mbed_official 579:53297373a894 232 * numbered masters.
mbed_official 579:53297373a894 233 *
mbed_official 579:53297373a894 234 * \subsection asfdoc_sam0_tc_module_overview_clock Clock Settings
mbed_official 579:53297373a894 235 *
mbed_official 579:53297373a894 236 * \subsubsection asfdoc_sam0_tc_module_overview_clock_selection Clock Selection
mbed_official 579:53297373a894 237 * Each TC peripheral is clocked asynchronously to the system clock by a GCLK
mbed_official 579:53297373a894 238 * (Generic Clock) channel. The GCLK channel connects to any of the GCLK
mbed_official 579:53297373a894 239 * generators. The GCLK generators are configured to use one of the available
mbed_official 579:53297373a894 240 * clock sources on the system such as internal oscillator, external crystals,
mbed_official 579:53297373a894 241 * etc. see the \ref asfdoc_sam0_system_clock_group "Generic Clock driver"
mbed_official 579:53297373a894 242 *for
mbed_official 579:53297373a894 243 * more information.
mbed_official 579:53297373a894 244 *
mbed_official 579:53297373a894 245 * \subsubsection asfdoc_sam0_tc_module_overview_clock_prescaler Prescaler
mbed_official 579:53297373a894 246 * Each TC module in the SAM has its own individual clock prescaler, which
mbed_official 579:53297373a894 247 * can be used to divide the input clock frequency used in the counter. This
mbed_official 579:53297373a894 248 * prescaler only scales the clock used to provide clock pulses for the counter
mbed_official 579:53297373a894 249 * to count, and does not affect the digital register interface portion of
mbed_official 579:53297373a894 250 * the module, thus the timer registers will synchronize to the raw GCLK
mbed_official 579:53297373a894 251 * frequency input to the module.
mbed_official 579:53297373a894 252 *
mbed_official 579:53297373a894 253 * As a result of this, when selecting a GCLK frequency and timer prescaler
mbed_official 579:53297373a894 254 * value the user application should consider both the timer resolution
mbed_official 579:53297373a894 255 * required and the synchronization frequency, to avoid lengthy
mbed_official 579:53297373a894 256 * synchronization times of the module if a very slow GCLK frequency is fed
mbed_official 579:53297373a894 257 * into the TC module. It is preferable to use a higher module GCLK frequency
mbed_official 579:53297373a894 258 * as the input to the timer, and prescale this down as much as possible to
mbed_official 579:53297373a894 259 * obtain a suitable counter frequency in latency-sensitive applications.
mbed_official 579:53297373a894 260 *
mbed_official 579:53297373a894 261 * \subsubsection asfdoc_sam0_tc_module_overview_clock_reloading Reloading
mbed_official 579:53297373a894 262 * Timer modules also contain a configurable reload action, used when a
mbed_official 579:53297373a894 263 * re-trigger event occurs. Examples of a re-trigger event are the counter
mbed_official 579:53297373a894 264 * reaching the maximum value when counting up, or when an event from the event
mbed_official 579:53297373a894 265 * system tells the counter to re-trigger. The reload action determines if the
mbed_official 579:53297373a894 266 * prescaler should be reset, and when this should happen. The counter will
mbed_official 579:53297373a894 267 * always be reloaded with the value it is set to start counting from. The user
mbed_official 579:53297373a894 268 * can choose between three different reload actions, described in
mbed_official 579:53297373a894 269 * \ref asfdoc_sam0_tc_module_reload_act "the table below".
mbed_official 579:53297373a894 270 *
mbed_official 579:53297373a894 271 * \anchor asfdoc_sam0_tc_module_reload_act
mbed_official 579:53297373a894 272 * <table>
mbed_official 579:53297373a894 273 * <caption>TC Module Reload Actions</caption>
mbed_official 579:53297373a894 274 * <tr>
mbed_official 579:53297373a894 275 * <th>Reload action</th>
mbed_official 579:53297373a894 276 * <th>Description</th>
mbed_official 579:53297373a894 277 * </tr>
mbed_official 579:53297373a894 278 * <tr>
mbed_official 579:53297373a894 279 * <td>\ref TC_RELOAD_ACTION_GCLK </td>
mbed_official 579:53297373a894 280 * <td>Reload TC counter value on next GCLK cycle. Leave prescaler
mbed_official 579:53297373a894 281 * as-is.</td>
mbed_official 579:53297373a894 282 * </tr>
mbed_official 579:53297373a894 283 * <tr>
mbed_official 579:53297373a894 284 * <td>\ref TC_RELOAD_ACTION_PRESC </td>
mbed_official 579:53297373a894 285 * <td>Reloads TC counter value on next prescaler clock. Leave prescaler
mbed_official 579:53297373a894 286 * as-is.</td>
mbed_official 579:53297373a894 287 * </tr>
mbed_official 579:53297373a894 288 * <tr>
mbed_official 579:53297373a894 289 * <td> \ref TC_RELOAD_ACTION_RESYNC </td>
mbed_official 579:53297373a894 290 * <td>Reload TC counter value on next GCLK cycle. Clear prescaler to
mbed_official 579:53297373a894 291 * zero.</td>
mbed_official 579:53297373a894 292 * </tr>
mbed_official 579:53297373a894 293 * </table>
mbed_official 579:53297373a894 294 *
mbed_official 579:53297373a894 295 * The reload action to use will depend on the specific application being
mbed_official 579:53297373a894 296 * implemented. One example is when an external trigger for a reload occurs; if
mbed_official 579:53297373a894 297 * the TC uses the prescaler, the counter in the prescaler should not have a
mbed_official 579:53297373a894 298 * value between zero and the division factor. The TC counter and the counter
mbed_official 579:53297373a894 299 * in the prescaler should both start at zero. When the counter is set to
mbed_official 579:53297373a894 300 * re-trigger when it reaches the maximum value on the other hand, this is not the
mbed_official 579:53297373a894 301 * right option to use. In such a case it would be better if the prescaler is
mbed_official 579:53297373a894 302 * left unaltered when the re-trigger happens, letting the counter reset on the
mbed_official 579:53297373a894 303 * next GCLK cycle.
mbed_official 579:53297373a894 304 *
mbed_official 579:53297373a894 305 * \subsection asfdoc_sam0_tc_module_overview_compare_match Compare Match Operations
mbed_official 579:53297373a894 306 * In compare match operation, Compare/Capture registers are used in comparison
mbed_official 579:53297373a894 307 * with the counter value. When the timer's count value matches the value of a
mbed_official 579:53297373a894 308 * compare channel, a user defined action can be taken.
mbed_official 579:53297373a894 309 *
mbed_official 579:53297373a894 310 * \subsubsection asfdoc_sam0_tc_module_overview_compare_match_timer Basic Timer
mbed_official 579:53297373a894 311 *
mbed_official 579:53297373a894 312 * A Basic Timer is a simple application where compare match operations is used
mbed_official 579:53297373a894 313 * to determine when a specific period has elapsed. In Basic Timer operations,
mbed_official 579:53297373a894 314 * one or more values in the module's Compare/Capture registers are used to
mbed_official 579:53297373a894 315 * specify the time (as a number of prescaled GCLK cycles) when an action should
mbed_official 579:53297373a894 316 * be taken by the microcontroller. This can be an Interrupt Service Routine
mbed_official 579:53297373a894 317 * (ISR), event generator via the event system, or a software flag that is
mbed_official 579:53297373a894 318 * polled via the user application.
mbed_official 579:53297373a894 319 *
mbed_official 579:53297373a894 320 * \subsubsection asfdoc_sam0_tc_module_overview_compare_match_wg Waveform Generation
mbed_official 579:53297373a894 321 *
mbed_official 579:53297373a894 322 * Waveform generation enables the TC module to generate square waves, or if
mbed_official 579:53297373a894 323 * combined with an external passive low-pass filter; analog waveforms.
mbed_official 579:53297373a894 324 *
mbed_official 579:53297373a894 325 * \subsubsection asfdoc_sam0_tc_module_overview_compare_match_wg_pwm Waveform Generation - PWM
mbed_official 579:53297373a894 326 *
mbed_official 579:53297373a894 327 * Pulse width modulation is a form of waveform generation and a signalling
mbed_official 579:53297373a894 328 * technique that can be useful in many situations. When PWM mode is used,
mbed_official 579:53297373a894 329 * a digital pulse train with a configurable frequency and duty cycle can be
mbed_official 579:53297373a894 330 * generated by the TC module and output to a GPIO pin of the device.
mbed_official 579:53297373a894 331 *
mbed_official 579:53297373a894 332 * Often PWM is used to communicate a control or information parameter to an
mbed_official 579:53297373a894 333 * external circuit or component. Differing impedances of the source generator
mbed_official 579:53297373a894 334 * and sink receiver circuits is less of an issue when using PWM compared to
mbed_official 579:53297373a894 335 * using an analog voltage value, as noise will not generally affect the
mbed_official 579:53297373a894 336 * signal's integrity to a meaningful extent.
mbed_official 579:53297373a894 337 *
mbed_official 579:53297373a894 338 * \ref asfdoc_sam0_tc_module_pwm_normal_diag "The figure below" illustrates
mbed_official 579:53297373a894 339 * operations and different states of the counter and its output when running
mbed_official 579:53297373a894 340 * the counter in PWM normal mode. As can be seen, the TOP value is unchanged
mbed_official 579:53297373a894 341 * and is set to MAX. The compare match value is changed at several points to
mbed_official 579:53297373a894 342 * illustrate the resulting waveform output changes. The PWM output is set to
mbed_official 579:53297373a894 343 * normal (i.e. non-inverted) output mode.
mbed_official 579:53297373a894 344 *
mbed_official 579:53297373a894 345 * \anchor asfdoc_sam0_tc_module_pwm_normal_diag
mbed_official 579:53297373a894 346 * \image html pwm_normal_ex.svg "Example of PWM in Normal Mode, and Different Counter Operations"
mbed_official 579:53297373a894 347 *
mbed_official 579:53297373a894 348 *
mbed_official 579:53297373a894 349 * In \ref asfdoc_sam0_tc_module_pwm_match_diag "the figure below", the
mbed_official 579:53297373a894 350 * counter is set to generate PWM in Match mode. The PWM output is inverted via
mbed_official 579:53297373a894 351 * the appropriate configuration option in the TC driver configuration
mbed_official 579:53297373a894 352 * structure. In this example, the counter value is changed once, but the
mbed_official 579:53297373a894 353 * compare match value is kept unchanged. As can be seen, it is possible to
mbed_official 579:53297373a894 354 * change the TOP value when running in PWM match mode.
mbed_official 579:53297373a894 355 *
mbed_official 579:53297373a894 356 * \anchor asfdoc_sam0_tc_module_pwm_match_diag
mbed_official 579:53297373a894 357 * \image html pwm_match_ex.svg "Example of PWM in Match Mode, and Different Counter Operations"
mbed_official 579:53297373a894 358 *
mbed_official 579:53297373a894 359 * \subsubsection asfdoc_sam0_tc_module_overview_compare_match_wg_freq Waveform Generation - Frequency
mbed_official 579:53297373a894 360 *
mbed_official 579:53297373a894 361 * Frequency Generation mode is in many ways identical to PWM
mbed_official 579:53297373a894 362 * generation. However, in Frequency Generation a toggle only occurs
mbed_official 579:53297373a894 363 * on the output when a match on a capture channels occurs. When the
mbed_official 579:53297373a894 364 * match is made, the timer value is reset, resulting in a variable
mbed_official 579:53297373a894 365 * frequency square wave with a fixed 50% duty cycle.
mbed_official 579:53297373a894 366 *
mbed_official 579:53297373a894 367 * \subsubsection asfdoc_sam0_tc_module_overview_compare_match_capt Capture Operations
mbed_official 579:53297373a894 368 *
mbed_official 579:53297373a894 369 * In capture operations, any event from the event system or a pin change can
mbed_official 579:53297373a894 370 * trigger a capture of the counter value. This captured counter value can be
mbed_official 579:53297373a894 371 * used as a timestamp for the event, or it can be used in frequency and pulse
mbed_official 579:53297373a894 372 * width capture.
mbed_official 579:53297373a894 373 *
mbed_official 579:53297373a894 374 * \subsubsection asfdoc_sam0_tc_module_overview_compare_match_capt_event_capture Capture Operations - Event
mbed_official 579:53297373a894 375 *
mbed_official 579:53297373a894 376 * Event capture is a simple use of the capture functionality,
mbed_official 579:53297373a894 377 * designed to create timestamps for specific events. When the TC
mbed_official 579:53297373a894 378 * module's input capture pin is externally toggled, the current timer
mbed_official 579:53297373a894 379 * count value is copied into a buffered register which can then be
mbed_official 579:53297373a894 380 * read out by the user application.
mbed_official 579:53297373a894 381 *
mbed_official 579:53297373a894 382 * Note that when performing any capture operation, there is a risk that the
mbed_official 579:53297373a894 383 * counter reaches its top value (MAX) when counting up, or the bottom value
mbed_official 579:53297373a894 384 * (zero) when counting down, before the capture event occurs. This can distort
mbed_official 579:53297373a894 385 * the result, making event timestamps to appear shorter than reality; the
mbed_official 579:53297373a894 386 * user application should check for timer overflow when reading a capture
mbed_official 579:53297373a894 387 * result in order to detect this situation and perform an appropriate
mbed_official 579:53297373a894 388 * adjustment.
mbed_official 579:53297373a894 389 *
mbed_official 579:53297373a894 390 * Before checking for a new capture, \ref TC_STATUS_COUNT_OVERFLOW
mbed_official 579:53297373a894 391 * should be checked. The response to an overflow error is left to the user
mbed_official 579:53297373a894 392 * application, however it may be necessary to clear both the capture overflow
mbed_official 579:53297373a894 393 * flag and the capture flag upon each capture reading.
mbed_official 579:53297373a894 394 *
mbed_official 579:53297373a894 395 * \subsubsection asfdoc_sam0_tc_module_overview_compare_match_capt_pwc Capture Operations - Pulse Width
mbed_official 579:53297373a894 396 *
mbed_official 579:53297373a894 397 * Pulse Width Capture mode makes it possible to measure the pulse width and
mbed_official 579:53297373a894 398 * period of PWM signals. This mode uses two capture channels of the counter.
mbed_official 579:53297373a894 399 * This means that the counter module used for Pulse Width Capture can not be
mbed_official 579:53297373a894 400 * used for any other purpose. There are two modes for pulse width capture;
mbed_official 579:53297373a894 401 * Pulse Width Period (PWP) and Period Pulse Width (PPW). In PWP mode, capture
mbed_official 579:53297373a894 402 * channel 0 is used for storing the pulse width and capture channel 1 stores
mbed_official 579:53297373a894 403 * the observed period. While in PPW mode, the roles of the two capture channels
mbed_official 579:53297373a894 404 * is reversed.
mbed_official 579:53297373a894 405 *
mbed_official 579:53297373a894 406 * As in the above example it is necessary to poll on interrupt flags to see
mbed_official 579:53297373a894 407 * if a new capture has happened and check that a capture overflow error has
mbed_official 579:53297373a894 408 * not occurred.
mbed_official 579:53297373a894 409 *
mbed_official 579:53297373a894 410 * \subsection asfdoc_sam0_tc_module_overview_oneshot One-shot Mode
mbed_official 579:53297373a894 411 *
mbed_official 579:53297373a894 412 * TC modules can be configured into a one-shot mode. When configured in this
mbed_official 579:53297373a894 413 * manner, starting the timer will cause it to count until the next overflow
mbed_official 579:53297373a894 414 * or underflow condition before automatically halting, waiting to be manually
mbed_official 579:53297373a894 415 * triggered by the user application software or an event signal from the event
mbed_official 579:53297373a894 416 * system.
mbed_official 579:53297373a894 417 *
mbed_official 579:53297373a894 418 * \subsubsection asfdoc_sam0_tc_module_overview_inversion Wave Generation Output Inversion
mbed_official 579:53297373a894 419 *
mbed_official 579:53297373a894 420 * The output of the wave generation can be inverted by hardware if desired,
mbed_official 579:53297373a894 421 * resulting in the logically inverted value being output to the configured
mbed_official 579:53297373a894 422 * device GPIO pin.
mbed_official 579:53297373a894 423 *
mbed_official 579:53297373a894 424 *
mbed_official 579:53297373a894 425 * \section asfdoc_sam0_tc_special_considerations Special Considerations
mbed_official 579:53297373a894 426 *
mbed_official 579:53297373a894 427 * The number of capture compare registers in each TC module is dependent on
mbed_official 579:53297373a894 428 * the specific SAM device being used, and in some cases the counter size.
mbed_official 579:53297373a894 429 *
mbed_official 579:53297373a894 430 * The maximum amount of capture compare registers available in any SAM
mbed_official 579:53297373a894 431 * device is two when running in 32-bit mode and four in 8- and 16-bit modes.
mbed_official 579:53297373a894 432 *
mbed_official 579:53297373a894 433 *
mbed_official 579:53297373a894 434 * \section asfdoc_sam0_tc_extra_info Extra Information
mbed_official 579:53297373a894 435 *
mbed_official 579:53297373a894 436 * For extra information, see \ref asfdoc_sam0_tc_extra. This includes:
mbed_official 579:53297373a894 437 * - \ref asfdoc_sam0_tc_extra_acronyms
mbed_official 579:53297373a894 438 * - \ref asfdoc_sam0_tc_extra_dependencies
mbed_official 579:53297373a894 439 * - \ref asfdoc_sam0_tc_extra_errata
mbed_official 579:53297373a894 440 * - \ref asfdoc_sam0_tc_extra_history
mbed_official 579:53297373a894 441 *
mbed_official 579:53297373a894 442 *
mbed_official 579:53297373a894 443 * \section asfdoc_sam0_tc_examples Examples
mbed_official 579:53297373a894 444 *
mbed_official 579:53297373a894 445 * For a list of examples related to this driver, see
mbed_official 579:53297373a894 446 * \ref asfdoc_sam0_tc_exqsg.
mbed_official 579:53297373a894 447 *
mbed_official 579:53297373a894 448 * \section asfdoc_sam0_tc_api_overview API Overview
mbed_official 579:53297373a894 449 * @{
mbed_official 579:53297373a894 450 */
mbed_official 579:53297373a894 451
mbed_official 579:53297373a894 452 #include <compiler.h>
mbed_official 579:53297373a894 453 #include <clock.h>
mbed_official 579:53297373a894 454 #include <gclk.h>
mbed_official 579:53297373a894 455 #include <pinmux.h>
mbed_official 579:53297373a894 456
mbed_official 579:53297373a894 457 /**
mbed_official 579:53297373a894 458 * Define port features set according to different device family
mbed_official 579:53297373a894 459 * @{
mbed_official 579:53297373a894 460 */
mbed_official 579:53297373a894 461 #if (SAML21) || defined(__DOXYGEN__)
mbed_official 579:53297373a894 462 /** TC double buffered */
mbed_official 579:53297373a894 463 # define FEATURE_TC_DOUBLE_BUFFERED
mbed_official 579:53297373a894 464 /** SYNCBUSY scheme version 2 */
mbed_official 579:53297373a894 465 # define FEATURE_TC_SYNCBUSY_SCHEME_VERSION_2
mbed_official 579:53297373a894 466 /** TC time stamp capture and pulse width capture */
mbed_official 579:53297373a894 467 # define FEATURE_TC_STAMP_PW_CAPTURE
mbed_official 579:53297373a894 468 /** Read synchronization of COUNT*/
mbed_official 579:53297373a894 469 # define FEATURE_TC_READ_SYNC
mbed_official 579:53297373a894 470 /** IO pin edge capture*/
mbed_official 579:53297373a894 471 # define FEATURE_TC_IO_CAPTURE
mbed_official 579:53297373a894 472 #endif
mbed_official 579:53297373a894 473 /*@}*/
mbed_official 579:53297373a894 474
mbed_official 579:53297373a894 475 #if !defined(__DOXYGEN__)
mbed_official 579:53297373a894 476 #if SAMD20 || SAML21
mbed_official 579:53297373a894 477 # define TC_INSTANCE_OFFSET 0
mbed_official 579:53297373a894 478 #endif
mbed_official 579:53297373a894 479 #if defined(SAMD21) || defined(SAMR21)
mbed_official 579:53297373a894 480 //#if SAMD21 || SAMR21
mbed_official 579:53297373a894 481 # define TC_INSTANCE_OFFSET 3
mbed_official 579:53297373a894 482 #endif
mbed_official 579:53297373a894 483 #if SAMD10 || SAMD11
mbed_official 579:53297373a894 484 # define TC_INSTANCE_OFFSET 1
mbed_official 579:53297373a894 485 #endif
mbed_official 579:53297373a894 486
mbed_official 579:53297373a894 487 #if SAMD20
mbed_official 579:53297373a894 488 # define NUMBER_OF_COMPARE_CAPTURE_CHANNELS TC0_CC8_NUM
mbed_official 579:53297373a894 489 #elif SAML21
mbed_official 579:53297373a894 490 # define NUMBER_OF_COMPARE_CAPTURE_CHANNELS TC0_CC_NUM
mbed_official 579:53297373a894 491 #elif SAMD10 || SAMD11
mbed_official 579:53297373a894 492 # define NUMBER_OF_COMPARE_CAPTURE_CHANNELS TC1_CC8_NUM
mbed_official 579:53297373a894 493 #else
mbed_official 579:53297373a894 494 # define NUMBER_OF_COMPARE_CAPTURE_CHANNELS TC3_CC8_NUM
mbed_official 579:53297373a894 495 /* Same number for 8-, 16- and 32-bit TC and all TC instances */
mbed_official 579:53297373a894 496 #endif
mbed_official 579:53297373a894 497
mbed_official 579:53297373a894 498 /** TC Instance MAX ID Number. */
mbed_official 579:53297373a894 499 #if SAMD20E || SAMD21G || SAMD21E || SAMR21
mbed_official 579:53297373a894 500 #define TC_INST_MAX_ID 5
mbed_official 579:53297373a894 501 #elif SAML21
mbed_official 579:53297373a894 502 #define TC_INST_MAX_ID 4
mbed_official 579:53297373a894 503 #elif SAMD10 || SAMD11
mbed_official 579:53297373a894 504 #define TC_INST_MAX_ID 2
mbed_official 579:53297373a894 505 #else
mbed_official 579:53297373a894 506 #define TC_INST_MAX_ID 7
mbed_official 579:53297373a894 507 #endif
mbed_official 579:53297373a894 508
mbed_official 579:53297373a894 509 #endif
mbed_official 579:53297373a894 510
mbed_official 579:53297373a894 511 //#if TC_ASYNC == true // TEMP: Commented by V
mbed_official 579:53297373a894 512 # include <system_interrupt.h>
mbed_official 579:53297373a894 513 //#endif
mbed_official 579:53297373a894 514
mbed_official 579:53297373a894 515 #ifdef __cplusplus
mbed_official 579:53297373a894 516 extern "C" {
mbed_official 579:53297373a894 517 #endif
mbed_official 579:53297373a894 518
mbed_official 579:53297373a894 519 //#if TC_ASYNC == true // TEMP: Commented by V
mbed_official 579:53297373a894 520 /** Enum for the possible callback types for the TC module. */
mbed_official 579:53297373a894 521 enum tc_callback {
mbed_official 579:53297373a894 522 /** Callback for TC overflow. */
mbed_official 579:53297373a894 523 TC_CALLBACK_OVERFLOW,
mbed_official 579:53297373a894 524 /** Callback for capture overflow error. */
mbed_official 579:53297373a894 525 TC_CALLBACK_ERROR,
mbed_official 579:53297373a894 526 /** Callback for capture compare channel 0. */
mbed_official 579:53297373a894 527 TC_CALLBACK_CC_CHANNEL0,
mbed_official 579:53297373a894 528 /** Callback for capture compare channel 1. */
mbed_official 579:53297373a894 529 TC_CALLBACK_CC_CHANNEL1,
mbed_official 579:53297373a894 530 # if !defined(__DOXYGEN__)
mbed_official 579:53297373a894 531 /** Number of available callbacks. */
mbed_official 579:53297373a894 532 TC_CALLBACK_N,
mbed_official 579:53297373a894 533 # endif
mbed_official 579:53297373a894 534 };
mbed_official 579:53297373a894 535 //#endif
mbed_official 579:53297373a894 536
mbed_official 579:53297373a894 537 /**
mbed_official 579:53297373a894 538 * \name Module Status Flags
mbed_official 579:53297373a894 539 *
mbed_official 579:53297373a894 540 * TC status flags, returned by \ref tc_get_status() and cleared by
mbed_official 579:53297373a894 541 * \ref tc_clear_status().
mbed_official 579:53297373a894 542 *
mbed_official 579:53297373a894 543 * @{
mbed_official 579:53297373a894 544 */
mbed_official 579:53297373a894 545
mbed_official 579:53297373a894 546 /** Timer channel 0 has matched against its compare value, or has captured a
mbed_official 579:53297373a894 547 * new value.
mbed_official 579:53297373a894 548 */
mbed_official 579:53297373a894 549 #define TC_STATUS_CHANNEL_0_MATCH (1UL << 0)
mbed_official 579:53297373a894 550
mbed_official 579:53297373a894 551 /** Timer channel 1 has matched against its compare value, or has captured a
mbed_official 579:53297373a894 552 * new value.
mbed_official 579:53297373a894 553 */
mbed_official 579:53297373a894 554 #define TC_STATUS_CHANNEL_1_MATCH (1UL << 1)
mbed_official 579:53297373a894 555
mbed_official 579:53297373a894 556 /** Timer register synchronization has completed, and the synchronized count
mbed_official 579:53297373a894 557 * value may be read.
mbed_official 579:53297373a894 558 */
mbed_official 579:53297373a894 559 #define TC_STATUS_SYNC_READY (1UL << 2)
mbed_official 579:53297373a894 560
mbed_official 579:53297373a894 561 /** A new value was captured before the previous value was read, resulting in
mbed_official 579:53297373a894 562 * lost data.
mbed_official 579:53297373a894 563 */
mbed_official 579:53297373a894 564 #define TC_STATUS_CAPTURE_OVERFLOW (1UL << 3)
mbed_official 579:53297373a894 565
mbed_official 579:53297373a894 566 /** The timer count value has overflowed from its maximum value to its minimum
mbed_official 579:53297373a894 567 * when counting upward, or from its minimum value to its maximum when
mbed_official 579:53297373a894 568 * counting downward.
mbed_official 579:53297373a894 569 */
mbed_official 579:53297373a894 570 #define TC_STATUS_COUNT_OVERFLOW (1UL << 4)
mbed_official 579:53297373a894 571
mbed_official 579:53297373a894 572 #ifdef FEATURE_TC_DOUBLE_BUFFERED
mbed_official 579:53297373a894 573 /** Channel 0 compare or capture buffer valid. */
mbed_official 579:53297373a894 574 #define TC_STATUS_CHN0_BUFFER_VALID (1UL << 5)
mbed_official 579:53297373a894 575 /** Channel 1 compare or capture buffer valid. */
mbed_official 579:53297373a894 576 #define TC_STATUS_CHN1_BUFFER_VALID (1UL << 6)
mbed_official 579:53297373a894 577 /** Period buffer valid. */
mbed_official 579:53297373a894 578 #define TC_STATUS_PERIOD_BUFFER_VALID (1UL << 7)
mbed_official 579:53297373a894 579 #endif
mbed_official 579:53297373a894 580 /** @} */
mbed_official 579:53297373a894 581
mbed_official 579:53297373a894 582 /**
mbed_official 579:53297373a894 583 * \brief Index of the compare capture channels.
mbed_official 579:53297373a894 584 *
mbed_official 579:53297373a894 585 * This enum is used to specify which capture/compare channel to do
mbed_official 579:53297373a894 586 * operations on.
mbed_official 579:53297373a894 587 */
mbed_official 579:53297373a894 588 enum tc_compare_capture_channel {
mbed_official 579:53297373a894 589 /** Index of compare capture channel 0. */
mbed_official 579:53297373a894 590 TC_COMPARE_CAPTURE_CHANNEL_0,
mbed_official 579:53297373a894 591 /** Index of compare capture channel 1. */
mbed_official 579:53297373a894 592 TC_COMPARE_CAPTURE_CHANNEL_1,
mbed_official 579:53297373a894 593 };
mbed_official 579:53297373a894 594
mbed_official 579:53297373a894 595 /** TC wave generation mode. */
mbed_official 579:53297373a894 596 #if SAML21
mbed_official 579:53297373a894 597 #define TC_WAVE_GENERATION_NORMAL_FREQ_MODE TC_WAVE_WAVEGEN_NFRQ
mbed_official 579:53297373a894 598 #define TC_WAVE_GENERATION_MATCH_FREQ_MODE TC_WAVE_WAVEGEN_MFRQ
mbed_official 579:53297373a894 599 #define TC_WAVE_GENERATION_NORMAL_PWM_MODE TC_WAVE_WAVEGEN_NPWM
mbed_official 579:53297373a894 600 #define TC_WAVE_GENERATION_MATCH_PWM_MODE TC_WAVE_WAVEGEN_MPWM
mbed_official 579:53297373a894 601 #else
mbed_official 579:53297373a894 602 #define TC_WAVE_GENERATION_NORMAL_FREQ_MODE TC_CTRLA_WAVEGEN_NFRQ
mbed_official 579:53297373a894 603 #define TC_WAVE_GENERATION_MATCH_FREQ_MODE TC_CTRLA_WAVEGEN_MFRQ
mbed_official 579:53297373a894 604 #define TC_WAVE_GENERATION_NORMAL_PWM_MODE TC_CTRLA_WAVEGEN_NPWM
mbed_official 579:53297373a894 605 #define TC_WAVE_GENERATION_MATCH_PWM_MODE TC_CTRLA_WAVEGEN_MPWM
mbed_official 579:53297373a894 606 #endif
mbed_official 579:53297373a894 607
mbed_official 579:53297373a894 608 /**
mbed_official 579:53297373a894 609 * \brief TC wave generation mode enum.
mbed_official 579:53297373a894 610 *
mbed_official 579:53297373a894 611 * This enum is used to select which mode to run the wave
mbed_official 579:53297373a894 612 * generation in.
mbed_official 579:53297373a894 613 *
mbed_official 579:53297373a894 614 */
mbed_official 579:53297373a894 615 enum tc_wave_generation {
mbed_official 579:53297373a894 616 /** Top is maximum, except in 8-bit counter size where it is the PER
mbed_official 579:53297373a894 617 * register.
mbed_official 579:53297373a894 618 */
mbed_official 579:53297373a894 619 TC_WAVE_GENERATION_NORMAL_FREQ = TC_WAVE_GENERATION_NORMAL_FREQ_MODE,
mbed_official 579:53297373a894 620
mbed_official 579:53297373a894 621 /** Top is CC0, except in 8-bit counter size where it is the PER
mbed_official 579:53297373a894 622 * register.
mbed_official 579:53297373a894 623 */
mbed_official 579:53297373a894 624 TC_WAVE_GENERATION_MATCH_FREQ = TC_WAVE_GENERATION_MATCH_FREQ_MODE,
mbed_official 579:53297373a894 625
mbed_official 579:53297373a894 626 /** Top is maximum, except in 8-bit counter size where it is the PER
mbed_official 579:53297373a894 627 * register.
mbed_official 579:53297373a894 628 */
mbed_official 579:53297373a894 629 TC_WAVE_GENERATION_NORMAL_PWM = TC_WAVE_GENERATION_NORMAL_PWM_MODE,
mbed_official 579:53297373a894 630
mbed_official 579:53297373a894 631 /** Top is CC0, except in 8-bit counter size where it is the PER
mbed_official 579:53297373a894 632 * register.
mbed_official 579:53297373a894 633 */
mbed_official 579:53297373a894 634 TC_WAVE_GENERATION_MATCH_PWM = TC_WAVE_GENERATION_MATCH_PWM_MODE,
mbed_official 579:53297373a894 635 };
mbed_official 579:53297373a894 636
mbed_official 579:53297373a894 637 /**
mbed_official 579:53297373a894 638 * \brief Specifies if the counter is 8-, 16-, or 32-bit.
mbed_official 579:53297373a894 639 *
mbed_official 579:53297373a894 640 * This enum specifies the maximum value it is possible to count to.
mbed_official 579:53297373a894 641 */
mbed_official 579:53297373a894 642 enum tc_counter_size {
mbed_official 579:53297373a894 643 /** The counter's maximum value is 0xFF, the period register is
mbed_official 579:53297373a894 644 * available to be used as top value.
mbed_official 579:53297373a894 645 */
mbed_official 579:53297373a894 646 TC_COUNTER_SIZE_8BIT = TC_CTRLA_MODE_COUNT8,
mbed_official 579:53297373a894 647
mbed_official 579:53297373a894 648 /** The counter's maximum value is 0xFFFF. There is no separate
mbed_official 579:53297373a894 649 * period register, to modify top one of the capture compare
mbed_official 579:53297373a894 650 * registers has to be used. This limits the amount of
mbed_official 579:53297373a894 651 * available channels.
mbed_official 579:53297373a894 652 */
mbed_official 579:53297373a894 653 TC_COUNTER_SIZE_16BIT = TC_CTRLA_MODE_COUNT16,
mbed_official 579:53297373a894 654
mbed_official 579:53297373a894 655 /** The counter's maximum value is 0xFFFFFFFF. There is no separate
mbed_official 579:53297373a894 656 * period register, to modify top one of the capture compare
mbed_official 579:53297373a894 657 * registers has to be used. This limits the amount of
mbed_official 579:53297373a894 658 * available channels.
mbed_official 579:53297373a894 659 */
mbed_official 579:53297373a894 660 TC_COUNTER_SIZE_32BIT = TC_CTRLA_MODE_COUNT32,
mbed_official 579:53297373a894 661 };
mbed_official 579:53297373a894 662
mbed_official 579:53297373a894 663 /**
mbed_official 579:53297373a894 664 * \brief TC Counter reload action enum.
mbed_official 579:53297373a894 665 *
mbed_official 579:53297373a894 666 * This enum specify how the counter and prescaler should reload.
mbed_official 579:53297373a894 667 */
mbed_official 579:53297373a894 668 enum tc_reload_action {
mbed_official 579:53297373a894 669 /** The counter is reloaded/reset on the next GCLK and starts
mbed_official 579:53297373a894 670 * counting on the prescaler clock.
mbed_official 579:53297373a894 671 */
mbed_official 579:53297373a894 672 TC_RELOAD_ACTION_GCLK = TC_CTRLA_PRESCSYNC_GCLK,
mbed_official 579:53297373a894 673
mbed_official 579:53297373a894 674 /** The counter is reloaded/reset on the next prescaler clock.
mbed_official 579:53297373a894 675 */
mbed_official 579:53297373a894 676 TC_RELOAD_ACTION_PRESC = TC_CTRLA_PRESCSYNC_PRESC,
mbed_official 579:53297373a894 677
mbed_official 579:53297373a894 678 /** The counter is reloaded/reset on the next GCLK, and the
mbed_official 579:53297373a894 679 * prescaler is restarted as well.
mbed_official 579:53297373a894 680 */
mbed_official 579:53297373a894 681 TC_RELOAD_ACTION_RESYNC = TC_CTRLA_PRESCSYNC_RESYNC,
mbed_official 579:53297373a894 682 };
mbed_official 579:53297373a894 683
mbed_official 579:53297373a894 684 /**
mbed_official 579:53297373a894 685 * \brief TC clock prescaler values.
mbed_official 579:53297373a894 686 *
mbed_official 579:53297373a894 687 * This enum is used to choose the clock prescaler
mbed_official 579:53297373a894 688 * configuration. The prescaler divides the clock frequency of the TC
mbed_official 579:53297373a894 689 * module to make the counter count slower.
mbed_official 579:53297373a894 690 */
mbed_official 579:53297373a894 691 enum tc_clock_prescaler {
mbed_official 579:53297373a894 692 /** Divide clock by 1. */
mbed_official 579:53297373a894 693 TC_CLOCK_PRESCALER_DIV1 = TC_CTRLA_PRESCALER(0),
mbed_official 579:53297373a894 694 /** Divide clock by 2. */
mbed_official 579:53297373a894 695 TC_CLOCK_PRESCALER_DIV2 = TC_CTRLA_PRESCALER(1),
mbed_official 579:53297373a894 696 /** Divide clock by 4. */
mbed_official 579:53297373a894 697 TC_CLOCK_PRESCALER_DIV4 = TC_CTRLA_PRESCALER(2),
mbed_official 579:53297373a894 698 /** Divide clock by 8. */
mbed_official 579:53297373a894 699 TC_CLOCK_PRESCALER_DIV8 = TC_CTRLA_PRESCALER(3),
mbed_official 579:53297373a894 700 /** Divide clock by 16. */
mbed_official 579:53297373a894 701 TC_CLOCK_PRESCALER_DIV16 = TC_CTRLA_PRESCALER(4),
mbed_official 579:53297373a894 702 /** Divide clock by 64. */
mbed_official 579:53297373a894 703 TC_CLOCK_PRESCALER_DIV64 = TC_CTRLA_PRESCALER(5),
mbed_official 579:53297373a894 704 /** Divide clock by 256. */
mbed_official 579:53297373a894 705 TC_CLOCK_PRESCALER_DIV256 = TC_CTRLA_PRESCALER(6),
mbed_official 579:53297373a894 706 /** Divide clock by 1024. */
mbed_official 579:53297373a894 707 TC_CLOCK_PRESCALER_DIV1024 = TC_CTRLA_PRESCALER(7),
mbed_official 579:53297373a894 708 };
mbed_official 579:53297373a894 709
mbed_official 579:53297373a894 710 /**
mbed_official 579:53297373a894 711 * \brief TC module count direction.
mbed_official 579:53297373a894 712 *
mbed_official 579:53297373a894 713 * Timer/Counter count direction.
mbed_official 579:53297373a894 714 */
mbed_official 579:53297373a894 715 enum tc_count_direction {
mbed_official 579:53297373a894 716 /** Timer should count upward from zero to MAX. */
mbed_official 579:53297373a894 717 TC_COUNT_DIRECTION_UP,
mbed_official 579:53297373a894 718
mbed_official 579:53297373a894 719 /** Timer should count downward to zero from MAX. */
mbed_official 579:53297373a894 720 TC_COUNT_DIRECTION_DOWN,
mbed_official 579:53297373a894 721 };
mbed_official 579:53297373a894 722
mbed_official 579:53297373a894 723 /** Waveform inversion mode. */
mbed_official 579:53297373a894 724 #if SAML21
mbed_official 579:53297373a894 725 #define TC_WAVEFORM_INVERT_CC0_MODE TC_DRVCTRL_INVEN(1)
mbed_official 579:53297373a894 726 #define TC_WAVEFORM_INVERT_CC1_MODE TC_DRVCTRL_INVEN(2)
mbed_official 579:53297373a894 727 #else
mbed_official 579:53297373a894 728 #define TC_WAVEFORM_INVERT_CC0_MODE TC_CTRLC_INVEN(1)
mbed_official 579:53297373a894 729 #define TC_WAVEFORM_INVERT_CC1_MODE TC_CTRLC_INVEN(2)
mbed_official 579:53297373a894 730 #endif
mbed_official 579:53297373a894 731
mbed_official 579:53297373a894 732 /**
mbed_official 579:53297373a894 733 * \brief Waveform inversion mode.
mbed_official 579:53297373a894 734 *
mbed_official 579:53297373a894 735 * Output waveform inversion mode.
mbed_official 579:53297373a894 736 */
mbed_official 579:53297373a894 737 enum tc_waveform_invert_output {
mbed_official 579:53297373a894 738 /** No inversion of the waveform output. */
mbed_official 579:53297373a894 739 TC_WAVEFORM_INVERT_OUTPUT_NONE = 0,
mbed_official 579:53297373a894 740 /** Invert output from compare channel 0. */
mbed_official 579:53297373a894 741 TC_WAVEFORM_INVERT_OUTPUT_CHANNEL_0 = TC_WAVEFORM_INVERT_CC0_MODE,
mbed_official 579:53297373a894 742 /** Invert output from compare channel 1. */
mbed_official 579:53297373a894 743 TC_WAVEFORM_INVERT_OUTPUT_CHANNEL_1 = TC_WAVEFORM_INVERT_CC1_MODE,
mbed_official 579:53297373a894 744 };
mbed_official 579:53297373a894 745
mbed_official 579:53297373a894 746 /**
mbed_official 579:53297373a894 747 * \brief Action to perform when the TC module is triggered by an event.
mbed_official 579:53297373a894 748 *
mbed_official 579:53297373a894 749 * Event action to perform when the module is triggered by an event.
mbed_official 579:53297373a894 750 */
mbed_official 579:53297373a894 751 enum tc_event_action {
mbed_official 579:53297373a894 752 /** No event action. */
mbed_official 579:53297373a894 753 TC_EVENT_ACTION_OFF = TC_EVCTRL_EVACT_OFF,
mbed_official 579:53297373a894 754 /** Re-trigger on event. */
mbed_official 579:53297373a894 755 TC_EVENT_ACTION_RETRIGGER = TC_EVCTRL_EVACT_RETRIGGER,
mbed_official 579:53297373a894 756 /** Increment counter on event. */
mbed_official 579:53297373a894 757 TC_EVENT_ACTION_INCREMENT_COUNTER = TC_EVCTRL_EVACT_COUNT,
mbed_official 579:53297373a894 758 /** Start counter on event. */
mbed_official 579:53297373a894 759 TC_EVENT_ACTION_START = TC_EVCTRL_EVACT_START,
mbed_official 579:53297373a894 760
mbed_official 579:53297373a894 761 /** Store period in capture register 0, pulse width in capture
mbed_official 579:53297373a894 762 * register 1.
mbed_official 579:53297373a894 763 */
mbed_official 579:53297373a894 764 TC_EVENT_ACTION_PPW = TC_EVCTRL_EVACT_PPW,
mbed_official 579:53297373a894 765
mbed_official 579:53297373a894 766 /** Store pulse width in capture register 0, period in capture
mbed_official 579:53297373a894 767 * register 1.
mbed_official 579:53297373a894 768 */
mbed_official 579:53297373a894 769 TC_EVENT_ACTION_PWP = TC_EVCTRL_EVACT_PWP,
mbed_official 579:53297373a894 770 #ifdef FEATURE_TC_STAMP_PW_CAPTURE
mbed_official 579:53297373a894 771 /** Time stamp capture. */
mbed_official 579:53297373a894 772 TC_EVENT_ACTION_STAMP = TC_EVCTRL_EVACT_STAMP,
mbed_official 579:53297373a894 773 /** Pulse width capture. */
mbed_official 579:53297373a894 774 TC_EVENT_ACTION_PW = TC_EVCTRL_EVACT_PW,
mbed_official 579:53297373a894 775 #endif
mbed_official 579:53297373a894 776 };
mbed_official 579:53297373a894 777
mbed_official 579:53297373a894 778 /**
mbed_official 579:53297373a894 779 * \brief TC event enable/disable structure.
mbed_official 579:53297373a894 780 *
mbed_official 579:53297373a894 781 * Event flags for the \ref tc_enable_events() and \ref tc_disable_events().
mbed_official 579:53297373a894 782 */
mbed_official 579:53297373a894 783 struct tc_events {
mbed_official 579:53297373a894 784 /** Generate an output event on a compare channel match. */
mbed_official 579:53297373a894 785 bool generate_event_on_compare_channel
mbed_official 579:53297373a894 786 [NUMBER_OF_COMPARE_CAPTURE_CHANNELS];
mbed_official 579:53297373a894 787 /** Generate an output event on counter overflow. */
mbed_official 579:53297373a894 788 bool generate_event_on_overflow;
mbed_official 579:53297373a894 789 /** Perform the configured event action when an incoming event is signalled. */
mbed_official 579:53297373a894 790 bool on_event_perform_action;
mbed_official 579:53297373a894 791 /** Specifies if the input event source is inverted, when used in PWP or
mbed_official 579:53297373a894 792 * PPW event action modes.
mbed_official 579:53297373a894 793 */
mbed_official 579:53297373a894 794 bool invert_event_input;
mbed_official 579:53297373a894 795 /** Specifies which event to trigger if an event is triggered. */
mbed_official 579:53297373a894 796 enum tc_event_action event_action;
mbed_official 579:53297373a894 797 };
mbed_official 579:53297373a894 798
mbed_official 579:53297373a894 799 /**
mbed_official 579:53297373a894 800 * \brief Configuration struct for TC module in 8-bit size counter mode.
mbed_official 579:53297373a894 801 */
mbed_official 579:53297373a894 802 struct tc_8bit_config {
mbed_official 579:53297373a894 803 /** Initial timer count value. */
mbed_official 579:53297373a894 804 uint8_t value;
mbed_official 579:53297373a894 805 /** Where to count to or from depending on the direction on the counter. */
mbed_official 579:53297373a894 806 uint8_t period;
mbed_official 579:53297373a894 807 /** Value to be used for compare match on each channel. */
mbed_official 579:53297373a894 808 uint8_t compare_capture_channel[NUMBER_OF_COMPARE_CAPTURE_CHANNELS];
mbed_official 579:53297373a894 809 };
mbed_official 579:53297373a894 810
mbed_official 579:53297373a894 811 /**
mbed_official 579:53297373a894 812 * \brief Configuration struct for TC module in 16-bit size counter mode.
mbed_official 579:53297373a894 813 */
mbed_official 579:53297373a894 814 struct tc_16bit_config {
mbed_official 579:53297373a894 815 /** Initial timer count value. */
mbed_official 579:53297373a894 816 uint16_t value;
mbed_official 579:53297373a894 817 /** Value to be used for compare match on each channel. */
mbed_official 579:53297373a894 818 uint16_t compare_capture_channel[NUMBER_OF_COMPARE_CAPTURE_CHANNELS];
mbed_official 579:53297373a894 819 };
mbed_official 579:53297373a894 820
mbed_official 579:53297373a894 821 /**
mbed_official 579:53297373a894 822 * \brief Configuration struct for TC module in 32-bit size counter mode.
mbed_official 579:53297373a894 823 */
mbed_official 579:53297373a894 824 struct tc_32bit_config {
mbed_official 579:53297373a894 825 /** Initial timer count value. */
mbed_official 579:53297373a894 826 uint32_t value;
mbed_official 579:53297373a894 827 /** Value to be used for compare match on each channel. */
mbed_official 579:53297373a894 828 uint32_t compare_capture_channel[NUMBER_OF_COMPARE_CAPTURE_CHANNELS];
mbed_official 579:53297373a894 829 };
mbed_official 579:53297373a894 830
mbed_official 579:53297373a894 831 /**
mbed_official 579:53297373a894 832 * \brief Configuration struct for TC module in 32-bit size counter mode.
mbed_official 579:53297373a894 833 */
mbed_official 579:53297373a894 834 struct tc_pwm_channel {
mbed_official 579:53297373a894 835 /** When \c true, PWM output for the given channel is enabled. */
mbed_official 579:53297373a894 836 bool enabled;
mbed_official 579:53297373a894 837 /** Specifies pin output for each channel. */
mbed_official 579:53297373a894 838 uint32_t pin_out;
mbed_official 579:53297373a894 839 /** Specifies MUX setting for each output channel pin. */
mbed_official 579:53297373a894 840 uint32_t pin_mux;
mbed_official 579:53297373a894 841 };
mbed_official 579:53297373a894 842
mbed_official 579:53297373a894 843 /**
mbed_official 579:53297373a894 844 * \brief TC configuration structure.
mbed_official 579:53297373a894 845 *
mbed_official 579:53297373a894 846 * Configuration struct for a TC instance. This structure should be
mbed_official 579:53297373a894 847 * initialized by the \ref tc_get_config_defaults function before being
mbed_official 579:53297373a894 848 * modified by the user application.
mbed_official 579:53297373a894 849 */
mbed_official 579:53297373a894 850 struct tc_config {
mbed_official 579:53297373a894 851 /** GCLK generator used to clock the peripheral. */
mbed_official 579:53297373a894 852 enum gclk_generator clock_source;
mbed_official 579:53297373a894 853
mbed_official 579:53297373a894 854 /** When \c true the module is enabled during standby. */
mbed_official 579:53297373a894 855 bool run_in_standby;
mbed_official 579:53297373a894 856 #if (SAML21)
mbed_official 579:53297373a894 857 /** Run on demand. */
mbed_official 579:53297373a894 858 bool on_demand;
mbed_official 579:53297373a894 859 #endif
mbed_official 579:53297373a894 860 /** Specifies either 8-, 16-, or 32-bit counter size. */
mbed_official 579:53297373a894 861 enum tc_counter_size counter_size;
mbed_official 579:53297373a894 862 /** Specifies the prescaler value for GCLK_TC. */
mbed_official 579:53297373a894 863 enum tc_clock_prescaler clock_prescaler;
mbed_official 579:53297373a894 864 /** Specifies which waveform generation mode to use. */
mbed_official 579:53297373a894 865 enum tc_wave_generation wave_generation;
mbed_official 579:53297373a894 866
mbed_official 579:53297373a894 867 /** Specifies the reload or reset time of the counter and prescaler
mbed_official 579:53297373a894 868 * resynchronization on a re-trigger event for the TC.
mbed_official 579:53297373a894 869 */
mbed_official 579:53297373a894 870 enum tc_reload_action reload_action;
mbed_official 579:53297373a894 871
mbed_official 579:53297373a894 872 /** Specifies which channel(s) to invert the waveform on.
mbed_official 579:53297373a894 873 For SAML21, it's also used to invert IO input pin. */
mbed_official 579:53297373a894 874 uint8_t waveform_invert_output;
mbed_official 579:53297373a894 875
mbed_official 579:53297373a894 876 /** Specifies which channel(s) to enable channel capture
mbed_official 579:53297373a894 877 * operation on.
mbed_official 579:53297373a894 878 */
mbed_official 579:53297373a894 879 bool enable_capture_on_channel[NUMBER_OF_COMPARE_CAPTURE_CHANNELS];
mbed_official 579:53297373a894 880 #ifdef FEATURE_TC_IO_CAPTURE
mbed_official 579:53297373a894 881 /** Specifies which channel(s) to enable I/O capture
mbed_official 579:53297373a894 882 * operation on.
mbed_official 579:53297373a894 883 */
mbed_official 579:53297373a894 884 bool enable_capture_on_IO[NUMBER_OF_COMPARE_CAPTURE_CHANNELS];
mbed_official 579:53297373a894 885 #endif
mbed_official 579:53297373a894 886
mbed_official 579:53297373a894 887 /** When \c true, one-shot will stop the TC on next hardware or software
mbed_official 579:53297373a894 888 * re-trigger event or overflow/underflow.
mbed_official 579:53297373a894 889 */
mbed_official 579:53297373a894 890 bool oneshot;
mbed_official 579:53297373a894 891
mbed_official 579:53297373a894 892 /** Specifies the direction for the TC to count. */
mbed_official 579:53297373a894 893 enum tc_count_direction count_direction;
mbed_official 579:53297373a894 894
mbed_official 579:53297373a894 895 /** Specifies the PWM channel for TC. */
mbed_official 579:53297373a894 896 struct tc_pwm_channel pwm_channel[NUMBER_OF_COMPARE_CAPTURE_CHANNELS];
mbed_official 579:53297373a894 897
mbed_official 579:53297373a894 898 /** Access the different counter size settings though this configuration member. */
mbed_official 579:53297373a894 899 union {
mbed_official 579:53297373a894 900 /** Struct for 8-bit specific timer configuration. */
mbed_official 579:53297373a894 901 struct tc_8bit_config counter_8_bit;
mbed_official 579:53297373a894 902 /** Struct for 16-bit specific timer configuration. */
mbed_official 579:53297373a894 903 struct tc_16bit_config counter_16_bit;
mbed_official 579:53297373a894 904 /** Struct for 32-bit specific timer configuration. */
mbed_official 579:53297373a894 905 struct tc_32bit_config counter_32_bit;
mbed_official 579:53297373a894 906 };
mbed_official 579:53297373a894 907
mbed_official 579:53297373a894 908 #ifdef FEATURE_TC_DOUBLE_BUFFERED
mbed_official 579:53297373a894 909 /** Set to \c true to enable double buffering write. When enabled any write
mbed_official 579:53297373a894 910 * through \ref tc_set_top_value(), \ref tc_set_compare_value() and
mbed_official 579:53297373a894 911 * will direct to the buffer register as buffered
mbed_official 579:53297373a894 912 * value, and the buffered value will be committed to effective register
mbed_official 579:53297373a894 913 * on UPDATE condition, if update is not locked.
mbed_official 579:53297373a894 914 */
mbed_official 579:53297373a894 915 bool double_buffering_enabled;
mbed_official 579:53297373a894 916 #endif
mbed_official 579:53297373a894 917 };
mbed_official 579:53297373a894 918
mbed_official 579:53297373a894 919
mbed_official 579:53297373a894 920 //#if TC_ASYNC == true // TEMP: Commented by V
mbed_official 579:53297373a894 921 /* Forward Declaration for the device instance. */
mbed_official 579:53297373a894 922 struct tc_module;
mbed_official 579:53297373a894 923
mbed_official 579:53297373a894 924 /* Type of the callback functions. */
mbed_official 579:53297373a894 925 typedef void (*tc_callback_t)(struct tc_module *const module);
mbed_official 579:53297373a894 926 //#endif
mbed_official 579:53297373a894 927
mbed_official 579:53297373a894 928 /**
mbed_official 579:53297373a894 929 * \brief TC software device instance structure.
mbed_official 579:53297373a894 930 *
mbed_official 579:53297373a894 931 * TC software instance structure, used to retain software state information
mbed_official 579:53297373a894 932 * of an associated hardware module instance.
mbed_official 579:53297373a894 933 *
mbed_official 579:53297373a894 934 * \note The fields of this structure should not be altered by the user
mbed_official 579:53297373a894 935 * application; they are reserved for module-internal use only.
mbed_official 579:53297373a894 936 */
mbed_official 579:53297373a894 937 struct tc_module {
mbed_official 579:53297373a894 938 #if !defined(__DOXYGEN__)
mbed_official 579:53297373a894 939 /** Hardware module pointer of the associated Timer/Counter peripheral. */
mbed_official 579:53297373a894 940 Tc *hw;
mbed_official 579:53297373a894 941
mbed_official 579:53297373a894 942 /** Size of the initialized Timer/Counter module configuration. */
mbed_official 579:53297373a894 943 enum tc_counter_size counter_size;
mbed_official 579:53297373a894 944 //# if TC_ASYNC == true // TEMP: Commented by V
mbed_official 579:53297373a894 945 /** Array of callbacks. */
mbed_official 579:53297373a894 946 tc_callback_t callback[TC_CALLBACK_N];
mbed_official 579:53297373a894 947 /** Bit mask for callbacks registered. */
mbed_official 579:53297373a894 948 uint8_t register_callback_mask;
mbed_official 579:53297373a894 949 /** Bit mask for callbacks enabled. */
mbed_official 579:53297373a894 950 uint8_t enable_callback_mask;
mbed_official 579:53297373a894 951 //# endif
mbed_official 579:53297373a894 952 #ifdef FEATURE_TC_DOUBLE_BUFFERED
mbed_official 579:53297373a894 953 /** Set to \c true to enable double buffering write. */
mbed_official 579:53297373a894 954 bool double_buffering_enabled;
mbed_official 579:53297373a894 955 #endif
mbed_official 579:53297373a894 956 #endif
mbed_official 579:53297373a894 957 };
mbed_official 579:53297373a894 958
mbed_official 579:53297373a894 959 #if !defined(__DOXYGEN__)
mbed_official 579:53297373a894 960 uint8_t _tc_get_inst_index(
mbed_official 579:53297373a894 961 Tc *const hw);
mbed_official 579:53297373a894 962 #endif
mbed_official 579:53297373a894 963
mbed_official 579:53297373a894 964 /**
mbed_official 579:53297373a894 965 * \name Driver Initialization and Configuration
mbed_official 579:53297373a894 966 * @{
mbed_official 579:53297373a894 967 */
mbed_official 579:53297373a894 968
mbed_official 579:53297373a894 969 /**
mbed_official 579:53297373a894 970 * \brief Determines if the hardware module(s) are currently synchronizing to
mbed_official 579:53297373a894 971 *the bus.
mbed_official 579:53297373a894 972 *
mbed_official 579:53297373a894 973 * Checks to see if the underlying hardware peripheral module(s) are currently
mbed_official 579:53297373a894 974 * synchronizing across multiple clock domains to the hardware bus. This
mbed_official 579:53297373a894 975 * function can be used to delay further operations on a module until such time
mbed_official 579:53297373a894 976 * that it is ready, to prevent blocking delays for synchronization in the
mbed_official 579:53297373a894 977 * user application.
mbed_official 579:53297373a894 978 *
mbed_official 579:53297373a894 979 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 980 *
mbed_official 579:53297373a894 981 * \return Synchronization status of the underlying hardware module(s).
mbed_official 579:53297373a894 982 *
mbed_official 579:53297373a894 983 * \retval false If the module has completed synchronization
mbed_official 579:53297373a894 984 * \retval true If the module synchronization is ongoing
mbed_official 579:53297373a894 985 */
mbed_official 579:53297373a894 986 static inline bool tc_is_syncing(
mbed_official 579:53297373a894 987 const struct tc_module *const module_inst)
mbed_official 579:53297373a894 988 {
mbed_official 579:53297373a894 989 /* Sanity check arguments */
mbed_official 579:53297373a894 990 Assert(module_inst);
mbed_official 579:53297373a894 991 Assert(module_inst->hw);
mbed_official 579:53297373a894 992
mbed_official 579:53297373a894 993 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 994 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 995
mbed_official 579:53297373a894 996 #if (SAML21)
mbed_official 579:53297373a894 997 return (tc_module->SYNCBUSY.reg);
mbed_official 579:53297373a894 998 #else
mbed_official 579:53297373a894 999 return (tc_module->STATUS.reg & TC_STATUS_SYNCBUSY);
mbed_official 579:53297373a894 1000 #endif
mbed_official 579:53297373a894 1001 }
mbed_official 579:53297373a894 1002
mbed_official 579:53297373a894 1003 /**
mbed_official 579:53297373a894 1004 * \brief Initializes config with predefined default values.
mbed_official 579:53297373a894 1005 *
mbed_official 579:53297373a894 1006 * This function will initialize a given TC configuration structure to
mbed_official 579:53297373a894 1007 * a set of known default values. This function should be called on
mbed_official 579:53297373a894 1008 * any new instance of the configuration structures before being
mbed_official 579:53297373a894 1009 * modified by the user application.
mbed_official 579:53297373a894 1010 *
mbed_official 579:53297373a894 1011 * The default configuration is as follows:
mbed_official 579:53297373a894 1012 * \li GCLK generator 0 (GCLK main) clock source
mbed_official 579:53297373a894 1013 * \li 16-bit counter size on the counter
mbed_official 579:53297373a894 1014 * \li No prescaler
mbed_official 579:53297373a894 1015 * \li Normal frequency wave generation
mbed_official 579:53297373a894 1016 * \li GCLK reload action
mbed_official 579:53297373a894 1017 * \li Don't run in standby
mbed_official 579:53297373a894 1018 * \li Don't run on demand for SAML21
mbed_official 579:53297373a894 1019 * \li No inversion of waveform output
mbed_official 579:53297373a894 1020 * \li No capture enabled
mbed_official 579:53297373a894 1021 * \li No I/O capture enabled for SAML21
mbed_official 579:53297373a894 1022 * \li No event input enabled
mbed_official 579:53297373a894 1023 * \li Count upward
mbed_official 579:53297373a894 1024 * \li Don't perform one-shot operations
mbed_official 579:53297373a894 1025 * \li No event action
mbed_official 579:53297373a894 1026 * \li No channel 0 PWM output
mbed_official 579:53297373a894 1027 * \li No channel 1 PWM output
mbed_official 579:53297373a894 1028 * \li Counter starts on 0
mbed_official 579:53297373a894 1029 * \li Capture compare channel 0 set to 0
mbed_official 579:53297373a894 1030 * \li Capture compare channel 1 set to 0
mbed_official 579:53297373a894 1031 * \li No PWM pin output enabled
mbed_official 579:53297373a894 1032 * \li Pin and MUX configuration not set
mbed_official 579:53297373a894 1033 * \li Double buffer disabled (if have this feature)
mbed_official 579:53297373a894 1034 *
mbed_official 579:53297373a894 1035 * \param[out] config Pointer to a TC module configuration structure to set
mbed_official 579:53297373a894 1036 */
mbed_official 579:53297373a894 1037 static inline void tc_get_config_defaults(
mbed_official 579:53297373a894 1038 struct tc_config *const config)
mbed_official 579:53297373a894 1039 {
mbed_official 579:53297373a894 1040 /* Sanity check arguments */
mbed_official 579:53297373a894 1041 Assert(config);
mbed_official 579:53297373a894 1042
mbed_official 579:53297373a894 1043 /* Write default config to config struct */
mbed_official 579:53297373a894 1044 config->clock_source = GCLK_GENERATOR_0;
mbed_official 579:53297373a894 1045 config->counter_size = TC_COUNTER_SIZE_16BIT;
mbed_official 579:53297373a894 1046 config->clock_prescaler = TC_CLOCK_PRESCALER_DIV1;
mbed_official 579:53297373a894 1047 config->wave_generation = TC_WAVE_GENERATION_NORMAL_FREQ;
mbed_official 579:53297373a894 1048 config->reload_action = TC_RELOAD_ACTION_GCLK;
mbed_official 579:53297373a894 1049 config->run_in_standby = false;
mbed_official 579:53297373a894 1050 #if (SAML21)
mbed_official 579:53297373a894 1051 config->on_demand = false;
mbed_official 579:53297373a894 1052 #endif
mbed_official 579:53297373a894 1053 config->waveform_invert_output = TC_WAVEFORM_INVERT_OUTPUT_NONE;
mbed_official 579:53297373a894 1054 config->enable_capture_on_channel[TC_COMPARE_CAPTURE_CHANNEL_0] = false;
mbed_official 579:53297373a894 1055 config->enable_capture_on_channel[TC_COMPARE_CAPTURE_CHANNEL_1] = false;
mbed_official 579:53297373a894 1056 #ifdef FEATURE_TC_IO_CAPTURE
mbed_official 579:53297373a894 1057 config->enable_capture_on_IO[TC_COMPARE_CAPTURE_CHANNEL_0] = false;
mbed_official 579:53297373a894 1058 config->enable_capture_on_IO[TC_COMPARE_CAPTURE_CHANNEL_1] = false;
mbed_official 579:53297373a894 1059 #endif
mbed_official 579:53297373a894 1060
mbed_official 579:53297373a894 1061 config->count_direction = TC_COUNT_DIRECTION_UP;
mbed_official 579:53297373a894 1062 config->oneshot = false;
mbed_official 579:53297373a894 1063
mbed_official 579:53297373a894 1064 config->pwm_channel[TC_COMPARE_CAPTURE_CHANNEL_0].enabled = false;
mbed_official 579:53297373a894 1065 config->pwm_channel[TC_COMPARE_CAPTURE_CHANNEL_0].pin_out = 0;
mbed_official 579:53297373a894 1066 config->pwm_channel[TC_COMPARE_CAPTURE_CHANNEL_0].pin_mux = 0;
mbed_official 579:53297373a894 1067
mbed_official 579:53297373a894 1068 config->pwm_channel[TC_COMPARE_CAPTURE_CHANNEL_1].enabled = false;
mbed_official 579:53297373a894 1069 config->pwm_channel[TC_COMPARE_CAPTURE_CHANNEL_1].pin_out = 0;
mbed_official 579:53297373a894 1070 config->pwm_channel[TC_COMPARE_CAPTURE_CHANNEL_1].pin_mux = 0;
mbed_official 579:53297373a894 1071
mbed_official 579:53297373a894 1072 config->counter_16_bit.value = 0x0000;
mbed_official 579:53297373a894 1073 config->counter_16_bit.compare_capture_channel\
mbed_official 579:53297373a894 1074 [TC_COMPARE_CAPTURE_CHANNEL_0] = 0x0000;
mbed_official 579:53297373a894 1075 config->counter_16_bit.compare_capture_channel\
mbed_official 579:53297373a894 1076 [TC_COMPARE_CAPTURE_CHANNEL_1] = 0x0000;
mbed_official 579:53297373a894 1077 #ifdef FEATURE_TC_DOUBLE_BUFFERED
mbed_official 579:53297373a894 1078 config->double_buffering_enabled = false;
mbed_official 579:53297373a894 1079 #endif
mbed_official 579:53297373a894 1080
mbed_official 579:53297373a894 1081 }
mbed_official 579:53297373a894 1082
mbed_official 579:53297373a894 1083 enum status_code tc_init(
mbed_official 579:53297373a894 1084 struct tc_module *const module_inst,
mbed_official 579:53297373a894 1085 Tc *const hw,
mbed_official 579:53297373a894 1086 const struct tc_config *const config);
mbed_official 579:53297373a894 1087
mbed_official 579:53297373a894 1088 /** @} */
mbed_official 579:53297373a894 1089
mbed_official 579:53297373a894 1090 /**
mbed_official 579:53297373a894 1091 * \name Event Management
mbed_official 579:53297373a894 1092 * @{
mbed_official 579:53297373a894 1093 */
mbed_official 579:53297373a894 1094
mbed_official 579:53297373a894 1095 /**
mbed_official 579:53297373a894 1096 * \brief Enables a TC module event input or output.
mbed_official 579:53297373a894 1097 *
mbed_official 579:53297373a894 1098 * Enables one or more input or output events to or from the TC module.
mbed_official 579:53297373a894 1099 * See \ref tc_events for a list of events this module supports.
mbed_official 579:53297373a894 1100 *
mbed_official 579:53297373a894 1101 * \note Events cannot be altered while the module is enabled.
mbed_official 579:53297373a894 1102 *
mbed_official 579:53297373a894 1103 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1104 * \param[in] events Struct containing flags of events to enable
mbed_official 579:53297373a894 1105 */
mbed_official 579:53297373a894 1106 static inline void tc_enable_events(
mbed_official 579:53297373a894 1107 struct tc_module *const module_inst,
mbed_official 579:53297373a894 1108 struct tc_events *const events)
mbed_official 579:53297373a894 1109 {
mbed_official 579:53297373a894 1110 /* Sanity check arguments */
mbed_official 579:53297373a894 1111 Assert(module_inst);
mbed_official 579:53297373a894 1112 Assert(module_inst->hw);
mbed_official 579:53297373a894 1113 Assert(events);
mbed_official 579:53297373a894 1114
mbed_official 579:53297373a894 1115 Tc *const tc_module = module_inst->hw;
mbed_official 579:53297373a894 1116
mbed_official 579:53297373a894 1117 uint32_t event_mask = 0;
mbed_official 579:53297373a894 1118
mbed_official 579:53297373a894 1119 if (events->invert_event_input == true) {
mbed_official 579:53297373a894 1120 event_mask |= TC_EVCTRL_TCINV;
mbed_official 579:53297373a894 1121 }
mbed_official 579:53297373a894 1122
mbed_official 579:53297373a894 1123 if (events->on_event_perform_action == true) {
mbed_official 579:53297373a894 1124 event_mask |= TC_EVCTRL_TCEI;
mbed_official 579:53297373a894 1125 }
mbed_official 579:53297373a894 1126
mbed_official 579:53297373a894 1127 if (events->generate_event_on_overflow == true) {
mbed_official 579:53297373a894 1128 event_mask |= TC_EVCTRL_OVFEO;
mbed_official 579:53297373a894 1129 }
mbed_official 579:53297373a894 1130
mbed_official 579:53297373a894 1131 for (uint8_t i = 0; i < NUMBER_OF_COMPARE_CAPTURE_CHANNELS; i++) {
mbed_official 579:53297373a894 1132 if (events->generate_event_on_compare_channel[i] == true) {
mbed_official 579:53297373a894 1133 event_mask |= (TC_EVCTRL_MCEO(1) << i);
mbed_official 579:53297373a894 1134 }
mbed_official 579:53297373a894 1135 }
mbed_official 579:53297373a894 1136
mbed_official 579:53297373a894 1137 tc_module->COUNT8.EVCTRL.reg |= event_mask | events->event_action;
mbed_official 579:53297373a894 1138 }
mbed_official 579:53297373a894 1139
mbed_official 579:53297373a894 1140 /**
mbed_official 579:53297373a894 1141 * \brief Disables a TC module event input or output.
mbed_official 579:53297373a894 1142 *
mbed_official 579:53297373a894 1143 * Disables one or more input or output events to or from the TC module.
mbed_official 579:53297373a894 1144 * See \ref tc_events for a list of events this module supports.
mbed_official 579:53297373a894 1145 *
mbed_official 579:53297373a894 1146 * \note Events cannot be altered while the module is enabled.
mbed_official 579:53297373a894 1147 *
mbed_official 579:53297373a894 1148 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1149 * \param[in] events Struct containing flags of events to disable
mbed_official 579:53297373a894 1150 */
mbed_official 579:53297373a894 1151 static inline void tc_disable_events(
mbed_official 579:53297373a894 1152 struct tc_module *const module_inst,
mbed_official 579:53297373a894 1153 struct tc_events *const events)
mbed_official 579:53297373a894 1154 {
mbed_official 579:53297373a894 1155 /* Sanity check arguments */
mbed_official 579:53297373a894 1156 Assert(module_inst);
mbed_official 579:53297373a894 1157 Assert(module_inst->hw);
mbed_official 579:53297373a894 1158 Assert(events);
mbed_official 579:53297373a894 1159
mbed_official 579:53297373a894 1160 Tc *const tc_module = module_inst->hw;
mbed_official 579:53297373a894 1161
mbed_official 579:53297373a894 1162 uint32_t event_mask = 0;
mbed_official 579:53297373a894 1163
mbed_official 579:53297373a894 1164 if (events->invert_event_input == true) {
mbed_official 579:53297373a894 1165 event_mask |= TC_EVCTRL_TCINV;
mbed_official 579:53297373a894 1166 }
mbed_official 579:53297373a894 1167
mbed_official 579:53297373a894 1168 if (events->on_event_perform_action == true) {
mbed_official 579:53297373a894 1169 event_mask |= TC_EVCTRL_TCEI;
mbed_official 579:53297373a894 1170 }
mbed_official 579:53297373a894 1171
mbed_official 579:53297373a894 1172 if (events->generate_event_on_overflow == true) {
mbed_official 579:53297373a894 1173 event_mask |= TC_EVCTRL_OVFEO;
mbed_official 579:53297373a894 1174 }
mbed_official 579:53297373a894 1175
mbed_official 579:53297373a894 1176 for (uint8_t i = 0; i < NUMBER_OF_COMPARE_CAPTURE_CHANNELS; i++) {
mbed_official 579:53297373a894 1177 if (events->generate_event_on_compare_channel[i] == true) {
mbed_official 579:53297373a894 1178 event_mask |= (TC_EVCTRL_MCEO(1) << i);
mbed_official 579:53297373a894 1179 }
mbed_official 579:53297373a894 1180 }
mbed_official 579:53297373a894 1181
mbed_official 579:53297373a894 1182 tc_module->COUNT8.EVCTRL.reg &= ~event_mask;
mbed_official 579:53297373a894 1183 }
mbed_official 579:53297373a894 1184
mbed_official 579:53297373a894 1185 /** @} */
mbed_official 579:53297373a894 1186
mbed_official 579:53297373a894 1187 /**
mbed_official 579:53297373a894 1188 * \name Enable/Disable/Reset
mbed_official 579:53297373a894 1189 * @{
mbed_official 579:53297373a894 1190 */
mbed_official 579:53297373a894 1191
mbed_official 579:53297373a894 1192 enum status_code tc_reset(
mbed_official 579:53297373a894 1193 const struct tc_module *const module_inst);
mbed_official 579:53297373a894 1194
mbed_official 579:53297373a894 1195 /**
mbed_official 579:53297373a894 1196 * \brief Enable the TC module.
mbed_official 579:53297373a894 1197 *
mbed_official 579:53297373a894 1198 * Enables a TC module that has been previously initialized. The counter will
mbed_official 579:53297373a894 1199 * start when the counter is enabled.
mbed_official 579:53297373a894 1200 *
mbed_official 579:53297373a894 1201 * \note When the counter is configured to re-trigger on an event, the counter
mbed_official 579:53297373a894 1202 * will not start until the start function is used.
mbed_official 579:53297373a894 1203 *
mbed_official 579:53297373a894 1204 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1205 */
mbed_official 579:53297373a894 1206 static inline void tc_enable(
mbed_official 579:53297373a894 1207 const struct tc_module *const module_inst)
mbed_official 579:53297373a894 1208 {
mbed_official 579:53297373a894 1209 /* Sanity check arguments */
mbed_official 579:53297373a894 1210 Assert(module_inst);
mbed_official 579:53297373a894 1211 Assert(module_inst->hw);
mbed_official 579:53297373a894 1212
mbed_official 579:53297373a894 1213 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1214 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1215
mbed_official 579:53297373a894 1216 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1217 /* Wait for sync */
mbed_official 579:53297373a894 1218 }
mbed_official 579:53297373a894 1219
mbed_official 579:53297373a894 1220 /* Enable TC module */
mbed_official 579:53297373a894 1221 tc_module->CTRLA.reg |= TC_CTRLA_ENABLE;
mbed_official 579:53297373a894 1222 }
mbed_official 579:53297373a894 1223
mbed_official 579:53297373a894 1224 /**
mbed_official 579:53297373a894 1225 * \brief Disables the TC module.
mbed_official 579:53297373a894 1226 *
mbed_official 579:53297373a894 1227 * Disables a TC module and stops the counter.
mbed_official 579:53297373a894 1228 *
mbed_official 579:53297373a894 1229 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1230 */
mbed_official 579:53297373a894 1231 static inline void tc_disable(
mbed_official 579:53297373a894 1232 const struct tc_module *const module_inst)
mbed_official 579:53297373a894 1233 {
mbed_official 579:53297373a894 1234 /* Sanity check arguments */
mbed_official 579:53297373a894 1235 Assert(module_inst);
mbed_official 579:53297373a894 1236 Assert(module_inst->hw);
mbed_official 579:53297373a894 1237
mbed_official 579:53297373a894 1238 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1239 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1240
mbed_official 579:53297373a894 1241 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1242 /* Wait for sync */
mbed_official 579:53297373a894 1243 }
mbed_official 579:53297373a894 1244
mbed_official 579:53297373a894 1245 /* Disable TC module */
mbed_official 579:53297373a894 1246 tc_module->CTRLA.reg &= ~TC_CTRLA_ENABLE;
mbed_official 579:53297373a894 1247 }
mbed_official 579:53297373a894 1248
mbed_official 579:53297373a894 1249 /** @} */
mbed_official 579:53297373a894 1250
mbed_official 579:53297373a894 1251 /**
mbed_official 579:53297373a894 1252 * \name Get/Set Count Value
mbed_official 579:53297373a894 1253 * @{
mbed_official 579:53297373a894 1254 */
mbed_official 579:53297373a894 1255
mbed_official 579:53297373a894 1256 uint32_t tc_get_count_value(
mbed_official 579:53297373a894 1257 const struct tc_module *const module_inst);
mbed_official 579:53297373a894 1258
mbed_official 579:53297373a894 1259 enum status_code tc_set_count_value(
mbed_official 579:53297373a894 1260 const struct tc_module *const module_inst,
mbed_official 579:53297373a894 1261 const uint32_t count);
mbed_official 579:53297373a894 1262
mbed_official 579:53297373a894 1263 /** @} */
mbed_official 579:53297373a894 1264
mbed_official 579:53297373a894 1265 /**
mbed_official 579:53297373a894 1266 * \name Start/Stop Counter
mbed_official 579:53297373a894 1267 * @{
mbed_official 579:53297373a894 1268 */
mbed_official 579:53297373a894 1269
mbed_official 579:53297373a894 1270 /**
mbed_official 579:53297373a894 1271 * \brief Stops the counter.
mbed_official 579:53297373a894 1272 *
mbed_official 579:53297373a894 1273 * This function will stop the counter. When the counter is stopped
mbed_official 579:53297373a894 1274 * the value in the count value is set to 0 if the counter was
mbed_official 579:53297373a894 1275 * counting up, or maximum if the counter was counting
mbed_official 579:53297373a894 1276 * down when stopped.
mbed_official 579:53297373a894 1277 *
mbed_official 579:53297373a894 1278 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1279 */
mbed_official 579:53297373a894 1280 static inline void tc_stop_counter(
mbed_official 579:53297373a894 1281 const struct tc_module *const module_inst)
mbed_official 579:53297373a894 1282 {
mbed_official 579:53297373a894 1283 /* Sanity check arguments */
mbed_official 579:53297373a894 1284 Assert(module_inst);
mbed_official 579:53297373a894 1285 Assert(module_inst->hw);
mbed_official 579:53297373a894 1286
mbed_official 579:53297373a894 1287 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1288 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1289
mbed_official 579:53297373a894 1290 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1291 /* Wait for sync */
mbed_official 579:53297373a894 1292 }
mbed_official 579:53297373a894 1293
mbed_official 579:53297373a894 1294 /* Write command to execute */
mbed_official 579:53297373a894 1295 tc_module->CTRLBSET.reg = TC_CTRLBSET_CMD(2);
mbed_official 579:53297373a894 1296 }
mbed_official 579:53297373a894 1297
mbed_official 579:53297373a894 1298 /**
mbed_official 579:53297373a894 1299 * \brief Starts the counter.
mbed_official 579:53297373a894 1300 *
mbed_official 579:53297373a894 1301 * Starts or restarts an initialized TC module's counter.
mbed_official 579:53297373a894 1302 *
mbed_official 579:53297373a894 1303 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1304 */
mbed_official 579:53297373a894 1305 static inline void tc_start_counter(
mbed_official 579:53297373a894 1306 const struct tc_module *const module_inst)
mbed_official 579:53297373a894 1307 {
mbed_official 579:53297373a894 1308 /* Sanity check arguments */
mbed_official 579:53297373a894 1309 Assert(module_inst);
mbed_official 579:53297373a894 1310 Assert(module_inst->hw);
mbed_official 579:53297373a894 1311
mbed_official 579:53297373a894 1312 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1313 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1314
mbed_official 579:53297373a894 1315 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1316 /* Wait for sync */
mbed_official 579:53297373a894 1317 }
mbed_official 579:53297373a894 1318
mbed_official 579:53297373a894 1319 /* Make certain that there are no conflicting commands in the register */
mbed_official 579:53297373a894 1320 tc_module->CTRLBCLR.reg = TC_CTRLBCLR_CMD_NONE;
mbed_official 579:53297373a894 1321
mbed_official 579:53297373a894 1322 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1323 /* Wait for sync */
mbed_official 579:53297373a894 1324 }
mbed_official 579:53297373a894 1325
mbed_official 579:53297373a894 1326 /* Write command to execute */
mbed_official 579:53297373a894 1327 tc_module->CTRLBSET.reg = TC_CTRLBSET_CMD(1);
mbed_official 579:53297373a894 1328 }
mbed_official 579:53297373a894 1329
mbed_official 579:53297373a894 1330 /** @} */
mbed_official 579:53297373a894 1331
mbed_official 579:53297373a894 1332 #ifdef FEATURE_TC_DOUBLE_BUFFERED
mbed_official 579:53297373a894 1333 /**
mbed_official 579:53297373a894 1334 * \name Double Buffering
mbed_official 579:53297373a894 1335 * @{
mbed_official 579:53297373a894 1336 */
mbed_official 579:53297373a894 1337
mbed_official 579:53297373a894 1338 /**
mbed_official 579:53297373a894 1339 * \brief Update double buffer.
mbed_official 579:53297373a894 1340 *
mbed_official 579:53297373a894 1341 * Update double buffer.
mbed_official 579:53297373a894 1342 *
mbed_official 579:53297373a894 1343 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1344 */
mbed_official 579:53297373a894 1345 static inline void tc_update_double_buffer(
mbed_official 579:53297373a894 1346 const struct tc_module *const module_inst)
mbed_official 579:53297373a894 1347 {
mbed_official 579:53297373a894 1348 /* Sanity check arguments */
mbed_official 579:53297373a894 1349 Assert(module_inst);
mbed_official 579:53297373a894 1350 Assert(module_inst->hw);
mbed_official 579:53297373a894 1351
mbed_official 579:53297373a894 1352 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1353 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1354
mbed_official 579:53297373a894 1355 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1356 /* Wait for sync */
mbed_official 579:53297373a894 1357 }
mbed_official 579:53297373a894 1358
mbed_official 579:53297373a894 1359 /* Make certain that there are no conflicting commands in the register */
mbed_official 579:53297373a894 1360 tc_module->CTRLBCLR.reg = TC_CTRLBCLR_CMD_NONE;
mbed_official 579:53297373a894 1361
mbed_official 579:53297373a894 1362 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1363 /* Wait for sync */
mbed_official 579:53297373a894 1364 }
mbed_official 579:53297373a894 1365
mbed_official 579:53297373a894 1366 /* Write command to execute */
mbed_official 579:53297373a894 1367 tc_module->CTRLBSET.reg = TC_CTRLBSET_CMD(3);
mbed_official 579:53297373a894 1368 }
mbed_official 579:53297373a894 1369 /** @} */
mbed_official 579:53297373a894 1370 #endif
mbed_official 579:53297373a894 1371
mbed_official 579:53297373a894 1372 #ifdef FEATURE_TC_READ_SYNC
mbed_official 579:53297373a894 1373 /**
mbed_official 579:53297373a894 1374 * \name Count Read Synchronization
mbed_official 579:53297373a894 1375 * @{
mbed_official 579:53297373a894 1376 */
mbed_official 579:53297373a894 1377
mbed_official 579:53297373a894 1378 /**
mbed_official 579:53297373a894 1379 * \brief Read synchronization of COUNT.
mbed_official 579:53297373a894 1380 *
mbed_official 579:53297373a894 1381 * Read synchronization of COUNT.
mbed_official 579:53297373a894 1382 *
mbed_official 579:53297373a894 1383 * \param[in] module_inst Pointer to the software module instance struct
mbed_official 579:53297373a894 1384 */
mbed_official 579:53297373a894 1385 static inline void tc_sync_read_count(
mbed_official 579:53297373a894 1386 const struct tc_module *const module_inst)
mbed_official 579:53297373a894 1387 {
mbed_official 579:53297373a894 1388 /* Sanity check arguments */
mbed_official 579:53297373a894 1389 Assert(module_inst);
mbed_official 579:53297373a894 1390 Assert(module_inst->hw);
mbed_official 579:53297373a894 1391
mbed_official 579:53297373a894 1392 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1393 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1394
mbed_official 579:53297373a894 1395 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1396 /* Wait for sync */
mbed_official 579:53297373a894 1397 }
mbed_official 579:53297373a894 1398
mbed_official 579:53297373a894 1399 /* Make certain that there are no conflicting commands in the register */
mbed_official 579:53297373a894 1400 tc_module->CTRLBCLR.reg = TC_CTRLBCLR_CMD_NONE;
mbed_official 579:53297373a894 1401
mbed_official 579:53297373a894 1402 while (tc_is_syncing(module_inst)) {
mbed_official 579:53297373a894 1403 /* Wait for sync */
mbed_official 579:53297373a894 1404 }
mbed_official 579:53297373a894 1405
mbed_official 579:53297373a894 1406 /* Write command to execute */
mbed_official 579:53297373a894 1407 tc_module->CTRLBSET.reg = TC_CTRLBSET_CMD(4);
mbed_official 579:53297373a894 1408 }
mbed_official 579:53297373a894 1409 /** @} */
mbed_official 579:53297373a894 1410 #endif
mbed_official 579:53297373a894 1411
mbed_official 579:53297373a894 1412 /**
mbed_official 579:53297373a894 1413 * \name Get Capture Set Compare
mbed_official 579:53297373a894 1414 * @{
mbed_official 579:53297373a894 1415 */
mbed_official 579:53297373a894 1416
mbed_official 579:53297373a894 1417 uint32_t tc_get_capture_value(
mbed_official 579:53297373a894 1418 const struct tc_module *const module_inst,
mbed_official 579:53297373a894 1419 const enum tc_compare_capture_channel channel_index);
mbed_official 579:53297373a894 1420
mbed_official 579:53297373a894 1421 enum status_code tc_set_compare_value(
mbed_official 579:53297373a894 1422 const struct tc_module *const module_inst,
mbed_official 579:53297373a894 1423 const enum tc_compare_capture_channel channel_index,
mbed_official 579:53297373a894 1424 const uint32_t compare_value);
mbed_official 579:53297373a894 1425
mbed_official 579:53297373a894 1426 /** @} */
mbed_official 579:53297373a894 1427
mbed_official 579:53297373a894 1428 /**
mbed_official 579:53297373a894 1429 * \name Set Top Value
mbed_official 579:53297373a894 1430 * @{
mbed_official 579:53297373a894 1431 */
mbed_official 579:53297373a894 1432
mbed_official 579:53297373a894 1433 enum status_code tc_set_top_value(
mbed_official 579:53297373a894 1434 const struct tc_module *const module_inst,
mbed_official 579:53297373a894 1435 const uint32_t top_value);
mbed_official 579:53297373a894 1436
mbed_official 579:53297373a894 1437 /** @} */
mbed_official 579:53297373a894 1438
mbed_official 579:53297373a894 1439 /**
mbed_official 579:53297373a894 1440 * \name Status Management
mbed_official 579:53297373a894 1441 * @{
mbed_official 579:53297373a894 1442 */
mbed_official 579:53297373a894 1443
mbed_official 579:53297373a894 1444 /**
mbed_official 579:53297373a894 1445 * \brief Retrieves the current module status.
mbed_official 579:53297373a894 1446 *
mbed_official 579:53297373a894 1447 * Retrieves the status of the module, giving overall state information.
mbed_official 579:53297373a894 1448 *
mbed_official 579:53297373a894 1449 * \param[in] module_inst Pointer to the TC software instance struct
mbed_official 579:53297373a894 1450 *
mbed_official 579:53297373a894 1451 * \return Bitmask of \c TC_STATUS_* flags.
mbed_official 579:53297373a894 1452 *
mbed_official 579:53297373a894 1453 * \retval TC_STATUS_CHANNEL_0_MATCH Timer channel 0 compare/capture match
mbed_official 579:53297373a894 1454 * \retval TC_STATUS_CHANNEL_1_MATCH Timer channel 1 compare/capture match
mbed_official 579:53297373a894 1455 * \retval TC_STATUS_SYNC_READY Timer read synchronization has completed
mbed_official 579:53297373a894 1456 * \retval TC_STATUS_CAPTURE_OVERFLOW Timer capture data has overflowed
mbed_official 579:53297373a894 1457 * \retval TC_STATUS_COUNT_OVERFLOW Timer count value has overflowed
mbed_official 579:53297373a894 1458 * \retval TC_STATUS_CHN0_BUFFER_VALID Timer count channel 0 compare/capture buffer valid
mbed_official 579:53297373a894 1459 * \retval TC_STATUS_CHN1_BUFFER_VALID Timer count channel 1 compare/capture buffer valid
mbed_official 579:53297373a894 1460 * \retval TC_STATUS_PERIOD_BUFFER_VALID Timer count period buffer valid
mbed_official 579:53297373a894 1461 */
mbed_official 579:53297373a894 1462 static inline uint32_t tc_get_status(
mbed_official 579:53297373a894 1463 struct tc_module *const module_inst)
mbed_official 579:53297373a894 1464 {
mbed_official 579:53297373a894 1465 /* Sanity check arguments */
mbed_official 579:53297373a894 1466 Assert(module_inst);
mbed_official 579:53297373a894 1467 Assert(module_inst->hw);
mbed_official 579:53297373a894 1468
mbed_official 579:53297373a894 1469 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1470 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1471
mbed_official 579:53297373a894 1472 uint32_t int_flags = tc_module->INTFLAG.reg;
mbed_official 579:53297373a894 1473
mbed_official 579:53297373a894 1474 uint32_t status_flags = 0;
mbed_official 579:53297373a894 1475
mbed_official 579:53297373a894 1476 /* Check for TC channel 0 match */
mbed_official 579:53297373a894 1477 if (int_flags & TC_INTFLAG_MC(1)) {
mbed_official 579:53297373a894 1478 status_flags |= TC_STATUS_CHANNEL_0_MATCH;
mbed_official 579:53297373a894 1479 }
mbed_official 579:53297373a894 1480
mbed_official 579:53297373a894 1481 /* Check for TC channel 1 match */
mbed_official 579:53297373a894 1482 if (int_flags & TC_INTFLAG_MC(2)) {
mbed_official 579:53297373a894 1483 status_flags |= TC_STATUS_CHANNEL_1_MATCH;
mbed_official 579:53297373a894 1484 }
mbed_official 579:53297373a894 1485
mbed_official 579:53297373a894 1486 #if !defined(FEATURE_TC_SYNCBUSY_SCHEME_VERSION_2)
mbed_official 579:53297373a894 1487 /* Check for TC read synchronization ready */
mbed_official 579:53297373a894 1488 if (int_flags & TC_INTFLAG_SYNCRDY) {
mbed_official 579:53297373a894 1489 status_flags |= TC_STATUS_SYNC_READY;
mbed_official 579:53297373a894 1490 }
mbed_official 579:53297373a894 1491 #endif
mbed_official 579:53297373a894 1492
mbed_official 579:53297373a894 1493 /* Check for TC capture overflow */
mbed_official 579:53297373a894 1494 if (int_flags & TC_INTFLAG_ERR) {
mbed_official 579:53297373a894 1495 status_flags |= TC_STATUS_CAPTURE_OVERFLOW;
mbed_official 579:53297373a894 1496 }
mbed_official 579:53297373a894 1497
mbed_official 579:53297373a894 1498 /* Check for TC count overflow */
mbed_official 579:53297373a894 1499 if (int_flags & TC_INTFLAG_OVF) {
mbed_official 579:53297373a894 1500 status_flags |= TC_STATUS_COUNT_OVERFLOW;
mbed_official 579:53297373a894 1501 }
mbed_official 579:53297373a894 1502 #ifdef FEATURE_TC_DOUBLE_BUFFERED
mbed_official 579:53297373a894 1503 uint8_t double_buffer_valid_status = tc_module->STATUS.reg;
mbed_official 579:53297373a894 1504
mbed_official 579:53297373a894 1505 /* Check channel 0 compare or capture buffer valid */
mbed_official 579:53297373a894 1506 if (double_buffer_valid_status & TC_STATUS_CCBUFV0) {
mbed_official 579:53297373a894 1507 status_flags |= TC_STATUS_CHN0_BUFFER_VALID;
mbed_official 579:53297373a894 1508 }
mbed_official 579:53297373a894 1509 /* Check channel 0 compare or capture buffer valid */
mbed_official 579:53297373a894 1510 if (double_buffer_valid_status & TC_STATUS_CCBUFV1) {
mbed_official 579:53297373a894 1511 status_flags |= TC_STATUS_CHN1_BUFFER_VALID;
mbed_official 579:53297373a894 1512 }
mbed_official 579:53297373a894 1513 /* Check period buffer valid */
mbed_official 579:53297373a894 1514 if (double_buffer_valid_status & TC_STATUS_PERBUFV) {
mbed_official 579:53297373a894 1515 status_flags |= TC_STATUS_PERIOD_BUFFER_VALID;
mbed_official 579:53297373a894 1516 }
mbed_official 579:53297373a894 1517 #endif
mbed_official 579:53297373a894 1518
mbed_official 579:53297373a894 1519 return status_flags;
mbed_official 579:53297373a894 1520 }
mbed_official 579:53297373a894 1521
mbed_official 579:53297373a894 1522 /**
mbed_official 579:53297373a894 1523 * \brief Clears a module status flag.
mbed_official 579:53297373a894 1524 *
mbed_official 579:53297373a894 1525 * Clears the given status flag of the module.
mbed_official 579:53297373a894 1526 *
mbed_official 579:53297373a894 1527 * \param[in] module_inst Pointer to the TC software instance struct
mbed_official 579:53297373a894 1528 * \param[in] status_flags Bitmask of \c TC_STATUS_* flags to clear
mbed_official 579:53297373a894 1529 */
mbed_official 579:53297373a894 1530 static inline void tc_clear_status(
mbed_official 579:53297373a894 1531 struct tc_module *const module_inst,
mbed_official 579:53297373a894 1532 const uint32_t status_flags)
mbed_official 579:53297373a894 1533 {
mbed_official 579:53297373a894 1534 /* Sanity check arguments */
mbed_official 579:53297373a894 1535 Assert(module_inst);
mbed_official 579:53297373a894 1536 Assert(module_inst->hw);
mbed_official 579:53297373a894 1537
mbed_official 579:53297373a894 1538 /* Get a pointer to the module's hardware instance */
mbed_official 579:53297373a894 1539 TcCount8 *const tc_module = &(module_inst->hw->COUNT8);
mbed_official 579:53297373a894 1540
mbed_official 579:53297373a894 1541 uint32_t int_flags = 0;
mbed_official 579:53297373a894 1542
mbed_official 579:53297373a894 1543 /* Check for TC channel 0 match */
mbed_official 579:53297373a894 1544 if (status_flags & TC_STATUS_CHANNEL_0_MATCH) {
mbed_official 579:53297373a894 1545 int_flags |= TC_INTFLAG_MC(1);
mbed_official 579:53297373a894 1546 }
mbed_official 579:53297373a894 1547
mbed_official 579:53297373a894 1548 /* Check for TC channel 1 match */
mbed_official 579:53297373a894 1549 if (status_flags & TC_STATUS_CHANNEL_1_MATCH) {
mbed_official 579:53297373a894 1550 int_flags |= TC_INTFLAG_MC(2);
mbed_official 579:53297373a894 1551 }
mbed_official 579:53297373a894 1552
mbed_official 579:53297373a894 1553 #if !defined(FEATURE_TC_SYNCBUSY_SCHEME_VERSION_2)
mbed_official 579:53297373a894 1554 /* Check for TC read synchronization ready */
mbed_official 579:53297373a894 1555 if (status_flags & TC_STATUS_SYNC_READY) {
mbed_official 579:53297373a894 1556 int_flags |= TC_INTFLAG_SYNCRDY;
mbed_official 579:53297373a894 1557 }
mbed_official 579:53297373a894 1558 #endif
mbed_official 579:53297373a894 1559
mbed_official 579:53297373a894 1560 /* Check for TC capture overflow */
mbed_official 579:53297373a894 1561 if (status_flags & TC_STATUS_CAPTURE_OVERFLOW) {
mbed_official 579:53297373a894 1562 int_flags |= TC_INTFLAG_ERR;
mbed_official 579:53297373a894 1563 }
mbed_official 579:53297373a894 1564
mbed_official 579:53297373a894 1565 /* Check for TC count overflow */
mbed_official 579:53297373a894 1566 if (status_flags & TC_STATUS_COUNT_OVERFLOW) {
mbed_official 579:53297373a894 1567 int_flags |= TC_INTFLAG_OVF;
mbed_official 579:53297373a894 1568 }
mbed_official 579:53297373a894 1569
mbed_official 579:53297373a894 1570 /* Clear interrupt flag */
mbed_official 579:53297373a894 1571 tc_module->INTFLAG.reg = int_flags;
mbed_official 579:53297373a894 1572 }
mbed_official 579:53297373a894 1573
mbed_official 579:53297373a894 1574 /** @} */
mbed_official 579:53297373a894 1575
mbed_official 579:53297373a894 1576 /** @} */
mbed_official 579:53297373a894 1577
mbed_official 579:53297373a894 1578 #ifdef __cplusplus
mbed_official 579:53297373a894 1579 }
mbed_official 579:53297373a894 1580 #endif
mbed_official 579:53297373a894 1581
mbed_official 579:53297373a894 1582 /**
mbed_official 579:53297373a894 1583 * \page asfdoc_sam0_tc_extra Extra Information for TC Driver
mbed_official 579:53297373a894 1584 *
mbed_official 579:53297373a894 1585 * \section asfdoc_sam0_tc_extra_acronyms Acronyms
mbed_official 579:53297373a894 1586 * The table below presents the acronyms used in this module:
mbed_official 579:53297373a894 1587 *
mbed_official 579:53297373a894 1588 * <table>
mbed_official 579:53297373a894 1589 * <tr>
mbed_official 579:53297373a894 1590 * <th>Acronym</th>
mbed_official 579:53297373a894 1591 * <th>Description</th>
mbed_official 579:53297373a894 1592 * </tr>
mbed_official 579:53297373a894 1593 * <tr>
mbed_official 579:53297373a894 1594 * <td>DMA</td>
mbed_official 579:53297373a894 1595 * <td>Direct Memory Access</td>
mbed_official 579:53297373a894 1596 * </tr>
mbed_official 579:53297373a894 1597 * <tr>
mbed_official 579:53297373a894 1598 * <td>TC</td>
mbed_official 579:53297373a894 1599 * <td>Timer Counter</td>
mbed_official 579:53297373a894 1600 * </tr>
mbed_official 579:53297373a894 1601 * <tr>
mbed_official 579:53297373a894 1602 * <td>PWM</td>
mbed_official 579:53297373a894 1603 * <td>Pulse Width Modulation</td>
mbed_official 579:53297373a894 1604 * </tr>
mbed_official 579:53297373a894 1605 * <tr>
mbed_official 579:53297373a894 1606 * <td>PWP</td>
mbed_official 579:53297373a894 1607 * <td>Pulse Width Period</td>
mbed_official 579:53297373a894 1608 * </tr>
mbed_official 579:53297373a894 1609 * <tr>
mbed_official 579:53297373a894 1610 * <td>PPW</td>
mbed_official 579:53297373a894 1611 * <td>Period Pulse Width</td>
mbed_official 579:53297373a894 1612 * </tr>
mbed_official 579:53297373a894 1613 * </table>
mbed_official 579:53297373a894 1614 *
mbed_official 579:53297373a894 1615 *
mbed_official 579:53297373a894 1616 * \section asfdoc_sam0_tc_extra_dependencies Dependencies
mbed_official 579:53297373a894 1617 * This driver has the following dependencies:
mbed_official 579:53297373a894 1618 *
mbed_official 579:53297373a894 1619 * - \ref asfdoc_sam0_system_pinmux_group "System Pin Multiplexer Driver"
mbed_official 579:53297373a894 1620 *
mbed_official 579:53297373a894 1621 *
mbed_official 579:53297373a894 1622 * \section asfdoc_sam0_tc_extra_errata Errata
mbed_official 579:53297373a894 1623 * There are no errata related to this driver.
mbed_official 579:53297373a894 1624 *
mbed_official 579:53297373a894 1625 *
mbed_official 579:53297373a894 1626 * \section asfdoc_sam0_tc_extra_history Module History
mbed_official 579:53297373a894 1627 * An overview of the module history is presented in the table below, with
mbed_official 579:53297373a894 1628 * details on the enhancements and fixes made to the module since its first
mbed_official 579:53297373a894 1629 * release. The current version of this corresponds to the newest version in
mbed_official 579:53297373a894 1630 * the table.
mbed_official 579:53297373a894 1631 *
mbed_official 579:53297373a894 1632 * <table>
mbed_official 579:53297373a894 1633 * <tr>
mbed_official 579:53297373a894 1634 * <th>Changelog</th>
mbed_official 579:53297373a894 1635 * </tr>
mbed_official 579:53297373a894 1636 * <tr>
mbed_official 579:53297373a894 1637 * <td>Added support for SAML21</td>
mbed_official 579:53297373a894 1638 * </tr>
mbed_official 579:53297373a894 1639 * <tr>
mbed_official 579:53297373a894 1640 * <td>Added support for SAMD10/D11</td>
mbed_official 579:53297373a894 1641 * </tr>
mbed_official 579:53297373a894 1642 * <tr>
mbed_official 579:53297373a894 1643 * <td>Added support for SAMR21</td>
mbed_official 579:53297373a894 1644 * </tr>
mbed_official 579:53297373a894 1645 * <tr>
mbed_official 579:53297373a894 1646 * <td>Added support for SAMD21 and do some modifications as below:
mbed_official 579:53297373a894 1647 * \li Clean up in the configuration structure, the counter size
mbed_official 579:53297373a894 1648 * setting specific registers is accessed through the counter_8_bit,
mbed_official 579:53297373a894 1649 * counter_16_bit and counter_32_bit structures
mbed_official 579:53297373a894 1650 * \li All event related settings moved into the tc_event structure </td>
mbed_official 579:53297373a894 1651 * </tr>
mbed_official 579:53297373a894 1652 * <tr>
mbed_official 579:53297373a894 1653 * <td>Added automatic digital clock interface enable for the slave TC
mbed_official 579:53297373a894 1654 * module when a timer is initialized in 32-bit mode</td>
mbed_official 579:53297373a894 1655 * </tr>
mbed_official 579:53297373a894 1656 * <tr>
mbed_official 579:53297373a894 1657 * <td>Initial Release</td>
mbed_official 579:53297373a894 1658 * </tr>
mbed_official 579:53297373a894 1659 * </table>
mbed_official 579:53297373a894 1660 */
mbed_official 579:53297373a894 1661
mbed_official 579:53297373a894 1662 /**
mbed_official 579:53297373a894 1663 * \page asfdoc_sam0_tc_exqsg Examples for TC Driver
mbed_official 579:53297373a894 1664 *
mbed_official 579:53297373a894 1665 * This is a list of the available Quick Start guides (QSGs) and example
mbed_official 579:53297373a894 1666 * applications for \ref asfdoc_sam0_tc_group. QSGs are simple examples with
mbed_official 579:53297373a894 1667 * step-by-step instructions to configure and use this driver in a selection of
mbed_official 579:53297373a894 1668 * use cases. Note that QSGs can be compiled as a standalone application or be
mbed_official 579:53297373a894 1669 * added to the user application.
mbed_official 579:53297373a894 1670 *
mbed_official 579:53297373a894 1671 * - \subpage asfdoc_sam0_tc_basic_use_case
mbed_official 579:53297373a894 1672 * \if TC_CALLBACK_MODE
mbed_official 579:53297373a894 1673 * - \subpage asfdoc_sam0_tc_timer_use_case
mbed_official 579:53297373a894 1674 * - \subpage asfdoc_sam0_tc_callback_use_case
mbed_official 579:53297373a894 1675 * \endif
mbed_official 579:53297373a894 1676 * - \subpage asfdoc_sam0_tc_dma_use_case
mbed_official 579:53297373a894 1677 *
mbed_official 579:53297373a894 1678 * \page asfdoc_sam0_tc_document_revision_history Document Revision History
mbed_official 579:53297373a894 1679 *
mbed_official 579:53297373a894 1680 * <table>
mbed_official 579:53297373a894 1681 * <tr>
mbed_official 579:53297373a894 1682 * <th>Doc. Rev.</td>
mbed_official 579:53297373a894 1683 * <th>Date</td>
mbed_official 579:53297373a894 1684 * <th>Comments</td>
mbed_official 579:53297373a894 1685 * </tr>
mbed_official 579:53297373a894 1686 * <tr>
mbed_official 579:53297373a894 1687 * <td>E</td>
mbed_official 579:53297373a894 1688 * <td>11/2014</td>
mbed_official 579:53297373a894 1689 * <td>Added support for SAML21.</td>
mbed_official 579:53297373a894 1690 * </tr>
mbed_official 579:53297373a894 1691 * <tr>
mbed_official 579:53297373a894 1692 * <td>D</td>
mbed_official 579:53297373a894 1693 * <td>12/2014</td>
mbed_official 579:53297373a894 1694 * <td>Added timer use case.
mbed_official 579:53297373a894 1695 * Added support for SAMR21 and SAMD10/D11.</td>
mbed_official 579:53297373a894 1696 * </tr>
mbed_official 579:53297373a894 1697 * <tr>
mbed_official 579:53297373a894 1698 * <td>C</td>
mbed_official 579:53297373a894 1699 * <td>01/2014</td>
mbed_official 579:53297373a894 1700 * <td>Added support for SAMD21.</td>
mbed_official 579:53297373a894 1701 * </tr>
mbed_official 579:53297373a894 1702 * <tr>
mbed_official 579:53297373a894 1703 * <td>B</td>
mbed_official 579:53297373a894 1704 * <td>06/2013</td>
mbed_official 579:53297373a894 1705 * <td>Corrected documentation typos.</td>
mbed_official 579:53297373a894 1706 * </tr>
mbed_official 579:53297373a894 1707 * <tr>
mbed_official 579:53297373a894 1708 * <td>A</td>
mbed_official 579:53297373a894 1709 * <td>06/2013</td>
mbed_official 579:53297373a894 1710 * <td>Initial release</td>
mbed_official 579:53297373a894 1711 * </tr>
mbed_official 579:53297373a894 1712 * </table>
mbed_official 579:53297373a894 1713 */
mbed_official 579:53297373a894 1714
mbed_official 579:53297373a894 1715 #endif /* TC_H_INCLUDED */