mbed library sources. Supersedes mbed-src.

Fork of mbed-dev by mbed official

Committer:
screamer
Date:
Tue Aug 02 14:07:36 2016 +0000
Revision:
144:423e1876dc07
Parent:
15:a81a8d6c1dfe
Added targets.json file for the supported targets in the release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 15:a81a8d6c1dfe 1 /**
mbed_official 15:a81a8d6c1dfe 2 * \file
mbed_official 15:a81a8d6c1dfe 3 *
mbed_official 15:a81a8d6c1dfe 4 * \brief SAM RTC Driver (Count Mode)
mbed_official 15:a81a8d6c1dfe 5 *
mbed_official 15:a81a8d6c1dfe 6 * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.
mbed_official 15:a81a8d6c1dfe 7 *
mbed_official 15:a81a8d6c1dfe 8 * \asf_license_start
mbed_official 15:a81a8d6c1dfe 9 *
mbed_official 15:a81a8d6c1dfe 10 * \page License
mbed_official 15:a81a8d6c1dfe 11 *
mbed_official 15:a81a8d6c1dfe 12 * Redistribution and use in source and binary forms, with or without
mbed_official 15:a81a8d6c1dfe 13 * modification, are permitted provided that the following conditions are met:
mbed_official 15:a81a8d6c1dfe 14 *
mbed_official 15:a81a8d6c1dfe 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 15:a81a8d6c1dfe 16 * this list of conditions and the following disclaimer.
mbed_official 15:a81a8d6c1dfe 17 *
mbed_official 15:a81a8d6c1dfe 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 15:a81a8d6c1dfe 19 * this list of conditions and the following disclaimer in the documentation
mbed_official 15:a81a8d6c1dfe 20 * and/or other materials provided with the distribution.
mbed_official 15:a81a8d6c1dfe 21 *
mbed_official 15:a81a8d6c1dfe 22 * 3. The name of Atmel may not be used to endorse or promote products derived
mbed_official 15:a81a8d6c1dfe 23 * from this software without specific prior written permission.
mbed_official 15:a81a8d6c1dfe 24 *
mbed_official 15:a81a8d6c1dfe 25 * 4. This software may only be redistributed and used in connection with an
mbed_official 15:a81a8d6c1dfe 26 * Atmel microcontroller product.
mbed_official 15:a81a8d6c1dfe 27 *
mbed_official 15:a81a8d6c1dfe 28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
mbed_official 15:a81a8d6c1dfe 29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
mbed_official 15:a81a8d6c1dfe 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
mbed_official 15:a81a8d6c1dfe 31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
mbed_official 15:a81a8d6c1dfe 32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 15:a81a8d6c1dfe 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
mbed_official 15:a81a8d6c1dfe 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
mbed_official 15:a81a8d6c1dfe 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
mbed_official 15:a81a8d6c1dfe 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
mbed_official 15:a81a8d6c1dfe 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
mbed_official 15:a81a8d6c1dfe 38 * POSSIBILITY OF SUCH DAMAGE.
mbed_official 15:a81a8d6c1dfe 39 *
mbed_official 15:a81a8d6c1dfe 40 * \asf_license_stop
mbed_official 15:a81a8d6c1dfe 41 *
mbed_official 15:a81a8d6c1dfe 42 */
mbed_official 15:a81a8d6c1dfe 43 /*
mbed_official 15:a81a8d6c1dfe 44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
mbed_official 15:a81a8d6c1dfe 45 */
mbed_official 15:a81a8d6c1dfe 46
mbed_official 15:a81a8d6c1dfe 47 #ifndef RTC_COUNT_H_INCLUDED
mbed_official 15:a81a8d6c1dfe 48 #define RTC_COUNT_H_INCLUDED
mbed_official 15:a81a8d6c1dfe 49
mbed_official 15:a81a8d6c1dfe 50 /**
mbed_official 15:a81a8d6c1dfe 51 * \defgroup asfdoc_sam0_rtc_count_group SAM RTC Count Driver (RTC COUNT)
mbed_official 15:a81a8d6c1dfe 52 *
mbed_official 15:a81a8d6c1dfe 53 * This driver for Atmel&reg; | SMART SAM devices provides an interface for the configuration
mbed_official 15:a81a8d6c1dfe 54 * and management of the device's Real Time Clock functionality in Count
mbed_official 15:a81a8d6c1dfe 55 * operating mode, for the configuration and retrieval of the current RTC
mbed_official 15:a81a8d6c1dfe 56 * counter value. The following driver API modes are covered by this
mbed_official 15:a81a8d6c1dfe 57 * manual:
mbed_official 15:a81a8d6c1dfe 58 *
mbed_official 15:a81a8d6c1dfe 59 * - Polled APIs
mbed_official 15:a81a8d6c1dfe 60 * \if RTC_COUNT_CALLBACK_MODE
mbed_official 15:a81a8d6c1dfe 61 * - Callback APIs
mbed_official 15:a81a8d6c1dfe 62 * \endif
mbed_official 15:a81a8d6c1dfe 63 *
mbed_official 15:a81a8d6c1dfe 64 * The following peripherals are used by this module:
mbed_official 15:a81a8d6c1dfe 65 * - RTC (Real Time Clock)
mbed_official 15:a81a8d6c1dfe 66 *
mbed_official 15:a81a8d6c1dfe 67 * The following devices can use this module:
mbed_official 15:a81a8d6c1dfe 68 * - Atmel | SMART SAM D20/D21
mbed_official 15:a81a8d6c1dfe 69 * - Atmel | SMART SAM R21
mbed_official 15:a81a8d6c1dfe 70 * - Atmel | SMART SAM D10/D11
mbed_official 15:a81a8d6c1dfe 71 * - Atmel | SMART SAM L21
mbed_official 15:a81a8d6c1dfe 72 * - Atmel | SMART SAM DAx
mbed_official 15:a81a8d6c1dfe 73 * - Atmel | SMART SAM C20/C21
mbed_official 15:a81a8d6c1dfe 74 *
mbed_official 15:a81a8d6c1dfe 75 * The outline of this documentation is as follows:
mbed_official 15:a81a8d6c1dfe 76 * - \ref asfdoc_sam0_rtc_count_prerequisites
mbed_official 15:a81a8d6c1dfe 77 * - \ref asfdoc_sam0_rtc_count_module_overview
mbed_official 15:a81a8d6c1dfe 78 * - \ref asfdoc_sam0_rtc_count_special_considerations
mbed_official 15:a81a8d6c1dfe 79 * - \ref asfdoc_sam0_rtc_count_extra_info
mbed_official 15:a81a8d6c1dfe 80 * - \ref asfdoc_sam0_rtc_count_examples
mbed_official 15:a81a8d6c1dfe 81 * - \ref asfdoc_sam0_rtc_count_api_overview
mbed_official 15:a81a8d6c1dfe 82 *
mbed_official 15:a81a8d6c1dfe 83 *
mbed_official 15:a81a8d6c1dfe 84 * \section asfdoc_sam0_rtc_count_prerequisites Prerequisites
mbed_official 15:a81a8d6c1dfe 85 *
mbed_official 15:a81a8d6c1dfe 86 * There are no prerequisites for this module.
mbed_official 15:a81a8d6c1dfe 87 *
mbed_official 15:a81a8d6c1dfe 88 *
mbed_official 15:a81a8d6c1dfe 89 * \section asfdoc_sam0_rtc_count_module_overview Module Overview
mbed_official 15:a81a8d6c1dfe 90 *
mbed_official 15:a81a8d6c1dfe 91 * The RTC module in the SAM devices is a 32-bit counter, with a 10-bit
mbed_official 15:a81a8d6c1dfe 92 * programmable prescaler. Typically, the RTC clock is run continuously,
mbed_official 15:a81a8d6c1dfe 93 * including in the device's low-power sleep modes, to track the current time
mbed_official 15:a81a8d6c1dfe 94 * and date information. The RTC can be used as a source to wake up the system
mbed_official 15:a81a8d6c1dfe 95 * at a scheduled time or periodically using the alarm functions.
mbed_official 15:a81a8d6c1dfe 96 *
mbed_official 15:a81a8d6c1dfe 97 * In this driver, the RTC is operated in Count mode. This allows for an
mbed_official 15:a81a8d6c1dfe 98 * easy integration of an asynchronous counter into a user application, which is
mbed_official 15:a81a8d6c1dfe 99 * capable of operating while the device is in sleep mode.
mbed_official 15:a81a8d6c1dfe 100 *
mbed_official 15:a81a8d6c1dfe 101 * Whilst operating in Count mode, the RTC features:
mbed_official 15:a81a8d6c1dfe 102 * - 16-bit counter mode
mbed_official 15:a81a8d6c1dfe 103 * - Selectable counter period
mbed_official 15:a81a8d6c1dfe 104 * - Up to six configurable compare values
mbed_official 15:a81a8d6c1dfe 105 * - 32-bit counter mode
mbed_official 15:a81a8d6c1dfe 106 * - Clear counter value on match
mbed_official 15:a81a8d6c1dfe 107 * - Up to four configurable compare values
mbed_official 15:a81a8d6c1dfe 108 *
mbed_official 15:a81a8d6c1dfe 109 * \subsection asfdoc_sam0_rtc_count_features Driver Feature Macro Definition
mbed_official 15:a81a8d6c1dfe 110 * <table>
mbed_official 15:a81a8d6c1dfe 111 * <tr>
mbed_official 15:a81a8d6c1dfe 112 * <th>Driver Feature Macro</th>
mbed_official 15:a81a8d6c1dfe 113 * <th>Supported devices</th>
mbed_official 15:a81a8d6c1dfe 114 * </tr>
mbed_official 15:a81a8d6c1dfe 115 * <tr>
mbed_official 15:a81a8d6c1dfe 116 * <td>FEATURE_RTC_PERIODIC_INT</td>
mbed_official 15:a81a8d6c1dfe 117 * <td>SAML21/C20/C21</td>
mbed_official 15:a81a8d6c1dfe 118 * </tr>
mbed_official 15:a81a8d6c1dfe 119 * <tr>
mbed_official 15:a81a8d6c1dfe 120 * <td>FEATURE_RTC_PRESCALER_OFF</td>
mbed_official 15:a81a8d6c1dfe 121 * <td>SAML21/C20/C21</td>
mbed_official 15:a81a8d6c1dfe 122 * </tr>
mbed_official 15:a81a8d6c1dfe 123 * <tr>
mbed_official 15:a81a8d6c1dfe 124 * <td>FEATURE_RTC_CLOCK_SELECTION</td>
mbed_official 15:a81a8d6c1dfe 125 * <td>SAML21/C20/C21</td>
mbed_official 15:a81a8d6c1dfe 126 * </tr>
mbed_official 15:a81a8d6c1dfe 127 * <tr>
mbed_official 15:a81a8d6c1dfe 128 * <td>FEATURE_RTC_GENERAL_PURPOSE_REG</td>
mbed_official 15:a81a8d6c1dfe 129 * <td>SAML21</td>
mbed_official 15:a81a8d6c1dfe 130 * </tr>
mbed_official 15:a81a8d6c1dfe 131 * <tr>
mbed_official 15:a81a8d6c1dfe 132 * <td>FEATURE_RTC_CONTINUOUSLY_UPDATED</td>
mbed_official 15:a81a8d6c1dfe 133 * <td>SAMD20, SAMD21, SAMR21, SAMD10, SAMD11, SAMDAx</td>
mbed_official 15:a81a8d6c1dfe 134 * </tr>
mbed_official 15:a81a8d6c1dfe 135 * </table>
mbed_official 15:a81a8d6c1dfe 136 * \note The specific features are only available in the driver when the
mbed_official 15:a81a8d6c1dfe 137 * selected device supports those features.
mbed_official 15:a81a8d6c1dfe 138 *
mbed_official 15:a81a8d6c1dfe 139 * \section asfdoc_sam0_rtc_count_module_overview_compares Compare and Overflow
mbed_official 15:a81a8d6c1dfe 140 * The RTC can be used with up to 4/6 compare values (depending on selected
mbed_official 15:a81a8d6c1dfe 141 * operation mode). These compare values will trigger on match with the current
mbed_official 15:a81a8d6c1dfe 142 * RTC counter value, and can be set up to trigger an interrupt, event, or both.
mbed_official 15:a81a8d6c1dfe 143 * The RTC can also be configured to clear the counter value on compare match
mbed_official 15:a81a8d6c1dfe 144 * in 32-bit mode, resetting the count value back to zero.
mbed_official 15:a81a8d6c1dfe 145 *
mbed_official 15:a81a8d6c1dfe 146 * If the RTC is operated without the Clear on Match option enabled, or in
mbed_official 15:a81a8d6c1dfe 147 * 16-bit mode, the RTC counter value will instead be cleared on overflow once
mbed_official 15:a81a8d6c1dfe 148 * the maximum count value has been reached:
mbed_official 15:a81a8d6c1dfe 149 *
mbed_official 15:a81a8d6c1dfe 150 * \f[ COUNT_{MAX} = 2^{32}-1 \f] for 32-bit counter mode, and
mbed_official 15:a81a8d6c1dfe 151 * \f[ COUNT_{MAX} = 2^{16}-1 \f] for 16-bit counter mode.
mbed_official 15:a81a8d6c1dfe 152 *
mbed_official 15:a81a8d6c1dfe 153 * When running in 16-bit mode, the overflow value is selectable with a period
mbed_official 15:a81a8d6c1dfe 154 * value. The counter overflow will then occur when the counter value reaches
mbed_official 15:a81a8d6c1dfe 155 * the specified period value.
mbed_official 15:a81a8d6c1dfe 156 *
mbed_official 15:a81a8d6c1dfe 157 * \subsection asfdoc_sam0_rtc_count_module_overview_periodic Periodic Events
mbed_official 15:a81a8d6c1dfe 158 * The RTC can generate events at periodic intervals, allowing for direct
mbed_official 15:a81a8d6c1dfe 159 * peripheral actions without CPU intervention. The periodic events can be
mbed_official 15:a81a8d6c1dfe 160 * generated on the upper eight bits of the RTC prescaler, and will be generated on
mbed_official 15:a81a8d6c1dfe 161 * the rising edge transition of the specified bit. The resulting periodic
mbed_official 15:a81a8d6c1dfe 162 * frequency can be calculated by the following formula:
mbed_official 15:a81a8d6c1dfe 163 *
mbed_official 15:a81a8d6c1dfe 164 * \f[ f_{PERIODIC}=\frac{f_{ASY}}{2^{n+3}} \f]
mbed_official 15:a81a8d6c1dfe 165 *
mbed_official 15:a81a8d6c1dfe 166 * Where \f$f_{ASY}\f$ refers to the \e asynchronous clock set up in the RTC
mbed_official 15:a81a8d6c1dfe 167 * module configuration. The \b n parameter is the event source generator index
mbed_official 15:a81a8d6c1dfe 168 * of the RTC module. If the asynchronous clock is operated at the recommended
mbed_official 15:a81a8d6c1dfe 169 * frequency of 1KHz, the formula results in the values shown in
mbed_official 15:a81a8d6c1dfe 170 * \ref asfdoc_sam0_rtc_count_module_rtc_hz "the table below".
mbed_official 15:a81a8d6c1dfe 171 *
mbed_official 15:a81a8d6c1dfe 172 * \anchor asfdoc_sam0_rtc_count_module_rtc_hz
mbed_official 15:a81a8d6c1dfe 173 * <table>
mbed_official 15:a81a8d6c1dfe 174 * <caption>RTC Event Frequencies for Each Prescaler Bit Using a 1KHz Clock</caption>
mbed_official 15:a81a8d6c1dfe 175 * <tr>
mbed_official 15:a81a8d6c1dfe 176 * <th>n</th> <th>Periodic event</th>
mbed_official 15:a81a8d6c1dfe 177 * </tr>
mbed_official 15:a81a8d6c1dfe 178 * <tr>
mbed_official 15:a81a8d6c1dfe 179 * <td>7</td> <td>1Hz</td>
mbed_official 15:a81a8d6c1dfe 180 * </tr>
mbed_official 15:a81a8d6c1dfe 181 * <tr>
mbed_official 15:a81a8d6c1dfe 182 * <td>6</td> <td>2Hz</td>
mbed_official 15:a81a8d6c1dfe 183 * </tr>
mbed_official 15:a81a8d6c1dfe 184 * <tr>
mbed_official 15:a81a8d6c1dfe 185 * <td>5</td> <td>4Hz</td>
mbed_official 15:a81a8d6c1dfe 186 * </tr>
mbed_official 15:a81a8d6c1dfe 187 * <tr>
mbed_official 15:a81a8d6c1dfe 188 * <td>4</td> <td>8Hz</td>
mbed_official 15:a81a8d6c1dfe 189 * </tr>
mbed_official 15:a81a8d6c1dfe 190 * <tr>
mbed_official 15:a81a8d6c1dfe 191 * <td>3</td> <td>16Hz</td>
mbed_official 15:a81a8d6c1dfe 192 * </tr>
mbed_official 15:a81a8d6c1dfe 193 * <tr>
mbed_official 15:a81a8d6c1dfe 194 * <td>2</td> <td>32Hz</td>
mbed_official 15:a81a8d6c1dfe 195 * </tr>
mbed_official 15:a81a8d6c1dfe 196 * <tr>
mbed_official 15:a81a8d6c1dfe 197 * <td>1</td> <td>64Hz</td>
mbed_official 15:a81a8d6c1dfe 198 * </tr>
mbed_official 15:a81a8d6c1dfe 199 * <tr>
mbed_official 15:a81a8d6c1dfe 200 * <td>0</td> <td>128Hz</td>
mbed_official 15:a81a8d6c1dfe 201 * </tr>
mbed_official 15:a81a8d6c1dfe 202 * </table>
mbed_official 15:a81a8d6c1dfe 203 *
mbed_official 15:a81a8d6c1dfe 204 * \note The connection of events between modules requires the use of the
mbed_official 15:a81a8d6c1dfe 205 * \ref asfdoc_sam0_events_group "SAM Event System Driver (EVENTS)"
mbed_official 15:a81a8d6c1dfe 206 * to route output event of one module to the the input event of another.
mbed_official 15:a81a8d6c1dfe 207 * For more information on event routing, refer to the event driver
mbed_official 15:a81a8d6c1dfe 208 * documentation.
mbed_official 15:a81a8d6c1dfe 209 *
mbed_official 15:a81a8d6c1dfe 210 * \subsection asfdoc_sam0_rtc_count_module_overview_correction Digital Frequency Correction
mbed_official 15:a81a8d6c1dfe 211 * The RTC module contains Digital Frequency Correction logic to compensate for
mbed_official 15:a81a8d6c1dfe 212 * inaccurate source clock frequencies which would otherwise result in skewed
mbed_official 15:a81a8d6c1dfe 213 * time measurements. The correction scheme requires that at least two bits
mbed_official 15:a81a8d6c1dfe 214 * in the RTC module prescaler are reserved by the correction logic. As a
mbed_official 15:a81a8d6c1dfe 215 * result of this implementation, frequency correction is only available when
mbed_official 15:a81a8d6c1dfe 216 * the RTC is running from a 1Hz reference clock.
mbed_official 15:a81a8d6c1dfe 217 *
mbed_official 15:a81a8d6c1dfe 218 * The correction procedure is implemented by subtracting or adding a single
mbed_official 15:a81a8d6c1dfe 219 * cycle from the RTC prescaler every 1024 RTC GCLK cycles. The adjustment is
mbed_official 15:a81a8d6c1dfe 220 * applied the specified number of time (maximum 127) over 976 of these periods. The
mbed_official 15:a81a8d6c1dfe 221 * corresponding correction in PPM will be given by:
mbed_official 15:a81a8d6c1dfe 222 *
mbed_official 15:a81a8d6c1dfe 223 * \f[ Correction(PPM) = \frac{VALUE}{999424}10^6 \f]
mbed_official 15:a81a8d6c1dfe 224 *
mbed_official 15:a81a8d6c1dfe 225 * The RTC clock will tick faster if provided with a positive correction value,
mbed_official 15:a81a8d6c1dfe 226 * and slower when given a negative correction value.
mbed_official 15:a81a8d6c1dfe 227 *
mbed_official 15:a81a8d6c1dfe 228 *
mbed_official 15:a81a8d6c1dfe 229 * \section asfdoc_sam0_rtc_count_special_considerations Special Considerations
mbed_official 15:a81a8d6c1dfe 230 *
mbed_official 15:a81a8d6c1dfe 231 * \subsection asfdoc_sam0_rtc_count_special_considerations_clock Clock Setup
mbed_official 15:a81a8d6c1dfe 232 * \subsubsection asfdoc_sam0_rtc_count_clock_samd_r SAM D20/D21/R21/D10/D11/DA0/DA1 Clock Setup
mbed_official 15:a81a8d6c1dfe 233 * The RTC is typically clocked by a specialized GCLK generator that has a
mbed_official 15:a81a8d6c1dfe 234 * smaller prescaler than the others. By default the RTC clock is on, selected
mbed_official 15:a81a8d6c1dfe 235 * to use the internal 32KHz RC-oscillator with a prescaler of 32, giving a
mbed_official 15:a81a8d6c1dfe 236 * resulting clock frequency of 1KHz to the RTC. When the internal RTC
mbed_official 15:a81a8d6c1dfe 237 * prescaler is set to 1024, this yields an end-frequency of 1Hz.
mbed_official 15:a81a8d6c1dfe 238 *
mbed_official 15:a81a8d6c1dfe 239 * The implementer also has the option to set other end-frequencies.
mbed_official 15:a81a8d6c1dfe 240 * \ref asfdoc_sam0_rtc_count_rtc_out_freq "The table below" lists the
mbed_official 15:a81a8d6c1dfe 241 * available RTC frequencies for each possible GCLK and RTC input prescaler
mbed_official 15:a81a8d6c1dfe 242 * options.
mbed_official 15:a81a8d6c1dfe 243 *
mbed_official 15:a81a8d6c1dfe 244 * \anchor asfdoc_sam0_rtc_count_rtc_out_freq
mbed_official 15:a81a8d6c1dfe 245 * <table>
mbed_official 15:a81a8d6c1dfe 246 * <caption>RTC Output Frequencies from Allowable Input Clocks</caption>
mbed_official 15:a81a8d6c1dfe 247 * <tr>
mbed_official 15:a81a8d6c1dfe 248 * <th>End-frequency</th>
mbed_official 15:a81a8d6c1dfe 249 * <th>GCLK prescaler</th>
mbed_official 15:a81a8d6c1dfe 250 * <th>RTC prescaler</th>
mbed_official 15:a81a8d6c1dfe 251 * </tr>
mbed_official 15:a81a8d6c1dfe 252 * <tr>
mbed_official 15:a81a8d6c1dfe 253 * <td>32KHz</td>
mbed_official 15:a81a8d6c1dfe 254 * <td>1</td>
mbed_official 15:a81a8d6c1dfe 255 * <td>1</td>
mbed_official 15:a81a8d6c1dfe 256 * </tr>
mbed_official 15:a81a8d6c1dfe 257 * <tr>
mbed_official 15:a81a8d6c1dfe 258 * <td>1KHz</td>
mbed_official 15:a81a8d6c1dfe 259 * <td>32</td>
mbed_official 15:a81a8d6c1dfe 260 * <td>1</td>
mbed_official 15:a81a8d6c1dfe 261 * </tr>
mbed_official 15:a81a8d6c1dfe 262 * <tr>
mbed_official 15:a81a8d6c1dfe 263 * <td>1Hz</td>
mbed_official 15:a81a8d6c1dfe 264 * <td>32</td>
mbed_official 15:a81a8d6c1dfe 265 * <td>1024</td>
mbed_official 15:a81a8d6c1dfe 266 * </tr>
mbed_official 15:a81a8d6c1dfe 267 * </table>
mbed_official 15:a81a8d6c1dfe 268 *
mbed_official 15:a81a8d6c1dfe 269 * The overall RTC module clocking scheme is shown in
mbed_official 15:a81a8d6c1dfe 270 * \ref asfdoc_sam0_rtc_count_rtc_clock_fig "the figure below".
mbed_official 15:a81a8d6c1dfe 271 *
mbed_official 15:a81a8d6c1dfe 272 * \anchor asfdoc_sam0_rtc_count_rtc_clock_fig
mbed_official 15:a81a8d6c1dfe 273 * \dot
mbed_official 15:a81a8d6c1dfe 274 * digraph clocking_scheme {
mbed_official 15:a81a8d6c1dfe 275 * rankdir=LR;
mbed_official 15:a81a8d6c1dfe 276 * GCLK [shape="record", label="<f0> GCLK | <f1> RTC_GCLK",
mbed_official 15:a81a8d6c1dfe 277 * bgcolor="lightgray", style="filled"];
mbed_official 15:a81a8d6c1dfe 278 * RTCPRE [shape="record" label="<f0> RTC | <f1> RTC PRESCALER"];
mbed_official 15:a81a8d6c1dfe 279 * RTC [shape="record", label="<f0> RTC | <f1> RTC CLOCK"];
mbed_official 15:a81a8d6c1dfe 280 *
mbed_official 15:a81a8d6c1dfe 281 * GCLK:f1 -> RTCPRE:f1;
mbed_official 15:a81a8d6c1dfe 282 * RTCPRE:f1 -> RTC:f1;
mbed_official 15:a81a8d6c1dfe 283 * }
mbed_official 15:a81a8d6c1dfe 284 * \enddot
mbed_official 15:a81a8d6c1dfe 285 *
mbed_official 15:a81a8d6c1dfe 286 * \subsubsection asfdoc_sam0_rtc_count_clock_saml SAM L21/C20/C21 Clock Setup
mbed_official 15:a81a8d6c1dfe 287 * The RTC clock can be selected from OSC32K,XOSC32K or OSCULP32K , and a 32KHz
mbed_official 15:a81a8d6c1dfe 288 * or 1KHz oscillator clock frequency is required. This clock must be
mbed_official 15:a81a8d6c1dfe 289 * configured and enabled in the 32KHz oscillator controller before using the RTC.
mbed_official 15:a81a8d6c1dfe 290 *
mbed_official 15:a81a8d6c1dfe 291 * The table below lists the available RTC clock \ref asfdoc_sam0_rtc_count_rtc_clk
mbed_official 15:a81a8d6c1dfe 292 *
mbed_official 15:a81a8d6c1dfe 293 * \anchor asfdoc_sam0_rtc_count_rtc_clk
mbed_official 15:a81a8d6c1dfe 294 * <table>
mbed_official 15:a81a8d6c1dfe 295 * <caption>RTC clocks source</caption>
mbed_official 15:a81a8d6c1dfe 296 * <tr>
mbed_official 15:a81a8d6c1dfe 297 * <th>RTC clock frequency</th>
mbed_official 15:a81a8d6c1dfe 298 * <th>Clock source</th>
mbed_official 15:a81a8d6c1dfe 299 * <th>Description</th>
mbed_official 15:a81a8d6c1dfe 300 * </tr>
mbed_official 15:a81a8d6c1dfe 301 * <tr>
mbed_official 15:a81a8d6c1dfe 302 * <td>1.024KHz</td>
mbed_official 15:a81a8d6c1dfe 303 * <td>ULP1K</td>
mbed_official 15:a81a8d6c1dfe 304 * <td>1.024KHz from 32KHz internal ULP oscillator</td>
mbed_official 15:a81a8d6c1dfe 305 * </tr>
mbed_official 15:a81a8d6c1dfe 306 * <tr>
mbed_official 15:a81a8d6c1dfe 307 * <td>32.768KHz</td>
mbed_official 15:a81a8d6c1dfe 308 * <td>ULP32K</td>
mbed_official 15:a81a8d6c1dfe 309 * <td>32.768KHz from 32KHz internal ULP oscillator</td>
mbed_official 15:a81a8d6c1dfe 310 * </tr>
mbed_official 15:a81a8d6c1dfe 311 * <tr>
mbed_official 15:a81a8d6c1dfe 312 * <td>1.024KHz</td>
mbed_official 15:a81a8d6c1dfe 313 * <td>OSC1K</td>
mbed_official 15:a81a8d6c1dfe 314 * <td>1.024KHz from 32KHz internal oscillator</td>
mbed_official 15:a81a8d6c1dfe 315 * </tr>
mbed_official 15:a81a8d6c1dfe 316 * <tr>
mbed_official 15:a81a8d6c1dfe 317 * <td>32.768KHz</td>
mbed_official 15:a81a8d6c1dfe 318 * <td>OSC32K</td>
mbed_official 15:a81a8d6c1dfe 319 * <td>32.768KHz from 32KHz internal oscillator</td>
mbed_official 15:a81a8d6c1dfe 320 * </tr>
mbed_official 15:a81a8d6c1dfe 321 * <tr>
mbed_official 15:a81a8d6c1dfe 322 * <td>1.024KHz</td>
mbed_official 15:a81a8d6c1dfe 323 * <td>XOSC1K</td>
mbed_official 15:a81a8d6c1dfe 324 * <td>1.024KHz from 32KHz internal oscillator</td>
mbed_official 15:a81a8d6c1dfe 325 * </tr>
mbed_official 15:a81a8d6c1dfe 326 * <tr>
mbed_official 15:a81a8d6c1dfe 327 * <td>32.768KHz</td>
mbed_official 15:a81a8d6c1dfe 328 * <td>XOSC32K</td>
mbed_official 15:a81a8d6c1dfe 329 * <td>32.768KHz from 32KHz external crystal oscillator</td>
mbed_official 15:a81a8d6c1dfe 330 * </tr>
mbed_official 15:a81a8d6c1dfe 331 * </table>
mbed_official 15:a81a8d6c1dfe 332 *
mbed_official 15:a81a8d6c1dfe 333 * \section asfdoc_sam0_rtc_count_extra_info Extra Information
mbed_official 15:a81a8d6c1dfe 334 *
mbed_official 15:a81a8d6c1dfe 335 * For extra information, see \ref asfdoc_sam0_rtc_count_extra. This includes:
mbed_official 15:a81a8d6c1dfe 336 * - \ref asfdoc_sam0_rtc_count_extra_acronyms
mbed_official 15:a81a8d6c1dfe 337 * - \ref asfdoc_sam0_rtc_count_extra_dependencies
mbed_official 15:a81a8d6c1dfe 338 * - \ref asfdoc_sam0_rtc_count_extra_errata
mbed_official 15:a81a8d6c1dfe 339 * - \ref asfdoc_sam0_rtc_count_extra_history
mbed_official 15:a81a8d6c1dfe 340 *
mbed_official 15:a81a8d6c1dfe 341 *
mbed_official 15:a81a8d6c1dfe 342 * \section asfdoc_sam0_rtc_count_examples Examples
mbed_official 15:a81a8d6c1dfe 343 *
mbed_official 15:a81a8d6c1dfe 344 * For a list of examples related to this driver, see
mbed_official 15:a81a8d6c1dfe 345 * \ref asfdoc_sam0_rtc_count_exqsg.
mbed_official 15:a81a8d6c1dfe 346 *
mbed_official 15:a81a8d6c1dfe 347 *
mbed_official 15:a81a8d6c1dfe 348 * \section asfdoc_sam0_rtc_count_api_overview API Overview
mbed_official 15:a81a8d6c1dfe 349 * @{
mbed_official 15:a81a8d6c1dfe 350 */
mbed_official 15:a81a8d6c1dfe 351
mbed_official 15:a81a8d6c1dfe 352 #include <compiler.h>
mbed_official 15:a81a8d6c1dfe 353 #include <conf_clocks.h>
mbed_official 15:a81a8d6c1dfe 354
mbed_official 15:a81a8d6c1dfe 355 #if RTC_COUNT_ASYNC == true
mbed_official 15:a81a8d6c1dfe 356 # include <system_interrupt.h>
mbed_official 15:a81a8d6c1dfe 357 #endif
mbed_official 15:a81a8d6c1dfe 358
mbed_official 15:a81a8d6c1dfe 359 #ifdef __cplusplus
mbed_official 15:a81a8d6c1dfe 360 extern "C" {
mbed_official 15:a81a8d6c1dfe 361 #endif
mbed_official 15:a81a8d6c1dfe 362
mbed_official 15:a81a8d6c1dfe 363 /**
mbed_official 15:a81a8d6c1dfe 364 * Define port features set according to different device family
mbed_official 15:a81a8d6c1dfe 365 * @{
mbed_official 15:a81a8d6c1dfe 366 */
mbed_official 15:a81a8d6c1dfe 367 #if (SAML21) || (SAMC20) || (SAMC21) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 368 /** RTC periodic interval interrupt. */
mbed_official 15:a81a8d6c1dfe 369 # define FEATURE_RTC_PERIODIC_INT
mbed_official 15:a81a8d6c1dfe 370 /** RTC prescaler is off. */
mbed_official 15:a81a8d6c1dfe 371 # define FEATURE_RTC_PRESCALER_OFF
mbed_official 15:a81a8d6c1dfe 372 /** RTC clock selection. */
mbed_official 15:a81a8d6c1dfe 373 # define FEATURE_RTC_CLOCK_SELECTION
mbed_official 15:a81a8d6c1dfe 374 # if !(SAMC20) && !(SAMC21)
mbed_official 15:a81a8d6c1dfe 375 /** General purpose registers. */
mbed_official 15:a81a8d6c1dfe 376 # define FEATURE_RTC_GENERAL_PURPOSE_REG
mbed_official 15:a81a8d6c1dfe 377 # endif
mbed_official 15:a81a8d6c1dfe 378 #else
mbed_official 15:a81a8d6c1dfe 379 /** RTC continuously updated. */
mbed_official 15:a81a8d6c1dfe 380 # define FEATURE_RTC_CONTINUOUSLY_UPDATED
mbed_official 15:a81a8d6c1dfe 381 #endif
mbed_official 15:a81a8d6c1dfe 382 /*@}*/
mbed_official 15:a81a8d6c1dfe 383
mbed_official 15:a81a8d6c1dfe 384 #ifdef FEATURE_RTC_CLOCK_SELECTION
mbed_official 15:a81a8d6c1dfe 385 /**
mbed_official 15:a81a8d6c1dfe 386 * \brief Available clock source for RTC.
mbed_official 15:a81a8d6c1dfe 387 * RTC clock source.
mbed_official 15:a81a8d6c1dfe 388 */
mbed_official 15:a81a8d6c1dfe 389 enum rtc_clock_sel {
mbed_official 15:a81a8d6c1dfe 390 /** 1.024KHz from 32KHz internal ULP oscillator. */
mbed_official 15:a81a8d6c1dfe 391 RTC_CLOCK_SELECTION_ULP1K = OSC32KCTRL_RTCCTRL_RTCSEL_ULP1K_Val,
mbed_official 15:a81a8d6c1dfe 392 /** 32.768KHz from 32KHz internal ULP oscillator. */
mbed_official 15:a81a8d6c1dfe 393 RTC_CLOCK_SELECTION_ULP32K = OSC32KCTRL_RTCCTRL_RTCSEL_ULP32K_Val,
mbed_official 15:a81a8d6c1dfe 394 /** 1.024KHz from 32KHz internal oscillator. */
mbed_official 15:a81a8d6c1dfe 395 RTC_CLOCK_SELECTION_OSC1K = OSC32KCTRL_RTCCTRL_RTCSEL_OSC1K_Val,
mbed_official 15:a81a8d6c1dfe 396 /** 32.768KHz from 32KHz internal oscillator. */
mbed_official 15:a81a8d6c1dfe 397 RTC_CLOCK_SELECTION_OSC32K = OSC32KCTRL_RTCCTRL_RTCSEL_OSC32K_Val,
mbed_official 15:a81a8d6c1dfe 398 /** 1.024KHz from 32KHz internal oscillator. */
mbed_official 15:a81a8d6c1dfe 399 RTC_CLOCK_SELECTION_XOSC1K = OSC32KCTRL_RTCCTRL_RTCSEL_XOSC1K_Val,
mbed_official 15:a81a8d6c1dfe 400 /** 32.768KHz from 32.768KHz external crystal oscillator. */
mbed_official 15:a81a8d6c1dfe 401 RTC_CLOCK_SELECTION_XOSC32K = OSC32KCTRL_RTCCTRL_RTCSEL_XOSC32K_Val,
mbed_official 15:a81a8d6c1dfe 402 };
mbed_official 15:a81a8d6c1dfe 403 #endif
mbed_official 15:a81a8d6c1dfe 404
mbed_official 15:a81a8d6c1dfe 405 /**
mbed_official 15:a81a8d6c1dfe 406 * \brief Available operation modes for the RTC.
mbed_official 15:a81a8d6c1dfe 407 *
mbed_official 15:a81a8d6c1dfe 408 * RTC Count operating modes, to select the counting width and associated module
mbed_official 15:a81a8d6c1dfe 409 * operation.
mbed_official 15:a81a8d6c1dfe 410 */
mbed_official 15:a81a8d6c1dfe 411 enum rtc_count_mode {
mbed_official 15:a81a8d6c1dfe 412 /** RTC Count module operates in 16-bit mode. */
mbed_official 15:a81a8d6c1dfe 413 RTC_COUNT_MODE_16BIT = 0,
mbed_official 15:a81a8d6c1dfe 414 /** RTC Count module operates in 32-bit mode. */
mbed_official 15:a81a8d6c1dfe 415 RTC_COUNT_MODE_32BIT = 1,
mbed_official 15:a81a8d6c1dfe 416 };
mbed_official 15:a81a8d6c1dfe 417
mbed_official 15:a81a8d6c1dfe 418 #if !defined (RTC_NUM_OF_COMP16) && defined(RTC_COMP16_NUM)
mbed_official 15:a81a8d6c1dfe 419 #define RTC_NUM_OF_COMP16 RTC_COMP16_NUM
mbed_official 15:a81a8d6c1dfe 420 #endif
mbed_official 15:a81a8d6c1dfe 421
mbed_official 15:a81a8d6c1dfe 422 /**
mbed_official 15:a81a8d6c1dfe 423 * \brief Available compare channels.
mbed_official 15:a81a8d6c1dfe 424 *
mbed_official 15:a81a8d6c1dfe 425 * \note Not all compare channels are available in all devices and modes.
mbed_official 15:a81a8d6c1dfe 426 */
mbed_official 15:a81a8d6c1dfe 427 enum rtc_count_compare {
mbed_official 15:a81a8d6c1dfe 428 /** Compare channel 0. */
mbed_official 15:a81a8d6c1dfe 429 RTC_COUNT_COMPARE_0 = 0,
mbed_official 15:a81a8d6c1dfe 430 #if (RTC_NUM_OF_COMP16 > 1) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 431 /** Compare channel 1. */
mbed_official 15:a81a8d6c1dfe 432 RTC_COUNT_COMPARE_1 = 1,
mbed_official 15:a81a8d6c1dfe 433 #endif
mbed_official 15:a81a8d6c1dfe 434 #if (RTC_NUM_OF_COMP16 > 2) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 435 /** Compare channel 2. */
mbed_official 15:a81a8d6c1dfe 436 RTC_COUNT_COMPARE_2 = 2,
mbed_official 15:a81a8d6c1dfe 437 #endif
mbed_official 15:a81a8d6c1dfe 438 #if (RTC_NUM_OF_COMP16 > 3) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 439 /** Compare channel 3. */
mbed_official 15:a81a8d6c1dfe 440 RTC_COUNT_COMPARE_3 = 3,
mbed_official 15:a81a8d6c1dfe 441 #endif
mbed_official 15:a81a8d6c1dfe 442 #if (RTC_NUM_OF_COMP16 > 4) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 443 /** Compare channel 4. */
mbed_official 15:a81a8d6c1dfe 444 RTC_COUNT_COMPARE_4 = 4,
mbed_official 15:a81a8d6c1dfe 445 #endif
mbed_official 15:a81a8d6c1dfe 446 #if (RTC_NUM_OF_COMP16 > 5) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 447 /** Compare channel 5. */
mbed_official 15:a81a8d6c1dfe 448 RTC_COUNT_COMPARE_5 = 5,
mbed_official 15:a81a8d6c1dfe 449 #endif
mbed_official 15:a81a8d6c1dfe 450 };
mbed_official 15:a81a8d6c1dfe 451
mbed_official 15:a81a8d6c1dfe 452 #ifdef FEATURE_RTC_PERIODIC_INT
mbed_official 15:a81a8d6c1dfe 453 /**
mbed_official 15:a81a8d6c1dfe 454 * \brief Available periodic interval source.
mbed_official 15:a81a8d6c1dfe 455 */
mbed_official 15:a81a8d6c1dfe 456 enum rtc_count_periodic_interval {
mbed_official 15:a81a8d6c1dfe 457 /** Periodic interval 0. */
mbed_official 15:a81a8d6c1dfe 458 RTC_COUNT_PERIODIC_INTERVAL_0 = 0,
mbed_official 15:a81a8d6c1dfe 459 /** Periodic interval 1. */
mbed_official 15:a81a8d6c1dfe 460 RTC_COUNT_PERIODIC_INTERVAL_1 = 1,
mbed_official 15:a81a8d6c1dfe 461 /** Periodic interval 2. */
mbed_official 15:a81a8d6c1dfe 462 RTC_COUNT_PERIODIC_INTERVAL_2 = 2,
mbed_official 15:a81a8d6c1dfe 463 /** Periodic interval 3. */
mbed_official 15:a81a8d6c1dfe 464 RTC_COUNT_PERIODIC_INTERVAL_3 = 3,
mbed_official 15:a81a8d6c1dfe 465 /** Periodic interval 4. */
mbed_official 15:a81a8d6c1dfe 466 RTC_COUNT_PERIODIC_INTERVAL_4 = 4,
mbed_official 15:a81a8d6c1dfe 467 /** Periodic interval 5. */
mbed_official 15:a81a8d6c1dfe 468 RTC_COUNT_PERIODIC_INTERVAL_5 = 5,
mbed_official 15:a81a8d6c1dfe 469 /** Periodic interval 6. */
mbed_official 15:a81a8d6c1dfe 470 RTC_COUNT_PERIODIC_INTERVAL_6 = 6,
mbed_official 15:a81a8d6c1dfe 471 /** Periodic interval 7. */
mbed_official 15:a81a8d6c1dfe 472 RTC_COUNT_PERIODIC_INTERVAL_7 = 7,
mbed_official 15:a81a8d6c1dfe 473 };
mbed_official 15:a81a8d6c1dfe 474 #endif
mbed_official 15:a81a8d6c1dfe 475
mbed_official 15:a81a8d6c1dfe 476 #if RTC_COUNT_ASYNC == true
mbed_official 15:a81a8d6c1dfe 477 #ifdef FEATURE_RTC_PERIODIC_INT
mbed_official 15:a81a8d6c1dfe 478 /**
mbed_official 15:a81a8d6c1dfe 479 * \brief Callback types.
mbed_official 15:a81a8d6c1dfe 480 *
mbed_official 15:a81a8d6c1dfe 481 * The available callback types for the RTC count module.
mbed_official 15:a81a8d6c1dfe 482 */
mbed_official 15:a81a8d6c1dfe 483 enum rtc_count_callback {
mbed_official 15:a81a8d6c1dfe 484 /** Callback for Periodic Interval 0 Interrupt. */
mbed_official 15:a81a8d6c1dfe 485 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_0 = 0,
mbed_official 15:a81a8d6c1dfe 486 /** Callback for Periodic Interval 1 Interrupt. */
mbed_official 15:a81a8d6c1dfe 487 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_1,
mbed_official 15:a81a8d6c1dfe 488 /** Callback for Periodic Interval 2 Interrupt. */
mbed_official 15:a81a8d6c1dfe 489 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_2,
mbed_official 15:a81a8d6c1dfe 490 /** Callback for Periodic Interval 3 Interrupt. */
mbed_official 15:a81a8d6c1dfe 491 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_3,
mbed_official 15:a81a8d6c1dfe 492 /** Callback for Periodic Interval 4 Interrupt. */
mbed_official 15:a81a8d6c1dfe 493 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_4,
mbed_official 15:a81a8d6c1dfe 494 /** Callback for Periodic Interval 5 Interrupt. */
mbed_official 15:a81a8d6c1dfe 495 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_5,
mbed_official 15:a81a8d6c1dfe 496 /** Callback for Periodic Interval 6 Interrupt. */
mbed_official 15:a81a8d6c1dfe 497 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_6,
mbed_official 15:a81a8d6c1dfe 498 /** Callback for Periodic Interval 7 Interrupt. */
mbed_official 15:a81a8d6c1dfe 499 RTC_COUNT_CALLBACK_PERIODIC_INTERVAL_7,
mbed_official 15:a81a8d6c1dfe 500 /** Callback for compare channel 0. */
mbed_official 15:a81a8d6c1dfe 501 RTC_COUNT_CALLBACK_COMPARE_0,
mbed_official 15:a81a8d6c1dfe 502 # if (RTC_NUM_OF_COMP16 > 1) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 503 /** Callback for compare channel 1. */
mbed_official 15:a81a8d6c1dfe 504 RTC_COUNT_CALLBACK_COMPARE_1,
mbed_official 15:a81a8d6c1dfe 505 # endif
mbed_official 15:a81a8d6c1dfe 506 # if (RTC_NUM_OF_COMP16 > 2) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 507 /** Callback for compare channel 2. */
mbed_official 15:a81a8d6c1dfe 508 RTC_COUNT_CALLBACK_COMPARE_2,
mbed_official 15:a81a8d6c1dfe 509 # endif
mbed_official 15:a81a8d6c1dfe 510 # if (RTC_NUM_OF_COMP16 > 3) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 511 /** Callback for compare channel 3. */
mbed_official 15:a81a8d6c1dfe 512 RTC_COUNT_CALLBACK_COMPARE_3,
mbed_official 15:a81a8d6c1dfe 513 # endif
mbed_official 15:a81a8d6c1dfe 514 # if (RTC_NUM_OF_COMP16 > 4) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 515 /** Callback for compare channel 4. */
mbed_official 15:a81a8d6c1dfe 516 RTC_COUNT_CALLBACK_COMPARE_4,
mbed_official 15:a81a8d6c1dfe 517 # endif
mbed_official 15:a81a8d6c1dfe 518 # if (RTC_NUM_OF_COMP16 > 5) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 519 /** Callback for compare channel 5. */
mbed_official 15:a81a8d6c1dfe 520 RTC_COUNT_CALLBACK_COMPARE_5,
mbed_official 15:a81a8d6c1dfe 521 # endif
mbed_official 15:a81a8d6c1dfe 522
mbed_official 15:a81a8d6c1dfe 523 /** Callback for overflow. */
mbed_official 15:a81a8d6c1dfe 524 RTC_COUNT_CALLBACK_OVERFLOW,
mbed_official 15:a81a8d6c1dfe 525 # if !defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 526 /** Total number of callbacks. */
mbed_official 15:a81a8d6c1dfe 527 _RTC_COUNT_CALLBACK_N
mbed_official 15:a81a8d6c1dfe 528 # endif
mbed_official 15:a81a8d6c1dfe 529 };
mbed_official 15:a81a8d6c1dfe 530 #else
mbed_official 15:a81a8d6c1dfe 531 /**
mbed_official 15:a81a8d6c1dfe 532 * \brief Callback types.
mbed_official 15:a81a8d6c1dfe 533 *
mbed_official 15:a81a8d6c1dfe 534 * The available callback types for the RTC count module.
mbed_official 15:a81a8d6c1dfe 535 */
mbed_official 15:a81a8d6c1dfe 536 enum rtc_count_callback {
mbed_official 15:a81a8d6c1dfe 537 /** Callback for compare channel 0. */
mbed_official 15:a81a8d6c1dfe 538 RTC_COUNT_CALLBACK_COMPARE_0 = 0,
mbed_official 15:a81a8d6c1dfe 539 # if (RTC_NUM_OF_COMP16 > 1) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 540 /** Callback for compare channel 1. */
mbed_official 15:a81a8d6c1dfe 541 RTC_COUNT_CALLBACK_COMPARE_1,
mbed_official 15:a81a8d6c1dfe 542 # endif
mbed_official 15:a81a8d6c1dfe 543 # if (RTC_NUM_OF_COMP16 > 2) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 544 /** Callback for compare channel 2. */
mbed_official 15:a81a8d6c1dfe 545 RTC_COUNT_CALLBACK_COMPARE_2,
mbed_official 15:a81a8d6c1dfe 546 # endif
mbed_official 15:a81a8d6c1dfe 547 # if (RTC_NUM_OF_COMP16 > 3) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 548 /** Callback for compare channel 3. */
mbed_official 15:a81a8d6c1dfe 549 RTC_COUNT_CALLBACK_COMPARE_3,
mbed_official 15:a81a8d6c1dfe 550 # endif
mbed_official 15:a81a8d6c1dfe 551 # if (RTC_NUM_OF_COMP16 > 4) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 552 /** Callback for compare channel 4. */
mbed_official 15:a81a8d6c1dfe 553 RTC_COUNT_CALLBACK_COMPARE_4,
mbed_official 15:a81a8d6c1dfe 554 # endif
mbed_official 15:a81a8d6c1dfe 555 # if (RTC_NUM_OF_COMP16 > 5) || defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 556 /** Callback for compare channel 5. */
mbed_official 15:a81a8d6c1dfe 557 RTC_COUNT_CALLBACK_COMPARE_5,
mbed_official 15:a81a8d6c1dfe 558 # endif
mbed_official 15:a81a8d6c1dfe 559 /** Callback for overflow. */
mbed_official 15:a81a8d6c1dfe 560 RTC_COUNT_CALLBACK_OVERFLOW,
mbed_official 15:a81a8d6c1dfe 561 # if !defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 562 /** Total number of callbacks. */
mbed_official 15:a81a8d6c1dfe 563 _RTC_COUNT_CALLBACK_N
mbed_official 15:a81a8d6c1dfe 564 # endif
mbed_official 15:a81a8d6c1dfe 565 };
mbed_official 15:a81a8d6c1dfe 566 #endif
mbed_official 15:a81a8d6c1dfe 567
mbed_official 15:a81a8d6c1dfe 568 # if !defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 569 typedef void (*rtc_count_callback_t)(void);
mbed_official 15:a81a8d6c1dfe 570 # endif
mbed_official 15:a81a8d6c1dfe 571 #endif
mbed_official 15:a81a8d6c1dfe 572
mbed_official 15:a81a8d6c1dfe 573 #ifdef FEATURE_RTC_PRESCALER_OFF
mbed_official 15:a81a8d6c1dfe 574 /**
mbed_official 15:a81a8d6c1dfe 575 * \brief RTC input clock prescaler settings.
mbed_official 15:a81a8d6c1dfe 576 *
mbed_official 15:a81a8d6c1dfe 577 * The available input clock prescaler values for the RTC count module.
mbed_official 15:a81a8d6c1dfe 578 */
mbed_official 15:a81a8d6c1dfe 579 enum rtc_count_prescaler {
mbed_official 15:a81a8d6c1dfe 580 /** RTC prescaler is off, and the input clock frequency is
mbed_official 15:a81a8d6c1dfe 581 prescaled by a factor of 1. */
mbed_official 15:a81a8d6c1dfe 582 RTC_COUNT_PRESCALER_OFF = RTC_MODE0_CTRLA_PRESCALER_OFF,
mbed_official 15:a81a8d6c1dfe 583 /** RTC input clock frequency is prescaled by a factor of 1. */
mbed_official 15:a81a8d6c1dfe 584 RTC_COUNT_PRESCALER_DIV_1 = RTC_MODE0_CTRLA_PRESCALER_DIV1,
mbed_official 15:a81a8d6c1dfe 585 /** RTC input clock frequency is prescaled by a factor of 2. */
mbed_official 15:a81a8d6c1dfe 586 RTC_COUNT_PRESCALER_DIV_2 = RTC_MODE0_CTRLA_PRESCALER_DIV2,
mbed_official 15:a81a8d6c1dfe 587 /** RTC input clock frequency is prescaled by a factor of 4. */
mbed_official 15:a81a8d6c1dfe 588 RTC_COUNT_PRESCALER_DIV_4 = RTC_MODE0_CTRLA_PRESCALER_DIV4,
mbed_official 15:a81a8d6c1dfe 589 /** RTC input clock frequency is prescaled by a factor of 8. */
mbed_official 15:a81a8d6c1dfe 590 RTC_COUNT_PRESCALER_DIV_8 = RTC_MODE0_CTRLA_PRESCALER_DIV8,
mbed_official 15:a81a8d6c1dfe 591 /** RTC input clock frequency is prescaled by a factor of 16. */
mbed_official 15:a81a8d6c1dfe 592 RTC_COUNT_PRESCALER_DIV_16 = RTC_MODE0_CTRLA_PRESCALER_DIV16,
mbed_official 15:a81a8d6c1dfe 593 /** RTC input clock frequency is prescaled by a factor of 32. */
mbed_official 15:a81a8d6c1dfe 594 RTC_COUNT_PRESCALER_DIV_32 = RTC_MODE0_CTRLA_PRESCALER_DIV32,
mbed_official 15:a81a8d6c1dfe 595 /** RTC input clock frequency is prescaled by a factor of 64. */
mbed_official 15:a81a8d6c1dfe 596 RTC_COUNT_PRESCALER_DIV_64 = RTC_MODE0_CTRLA_PRESCALER_DIV64,
mbed_official 15:a81a8d6c1dfe 597 /** RTC input clock frequency is prescaled by a factor of 128. */
mbed_official 15:a81a8d6c1dfe 598 RTC_COUNT_PRESCALER_DIV_128 = RTC_MODE0_CTRLA_PRESCALER_DIV128,
mbed_official 15:a81a8d6c1dfe 599 /** RTC input clock frequency is prescaled by a factor of 256. */
mbed_official 15:a81a8d6c1dfe 600 RTC_COUNT_PRESCALER_DIV_256 = RTC_MODE0_CTRLA_PRESCALER_DIV256,
mbed_official 15:a81a8d6c1dfe 601 /** RTC input clock frequency is prescaled by a factor of 512. */
mbed_official 15:a81a8d6c1dfe 602 RTC_COUNT_PRESCALER_DIV_512 = RTC_MODE0_CTRLA_PRESCALER_DIV512,
mbed_official 15:a81a8d6c1dfe 603 /** RTC input clock frequency is prescaled by a factor of 1024. */
mbed_official 15:a81a8d6c1dfe 604 RTC_COUNT_PRESCALER_DIV_1024 = RTC_MODE0_CTRLA_PRESCALER_DIV1024,
mbed_official 15:a81a8d6c1dfe 605 };
mbed_official 15:a81a8d6c1dfe 606 #else
mbed_official 15:a81a8d6c1dfe 607 /**
mbed_official 15:a81a8d6c1dfe 608 * \brief RTC input clock prescaler settings.
mbed_official 15:a81a8d6c1dfe 609 *
mbed_official 15:a81a8d6c1dfe 610 * The available input clock prescaler values for the RTC count module.
mbed_official 15:a81a8d6c1dfe 611 */
mbed_official 15:a81a8d6c1dfe 612 enum rtc_count_prescaler {
mbed_official 15:a81a8d6c1dfe 613 /** RTC input clock frequency is prescaled by a factor of 1. */
mbed_official 15:a81a8d6c1dfe 614 RTC_COUNT_PRESCALER_DIV_1 = RTC_MODE0_CTRL_PRESCALER_DIV1,
mbed_official 15:a81a8d6c1dfe 615 /** RTC input clock frequency is prescaled by a factor of 2. */
mbed_official 15:a81a8d6c1dfe 616 RTC_COUNT_PRESCALER_DIV_2 = RTC_MODE0_CTRL_PRESCALER_DIV2,
mbed_official 15:a81a8d6c1dfe 617 /** RTC input clock frequency is prescaled by a factor of 4. */
mbed_official 15:a81a8d6c1dfe 618 RTC_COUNT_PRESCALER_DIV_4 = RTC_MODE0_CTRL_PRESCALER_DIV4,
mbed_official 15:a81a8d6c1dfe 619 /** RTC input clock frequency is prescaled by a factor of 8. */
mbed_official 15:a81a8d6c1dfe 620 RTC_COUNT_PRESCALER_DIV_8 = RTC_MODE0_CTRL_PRESCALER_DIV8,
mbed_official 15:a81a8d6c1dfe 621 /** RTC input clock frequency is prescaled by a factor of 16. */
mbed_official 15:a81a8d6c1dfe 622 RTC_COUNT_PRESCALER_DIV_16 = RTC_MODE0_CTRL_PRESCALER_DIV16,
mbed_official 15:a81a8d6c1dfe 623 /** RTC input clock frequency is prescaled by a factor of 32. */
mbed_official 15:a81a8d6c1dfe 624 RTC_COUNT_PRESCALER_DIV_32 = RTC_MODE0_CTRL_PRESCALER_DIV32,
mbed_official 15:a81a8d6c1dfe 625 /** RTC input clock frequency is prescaled by a factor of 64. */
mbed_official 15:a81a8d6c1dfe 626 RTC_COUNT_PRESCALER_DIV_64 = RTC_MODE0_CTRL_PRESCALER_DIV64,
mbed_official 15:a81a8d6c1dfe 627 /** RTC input clock frequency is prescaled by a factor of 128. */
mbed_official 15:a81a8d6c1dfe 628 RTC_COUNT_PRESCALER_DIV_128 = RTC_MODE0_CTRL_PRESCALER_DIV128,
mbed_official 15:a81a8d6c1dfe 629 /** RTC input clock frequency is prescaled by a factor of 256. */
mbed_official 15:a81a8d6c1dfe 630 RTC_COUNT_PRESCALER_DIV_256 = RTC_MODE0_CTRL_PRESCALER_DIV256,
mbed_official 15:a81a8d6c1dfe 631 /** RTC input clock frequency is prescaled by a factor of 512. */
mbed_official 15:a81a8d6c1dfe 632 RTC_COUNT_PRESCALER_DIV_512 = RTC_MODE0_CTRL_PRESCALER_DIV512,
mbed_official 15:a81a8d6c1dfe 633 /** RTC input clock frequency is prescaled by a factor of 1024. */
mbed_official 15:a81a8d6c1dfe 634 RTC_COUNT_PRESCALER_DIV_1024 = RTC_MODE0_CTRL_PRESCALER_DIV1024,
mbed_official 15:a81a8d6c1dfe 635 };
mbed_official 15:a81a8d6c1dfe 636 #endif
mbed_official 15:a81a8d6c1dfe 637
mbed_official 15:a81a8d6c1dfe 638 /**
mbed_official 15:a81a8d6c1dfe 639 * \brief RTC Count event enable/disable structure.
mbed_official 15:a81a8d6c1dfe 640 *
mbed_official 15:a81a8d6c1dfe 641 * Event flags for the \ref rtc_count_enable_events() and
mbed_official 15:a81a8d6c1dfe 642 * \ref rtc_count_disable_events().
mbed_official 15:a81a8d6c1dfe 643 */
mbed_official 15:a81a8d6c1dfe 644 struct rtc_count_events {
mbed_official 15:a81a8d6c1dfe 645 /** Generate an output event on each overflow of the RTC count. */
mbed_official 15:a81a8d6c1dfe 646 bool generate_event_on_overflow;
mbed_official 15:a81a8d6c1dfe 647 /** Generate an output event on a compare channel match against the RTC
mbed_official 15:a81a8d6c1dfe 648 * count. */
mbed_official 15:a81a8d6c1dfe 649 bool generate_event_on_compare[RTC_NUM_OF_COMP16];
mbed_official 15:a81a8d6c1dfe 650 /** Generate an output event periodically at a binary division of the RTC
mbed_official 15:a81a8d6c1dfe 651 * counter frequency. */
mbed_official 15:a81a8d6c1dfe 652 bool generate_event_on_periodic[8];
mbed_official 15:a81a8d6c1dfe 653 };
mbed_official 15:a81a8d6c1dfe 654
mbed_official 15:a81a8d6c1dfe 655 #if !defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 656 /**
mbed_official 15:a81a8d6c1dfe 657 * \brief Device structure.
mbed_official 15:a81a8d6c1dfe 658 */
mbed_official 15:a81a8d6c1dfe 659 struct rtc_module {
mbed_official 15:a81a8d6c1dfe 660 /** RTC hardware module. */
mbed_official 15:a81a8d6c1dfe 661 Rtc *hw;
mbed_official 15:a81a8d6c1dfe 662 /** Operation mode of count. */
mbed_official 15:a81a8d6c1dfe 663 enum rtc_count_mode mode;
mbed_official 15:a81a8d6c1dfe 664 #ifdef FEATURE_RTC_CONTINUOUSLY_UPDATED
mbed_official 15:a81a8d6c1dfe 665 /** Set if counter value should be continuously updated. */
mbed_official 15:a81a8d6c1dfe 666 bool continuously_update;
mbed_official 15:a81a8d6c1dfe 667 #endif
mbed_official 15:a81a8d6c1dfe 668 # if RTC_COUNT_ASYNC == true
mbed_official 15:a81a8d6c1dfe 669 /** Pointers to callback functions. */
mbed_official 15:a81a8d6c1dfe 670 volatile rtc_count_callback_t callbacks[_RTC_COUNT_CALLBACK_N];
mbed_official 15:a81a8d6c1dfe 671 /** Mask for registered callbacks. */
mbed_official 15:a81a8d6c1dfe 672 volatile uint16_t registered_callback;
mbed_official 15:a81a8d6c1dfe 673 /** Mask for enabled callbacks. */
mbed_official 15:a81a8d6c1dfe 674 volatile uint16_t enabled_callback;
mbed_official 15:a81a8d6c1dfe 675 # endif
mbed_official 15:a81a8d6c1dfe 676 };
mbed_official 15:a81a8d6c1dfe 677 #endif
mbed_official 15:a81a8d6c1dfe 678
mbed_official 15:a81a8d6c1dfe 679 /**
mbed_official 15:a81a8d6c1dfe 680 * \brief RTC Count configuration structure.
mbed_official 15:a81a8d6c1dfe 681 *
mbed_official 15:a81a8d6c1dfe 682 * Configuration structure for the RTC instance. This structure should
mbed_official 15:a81a8d6c1dfe 683 * be initialized using the \ref rtc_count_get_config_defaults() before any
mbed_official 15:a81a8d6c1dfe 684 * user configurations are set.
mbed_official 15:a81a8d6c1dfe 685 */
mbed_official 15:a81a8d6c1dfe 686 struct rtc_count_config {
mbed_official 15:a81a8d6c1dfe 687 /** Input clock prescaler for the RTC module. */
mbed_official 15:a81a8d6c1dfe 688 enum rtc_count_prescaler prescaler;
mbed_official 15:a81a8d6c1dfe 689 /** Select the operation mode of the RTC.*/
mbed_official 15:a81a8d6c1dfe 690 enum rtc_count_mode mode;
mbed_official 15:a81a8d6c1dfe 691 /** If true, clears the counter value on compare match. Only available
mbed_official 15:a81a8d6c1dfe 692 * whilst running in 32-bit mode. */
mbed_official 15:a81a8d6c1dfe 693 bool clear_on_match;
mbed_official 15:a81a8d6c1dfe 694 #ifdef FEATURE_RTC_CONTINUOUSLY_UPDATED
mbed_official 15:a81a8d6c1dfe 695 /** Continuously update the counter value so no synchronization is
mbed_official 15:a81a8d6c1dfe 696 * needed for reading. */
mbed_official 15:a81a8d6c1dfe 697 bool continuously_update;
mbed_official 15:a81a8d6c1dfe 698 #endif
mbed_official 15:a81a8d6c1dfe 699 #if (SAML21) || (SAMC20) || (SAMC21)
mbed_official 15:a81a8d6c1dfe 700 /** Enable count read synchronization. The COUNT value requires
mbed_official 15:a81a8d6c1dfe 701 * synchronization when reading. Disabling the synchronization
mbed_official 15:a81a8d6c1dfe 702 * will prevent the COUNT value from displaying the current value. */
mbed_official 15:a81a8d6c1dfe 703 bool enable_read_sync;
mbed_official 15:a81a8d6c1dfe 704 #endif
mbed_official 15:a81a8d6c1dfe 705
mbed_official 15:a81a8d6c1dfe 706 /** Array of Compare values. Not all Compare values are available in 32-bit
mbed_official 15:a81a8d6c1dfe 707 * mode. */
mbed_official 15:a81a8d6c1dfe 708 uint32_t compare_values[RTC_NUM_OF_COMP16];
mbed_official 15:a81a8d6c1dfe 709 };
mbed_official 15:a81a8d6c1dfe 710
mbed_official 15:a81a8d6c1dfe 711
mbed_official 15:a81a8d6c1dfe 712 /**
mbed_official 15:a81a8d6c1dfe 713 * \name Configuration and Initialization
mbed_official 15:a81a8d6c1dfe 714 * @{
mbed_official 15:a81a8d6c1dfe 715 */
mbed_official 15:a81a8d6c1dfe 716
mbed_official 15:a81a8d6c1dfe 717 /**
mbed_official 15:a81a8d6c1dfe 718 * \brief Gets the RTC default configurations.
mbed_official 15:a81a8d6c1dfe 719 *
mbed_official 15:a81a8d6c1dfe 720 * Initializes the configuration structure to default values. This
mbed_official 15:a81a8d6c1dfe 721 * function should be called at the start of any RTC initialization.
mbed_official 15:a81a8d6c1dfe 722 *
mbed_official 15:a81a8d6c1dfe 723 * The default configuration is as follows:
mbed_official 15:a81a8d6c1dfe 724 * - Input clock divided by a factor of 1024
mbed_official 15:a81a8d6c1dfe 725 * - RTC in 32-bit mode
mbed_official 15:a81a8d6c1dfe 726 * - Clear on compare match off
mbed_official 15:a81a8d6c1dfe 727 * - Continuously sync count register off
mbed_official 15:a81a8d6c1dfe 728 * - No event source on
mbed_official 15:a81a8d6c1dfe 729 * - All compare values equal 0
mbed_official 15:a81a8d6c1dfe 730 * - Count read synchronization is disabled for SAML21
mbed_official 15:a81a8d6c1dfe 731 *
mbed_official 15:a81a8d6c1dfe 732 * \param[out] config Configuration structure to be initialized to default
mbed_official 15:a81a8d6c1dfe 733 * values.
mbed_official 15:a81a8d6c1dfe 734 */
mbed_official 15:a81a8d6c1dfe 735 static inline void rtc_count_get_config_defaults(
mbed_official 15:a81a8d6c1dfe 736 struct rtc_count_config *const config)
mbed_official 15:a81a8d6c1dfe 737 {
mbed_official 15:a81a8d6c1dfe 738 /* Sanity check argument */
mbed_official 15:a81a8d6c1dfe 739 Assert(config);
mbed_official 15:a81a8d6c1dfe 740
mbed_official 15:a81a8d6c1dfe 741 /* Set default into configuration structure */
mbed_official 15:a81a8d6c1dfe 742 config->prescaler = RTC_COUNT_PRESCALER_DIV_1024;
mbed_official 15:a81a8d6c1dfe 743 config->mode = RTC_COUNT_MODE_32BIT;
mbed_official 15:a81a8d6c1dfe 744 config->clear_on_match = false;
mbed_official 15:a81a8d6c1dfe 745
mbed_official 15:a81a8d6c1dfe 746 #ifdef FEATURE_RTC_CONTINUOUSLY_UPDATED
mbed_official 15:a81a8d6c1dfe 747 config->continuously_update = false;
mbed_official 15:a81a8d6c1dfe 748 #endif
mbed_official 15:a81a8d6c1dfe 749 #if (SAML21)
mbed_official 15:a81a8d6c1dfe 750 config->enable_read_sync = false;
mbed_official 15:a81a8d6c1dfe 751 #endif
mbed_official 15:a81a8d6c1dfe 752
mbed_official 15:a81a8d6c1dfe 753 for (uint8_t i = 0; i < RTC_NUM_OF_COMP16; i++) {
mbed_official 15:a81a8d6c1dfe 754 config->compare_values[i] = 0;
mbed_official 15:a81a8d6c1dfe 755 }
mbed_official 15:a81a8d6c1dfe 756 }
mbed_official 15:a81a8d6c1dfe 757
mbed_official 15:a81a8d6c1dfe 758 void rtc_count_reset(struct rtc_module *const module);
mbed_official 15:a81a8d6c1dfe 759 void rtc_count_enable(struct rtc_module *const module);
mbed_official 15:a81a8d6c1dfe 760 void rtc_count_disable(struct rtc_module *const module);
mbed_official 15:a81a8d6c1dfe 761
mbed_official 15:a81a8d6c1dfe 762 #if (RTC_INST_NUM > 1) && !defined(__DOXYGEN__)
mbed_official 15:a81a8d6c1dfe 763 /**
mbed_official 15:a81a8d6c1dfe 764 * \internal Find the index of given RTC module instance.
mbed_official 15:a81a8d6c1dfe 765 *
mbed_official 15:a81a8d6c1dfe 766 * \param[in] RTC module instance pointer
mbed_official 15:a81a8d6c1dfe 767 *
mbed_official 15:a81a8d6c1dfe 768 * \return Index of the given AC module instance.
mbed_official 15:a81a8d6c1dfe 769 */
mbed_official 15:a81a8d6c1dfe 770 uint8_t _rtc_get_inst_index(
mbed_official 15:a81a8d6c1dfe 771 Rtc *const hw)
mbed_official 15:a81a8d6c1dfe 772 {
mbed_official 15:a81a8d6c1dfe 773 /* List of available RTC modules. */
mbed_official 15:a81a8d6c1dfe 774 static Rtc *const rtc_modules[RTC_INST_NUM] = RTC_INSTS;
mbed_official 15:a81a8d6c1dfe 775
mbed_official 15:a81a8d6c1dfe 776 /* Find index for RTC instance. */
mbed_official 15:a81a8d6c1dfe 777 for (uint32_t i = 0; i < RTC_INST_NUM; i++) {
mbed_official 15:a81a8d6c1dfe 778 if (hw == rtc_modules[i]) {
mbed_official 15:a81a8d6c1dfe 779 return i;
mbed_official 15:a81a8d6c1dfe 780 }
mbed_official 15:a81a8d6c1dfe 781 }
mbed_official 15:a81a8d6c1dfe 782
mbed_official 15:a81a8d6c1dfe 783 /* Invalid data given. */
mbed_official 15:a81a8d6c1dfe 784 Assert(false);
mbed_official 15:a81a8d6c1dfe 785 return 0;
mbed_official 15:a81a8d6c1dfe 786 }
mbed_official 15:a81a8d6c1dfe 787 #endif /* (RTC_INST_NUM > 1) && !defined(__DOXYGEN__) */
mbed_official 15:a81a8d6c1dfe 788
mbed_official 15:a81a8d6c1dfe 789 enum status_code rtc_count_init(
mbed_official 15:a81a8d6c1dfe 790 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 791 Rtc *const hw,
mbed_official 15:a81a8d6c1dfe 792 const struct rtc_count_config *const config);
mbed_official 15:a81a8d6c1dfe 793
mbed_official 15:a81a8d6c1dfe 794 enum status_code rtc_count_frequency_correction(
mbed_official 15:a81a8d6c1dfe 795 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 796 const int8_t value);
mbed_official 15:a81a8d6c1dfe 797
mbed_official 15:a81a8d6c1dfe 798 /** @} */
mbed_official 15:a81a8d6c1dfe 799
mbed_official 15:a81a8d6c1dfe 800 /** \name Count and Compare Value Management
mbed_official 15:a81a8d6c1dfe 801 * @{
mbed_official 15:a81a8d6c1dfe 802 */
mbed_official 15:a81a8d6c1dfe 803 enum status_code rtc_count_set_count(
mbed_official 15:a81a8d6c1dfe 804 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 805 const uint32_t count_value);
mbed_official 15:a81a8d6c1dfe 806
mbed_official 15:a81a8d6c1dfe 807 uint32_t rtc_count_get_count(struct rtc_module *const module);
mbed_official 15:a81a8d6c1dfe 808
mbed_official 15:a81a8d6c1dfe 809 enum status_code rtc_count_set_compare(
mbed_official 15:a81a8d6c1dfe 810 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 811 const uint32_t comp_value,
mbed_official 15:a81a8d6c1dfe 812 const enum rtc_count_compare comp_index);
mbed_official 15:a81a8d6c1dfe 813
mbed_official 15:a81a8d6c1dfe 814 enum status_code rtc_count_get_compare(
mbed_official 15:a81a8d6c1dfe 815 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 816 uint32_t *const comp_value,
mbed_official 15:a81a8d6c1dfe 817 const enum rtc_count_compare comp_index);
mbed_official 15:a81a8d6c1dfe 818
mbed_official 15:a81a8d6c1dfe 819 enum status_code rtc_count_set_period(
mbed_official 15:a81a8d6c1dfe 820 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 821 uint16_t period_value);
mbed_official 15:a81a8d6c1dfe 822
mbed_official 15:a81a8d6c1dfe 823 enum status_code rtc_count_get_period(
mbed_official 15:a81a8d6c1dfe 824 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 825 uint16_t *const period_value);
mbed_official 15:a81a8d6c1dfe 826
mbed_official 15:a81a8d6c1dfe 827 /** @} */
mbed_official 15:a81a8d6c1dfe 828
mbed_official 15:a81a8d6c1dfe 829
mbed_official 15:a81a8d6c1dfe 830 /** \name Status Management
mbed_official 15:a81a8d6c1dfe 831 * @{
mbed_official 15:a81a8d6c1dfe 832 */
mbed_official 15:a81a8d6c1dfe 833
mbed_official 15:a81a8d6c1dfe 834 /**
mbed_official 15:a81a8d6c1dfe 835 * \brief Check if an RTC overflow has occurred.
mbed_official 15:a81a8d6c1dfe 836 *
mbed_official 15:a81a8d6c1dfe 837 * Checks the overflow flag in the RTC. The flag is set when there
mbed_official 15:a81a8d6c1dfe 838 * is an overflow in the clock.
mbed_official 15:a81a8d6c1dfe 839 *
mbed_official 15:a81a8d6c1dfe 840 * \param[in,out] module RTC hardware module
mbed_official 15:a81a8d6c1dfe 841 *
mbed_official 15:a81a8d6c1dfe 842 * \return Overflow state of the RTC module.
mbed_official 15:a81a8d6c1dfe 843 *
mbed_official 15:a81a8d6c1dfe 844 * \retval true If the RTC count value has overflowed
mbed_official 15:a81a8d6c1dfe 845 * \retval false If the RTC count value has not overflowed
mbed_official 15:a81a8d6c1dfe 846 */
mbed_official 15:a81a8d6c1dfe 847
mbed_official 15:a81a8d6c1dfe 848 static inline bool rtc_count_is_overflow(struct rtc_module *const module)
mbed_official 15:a81a8d6c1dfe 849 {
mbed_official 15:a81a8d6c1dfe 850 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 851 Assert(module);
mbed_official 15:a81a8d6c1dfe 852 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 853
mbed_official 15:a81a8d6c1dfe 854 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 855
mbed_official 15:a81a8d6c1dfe 856 /* Return status of flag */
mbed_official 15:a81a8d6c1dfe 857 return (rtc_module->MODE0.INTFLAG.reg & RTC_MODE0_INTFLAG_OVF);
mbed_official 15:a81a8d6c1dfe 858 }
mbed_official 15:a81a8d6c1dfe 859
mbed_official 15:a81a8d6c1dfe 860 /**
mbed_official 15:a81a8d6c1dfe 861 * \brief Clears the RTC overflow flag.
mbed_official 15:a81a8d6c1dfe 862 *
mbed_official 15:a81a8d6c1dfe 863 * Clears the RTC module counter overflow flag, so that new overflow conditions
mbed_official 15:a81a8d6c1dfe 864 * can be detected.
mbed_official 15:a81a8d6c1dfe 865 *
mbed_official 15:a81a8d6c1dfe 866 * \param[in,out] module RTC hardware module
mbed_official 15:a81a8d6c1dfe 867 */
mbed_official 15:a81a8d6c1dfe 868 static inline void rtc_count_clear_overflow(struct rtc_module *const module)
mbed_official 15:a81a8d6c1dfe 869 {
mbed_official 15:a81a8d6c1dfe 870 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 871 Assert(module);
mbed_official 15:a81a8d6c1dfe 872 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 873
mbed_official 15:a81a8d6c1dfe 874 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 875
mbed_official 15:a81a8d6c1dfe 876 /* Clear OVF flag */
mbed_official 15:a81a8d6c1dfe 877 rtc_module->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_OVF;
mbed_official 15:a81a8d6c1dfe 878 }
mbed_official 15:a81a8d6c1dfe 879
mbed_official 15:a81a8d6c1dfe 880 #ifdef FEATURE_RTC_PERIODIC_INT
mbed_official 15:a81a8d6c1dfe 881 /**
mbed_official 15:a81a8d6c1dfe 882 * \brief Check if an RTC periodic interval interrupt has occurred.
mbed_official 15:a81a8d6c1dfe 883 *
mbed_official 15:a81a8d6c1dfe 884 * Checks the periodic interval flag in the RTC.
mbed_official 15:a81a8d6c1dfe 885 *
mbed_official 15:a81a8d6c1dfe 886 * \param[in,out] module RTC hardware module
mbed_official 15:a81a8d6c1dfe 887 * \param[in] n RTC periodic interval interrupt
mbed_official 15:a81a8d6c1dfe 888 *
mbed_official 15:a81a8d6c1dfe 889 * \return periodic interval interrupt state of the RTC module.
mbed_official 15:a81a8d6c1dfe 890 *
mbed_official 15:a81a8d6c1dfe 891 * \retval true RTC periodic interval interrupt occurs
mbed_official 15:a81a8d6c1dfe 892 * \retval false RTC periodic interval interrupt dosen't occurs
mbed_official 15:a81a8d6c1dfe 893 */
mbed_official 15:a81a8d6c1dfe 894 static inline bool rtc_count_is_periodic_interval(struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 895 enum rtc_count_periodic_interval n)
mbed_official 15:a81a8d6c1dfe 896 {
mbed_official 15:a81a8d6c1dfe 897 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 898 Assert(module);
mbed_official 15:a81a8d6c1dfe 899 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 900
mbed_official 15:a81a8d6c1dfe 901 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 902
mbed_official 15:a81a8d6c1dfe 903 /* Return status of flag */
mbed_official 15:a81a8d6c1dfe 904 return (rtc_module->MODE0.INTFLAG.reg & RTC_MODE0_INTFLAG_PER(1 << n));
mbed_official 15:a81a8d6c1dfe 905 }
mbed_official 15:a81a8d6c1dfe 906
mbed_official 15:a81a8d6c1dfe 907 /**
mbed_official 15:a81a8d6c1dfe 908 * \brief Clears the RTC periodic interval flag.
mbed_official 15:a81a8d6c1dfe 909 *
mbed_official 15:a81a8d6c1dfe 910 * Clears the RTC module counter periodic interval flag, so that new periodic
mbed_official 15:a81a8d6c1dfe 911 * interval conditions can be detected.
mbed_official 15:a81a8d6c1dfe 912 *
mbed_official 15:a81a8d6c1dfe 913 * \param[in,out] module RTC hardware module
mbed_official 15:a81a8d6c1dfe 914 * \param[in] n RTC periodic interval interrupt
mbed_official 15:a81a8d6c1dfe 915 */
mbed_official 15:a81a8d6c1dfe 916 static inline void rtc_count_clear_periodic_interval(struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 917 enum rtc_count_periodic_interval n)
mbed_official 15:a81a8d6c1dfe 918 {
mbed_official 15:a81a8d6c1dfe 919 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 920 Assert(module);
mbed_official 15:a81a8d6c1dfe 921 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 922
mbed_official 15:a81a8d6c1dfe 923 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 924
mbed_official 15:a81a8d6c1dfe 925 /* Clear periodic interval flag */
mbed_official 15:a81a8d6c1dfe 926 rtc_module->MODE0.INTFLAG.reg = RTC_MODE0_INTFLAG_PER(1 << n);
mbed_official 15:a81a8d6c1dfe 927 }
mbed_official 15:a81a8d6c1dfe 928 #endif
mbed_official 15:a81a8d6c1dfe 929 bool rtc_count_is_compare_match(
mbed_official 15:a81a8d6c1dfe 930 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 931 const enum rtc_count_compare comp_index);
mbed_official 15:a81a8d6c1dfe 932
mbed_official 15:a81a8d6c1dfe 933 enum status_code rtc_count_clear_compare_match(
mbed_official 15:a81a8d6c1dfe 934 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 935 const enum rtc_count_compare comp_index);
mbed_official 15:a81a8d6c1dfe 936
mbed_official 15:a81a8d6c1dfe 937 /** @} */
mbed_official 15:a81a8d6c1dfe 938
mbed_official 15:a81a8d6c1dfe 939
mbed_official 15:a81a8d6c1dfe 940 /**
mbed_official 15:a81a8d6c1dfe 941 * \name Event Management
mbed_official 15:a81a8d6c1dfe 942 * @{
mbed_official 15:a81a8d6c1dfe 943 */
mbed_official 15:a81a8d6c1dfe 944
mbed_official 15:a81a8d6c1dfe 945 /**
mbed_official 15:a81a8d6c1dfe 946 * \brief Enables a RTC event output.
mbed_official 15:a81a8d6c1dfe 947 *
mbed_official 15:a81a8d6c1dfe 948 * Enables one or more output events from the RTC module. See
mbed_official 15:a81a8d6c1dfe 949 * \ref rtc_count_events for a list of events this module supports.
mbed_official 15:a81a8d6c1dfe 950 *
mbed_official 15:a81a8d6c1dfe 951 * \note Events cannot be altered while the module is enabled.
mbed_official 15:a81a8d6c1dfe 952 *
mbed_official 15:a81a8d6c1dfe 953 * \param[in,out] module RTC hardware module
mbed_official 15:a81a8d6c1dfe 954 * \param[in] events Struct containing flags of events to enable
mbed_official 15:a81a8d6c1dfe 955 */
mbed_official 15:a81a8d6c1dfe 956 static inline void rtc_count_enable_events(
mbed_official 15:a81a8d6c1dfe 957 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 958 struct rtc_count_events *const events)
mbed_official 15:a81a8d6c1dfe 959 {
mbed_official 15:a81a8d6c1dfe 960 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 961 Assert(module);
mbed_official 15:a81a8d6c1dfe 962 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 963
mbed_official 15:a81a8d6c1dfe 964 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 965
mbed_official 15:a81a8d6c1dfe 966 uint32_t event_mask = 0;
mbed_official 15:a81a8d6c1dfe 967
mbed_official 15:a81a8d6c1dfe 968 /* Check if the user has requested an overflow event. */
mbed_official 15:a81a8d6c1dfe 969 if (events->generate_event_on_overflow) {
mbed_official 15:a81a8d6c1dfe 970 event_mask |= RTC_MODE0_EVCTRL_OVFEO;
mbed_official 15:a81a8d6c1dfe 971 }
mbed_official 15:a81a8d6c1dfe 972
mbed_official 15:a81a8d6c1dfe 973 /* Check if the user has requested any compare events. */
mbed_official 15:a81a8d6c1dfe 974 for (uint8_t i = 0; i < RTC_NUM_OF_COMP16; i++) {
mbed_official 15:a81a8d6c1dfe 975 if (events->generate_event_on_compare[i]) {
mbed_official 15:a81a8d6c1dfe 976 event_mask |= RTC_MODE0_EVCTRL_CMPEO(1 << i);
mbed_official 15:a81a8d6c1dfe 977 }
mbed_official 15:a81a8d6c1dfe 978 }
mbed_official 15:a81a8d6c1dfe 979
mbed_official 15:a81a8d6c1dfe 980 /* Check if the user has requested any periodic events. */
mbed_official 15:a81a8d6c1dfe 981 for (uint8_t i = 0; i < 8; i++) {
mbed_official 15:a81a8d6c1dfe 982 if (events->generate_event_on_periodic[i]) {
mbed_official 15:a81a8d6c1dfe 983 event_mask |= RTC_MODE0_EVCTRL_PEREO(1 << i);
mbed_official 15:a81a8d6c1dfe 984 }
mbed_official 15:a81a8d6c1dfe 985 }
mbed_official 15:a81a8d6c1dfe 986
mbed_official 15:a81a8d6c1dfe 987 /* Enable given event(s). */
mbed_official 15:a81a8d6c1dfe 988 rtc_module->MODE0.EVCTRL.reg |= event_mask;
mbed_official 15:a81a8d6c1dfe 989 }
mbed_official 15:a81a8d6c1dfe 990
mbed_official 15:a81a8d6c1dfe 991 /**
mbed_official 15:a81a8d6c1dfe 992 * \brief Disables a RTC event output.
mbed_official 15:a81a8d6c1dfe 993 *
mbed_official 15:a81a8d6c1dfe 994 * Disabled one or more output events from the RTC module. See
mbed_official 15:a81a8d6c1dfe 995 * \ref rtc_count_events for a list of events this module supports.
mbed_official 15:a81a8d6c1dfe 996 *
mbed_official 15:a81a8d6c1dfe 997 * \note Events cannot be altered while the module is enabled.
mbed_official 15:a81a8d6c1dfe 998 *
mbed_official 15:a81a8d6c1dfe 999 * \param[in,out] module RTC hardware module
mbed_official 15:a81a8d6c1dfe 1000 * \param[in] events Struct containing flags of events to disable
mbed_official 15:a81a8d6c1dfe 1001 */
mbed_official 15:a81a8d6c1dfe 1002 static inline void rtc_count_disable_events(
mbed_official 15:a81a8d6c1dfe 1003 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 1004 struct rtc_count_events *const events)
mbed_official 15:a81a8d6c1dfe 1005 {
mbed_official 15:a81a8d6c1dfe 1006 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 1007 Assert(module);
mbed_official 15:a81a8d6c1dfe 1008 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 1009
mbed_official 15:a81a8d6c1dfe 1010 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 1011
mbed_official 15:a81a8d6c1dfe 1012 uint32_t event_mask = 0;
mbed_official 15:a81a8d6c1dfe 1013
mbed_official 15:a81a8d6c1dfe 1014 /* Check if the user has requested an overflow event. */
mbed_official 15:a81a8d6c1dfe 1015 if (events->generate_event_on_overflow) {
mbed_official 15:a81a8d6c1dfe 1016 event_mask |= RTC_MODE0_EVCTRL_OVFEO;
mbed_official 15:a81a8d6c1dfe 1017 }
mbed_official 15:a81a8d6c1dfe 1018
mbed_official 15:a81a8d6c1dfe 1019 /* Check if the user has requested any compare events. */
mbed_official 15:a81a8d6c1dfe 1020 for (uint8_t i = 0; i < RTC_NUM_OF_COMP16; i++) {
mbed_official 15:a81a8d6c1dfe 1021 if (events->generate_event_on_compare[i]) {
mbed_official 15:a81a8d6c1dfe 1022 event_mask |= RTC_MODE0_EVCTRL_CMPEO(1 << i);
mbed_official 15:a81a8d6c1dfe 1023 }
mbed_official 15:a81a8d6c1dfe 1024 }
mbed_official 15:a81a8d6c1dfe 1025
mbed_official 15:a81a8d6c1dfe 1026 /* Check if the user has requested any periodic events. */
mbed_official 15:a81a8d6c1dfe 1027 for (uint8_t i = 0; i < 8; i++) {
mbed_official 15:a81a8d6c1dfe 1028 if (events->generate_event_on_periodic[i]) {
mbed_official 15:a81a8d6c1dfe 1029 event_mask |= RTC_MODE0_EVCTRL_PEREO(1 << i);
mbed_official 15:a81a8d6c1dfe 1030 }
mbed_official 15:a81a8d6c1dfe 1031 }
mbed_official 15:a81a8d6c1dfe 1032
mbed_official 15:a81a8d6c1dfe 1033 /* Disable given event(s). */
mbed_official 15:a81a8d6c1dfe 1034 rtc_module->MODE0.EVCTRL.reg &= ~event_mask;
mbed_official 15:a81a8d6c1dfe 1035 }
mbed_official 15:a81a8d6c1dfe 1036
mbed_official 15:a81a8d6c1dfe 1037 /** @} */
mbed_official 15:a81a8d6c1dfe 1038
mbed_official 15:a81a8d6c1dfe 1039 #ifdef FEATURE_RTC_GENERAL_PURPOSE_REG
mbed_official 15:a81a8d6c1dfe 1040 /**
mbed_official 15:a81a8d6c1dfe 1041 * \name RTC General Purpose Registers
mbed_official 15:a81a8d6c1dfe 1042 * @{
mbed_official 15:a81a8d6c1dfe 1043 */
mbed_official 15:a81a8d6c1dfe 1044
mbed_official 15:a81a8d6c1dfe 1045 /**
mbed_official 15:a81a8d6c1dfe 1046 * \brief Write a value into general purpose register.
mbed_official 15:a81a8d6c1dfe 1047 *
mbed_official 15:a81a8d6c1dfe 1048 * \param[in] module Pointer to the software instance struct
mbed_official 15:a81a8d6c1dfe 1049 * \param[in] n General purpose type
mbed_official 15:a81a8d6c1dfe 1050 * \param[in] index General purpose register index (0..3)
mbed_official 15:a81a8d6c1dfe 1051 *
mbed_official 15:a81a8d6c1dfe 1052 */
mbed_official 15:a81a8d6c1dfe 1053 static inline void rtc_write_general_purpose_reg(
mbed_official 15:a81a8d6c1dfe 1054 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 1055 const uint8_t index,
mbed_official 15:a81a8d6c1dfe 1056 uint32_t value)
mbed_official 15:a81a8d6c1dfe 1057 {
mbed_official 15:a81a8d6c1dfe 1058 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 1059 Assert(module);
mbed_official 15:a81a8d6c1dfe 1060 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 1061 Assert(index <= 3);
mbed_official 15:a81a8d6c1dfe 1062
mbed_official 15:a81a8d6c1dfe 1063 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 1064
mbed_official 15:a81a8d6c1dfe 1065 rtc_module->MODE0.GP[index].reg = value;
mbed_official 15:a81a8d6c1dfe 1066 }
mbed_official 15:a81a8d6c1dfe 1067
mbed_official 15:a81a8d6c1dfe 1068 /**
mbed_official 15:a81a8d6c1dfe 1069 * \brief Read the value from general purpose register.
mbed_official 15:a81a8d6c1dfe 1070 *
mbed_official 15:a81a8d6c1dfe 1071 * \param[in] module Pointer to the software instance struct
mbed_official 15:a81a8d6c1dfe 1072 * \param[in] index General purpose register index (0..3)
mbed_official 15:a81a8d6c1dfe 1073 *
mbed_official 15:a81a8d6c1dfe 1074 * \return Value of general purpose register
mbed_official 15:a81a8d6c1dfe 1075 */
mbed_official 15:a81a8d6c1dfe 1076 static inline uint32_t rtc_read_general_purpose_reg(
mbed_official 15:a81a8d6c1dfe 1077 struct rtc_module *const module,
mbed_official 15:a81a8d6c1dfe 1078 const uint8_t index)
mbed_official 15:a81a8d6c1dfe 1079 {
mbed_official 15:a81a8d6c1dfe 1080 /* Sanity check arguments */
mbed_official 15:a81a8d6c1dfe 1081 Assert(module);
mbed_official 15:a81a8d6c1dfe 1082 Assert(module->hw);
mbed_official 15:a81a8d6c1dfe 1083 Assert(index <= 3);
mbed_official 15:a81a8d6c1dfe 1084
mbed_official 15:a81a8d6c1dfe 1085 Rtc *const rtc_module = module->hw;
mbed_official 15:a81a8d6c1dfe 1086
mbed_official 15:a81a8d6c1dfe 1087 return rtc_module->MODE0.GP[index].reg;
mbed_official 15:a81a8d6c1dfe 1088 }
mbed_official 15:a81a8d6c1dfe 1089
mbed_official 15:a81a8d6c1dfe 1090 /** @} */
mbed_official 15:a81a8d6c1dfe 1091 #endif
mbed_official 15:a81a8d6c1dfe 1092
mbed_official 15:a81a8d6c1dfe 1093 /** @} */
mbed_official 15:a81a8d6c1dfe 1094
mbed_official 15:a81a8d6c1dfe 1095 #ifdef __cplusplus
mbed_official 15:a81a8d6c1dfe 1096 }
mbed_official 15:a81a8d6c1dfe 1097 #endif
mbed_official 15:a81a8d6c1dfe 1098
mbed_official 15:a81a8d6c1dfe 1099 /**
mbed_official 15:a81a8d6c1dfe 1100 * \page asfdoc_sam0_rtc_count_extra Extra Information for RTC COUNT Driver
mbed_official 15:a81a8d6c1dfe 1101 *
mbed_official 15:a81a8d6c1dfe 1102 * \section asfdoc_sam0_rtc_count_extra_acronyms Acronyms
mbed_official 15:a81a8d6c1dfe 1103 * Below is a table listing the acronyms used in this module, along with their
mbed_official 15:a81a8d6c1dfe 1104 * intended meanings.
mbed_official 15:a81a8d6c1dfe 1105 *
mbed_official 15:a81a8d6c1dfe 1106 * <table>
mbed_official 15:a81a8d6c1dfe 1107 * <tr>
mbed_official 15:a81a8d6c1dfe 1108 * <th>Acronym</td>
mbed_official 15:a81a8d6c1dfe 1109 * <th>Description</td>
mbed_official 15:a81a8d6c1dfe 1110 * </tr>
mbed_official 15:a81a8d6c1dfe 1111 * <tr>
mbed_official 15:a81a8d6c1dfe 1112 * <td>RTC</td>
mbed_official 15:a81a8d6c1dfe 1113 * <td>Real Time Counter</td>
mbed_official 15:a81a8d6c1dfe 1114 * </tr>
mbed_official 15:a81a8d6c1dfe 1115 * <tr>
mbed_official 15:a81a8d6c1dfe 1116 * <td>PPM</td>
mbed_official 15:a81a8d6c1dfe 1117 * <td>Part Per Million</td>
mbed_official 15:a81a8d6c1dfe 1118 * </tr>
mbed_official 15:a81a8d6c1dfe 1119 * <tr>
mbed_official 15:a81a8d6c1dfe 1120 * <td>RC</td>
mbed_official 15:a81a8d6c1dfe 1121 * <td>Resistor/Capacitor</td>
mbed_official 15:a81a8d6c1dfe 1122 * </tr>
mbed_official 15:a81a8d6c1dfe 1123 * </table>
mbed_official 15:a81a8d6c1dfe 1124 *
mbed_official 15:a81a8d6c1dfe 1125 *
mbed_official 15:a81a8d6c1dfe 1126 * \section asfdoc_sam0_rtc_count_extra_dependencies Dependencies
mbed_official 15:a81a8d6c1dfe 1127 * This driver has the following dependencies:
mbed_official 15:a81a8d6c1dfe 1128 *
mbed_official 15:a81a8d6c1dfe 1129 * - None
mbed_official 15:a81a8d6c1dfe 1130 *
mbed_official 15:a81a8d6c1dfe 1131 *
mbed_official 15:a81a8d6c1dfe 1132 * \section asfdoc_sam0_rtc_count_extra_errata Errata
mbed_official 15:a81a8d6c1dfe 1133 * There are no errata related to this driver.
mbed_official 15:a81a8d6c1dfe 1134 *
mbed_official 15:a81a8d6c1dfe 1135 *
mbed_official 15:a81a8d6c1dfe 1136 * \section asfdoc_sam0_rtc_count_extra_history Module History
mbed_official 15:a81a8d6c1dfe 1137 * An overview of the module history is presented in the table below, with
mbed_official 15:a81a8d6c1dfe 1138 * details on the enhancements and fixes made to the module since its first
mbed_official 15:a81a8d6c1dfe 1139 * release. The current version of this corresponds to the newest version in
mbed_official 15:a81a8d6c1dfe 1140 * the table.
mbed_official 15:a81a8d6c1dfe 1141 *
mbed_official 15:a81a8d6c1dfe 1142 * <table>
mbed_official 15:a81a8d6c1dfe 1143 * <tr>
mbed_official 15:a81a8d6c1dfe 1144 * <th>Changelog</th>
mbed_official 15:a81a8d6c1dfe 1145 * </tr>
mbed_official 15:a81a8d6c1dfe 1146 * <tr>
mbed_official 15:a81a8d6c1dfe 1147 * <td>Added support for SAMC21</td>
mbed_official 15:a81a8d6c1dfe 1148 * </tr>
mbed_official 15:a81a8d6c1dfe 1149 * <tr>
mbed_official 15:a81a8d6c1dfe 1150 * <td>Added support for SAML21</td>
mbed_official 15:a81a8d6c1dfe 1151 * </tr>
mbed_official 15:a81a8d6c1dfe 1152 * <tr>
mbed_official 15:a81a8d6c1dfe 1153 * <td>
mbed_official 15:a81a8d6c1dfe 1154 * Added support for SAMD21 and added driver instance parameter to all
mbed_official 15:a81a8d6c1dfe 1155 * API function calls, except get_config_defaults
mbed_official 15:a81a8d6c1dfe 1156 * </td>
mbed_official 15:a81a8d6c1dfe 1157 * </tr>
mbed_official 15:a81a8d6c1dfe 1158 * <tr>
mbed_official 15:a81a8d6c1dfe 1159 * <td>Updated initialization function to also enable the digital interface
mbed_official 15:a81a8d6c1dfe 1160 * clock to the module if it is disabled</td>
mbed_official 15:a81a8d6c1dfe 1161 * </tr>
mbed_official 15:a81a8d6c1dfe 1162 * <tr>
mbed_official 15:a81a8d6c1dfe 1163 * <td>Initial Release</td>
mbed_official 15:a81a8d6c1dfe 1164 * </tr>
mbed_official 15:a81a8d6c1dfe 1165 * </table>
mbed_official 15:a81a8d6c1dfe 1166 */
mbed_official 15:a81a8d6c1dfe 1167
mbed_official 15:a81a8d6c1dfe 1168 /**
mbed_official 15:a81a8d6c1dfe 1169 * \page asfdoc_sam0_rtc_count_exqsg Examples for RTC (COUNT) Driver
mbed_official 15:a81a8d6c1dfe 1170 *
mbed_official 15:a81a8d6c1dfe 1171 * This is a list of the available Quick Start guides (QSGs) and example
mbed_official 15:a81a8d6c1dfe 1172 * applications for \ref asfdoc_sam0_rtc_count_group. QSGs are simple
mbed_official 15:a81a8d6c1dfe 1173 * examples with step-by-step instructions to configure and use this driver in a
mbed_official 15:a81a8d6c1dfe 1174 * selection of use cases. Note that QSGs can be compiled as a standalone
mbed_official 15:a81a8d6c1dfe 1175 * application or be added to the user application.
mbed_official 15:a81a8d6c1dfe 1176 *
mbed_official 15:a81a8d6c1dfe 1177 * - \subpage asfdoc_sam0_rtc_count_basic_use_case
mbed_official 15:a81a8d6c1dfe 1178 * \if RTC_COUNT_CALLBACK_MODE
mbed_official 15:a81a8d6c1dfe 1179 * - \subpage asfdoc_sam0_rtc_count_callback_use_case
mbed_official 15:a81a8d6c1dfe 1180 * \endif
mbed_official 15:a81a8d6c1dfe 1181 *
mbed_official 15:a81a8d6c1dfe 1182 * \page asfdoc_sam0_rtc_count_document_revision_history Document Revision History
mbed_official 15:a81a8d6c1dfe 1183 *
mbed_official 15:a81a8d6c1dfe 1184 * <table>
mbed_official 15:a81a8d6c1dfe 1185 * <tr>
mbed_official 15:a81a8d6c1dfe 1186 * <th>Doc. Rev.</td>
mbed_official 15:a81a8d6c1dfe 1187 * <th>Date</td>
mbed_official 15:a81a8d6c1dfe 1188 * <th>Comments</td>
mbed_official 15:a81a8d6c1dfe 1189 * </tr>
mbed_official 15:a81a8d6c1dfe 1190 * <tr>
mbed_official 15:a81a8d6c1dfe 1191 * <td>E</td>
mbed_official 15:a81a8d6c1dfe 1192 * <td>06/2015</td>
mbed_official 15:a81a8d6c1dfe 1193 * <td>Added support for SAML21, SAMC21, and SAMDAx.</td>
mbed_official 15:a81a8d6c1dfe 1194 * </tr>
mbed_official 15:a81a8d6c1dfe 1195 * <tr>
mbed_official 15:a81a8d6c1dfe 1196 * <td>D</td>
mbed_official 15:a81a8d6c1dfe 1197 * <td>12/2014</td>
mbed_official 15:a81a8d6c1dfe 1198 * <td>Added support for SAMR21 and SAMD10/D11.</td>
mbed_official 15:a81a8d6c1dfe 1199 * </tr>
mbed_official 15:a81a8d6c1dfe 1200 * <tr>
mbed_official 15:a81a8d6c1dfe 1201 * <td>C</td>
mbed_official 15:a81a8d6c1dfe 1202 * <td>01/2014</td>
mbed_official 15:a81a8d6c1dfe 1203 * <td>Added support for SAMD21.</td>
mbed_official 15:a81a8d6c1dfe 1204 * </tr>
mbed_official 15:a81a8d6c1dfe 1205 * <tr>
mbed_official 15:a81a8d6c1dfe 1206 * <td>B</td>
mbed_official 15:a81a8d6c1dfe 1207 * <td>06/2013</td>
mbed_official 15:a81a8d6c1dfe 1208 * <td>Added additional documentation on the event system. Corrected
mbed_official 15:a81a8d6c1dfe 1209 * documentation typos.</td>
mbed_official 15:a81a8d6c1dfe 1210 * </tr>
mbed_official 15:a81a8d6c1dfe 1211 * <tr>
mbed_official 15:a81a8d6c1dfe 1212 * <td>A</td>
mbed_official 15:a81a8d6c1dfe 1213 * <td>06/2013</td>
mbed_official 15:a81a8d6c1dfe 1214 * <td>Initial release</td>
mbed_official 15:a81a8d6c1dfe 1215 * </tr>
mbed_official 15:a81a8d6c1dfe 1216 * </table>
mbed_official 15:a81a8d6c1dfe 1217 */
mbed_official 15:a81a8d6c1dfe 1218
mbed_official 15:a81a8d6c1dfe 1219 #endif /* RTC_COUNT_H_INCLUDED */