mbed library sources

Fork of mbed-src by mbed official

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 System related functionality
mbed_official 579:53297373a894 5 *
mbed_official 579:53297373a894 6 * Copyright (C) 2012-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 #ifndef SYSTEM_H_INCLUDED
mbed_official 579:53297373a894 47 #define SYSTEM_H_INCLUDED
mbed_official 579:53297373a894 48
mbed_official 579:53297373a894 49 #include <compiler.h>
mbed_official 579:53297373a894 50 #include <clock.h>
mbed_official 579:53297373a894 51 #include <gclk.h>
mbed_official 579:53297373a894 52 #include <pinmux.h>
mbed_official 579:53297373a894 53 #include <power.h>
mbed_official 579:53297373a894 54 #include <reset.h>
mbed_official 579:53297373a894 55
mbed_official 579:53297373a894 56 #ifdef __cplusplus
mbed_official 579:53297373a894 57 extern "C" {
mbed_official 579:53297373a894 58 #endif
mbed_official 579:53297373a894 59
mbed_official 579:53297373a894 60 /**
mbed_official 579:53297373a894 61 * \defgroup asfdoc_sam0_system_group SAM System Driver (SYSTEM)
mbed_official 579:53297373a894 62 *
mbed_official 579:53297373a894 63 * This driver for Atmel庐 | SMART SAM devices provides an interface for the configuration
mbed_official 579:53297373a894 64 * and management of the device's system relation functionality, necessary for
mbed_official 579:53297373a894 65 * the basic device operation. This is not limited to a single peripheral, but
mbed_official 579:53297373a894 66 * extends across multiple hardware peripherals.
mbed_official 579:53297373a894 67 *
mbed_official 579:53297373a894 68 * The following peripherals are used by this module:
mbed_official 579:53297373a894 69 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 70 * - PM (Power Manager)
mbed_official 579:53297373a894 71 * - RSTC(Reset Controller)
mbed_official 579:53297373a894 72 * - SUPC(Supply Controller)
mbed_official 579:53297373a894 73 * \else
mbed_official 579:53297373a894 74 * - SYSCTRL (System Control)
mbed_official 579:53297373a894 75 * - PM (Power Manager)
mbed_official 579:53297373a894 76 * \endif
mbed_official 579:53297373a894 77 *
mbed_official 579:53297373a894 78 * The following devices can use this module:
mbed_official 579:53297373a894 79 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 80 * - Atmel | SMART SAM L21
mbed_official 579:53297373a894 81 * \else
mbed_official 579:53297373a894 82 * - Atmel | SMART SAM D20/D21
mbed_official 579:53297373a894 83 * - Atmel | SMART SAM R21
mbed_official 579:53297373a894 84 * - Atmel | SMART SAM D10/D11
mbed_official 579:53297373a894 85 * \endif
mbed_official 579:53297373a894 86 *
mbed_official 579:53297373a894 87 * The outline of this documentation is as follows:
mbed_official 579:53297373a894 88 * - \ref asfdoc_sam0_system_prerequisites
mbed_official 579:53297373a894 89 * - \ref asfdoc_sam0_system_module_overview
mbed_official 579:53297373a894 90 * - \ref asfdoc_sam0_system_special_considerations
mbed_official 579:53297373a894 91 * - \ref asfdoc_sam0_system_extra_info
mbed_official 579:53297373a894 92 * - \ref asfdoc_sam0_system_examples
mbed_official 579:53297373a894 93 * - \ref asfdoc_sam0_system_api_overview
mbed_official 579:53297373a894 94 *
mbed_official 579:53297373a894 95 *
mbed_official 579:53297373a894 96 * \section asfdoc_sam0_system_prerequisites Prerequisites
mbed_official 579:53297373a894 97 *
mbed_official 579:53297373a894 98 * There are no prerequisites for this module.
mbed_official 579:53297373a894 99 *
mbed_official 579:53297373a894 100 *
mbed_official 579:53297373a894 101 * \section asfdoc_sam0_system_module_overview Module Overview
mbed_official 579:53297373a894 102 *
mbed_official 579:53297373a894 103 * The System driver provides a collection of interfaces between the user
mbed_official 579:53297373a894 104 * application logic, and the core device functionality (such as clocks, reset
mbed_official 579:53297373a894 105 * cause determination, etc.) that is required for all applications. It contains
mbed_official 579:53297373a894 106 * a number of sub-modules that control one specific aspect of the device:
mbed_official 579:53297373a894 107 *
mbed_official 579:53297373a894 108 * - System Core (this module)
mbed_official 579:53297373a894 109 * - \ref asfdoc_sam0_system_clock_group "System Clock Control" (sub-module)
mbed_official 579:53297373a894 110 * - \ref asfdoc_sam0_system_interrupt_group "System Interrupt Control" (sub-module)
mbed_official 579:53297373a894 111 * - \ref asfdoc_sam0_system_pinmux_group "System Pin Multiplexer Control" (sub-module)
mbed_official 579:53297373a894 112 *
mbed_official 579:53297373a894 113 *
mbed_official 579:53297373a894 114 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 115 * \subsection asfdoc_sam0_system_module_overview_vreg Voltage Regulator
mbed_official 579:53297373a894 116 * The SAM device controls the voltage regulators for the core (VDDCORE) and
mbed_official 579:53297373a894 117 * backup (VDDBU) domains. It sets the voltage regulators according to the sleep
mbed_official 579:53297373a894 118 * modes, the performance level, or the user configuration.
mbed_official 579:53297373a894 119 *
mbed_official 579:53297373a894 120 * In active mode, the voltage regulator can be chosen on the fly between a LDO
mbed_official 579:53297373a894 121 * or a Buck converter.In standby mode, the low power voltage regulator is used
mbed_official 579:53297373a894 122 * to supply VDDCORE.
mbed_official 579:53297373a894 123 *
mbed_official 579:53297373a894 124 * \subsection asfdoc_sam0_system_module_overview_bbps Battery Backup Power Switch
mbed_official 579:53297373a894 125 * The SAM device supports connection of a battery backup to the VBAT power pin.
mbed_official 579:53297373a894 126 * It includes functionality that enables automatic power switching between main
mbed_official 579:53297373a894 127 * power and battery backup power. This will ensure power to the backup domain,
mbed_official 579:53297373a894 128 * when the main battery or power source is unavailable.
mbed_official 579:53297373a894 129 * \endif
mbed_official 579:53297373a894 130 *
mbed_official 579:53297373a894 131 * \subsection asfdoc_sam0_system_module_overview_vref Voltage References
mbed_official 579:53297373a894 132 * The various analog modules within the SAM devices (such as AC, ADC, and
mbed_official 579:53297373a894 133 * DAC) require a voltage reference to be configured to act as a reference point
mbed_official 579:53297373a894 134 * for comparisons and conversions.
mbed_official 579:53297373a894 135 *
mbed_official 579:53297373a894 136 * The SAM devices contain multiple references, including an internal
mbed_official 579:53297373a894 137 * temperature sensor, and a fixed band-gap voltage source. When enabled, the
mbed_official 579:53297373a894 138 * associated voltage reference can be selected within the desired peripheral
mbed_official 579:53297373a894 139 * where applicable.
mbed_official 579:53297373a894 140 *
mbed_official 579:53297373a894 141 * \subsection asfdoc_sam0_system_module_overview_reset_cause System Reset Cause
mbed_official 579:53297373a894 142 * In some applications there may be a need to execute a different program
mbed_official 579:53297373a894 143 * flow based on how the device was reset. For example, if the cause of reset
mbed_official 579:53297373a894 144 * was the Watchdog timer (WDT), this might indicate an error in the application
mbed_official 579:53297373a894 145 * and a form of error handling or error logging might be needed.
mbed_official 579:53297373a894 146 *
mbed_official 579:53297373a894 147 * For this reason, an API is provided to retrieve the cause of the last system
mbed_official 579:53297373a894 148 * reset, so that appropriate action can be taken.
mbed_official 579:53297373a894 149 *
mbed_official 579:53297373a894 150 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 151 * There are three groups of reset sources:
mbed_official 579:53297373a894 152 * - Power supply reset: Resets caused by an electrical issue. It covers POR and BODs reset.
mbed_official 579:53297373a894 153 * - User reset: Resets caused by the application. It covers external reset,
mbed_official 579:53297373a894 154 * system resetrequest and watchdog reset.
mbed_official 579:53297373a894 155 * - Backup reset: Resets caused by a backup mode exit condition.
mbed_official 579:53297373a894 156 *
mbed_official 579:53297373a894 157 * \subsection asfdoc_sam0_system_module_overview_performance_level Performance Level
mbed_official 579:53297373a894 158 * Performance level allows use to adjust the regulator output voltage to reduce
mbed_official 579:53297373a894 159 * power consumption. The user can select on the fly the performance level
mbed_official 579:53297373a894 160 * configuration which best suits its application.
mbed_official 579:53297373a894 161 *
mbed_official 579:53297373a894 162 * The SAM device embeds up to three performance level (PL0, PL1 and PL2).
mbed_official 579:53297373a894 163 * Each performance level defines a maximum frequency and a corresponding
mbed_official 579:53297373a894 164 * consumption in 渭A/MHz,when the application selects a new performance level,
mbed_official 579:53297373a894 165 * the voltage applied on the full logic area moves from a value to another,
mbed_official 579:53297373a894 166 * it can reduce the active consumption while decreasing the maximum frequency
mbed_official 579:53297373a894 167 * of the device.
mbed_official 579:53297373a894 168 *
mbed_official 579:53297373a894 169 * Performance level transition is possible only when the device is in active
mbed_official 579:53297373a894 170 * mode, after a reset, the device starts in the lowest performance level
mbed_official 579:53297373a894 171 * (lowest power consumption and lowest max. frequency). The application can then
mbed_official 579:53297373a894 172 * switch to another performance level at anytime without any stop in the code
mbed_official 579:53297373a894 173 * execution. As shown in \ref asfdoc_sam0_system_performance_level_transition_figure.
mbed_official 579:53297373a894 174 *
mbed_official 579:53297373a894 175 * \note When scaling down the performance level,the bus frequency should be first
mbed_official 579:53297373a894 176 * scaled down in order to not exceed the maximum frequency allowed for the
mbed_official 579:53297373a894 177 * low performance level.
mbed_official 579:53297373a894 178 * When scaling up the performance level (for example from PL0 to PL2), the bus
mbed_official 579:53297373a894 179 * frequency can be increased only once the performance level transition is
mbed_official 579:53297373a894 180 * completed,check the performance level status.
mbed_official 579:53297373a894 181 *
mbed_official 579:53297373a894 182 * \anchor asfdoc_sam0_system_performance_level_transition_figure
mbed_official 579:53297373a894 183 * \image html performance_level_transition.gif "The performance level transition"
mbed_official 579:53297373a894 184 *
mbed_official 579:53297373a894 185 * \subsection asfdoc_sam0_system_module_overview_power_domain Power Domain Gating
mbed_official 579:53297373a894 186 * Power domain gating can turn on or off power domain voltage to save power
mbed_official 579:53297373a894 187 * while keeping other domain powered up. It can be used in standby sleep mode,
mbed_official 579:53297373a894 188 * in standby mode, when power-gated, the internal state of the logic can be
mbed_official 579:53297373a894 189 * retained allowing the application context to be kept.
mbed_official 579:53297373a894 190 *
mbed_official 579:53297373a894 191 * Power domain can be in three states:
mbed_official 579:53297373a894 192 * - Active state: the power domain is powered on.
mbed_official 579:53297373a894 193 * - Retention state: the main voltage supply for the power domain is switched off,
mbed_official 579:53297373a894 194 * while maintaining a secondary low-power supply for the sequential cells. The
mbed_official 579:53297373a894 195 * logic context is restored when waking up.
mbed_official 579:53297373a894 196 * - Off state: the power domain is entirely powered off. The logic context is lost.
mbed_official 579:53297373a894 197 *
mbed_official 579:53297373a894 198 * The SAM L21 device has three power domains: PD0, PD1 and PD2.
mbed_official 579:53297373a894 199 * - By default, a power domain is set automatically to retention state in standby
mbed_official 579:53297373a894 200 * sleep mode if no activity is required in it, the application can force all power
mbed_official 579:53297373a894 201 * domains to remain in active state during standby sleep mode in order to accelerate
mbed_official 579:53297373a894 202 * wakeup time.
mbed_official 579:53297373a894 203 * - Static Power_SleepWalking: When entering standby mode, if a peripheral needs to
mbed_official 579:53297373a894 204 * remain in run mode to perform sleepwalking task, its power domain (PDn) remains in
mbed_official 579:53297373a894 205 * active state as well as the inferior power domains (<PDn).
mbed_official 579:53297373a894 206 * - Dynamic Power_SleepWalking: During standby mode, a power domain (PDn) in active
mbed_official 579:53297373a894 207 * state (using the static Power_SleepWalking principle), can wakeup a superior power
mbed_official 579:53297373a894 208 * domain (>PDn) in order to perform a sleepwalking task. The superior power domain is
mbed_official 579:53297373a894 209 * then automatically set to active state. At the end of the sleepwalking task, either
mbed_official 579:53297373a894 210 * the device can be waken-up or the superior power domain can be set again to retention
mbed_official 579:53297373a894 211 * state.
mbed_official 579:53297373a894 212 *
mbed_official 579:53297373a894 213 * Power domains can be linked each other,it allows a power domain (PDn) to be kept
mbed_official 579:53297373a894 214 * in active state if the inferior power domain (PDn-1) is in active state too.
mbed_official 579:53297373a894 215 *
mbed_official 579:53297373a894 216 * The table \ref asfdoc_sam0_system_power_domain_overview_table illustrates the
mbed_official 579:53297373a894 217 * four cases to consider in standby mode
mbed_official 579:53297373a894 218 *
mbed_official 579:53297373a894 219 * \anchor asfdoc_sam0_system_power_domain_overview_table
mbed_official 579:53297373a894 220 * <table>
mbed_official 579:53297373a894 221 * <caption>Sleep Mode versus Power Domain State Overview</caption>
mbed_official 579:53297373a894 222 * <tr>
mbed_official 579:53297373a894 223 * <th>Sleep mode</th>
mbed_official 579:53297373a894 224 * <th></th>
mbed_official 579:53297373a894 225 * <th>PD0</th>
mbed_official 579:53297373a894 226 * <th>PD1</th>
mbed_official 579:53297373a894 227 * <th>PD2</th>
mbed_official 579:53297373a894 228 * <th>PDTOP</th>
mbed_official 579:53297373a894 229 * <th>PDBACKUP</th>
mbed_official 579:53297373a894 230 * </tr>
mbed_official 579:53297373a894 231 * <tr>
mbed_official 579:53297373a894 232 * <td>IDLE</td>
mbed_official 579:53297373a894 233 * <td></td>
mbed_official 579:53297373a894 234 * <td>active</td>
mbed_official 579:53297373a894 235 * <td>active</td>
mbed_official 579:53297373a894 236 * <td>active</td>
mbed_official 579:53297373a894 237 * <td>active</td>
mbed_official 579:53297373a894 238 * <td>active</td>
mbed_official 579:53297373a894 239 * </tr>
mbed_official 579:53297373a894 240 * <tr>
mbed_official 579:53297373a894 241 * <td>Standby</td>
mbed_official 579:53297373a894 242 * <td>Case 1</td>
mbed_official 579:53297373a894 243 * <td>active</td>
mbed_official 579:53297373a894 244 * <td>active</td>
mbed_official 579:53297373a894 245 * <td>active</td>
mbed_official 579:53297373a894 246 * <td>active</td>
mbed_official 579:53297373a894 247 * <td>active</td>
mbed_official 579:53297373a894 248 * </tr>
mbed_official 579:53297373a894 249 * <tr>
mbed_official 579:53297373a894 250 * <td>Standby</td>
mbed_official 579:53297373a894 251 * <td>Case 2</td>
mbed_official 579:53297373a894 252 * <td>active</td>
mbed_official 579:53297373a894 253 * <td>active</td>
mbed_official 579:53297373a894 254 * <td>retention</td>
mbed_official 579:53297373a894 255 * <td>active</td>
mbed_official 579:53297373a894 256 * <td>active</td>
mbed_official 579:53297373a894 257 * </tr>
mbed_official 579:53297373a894 258 * <tr>
mbed_official 579:53297373a894 259 * <td>Standby</td>
mbed_official 579:53297373a894 260 * <td>Case 3</td>
mbed_official 579:53297373a894 261 * <td>active</td>
mbed_official 579:53297373a894 262 * <td>retention</td>
mbed_official 579:53297373a894 263 * <td>retention</td>
mbed_official 579:53297373a894 264 * <td>active</td>
mbed_official 579:53297373a894 265 * <td>active</td>
mbed_official 579:53297373a894 266 * </tr>
mbed_official 579:53297373a894 267 * <tr>
mbed_official 579:53297373a894 268 * <td>Standby</td>
mbed_official 579:53297373a894 269 * <td>Case 4</td>
mbed_official 579:53297373a894 270 * <td>retention</td>
mbed_official 579:53297373a894 271 * <td>retention</td>
mbed_official 579:53297373a894 272 * <td>retention</td>
mbed_official 579:53297373a894 273 * <td>active</td>
mbed_official 579:53297373a894 274 * <td>active</td>
mbed_official 579:53297373a894 275 * </tr>
mbed_official 579:53297373a894 276 * <tr>
mbed_official 579:53297373a894 277 * <td>Backup</td>
mbed_official 579:53297373a894 278 * <td></td>
mbed_official 579:53297373a894 279 * <td>OFF</td>
mbed_official 579:53297373a894 280 * <td>OFF</td>
mbed_official 579:53297373a894 281 * <td>OFF</td>
mbed_official 579:53297373a894 282 * <td>OFF</td>
mbed_official 579:53297373a894 283 * <td>active</td>
mbed_official 579:53297373a894 284 * </tr>
mbed_official 579:53297373a894 285 * <tr>
mbed_official 579:53297373a894 286 * <td>Off</td>
mbed_official 579:53297373a894 287 * <td></td>
mbed_official 579:53297373a894 288 * <td>OFF</td>
mbed_official 579:53297373a894 289 * <td>OFF</td>
mbed_official 579:53297373a894 290 * <td>OFF</td>
mbed_official 579:53297373a894 291 * <td>OFF</td>
mbed_official 579:53297373a894 292 * <td>OFF</td>
mbed_official 579:53297373a894 293 * </tr>
mbed_official 579:53297373a894 294 * </table>
mbed_official 579:53297373a894 295 *
mbed_official 579:53297373a894 296 * \subsection asfdoc_sam0_system_module_overview_ram_state RAMs Low Power Mode
mbed_official 579:53297373a894 297 * By default, in standby sleep mode, RAM is in low power mode (back biased)
mbed_official 579:53297373a894 298 * if its power domain is in retention state.
mbed_official 579:53297373a894 299 * The table \ref asfdoc_sam0_system_power_ram_state_table lists RAMs low power mode.
mbed_official 579:53297373a894 300 *
mbed_official 579:53297373a894 301 * \anchor asfdoc_sam0_system_power_ram_state_table
mbed_official 579:53297373a894 302 * <table>
mbed_official 579:53297373a894 303 * <caption>RAM Back-biasing mode</caption>
mbed_official 579:53297373a894 304 * <tr>
mbed_official 579:53297373a894 305 * <th>RAM mode</th>
mbed_official 579:53297373a894 306 * <th>Description</th>
mbed_official 579:53297373a894 307 * </tr>
mbed_official 579:53297373a894 308 * <tr>
mbed_official 579:53297373a894 309 * <td>Retention Back-biasing mode</td>
mbed_official 579:53297373a894 310 * <td>RAM is back-biased if its power domain is in retention mode</td>
mbed_official 579:53297373a894 311 * </tr>
mbed_official 579:53297373a894 312 * <tr>
mbed_official 579:53297373a894 313 * <td>Standby Back-biasing mode</td>
mbed_official 579:53297373a894 314 * <td>RAM is back-biased if the device is in standby mode</td>
mbed_official 579:53297373a894 315 * </tr>
mbed_official 579:53297373a894 316 * <tr>
mbed_official 579:53297373a894 317 * <td>Standby OFF mode</td>
mbed_official 579:53297373a894 318 * <td>RAM is OFF if the device is in standby mode</td>
mbed_official 579:53297373a894 319 * </tr>
mbed_official 579:53297373a894 320 * <tr>
mbed_official 579:53297373a894 321 * <td>Always OFF mode</td>
mbed_official 579:53297373a894 322 * <td>RAM is OFF if the device is in RET mode</td>
mbed_official 579:53297373a894 323 * </tr>
mbed_official 579:53297373a894 324 * </table>
mbed_official 579:53297373a894 325 *
mbed_official 579:53297373a894 326 * \endif
mbed_official 579:53297373a894 327 *
mbed_official 579:53297373a894 328 * \subsection asfdoc_sam0_system_module_overview_sleep_mode Sleep Modes
mbed_official 579:53297373a894 329 * The SAM devices have several sleep modes, where the sleep mode controls
mbed_official 579:53297373a894 330 * which clock systems on the device will remain enabled or disabled when the
mbed_official 579:53297373a894 331 * device enters a low power sleep mode.
mbed_official 579:53297373a894 332 * \ref asfdoc_sam0_system_module_sleep_mode_table "The table below" lists the
mbed_official 579:53297373a894 333 * clock settings of the different sleep modes.
mbed_official 579:53297373a894 334 *
mbed_official 579:53297373a894 335 * \anchor asfdoc_sam0_system_module_sleep_mode_table
mbed_official 579:53297373a894 336 * <table>
mbed_official 579:53297373a894 337 * <caption>SAM Device Sleep Modes</caption>
mbed_official 579:53297373a894 338 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 339 * <tr>
mbed_official 579:53297373a894 340 * <th>Sleep mode</th>
mbed_official 579:53297373a894 341 * <th>System clock</th>
mbed_official 579:53297373a894 342 * <th>CPU clock</th>
mbed_official 579:53297373a894 343 * <th>AHB/AHB clock</th>
mbed_official 579:53297373a894 344 * <th>GCLK clocks</th>
mbed_official 579:53297373a894 345 * <th>Oscillators (ONDEMAND = 0)</th>
mbed_official 579:53297373a894 346 * <th>Oscillators (ONDEMAND = 1)</th>
mbed_official 579:53297373a894 347 * <th>Regulator mode</th>
mbed_official 579:53297373a894 348 * <th>RAM mode</th>
mbed_official 579:53297373a894 349 * </tr>
mbed_official 579:53297373a894 350 * <tr>
mbed_official 579:53297373a894 351 * <td>IDLE</td>
mbed_official 579:53297373a894 352 * <td>Run</td>
mbed_official 579:53297373a894 353 * <td>Stop</td>
mbed_official 579:53297373a894 354 * <td>Run if requested</td>
mbed_official 579:53297373a894 355 * <td>Run</td>
mbed_official 579:53297373a894 356 * <td>Run</td>
mbed_official 579:53297373a894 357 * <td>Run if requested</td>
mbed_official 579:53297373a894 358 * <td>Normal</td>
mbed_official 579:53297373a894 359 * <td>Normal</td>
mbed_official 579:53297373a894 360 * </tr>
mbed_official 579:53297373a894 361 * <tr>
mbed_official 579:53297373a894 362 * <td>Standby</td>
mbed_official 579:53297373a894 363 * <td>Stop</td>
mbed_official 579:53297373a894 364 * <td>Stop</td>
mbed_official 579:53297373a894 365 * <td>Run if requested</td>
mbed_official 579:53297373a894 366 * <td>Run if requested</td>
mbed_official 579:53297373a894 367 * <td>Run if requested or RUNSTDBY = 1</td>
mbed_official 579:53297373a894 368 * <td>Run if requested</td>
mbed_official 579:53297373a894 369 * <td>Low pwer</td>
mbed_official 579:53297373a894 370 * <td>Low pwer</td>
mbed_official 579:53297373a894 371 * </tr>
mbed_official 579:53297373a894 372 * <tr>
mbed_official 579:53297373a894 373 * <td>Backup</td>
mbed_official 579:53297373a894 374 * <td>Stop</td>
mbed_official 579:53297373a894 375 * <td>Stop</td>
mbed_official 579:53297373a894 376 * <td>Stop</td>
mbed_official 579:53297373a894 377 * <td>Stop</td>
mbed_official 579:53297373a894 378 * <td>Stop</td>
mbed_official 579:53297373a894 379 * <td>Stop</td>
mbed_official 579:53297373a894 380 * <td>Backup</td>
mbed_official 579:53297373a894 381 * <td>OFF</td>
mbed_official 579:53297373a894 382 * </tr>
mbed_official 579:53297373a894 383 * <tr>
mbed_official 579:53297373a894 384 * <td>Off</td>
mbed_official 579:53297373a894 385 * <td>OFF</td>
mbed_official 579:53297373a894 386 * <td>OFF</td>
mbed_official 579:53297373a894 387 * <td>OFF</td>
mbed_official 579:53297373a894 388 * <td>OFF</td>
mbed_official 579:53297373a894 389 * <td>OFF</td>
mbed_official 579:53297373a894 390 * <td>OFF</td>
mbed_official 579:53297373a894 391 * <td>OFF</td>
mbed_official 579:53297373a894 392 * <td>OFF</td>
mbed_official 579:53297373a894 393 * </tr>
mbed_official 579:53297373a894 394 * \else
mbed_official 579:53297373a894 395 * <tr>
mbed_official 579:53297373a894 396 * <th>Sleep mode</th>
mbed_official 579:53297373a894 397 * <th>CPU clock</th>
mbed_official 579:53297373a894 398 * <th>AHB clock</th>
mbed_official 579:53297373a894 399 * <th>APB clocks</th>
mbed_official 579:53297373a894 400 * <th>Clock sources</th>
mbed_official 579:53297373a894 401 * <th>System clock</th>
mbed_official 579:53297373a894 402 * <th>32KHz</th>
mbed_official 579:53297373a894 403 * <th>Reg mode</th>
mbed_official 579:53297373a894 404 * <th>RAM mode</th>
mbed_official 579:53297373a894 405 * </tr>
mbed_official 579:53297373a894 406 * <tr>
mbed_official 579:53297373a894 407 * <td>IDLE 0</td>
mbed_official 579:53297373a894 408 * <td>Stop</td>
mbed_official 579:53297373a894 409 * <td>Run</td>
mbed_official 579:53297373a894 410 * <td>Run</td>
mbed_official 579:53297373a894 411 * <td>Run</td>
mbed_official 579:53297373a894 412 * <td>Run</td>
mbed_official 579:53297373a894 413 * <td>Run</td>
mbed_official 579:53297373a894 414 * <td>Normal</td>
mbed_official 579:53297373a894 415 * <td>Normal</td>
mbed_official 579:53297373a894 416 * </tr>
mbed_official 579:53297373a894 417 * <tr>
mbed_official 579:53297373a894 418 * <td>IDLE 1</td>
mbed_official 579:53297373a894 419 * <td>Stop</td>
mbed_official 579:53297373a894 420 * <td>Stop</td>
mbed_official 579:53297373a894 421 * <td>Run</td>
mbed_official 579:53297373a894 422 * <td>Run</td>
mbed_official 579:53297373a894 423 * <td>Run</td>
mbed_official 579:53297373a894 424 * <td>Run</td>
mbed_official 579:53297373a894 425 * <td>Normal</td>
mbed_official 579:53297373a894 426 * <td>Normal</td>
mbed_official 579:53297373a894 427 * </tr>
mbed_official 579:53297373a894 428 * <tr>
mbed_official 579:53297373a894 429 * <td>IDLE 2</td>
mbed_official 579:53297373a894 430 * <td>Stop</td>
mbed_official 579:53297373a894 431 * <td>Stop</td>
mbed_official 579:53297373a894 432 * <td>Stop</td>
mbed_official 579:53297373a894 433 * <td>Run</td>
mbed_official 579:53297373a894 434 * <td>Run</td>
mbed_official 579:53297373a894 435 * <td>Run</td>
mbed_official 579:53297373a894 436 * <td>Normal</td>
mbed_official 579:53297373a894 437 * <td>Normal</td>
mbed_official 579:53297373a894 438 * </tr>
mbed_official 579:53297373a894 439 * <tr>
mbed_official 579:53297373a894 440 * <td>STANDBY</td>
mbed_official 579:53297373a894 441 * <td>Stop</td>
mbed_official 579:53297373a894 442 * <td>Stop</td>
mbed_official 579:53297373a894 443 * <td>Stop</td>
mbed_official 579:53297373a894 444 * <td>Stop</td>
mbed_official 579:53297373a894 445 * <td>Stop</td>
mbed_official 579:53297373a894 446 * <td>Stop</td>
mbed_official 579:53297373a894 447 * <td>Low Power</td>
mbed_official 579:53297373a894 448 * <td>Source/Drain biasing</td>
mbed_official 579:53297373a894 449 * </tr>
mbed_official 579:53297373a894 450 * \endif
mbed_official 579:53297373a894 451 * </table>
mbed_official 579:53297373a894 452 *
mbed_official 579:53297373a894 453 * To enter device sleep, one of the available sleep modes must be set, and the
mbed_official 579:53297373a894 454 * function to enter sleep called. The device will automatically wake up in
mbed_official 579:53297373a894 455 * response to an interrupt being generated or other device event.
mbed_official 579:53297373a894 456 *
mbed_official 579:53297373a894 457 * Some peripheral clocks will remain enabled during sleep, depending on their
mbed_official 579:53297373a894 458 * configuration; if desired, modules can remain clocked during sleep to allow
mbed_official 579:53297373a894 459 * them to continue to operate while other parts of the system are powered down
mbed_official 579:53297373a894 460 * to save power.
mbed_official 579:53297373a894 461 *
mbed_official 579:53297373a894 462 *
mbed_official 579:53297373a894 463 * \section asfdoc_sam0_system_special_considerations Special Considerations
mbed_official 579:53297373a894 464 *
mbed_official 579:53297373a894 465 * Most of the functions in this driver have device specific restrictions and
mbed_official 579:53297373a894 466 * caveats; refer to your device datasheet.
mbed_official 579:53297373a894 467 *
mbed_official 579:53297373a894 468 *
mbed_official 579:53297373a894 469 * \section asfdoc_sam0_system_extra_info Extra Information
mbed_official 579:53297373a894 470 *
mbed_official 579:53297373a894 471 * For extra information, see \ref asfdoc_sam0_system_extra. This includes:
mbed_official 579:53297373a894 472 * - \ref asfdoc_sam0_system_extra_acronyms
mbed_official 579:53297373a894 473 * - \ref asfdoc_sam0_system_extra_dependencies
mbed_official 579:53297373a894 474 * - \ref asfdoc_sam0_system_extra_errata
mbed_official 579:53297373a894 475 * - \ref asfdoc_sam0_system_extra_history
mbed_official 579:53297373a894 476 *
mbed_official 579:53297373a894 477 *
mbed_official 579:53297373a894 478 * \section asfdoc_sam0_system_examples Examples
mbed_official 579:53297373a894 479 *
mbed_official 579:53297373a894 480 * For SYSTEM module related examples, refer to the sub-modules listed in
mbed_official 579:53297373a894 481 * the \ref asfdoc_sam0_system_module_overview "system module overview".
mbed_official 579:53297373a894 482 *
mbed_official 579:53297373a894 483 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 484 * For a list of examples related to this driver, see
mbed_official 579:53297373a894 485 * \ref asfdoc_sam0_drivers_power_exqsg.
mbed_official 579:53297373a894 486 * \endif
mbed_official 579:53297373a894 487 *
mbed_official 579:53297373a894 488 *
mbed_official 579:53297373a894 489 * \section asfdoc_sam0_system_api_overview API Overview
mbed_official 579:53297373a894 490 * @{
mbed_official 579:53297373a894 491 */
mbed_official 579:53297373a894 492
mbed_official 579:53297373a894 493 /**
mbed_official 579:53297373a894 494 * \name System Debugger
mbed_official 579:53297373a894 495 * @{
mbed_official 579:53297373a894 496 */
mbed_official 579:53297373a894 497
mbed_official 579:53297373a894 498 /**
mbed_official 579:53297373a894 499 * \brief Check if debugger is present.
mbed_official 579:53297373a894 500 *
mbed_official 579:53297373a894 501 * Check if debugger is connected to the onboard debug system (DAP).
mbed_official 579:53297373a894 502 *
mbed_official 579:53297373a894 503 * \return A bool identifying if a debugger is present.
mbed_official 579:53297373a894 504 *
mbed_official 579:53297373a894 505 * \retval true Debugger is connected to the system
mbed_official 579:53297373a894 506 * \retval false Debugger is not connected to the system
mbed_official 579:53297373a894 507 *
mbed_official 579:53297373a894 508 */
mbed_official 579:53297373a894 509 static inline bool system_is_debugger_present(void)
mbed_official 579:53297373a894 510 {
mbed_official 579:53297373a894 511 return DSU->STATUSB.reg & DSU_STATUSB_DBGPRES;
mbed_official 579:53297373a894 512 }
mbed_official 579:53297373a894 513
mbed_official 579:53297373a894 514 /**
mbed_official 579:53297373a894 515 * @}
mbed_official 579:53297373a894 516 */
mbed_official 579:53297373a894 517
mbed_official 579:53297373a894 518 /**
mbed_official 579:53297373a894 519 * \name System Identification
mbed_official 579:53297373a894 520 * @{
mbed_official 579:53297373a894 521 */
mbed_official 579:53297373a894 522
mbed_official 579:53297373a894 523 /**
mbed_official 579:53297373a894 524 * \brief Retrieve the device identification signature.
mbed_official 579:53297373a894 525 *
mbed_official 579:53297373a894 526 * Retrieves the signature of the current device.
mbed_official 579:53297373a894 527 *
mbed_official 579:53297373a894 528 * \return Device ID signature as a 32-bit integer.
mbed_official 579:53297373a894 529 */
mbed_official 579:53297373a894 530 static inline uint32_t system_get_device_id(void)
mbed_official 579:53297373a894 531 {
mbed_official 579:53297373a894 532 return DSU->DID.reg;
mbed_official 579:53297373a894 533 }
mbed_official 579:53297373a894 534
mbed_official 579:53297373a894 535 /**
mbed_official 579:53297373a894 536 * @}
mbed_official 579:53297373a894 537 */
mbed_official 579:53297373a894 538
mbed_official 579:53297373a894 539 /**
mbed_official 579:53297373a894 540 * \name System Initialization
mbed_official 579:53297373a894 541 * @{
mbed_official 579:53297373a894 542 */
mbed_official 579:53297373a894 543
mbed_official 579:53297373a894 544 void system_init(void);
mbed_official 579:53297373a894 545
mbed_official 579:53297373a894 546 /**
mbed_official 579:53297373a894 547 * @}
mbed_official 579:53297373a894 548 */
mbed_official 579:53297373a894 549
mbed_official 579:53297373a894 550
mbed_official 579:53297373a894 551 /**
mbed_official 579:53297373a894 552 * @}
mbed_official 579:53297373a894 553 */
mbed_official 579:53297373a894 554
mbed_official 579:53297373a894 555 /**
mbed_official 579:53297373a894 556
mbed_official 579:53297373a894 557 * \page asfdoc_sam0_drivers_power_exqsg Examples for Power Driver
mbed_official 579:53297373a894 558 *
mbed_official 579:53297373a894 559 * This is a list of the available Quick Start Guides (QSGs) and example
mbed_official 579:53297373a894 560 * applications. QSGs are simple examples with step-by-step instructions to
mbed_official 579:53297373a894 561 * configure and use this driver in a selection of
mbed_official 579:53297373a894 562 * use cases. Note that QSGs can be compiled as a standalone application or be
mbed_official 579:53297373a894 563 * added to the user application.
mbed_official 579:53297373a894 564 *
mbed_official 579:53297373a894 565 * - \subpage asfdoc_sam0_power_basic_use_case
mbed_official 579:53297373a894 566 *
mbed_official 579:53297373a894 567 * \page asfdoc_sam0_system_extra Extra Information for SYSTEM Driver
mbed_official 579:53297373a894 568 *
mbed_official 579:53297373a894 569 * \section asfdoc_sam0_system_extra_acronyms Acronyms
mbed_official 579:53297373a894 570 * Below is a table listing the acronyms used in this module, along with their
mbed_official 579:53297373a894 571 * intended meanings.
mbed_official 579:53297373a894 572 *
mbed_official 579:53297373a894 573 * <table>
mbed_official 579:53297373a894 574 * <tr>
mbed_official 579:53297373a894 575 * <th>Acronym</th>
mbed_official 579:53297373a894 576 * <th>Definition</th>
mbed_official 579:53297373a894 577 * </tr>
mbed_official 579:53297373a894 578 * <tr>
mbed_official 579:53297373a894 579 * <td>PM</td>
mbed_official 579:53297373a894 580 * <td>Power Manager</td>
mbed_official 579:53297373a894 581 * </tr>
mbed_official 579:53297373a894 582 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 583 * <tr>
mbed_official 579:53297373a894 584 * <td>SUPC</td>
mbed_official 579:53297373a894 585 * <td>Supply Controller</td>
mbed_official 579:53297373a894 586 * </tr>
mbed_official 579:53297373a894 587 * <tr>
mbed_official 579:53297373a894 588 * <td>RSTC</td>
mbed_official 579:53297373a894 589 * <td>Reset Controller</td>
mbed_official 579:53297373a894 590 * </tr>
mbed_official 579:53297373a894 591 * \else
mbed_official 579:53297373a894 592 * <tr>
mbed_official 579:53297373a894 593 * <td>SYSCTRL</td>
mbed_official 579:53297373a894 594 * <td>System control interface</td>
mbed_official 579:53297373a894 595 * </tr>
mbed_official 579:53297373a894 596 * \endif
mbed_official 579:53297373a894 597 * </table>
mbed_official 579:53297373a894 598 *
mbed_official 579:53297373a894 599 *
mbed_official 579:53297373a894 600 * \section asfdoc_sam0_system_extra_dependencies Dependencies
mbed_official 579:53297373a894 601 * This driver has the following dependencies:
mbed_official 579:53297373a894 602 *
mbed_official 579:53297373a894 603 * - None
mbed_official 579:53297373a894 604 *
mbed_official 579:53297373a894 605 *
mbed_official 579:53297373a894 606 * \section asfdoc_sam0_system_extra_errata Errata
mbed_official 579:53297373a894 607 * There are no errata related to this driver.
mbed_official 579:53297373a894 608 *
mbed_official 579:53297373a894 609 *
mbed_official 579:53297373a894 610 * \section asfdoc_sam0_system_extra_history Module History
mbed_official 579:53297373a894 611 * An overview of the module history is presented in the table below, with
mbed_official 579:53297373a894 612 * details on the enhancements and fixes made to the module since its first
mbed_official 579:53297373a894 613 * release. The current version of this corresponds to the newest version in
mbed_official 579:53297373a894 614 * the table.
mbed_official 579:53297373a894 615 *
mbed_official 579:53297373a894 616 * <table>
mbed_official 579:53297373a894 617 * <tr>
mbed_official 579:53297373a894 618 * <th>Changelog</th>
mbed_official 579:53297373a894 619 * </tr>
mbed_official 579:53297373a894 620 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 621 * <tr>
mbed_official 579:53297373a894 622 * <td>Initial Release</td>
mbed_official 579:53297373a894 623 * </tr>
mbed_official 579:53297373a894 624 * \else
mbed_official 579:53297373a894 625 * <tr>
mbed_official 579:53297373a894 626 * <td>Added low power features and support for SAML21</td>
mbed_official 579:53297373a894 627 * </tr>
mbed_official 579:53297373a894 628 * <tr>
mbed_official 579:53297373a894 629 * <td>Added support for SAMD21</td>
mbed_official 579:53297373a894 630 * </tr>
mbed_official 579:53297373a894 631 * <tr>
mbed_official 579:53297373a894 632 * <td>Added new \c system_reset() to reset the complete MCU with some exceptions</td>
mbed_official 579:53297373a894 633 * </tr>
mbed_official 579:53297373a894 634 * <tr>
mbed_official 579:53297373a894 635 * <td>Added new \c system_get_device_id() function to retrieved the device
mbed_official 579:53297373a894 636 * ID.</td>
mbed_official 579:53297373a894 637 * </tr>
mbed_official 579:53297373a894 638 * <tr>
mbed_official 579:53297373a894 639 * <td>Initial Release</td>
mbed_official 579:53297373a894 640 * </tr>
mbed_official 579:53297373a894 641 * \endif
mbed_official 579:53297373a894 642 * </table>
mbed_official 579:53297373a894 643 *
mbed_official 579:53297373a894 644 * \page asfdoc_sam0_system_document_revision_history Document Revision History
mbed_official 579:53297373a894 645 *
mbed_official 579:53297373a894 646 * <table>
mbed_official 579:53297373a894 647 * <tr>
mbed_official 579:53297373a894 648 * <th>Doc. Rev.</td>
mbed_official 579:53297373a894 649 * <th>Date</td>
mbed_official 579:53297373a894 650 * <th>Comments</td>
mbed_official 579:53297373a894 651 * </tr>
mbed_official 579:53297373a894 652 * \if DEVICE_SAML21_SUPPORT
mbed_official 579:53297373a894 653 * <tr>
mbed_official 579:53297373a894 654 * <td>A</td>
mbed_official 579:53297373a894 655 * <td>12/2014</td>
mbed_official 579:53297373a894 656 * <td>Initial release.</td>
mbed_official 579:53297373a894 657 * </tr>
mbed_official 579:53297373a894 658 * \else
mbed_official 579:53297373a894 659 * <tr>
mbed_official 579:53297373a894 660 * <td>D</td>
mbed_official 579:53297373a894 661 * <td>12/2014</td>
mbed_official 579:53297373a894 662 * <td>Added support for SAMR21 and SAMD10/D11.</td>
mbed_official 579:53297373a894 663 * </tr>
mbed_official 579:53297373a894 664 * <tr>
mbed_official 579:53297373a894 665 * <td>C</td>
mbed_official 579:53297373a894 666 * <td>01/2014</td>
mbed_official 579:53297373a894 667 * <td>Added support for SAMD21.</td>
mbed_official 579:53297373a894 668 * </tr>
mbed_official 579:53297373a894 669 * <tr>
mbed_official 579:53297373a894 670 * <td>B</td>
mbed_official 579:53297373a894 671 * <td>06/2013</td>
mbed_official 579:53297373a894 672 * <td>Corrected documentation typos.</td>
mbed_official 579:53297373a894 673 * </tr>
mbed_official 579:53297373a894 674 * <tr>
mbed_official 579:53297373a894 675 * <td>A</td>
mbed_official 579:53297373a894 676 * <td>06/2013</td>
mbed_official 579:53297373a894 677 * <td>Initial release</td>
mbed_official 579:53297373a894 678 * </tr>
mbed_official 579:53297373a894 679 * \endif
mbed_official 579:53297373a894 680 * </table>
mbed_official 579:53297373a894 681 */
mbed_official 579:53297373a894 682
mbed_official 579:53297373a894 683 #ifdef __cplusplus
mbed_official 579:53297373a894 684 }
mbed_official 579:53297373a894 685 #endif
mbed_official 579:53297373a894 686
mbed_official 579:53297373a894 687 #endif /* SYSTEM_H_INCLUDED */
mbed_official 579:53297373a894 688