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 SAM device controls the voltage regulators for the core (VDDCORE). It sets the voltage regulators according to the sleep modes.
There are a selectable reference voltage and voltage dependent on the temperature which can be used by analog modules like the ADC.
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.
Data Structures | |
struct | system_standby_config |
Standby configuration. More... | |
struct | system_voltage_references_config |
Voltage References System (VREF) Control configuration. More... | |
struct | system_voltage_regulator_config |
Voltage Regulator System (VREG) Control configuration. More... | |
Enumerations | |
enum | system_reset_cause { SYSTEM_RESET_CAUSE_SOFTWARE = RSTC_RCAUSE_SYST, SYSTEM_RESET_CAUSE_WDT = RSTC_RCAUSE_WDT, SYSTEM_RESET_CAUSE_EXTERNAL_RESET = RSTC_RCAUSE_EXT, SYSTEM_RESET_CAUSE_BODVDD = RSTC_RCAUSE_BODVDD, SYSTEM_RESET_CAUSE_BODCORE = RSTC_RCAUSE_BODCORE, SYSTEM_RESET_CAUSE_POR = RSTC_RCAUSE_POR } |
Reset causes of the system. More... | |
enum | system_sleepmode { SYSTEM_SLEEPMODE_IDLE_0 = PM_SLEEPCFG_SLEEPMODE(0), SYSTEM_SLEEPMODE_IDLE_1 = PM_SLEEPCFG_SLEEPMODE(0x1), SYSTEM_SLEEPMODE_IDLE_2 = PM_SLEEPCFG_SLEEPMODE(0x2), SYSTEM_SLEEPMODE_STANDBY = PM_SLEEPCFG_SLEEPMODE(0x4) } |
Device sleep modes. More... | |
enum | system_voltage_reference { SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE, SYSTEM_VOLTAGE_REFERENCE_OUTPUT } |
Voltage reference. More... | |
enum | system_voltage_references_sel { SYSTEM_VOLTAGE_REFERENCE_1V024 = SUPC_VREF_SEL_1V024_Val, SYSTEM_VOLTAGE_REFERENCE_2V048 = SUPC_VREF_SEL_2V048_Val, SYSTEM_VOLTAGE_REFERENCE_4V096 = SUPC_VREF_SEL_4V096_Val } |
Voltage reference value for ADC/DAC. More... | |
enum | system_vreg_switch_mode { SYSTEM_VREG_SWITCH_AUTO = PM_STDBYCFG_VREGSMOD_AUTO_Val, SYSTEM_VREG_SWITCH_PERFORMANCE = PM_STDBYCFG_VREGSMOD_PERFORMANCE_Val, SYSTEM_VREG_SWITCH_LP = PM_STDBYCFG_VREGSMOD_LP_Val } |
Voltage Regulator switch in Standby mode. More... | |
Reset Control | |
static void | system_reset (void) |
Reset the MCU. More... | |
static enum system_reset_cause | system_get_reset_cause (void) |
Get the reset cause. 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 Regulator | |
static void | system_voltage_regulator_get_config_defaults (struct system_voltage_regulator_config *const config) |
Retrieve the default configuration for voltage regulator. More... | |
static void | system_voltage_regulator_set_config (struct system_voltage_regulator_config *const config) |
Configure voltage regulator. More... | |
static void | system_voltage_regulator_enable (void) |
Enable the selected voltage regulator. More... | |
static void | system_voltage_regulator_disable (void) |
Disable the selected voltage regulator. More... | |
Voltage References | |
static void | system_voltage_reference_get_config_defaults (struct system_voltage_references_config *const config) |
Retrieve the default configuration for voltage reference. More... | |
static void | system_voltage_reference_set_config (struct system_voltage_references_config *const config) |
Configure voltage reference. More... | |
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 void | 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... | |
Standby Configuration | |
static void | system_standby_get_config_defaults (struct system_standby_config *const config) |
Retrieve the default configuration for standby. More... | |
static void | system_standby_set_config (struct system_standby_config *const config) |
Configure standby mode. 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 |
Get the reset cause.
Retrieves the cause of the last system reset.
Referenced by main().
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_divas_init(), _system_events_init(), _system_extint_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 _i2c_slave_set_config(), _spi_set_config(), _usart_set_config(), and spi_master_vec_init().
|
inlinestatic |
Reset the MCU.
Resets the MCU and all associated peripherals and registers, except RTC, OSC32KCTRL, RSTC, GCLK(if WRTLOCK is set) and I/O retention state of PM.
|
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 |
Referenced by main(), and sleepmgr_sleep().
|
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.
Referenced by main(), and sleepmgr_sleep().
|
inlinestatic |
Retrieve the default configuration for standby.
Fills a configuration structure with the default configuration for standby:
[out] | config | Configuration structure to fill with default values |
References Assert, system_standby_config::hmcramchs_back_bias, SYSTEM_VREG_SWITCH_AUTO, and system_standby_config::vreg_switch_mode.
Referenced by main().
|
inlinestatic |
Configure standby mode.
Configures standby with the given configuration.
[in] | config | Standby configuration structure containing the new config |
References Assert, system_standby_config::hmcramchs_back_bias, and system_standby_config::vreg_switch_mode.
Referenced by main().
|
inlinestatic |
Disable the selected voltage reference.
Disables the selected voltage reference source.
[in] | vref | Voltage reference to disable |
References Assert, SYSTEM_VOLTAGE_REFERENCE_OUTPUT, 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_OUTPUT, and SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE.
Referenced by adc_init(), and dac_enable().
|
inlinestatic |
Retrieve the default configuration for voltage reference.
Fill a configuration structure with the default configuration:
[out] | config | Configuration structure to fill with default values |
References Assert, system_voltage_references_config::on_demand, system_voltage_references_config::run_in_standby, system_voltage_references_config::sel, and SYSTEM_VOLTAGE_REFERENCE_1V024.
|
inlinestatic |
Configure voltage reference.
Configures voltage reference with the given configuration.
[in] | config | Voltage reference configuration structure containing the new config |
References Assert, system_voltage_references_config::on_demand, system_voltage_references_config::run_in_standby, and system_voltage_references_config::sel.
|
inlinestatic |
Disable the selected voltage regulator.
Disables the selected voltage regulator.
|
inlinestatic |
Enable the selected voltage regulator.
Enables the selected voltage regulator source.
|
inlinestatic |
Retrieve the default configuration for voltage regulator.
Fills a configuration structure with the default configuration:
[out] | config | Configuration structure to fill with default values |
References Assert, and system_voltage_regulator_config::run_in_standby.
|
inlinestatic |
Configure voltage regulator.
Configures voltage regulator with the given configuration.
[in] | config | Voltage regulator configuration structure containing the new config |
References system_voltage_regulator_config::run_in_standby.