This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's system relation functionality, necessary for the basic device operation.
This is not limited to a single peripheral, but extends across multiple hardware peripherals.
The following peripherals are used by this module:
The following devices can use this module:
The outline of this documentation is as follows:
There are no prerequisites for this module.
The System driver provides a collection of interfaces between the user application logic, and the core device functionality (such as clocks, reset cause determination, etc.) that is required for all applications. It contains a number of sub-modules that control one specific aspect of the device:
The various analog modules within the SAM devices (such as AC, ADC, and DAC) require a voltage reference to be configured to act as a reference point for comparisons and conversions.
The SAM devices contain multiple references, including an internal temperature sensor and a fixed band-gap voltage source. When enabled, the associated voltage reference can be selected within the desired peripheral where applicable.
In some applications there may be a need to execute a different program flow based on how the device was reset. For example, if the cause of reset was the Watchdog timer (WDT), this might indicate an error in the application, and a form of error handling or error logging might be needed.
For this reason, an API is provided to retrieve the cause of the last system reset, so that appropriate action can be taken.
The SAM devices have several sleep modes. The sleep mode controls which clock systems on the device will remain enabled or disabled when the device enters a low power sleep mode. The table below lists the clock settings of the different sleep modes.
Sleep mode | CPU clock | AHB clock | APB clocks | Clock sources | System clock | 32KHz | Reg mode | RAM mode |
---|---|---|---|---|---|---|---|---|
Idle 0 | Stop | Run | Run | Run | Run | Run | Normal | Normal |
Idle 1 | Stop | Stop | Run | Run | Run | Run | Normal | Normal |
Idle 2 | Stop | Stop | Stop | Run | Run | Run | Normal | Normal |
Standby | Stop | Stop | Stop | Stop | Stop | Stop | Low Power | Source/Drain biasing |
Before entering device sleep, one of the available sleep modes must be set. The device will automatically wake up in response to an interrupt being generated or upon any other sleep mode exit condition.
Some peripheral clocks will remain enabled during sleep, depending on their configuration. If desired, the modules can remain clocked during sleep to allow them continue to operate while other parts of the system are powered down to save power.
Most of the functions in this driver have device specific restrictions and caveats; refer to your device datasheet.
For extra information, see Extra Information for SYSTEM Driver. This includes:
For SYSTEM module related examples, refer to the sub-modules listed in the Module Overview.
Enumerations | |
enum | system_reset_cause { SYSTEM_RESET_CAUSE_SOFTWARE = PM_RCAUSE_SYST, SYSTEM_RESET_CAUSE_WDT = PM_RCAUSE_WDT, SYSTEM_RESET_CAUSE_EXTERNAL_RESET = PM_RCAUSE_EXT, SYSTEM_RESET_CAUSE_BOD33 = PM_RCAUSE_BOD33, SYSTEM_RESET_CAUSE_BOD12 = PM_RCAUSE_BOD12, SYSTEM_RESET_CAUSE_POR = PM_RCAUSE_POR } |
Reset causes of the system. More... | |
enum | system_sleepmode { SYSTEM_SLEEPMODE_IDLE_0, SYSTEM_SLEEPMODE_IDLE_1, SYSTEM_SLEEPMODE_IDLE_2, SYSTEM_SLEEPMODE_STANDBY } |
Device sleep modes. More... | |
enum | system_voltage_reference { SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE, SYSTEM_VOLTAGE_REFERENCE_BANDGAP } |
Voltage references within the device. More... | |
System Debugger | |
static bool | system_is_debugger_present (void) |
Check if debugger is present. More... | |
System Identification | |
static uint32_t | system_get_device_id (void) |
Retrieve the device identification signature. More... | |
System Initialization | |
void | system_init (void) |
Initialize system. More... | |
Voltage References | |
static void | system_voltage_reference_enable (const enum system_voltage_reference vref) |
Enable the selected voltage reference. More... | |
static void | system_voltage_reference_disable (const enum system_voltage_reference vref) |
Disable the selected voltage reference. More... | |
Device Sleep Control | |
static enum status_code | system_set_sleepmode (const enum system_sleepmode sleep_mode) |
Set the sleep mode of the device. More... | |
static void | system_sleep (void) |
Put the system to sleep waiting for interrupt. More... | |
Reset Control | |
static void | system_reset (void) |
Reset the MCU. More... | |
static enum system_reset_cause | system_get_reset_cause (void) |
Return the reset cause. More... | |
enum system_reset_cause |
Reset causes of the system.
List of possible reset causes of the system.
enum system_sleepmode |
Device sleep modes.
List of available sleep modes in the device. A table of clocks available in different sleep modes can be found in Sleep Modes.
Enumerator | |
---|---|
SYSTEM_SLEEPMODE_IDLE_0 |
IDLE 0 sleep mode. |
SYSTEM_SLEEPMODE_IDLE_1 |
IDLE 1 sleep mode. |
SYSTEM_SLEEPMODE_IDLE_2 |
IDLE 2 sleep mode. |
SYSTEM_SLEEPMODE_STANDBY |
Standby sleep mode. |
|
inlinestatic |
Retrieve the device identification signature.
Retrieves the signature of the current device.
|
inlinestatic |
Return the reset cause.
Retrieves the cause of the last system reset.
void system_init | ( | void | ) |
Initialize system.
This function will call the various initialization functions within the system namespace. If a given optional system module is not available, the associated call will effectively be a NOP (No Operation).
Currently the following initialization functions are supported:
References system_board_init(), and system_clock_init().
Referenced by main().
|
inlinestatic |
Check if debugger is present.
Check if debugger is connected to the onboard debug system (DAP).
true | Debugger is connected to the system |
false | Debugger is not connected to the system |
Referenced by _usart_set_config().
|
inlinestatic |
Reset the MCU.
Resets the MCU and all associated peripherals and registers, except RTC, all 32KHz sources, WDT (if ALWAYSON is set) and GCLK (if WRTLOCK is set).
|
inlinestatic |
Set the sleep mode of the device.
Sets the sleep mode of the device; the configured sleep mode will be entered upon the next call of the system_sleep() function.
For an overview of which systems are disabled in sleep for the different sleep modes, see Sleep Modes.
[in] | sleep_mode | Sleep mode to configure for the next sleep operation |
STATUS_OK | Operation completed successfully |
STATUS_ERR_INVALID_ARG | The requested sleep mode was invalid or not available |
References _SYSTEM_MCU_REVISION_D, _SYSTEM_MCU_REVISION_E, STATUS_ERR_INVALID_ARG, STATUS_OK, SYSTEM_SLEEPMODE_IDLE_0, SYSTEM_SLEEPMODE_IDLE_1, SYSTEM_SLEEPMODE_IDLE_2, and SYSTEM_SLEEPMODE_STANDBY.
|
inlinestatic |
Put the system to sleep waiting for interrupt.
Executes a device DSB (Data Synchronization Barrier) instruction to ensure all ongoing memory accesses have completed, then a WFI (Wait For Interrupt) instruction to place the device into the sleep mode specified by system_set_sleepmode until woken by an interrupt.
|
inlinestatic |
Disable the selected voltage reference.
Disables the selected voltage reference source.
[in] | vref | Voltage reference to disable |
References Assert, SYSTEM_VOLTAGE_REFERENCE_BANDGAP, and SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE.
|
inlinestatic |
Enable the selected voltage reference.
Enables the selected voltage reference source, making the voltage reference available on a pin as well as an input source to the analog peripherals.
[in] | vref | Voltage reference to enable |
References Assert, SYSTEM_VOLTAGE_REFERENCE_BANDGAP, and SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE.