mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

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

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

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

Import librarymbed

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

Committer:
mbed_official
Date:
Fri Jul 17 09:15:10 2015 +0100
Revision:
592:a274ee790e56
Parent:
579:53297373a894
Synchronized with git revision e7144f83a8d75df80c4877936b6ffe552b0be9e6

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

More API implementation for SAMR21

Who changed what in which revision?

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