Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM System (SYSTEM) Driver

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:

Prerequisites

There are no prerequisites for this module.

Module Overview

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:

Voltage Regulator

The SAM device controls the voltage regulators for the core (VDDCORE) and backup (VDDBU) domains. It sets the voltage regulators according to the sleep modes, the performance level, or the user configuration.

In active mode, the voltage regulator can be chosen on the fly between a LDO or a Buck converter. In standby mode, the low power voltage regulator is used to supply VDDCORE.

Battery Backup Power Switch

The SAM device supports connection of a battery backup to the VBAT power pin. It includes functionality that enables automatic power switching between main power and battery backup power. This will ensure power to the backup domain, when the main battery or power source is unavailable.

Voltage References

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.

System Reset Cause

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.

There are three groups of reset sources:

Performance Level

Performance level allows the user to adjust the regulator output voltage to reduce power consumption. The user can on the fly select the most suitable performance level, depending on the application demands.

The SAM device can operate at two different performance levels (PL0 and PL2). When operating at PL0, the voltage applied on the full logic area is reduced by voltage scaling. This voltage scaling technique allows to reduce the active power consumption while decreasing the maximum frequency of the device. When operating at PL2, the voltage regulator supplies the highest voltage, allowing the device to run at higher clock speeds.

Performance level transition is possible only when the device is in active mode. After a reset, the device starts at the lowest performance level (lowest power consumption and lowest max. frequency). The application can then switch to another performance level at any time without any stop in the code execution. As shown in asfdoc_sam0_system_performance_level_transition_figure.

Note
When scaling down the performance level, the bus frequency should first be scaled down in order to not exceed the maximum frequency allowed for the low performance level. When scaling up the performance level (e.g. from PL0 to PL2), check the performance level status before increasing the bus frequency. It can be increased only when the performance level transition is completed.

performance_level_transition.svg
Performance Level Transition

Power Domain Gating

Power domain gating allows power saving by reducing the voltage in logic areas in the device to a low-power supply. The feature is available in Standby sleep mode and will reduce the voltage in domains where all peripherals are idle. Internal logic will maintain its content, meaning the corresponding peripherals will not need to be reconfigured when normal operating voltage is returned. Most power domains can be in the following three states:

The SAM L21 device contains three power domains which can be controlled using power domain gating, namely PD0, PD1, and PD2. These power domains can be configured to the following cases:

Power domains can be linked to each other, it allows a power domain (PDn) to be kept in active state if the inferior power domain (PDn-1) is in active state too.

asfdoc_sam0_system_power_domain_overview_table illustrates the four cases to consider in standby mode.

Sleep Mode versus Power Domain State Overview
Sleep mode PD0 PD1 PD2 PDTOP PDBACKUP
Idle active active active active active
Standby - Case 1 active active active active active
Standby - Case 2 active active retention active active
Standby - Case 3 active retention retention active active
Standby - Case 4 retention retention retention active active
Backup off off off off active
Off off off off off off

RAMs Low Power Mode

By default, in standby sleep mode, RAM is in low power mode (back biased) if its power domain is in retention state. asfdoc_sam0_system_power_ram_state_table lists RAMs low power mode.

RAM Back-biasing Mode
RAM mode Description
Retention Back-biasing mode RAM is back-biased if its power domain is in retention mode
Standby Back-biasing mode RAM is back-biased if the device is in standby mode
Standby OFF mode RAM is OFF if the device is in standby mode
Always OFF mode RAM is OFF if the device is in RET mode

Sleep Modes

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.

SAM Device Sleep Modes
Sleep mode System clock CPU clock AHB/AHB clock GCLK clocks Oscillators (ONDEMAND = 0) Oscillators (ONDEMAND = 1) Regulator mode RAM mode
Idle Run Stop Run if requested Run Run Run if requested Normal Normal
Standby Stop Stop Run if requested Run if requested Run if requested or RUNSTDBY = 1 Run if requested Low pwer Low pwer
Backup Stop Stop Stop Stop Stop Stop Backup Off
Off Off Off Off Off Off Off Off Off

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.

Special Considerations

Most of the functions in this driver have device specific restrictions and caveats; refer to your device datasheet.

Extra Information

For extra information, see Extra Information for SYSTEM Driver. This includes:

Examples

For SYSTEM module related examples, refer to the sub-modules listed in the Module Overview.

For a list of examples related to this driver, see Examples for SYSTEM Driver.

API Overview

Data Structures

struct  system_battery_backup_power_switch_config
 Battery Backup Power Switch (BBPS) Control configuration. More...
 
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_backup_pin {
  SYSTEM_BACKUP_PIN_PSOK = (0x1 << 0),
  SYSTEM_BACKUP_PIN_OUT_0 = (0x1 << 1),
  SYSTEM_BACKUP_PIN_OUT_1 = (0x1 << 2)
}
 Backup IO enum. More...
 
enum  system_battery_power_switch {
  SYSTEM_BATTERY_POWER_SWITCH_NONE = SUPC_BBPS_CONF_NONE_Val,
  SYSTEM_BATTERY_POWER_SWITCH_AUTOMATIC = SUPC_BBPS_CONF_APWS_Val,
  SYSTEM_BATTERY_POWER_SWITCH_FORCED = SUPC_BBPS_CONF_FORCED_Val,
  SYSTEM_BATTERY_POWER_SWITCH_BOD33 = SUPC_BBPS_CONF_BOD33_Val
}
 Battery power switch configuration enum. More...
 
enum  system_performance_level {
  SYSTEM_PERFORMANCE_LEVEL_0 = PM_PLCFG_PLSEL_PL0,
  SYSTEM_PERFORMANCE_LEVEL_2 = PM_PLCFG_PLSEL_PL2
}
 Performance level. More...
 
enum  system_ram_back_bias_mode {
  SYSTEM_RAM_BACK_BIAS_RETENTION = 0,
  SYSTEM_RAM_BACK_BIAS_STANDBY,
  SYSTEM_RAM_BACK_BIAS_STANDBY_OFF,
  SYSTEM_RAM_BACK_BIAS_OFF
}
 RAM Back-biasing mode. More...
 
enum  system_reset_backup_exit_source {
  SYSTEM_RESET_BACKKUP_EXIT_RTC = RSTC_BKUPEXIT_RTC,
  SYSTEM_RESET_BACKKUP_EXIT_BBPS = RSTC_BKUPEXIT_BBPS
}
 Backup exit source after a backup reset occurs. More...
 
enum  system_reset_cause {
  SYSTEM_RESET_CAUSE_BACKUP = RSTC_RCAUSE_BACKUP,
  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_BOD33 = RSTC_RCAUSE_BODVDD,
  SYSTEM_RESET_CAUSE_BOD12 = RSTC_RCAUSE_BODCORE,
  SYSTEM_RESET_CAUSE_POR = RSTC_RCAUSE_POR
}
 Reset causes of the system. More...
 
enum  system_sleepmode {
  SYSTEM_SLEEPMODE_IDLE = PM_SLEEPCFG_SLEEPMODE(0x2),
  SYSTEM_SLEEPMODE_STANDBY = PM_SLEEPCFG_SLEEPMODE_STANDBY,
  SYSTEM_SLEEPMODE_BACKUP = PM_SLEEPCFG_SLEEPMODE_BACKUP,
  SYSTEM_SLEEPMODE_OFF = PM_SLEEPCFG_SLEEPMODE_OFF
}
 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_1V0 = SUPC_VREF_SEL_1V0_Val,
  SYSTEM_VOLTAGE_REFERENCE_1V1 = SUPC_VREF_SEL_1V1_Val,
  SYSTEM_VOLTAGE_REFERENCE_1V2 = SUPC_VREF_SEL_1V2_Val,
  SYSTEM_VOLTAGE_REFERENCE_1V25 = SUPC_VREF_SEL_1V25_Val,
  SYSTEM_VOLTAGE_REFERENCE_2V0 = SUPC_VREF_SEL_2V0_Val,
  SYSTEM_VOLTAGE_REFERENCE_2V2 = SUPC_VREF_SEL_2V2_Val,
  SYSTEM_VOLTAGE_REFERENCE_2V4 = SUPC_VREF_SEL_2V4_Val,
  SYSTEM_VOLTAGE_REFERENCE_2V5 = SUPC_VREF_SEL_2V5_Val
}
 Voltage reference value. More...
 
enum  system_voltage_regulator_low_power_efficiency {
  SYSTEM_VOLTAGE_REGULATOR_LOW_POWER_EFFICIENCY_DEFAULT,
  SYSTEM_VOLTAGE_REGULATOR_LOW_POWER_EFFICIENCY_HIGHTEST
}
 Low power efficiency. More...
 
enum  system_voltage_regulator_sel {
  SYSTEM_VOLTAGE_REGULATOR_LDO = SUPC_VREG_SEL_LDO_Val,
  SYSTEM_VOLTAGE_REGULATOR_BUCK = SUPC_VREG_SEL_BUCK_Val
}
 Voltage regulator. 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...
 

Battery Backup Power Switch

static void system_battery_backup_power_switch_get_config_defaults (struct system_battery_backup_power_switch_config *const config)
 Retrieve the default configuration for battery backup power switch control. More...
 
static void system_battery_backup_power_switch_set_config (struct system_battery_backup_power_switch_config *const config)
 Configure battery backup power switch. More...
 

Output Pins in Backup Mode

static void system_backup_pin_output_enable (enum system_backup_pin pin)
 Enable the backup pin output. More...
 
static void system_backup_pin_output_disable (enum system_backup_pin pin)
 Disable the backup pin output. More...
 
static bool system_backup_pin_output_is_enabled (enum system_backup_pin pin)
 Check if backup pin output is enabled. More...
 
static void system_backup_pin_output_enable_rtc_toggle (enum system_backup_pin pin)
 Enable the backup pin toggle on RTC event. More...
 
static void system_backup_pin_output_disable_rtc_toggle (enum system_backup_pin pin)
 Disable the backup pin toggle on RTC event. More...
 
static void system_backup_pin_output_set (enum system_backup_pin pin)
 Set the backup pin. More...
 
static void system_backup_pin_output_clear (enum system_backup_pin pin)
 Clear the backup pin. More...
 
static bool system_backup_pin_output_get (enum system_backup_pin pin)
 Get the backup I/O input values. 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...
 

Performance Level Control

static enum status_code system_switch_performance_level (const enum system_performance_level performance_level)
 Switch performance level. More...
 
static enum
system_performance_level 
system_get_performance_level (void)
 Get performance level. More...
 
static uint8_t system_get_performance_level_status (void)
 Get performance level status. More...
 
static void system_clear_performance_level_status (void)
 Clear performance level status. 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...
 

I/O Retention

static void system_io_retension_enable (void)
 Enable I/O retention. More...
 
static void system_io_retension_disable (void)
 Disable I/O retention. 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...
 

Backup Exit Control

static enum
system_reset_backup_exit_source 
system_get_backup_exit_source (void)
 Get the backup exit source. More...
 

Backup IO enum.

List of Backup input and output pins. If enabled (system_backup_pin_output_enable), the pins can be driven by the SUPC.

Enumerator
SYSTEM_BACKUP_PIN_PSOK 

Power Supply OK status pin.

SYSTEM_BACKUP_PIN_OUT_0 

Backup output pin 0.

SYSTEM_BACKUP_PIN_OUT_1 

Backup output pin 1.

Battery power switch configuration enum.

Enum for Battery power switch modes.

Enumerator
SYSTEM_BATTERY_POWER_SWITCH_NONE 

The backup domain is always supplied by main power.

SYSTEM_BATTERY_POWER_SWITCH_AUTOMATIC 

The power switch is handled by the automatic power switch.

SYSTEM_BATTERY_POWER_SWITCH_FORCED 

The backup domain is always supplied by battery backup power.

SYSTEM_BATTERY_POWER_SWITCH_BOD33 

The power switch is handled by the BOD33.

Performance level.

List of performance levels. Performance level technique consists of adjusting the regulator output voltage to reduce power consumption.

Enumerator
SYSTEM_PERFORMANCE_LEVEL_0 

Performance level 0.

SYSTEM_PERFORMANCE_LEVEL_2 

Performance level 2.

RAM Back-biasing mode.

List of RAM back bias modes. By default, in standby sleep mode, RAM is in low power mode (back biased) if its power domain is in retention state. This behavior can be changed by configuring the Back Bias bit groups in STDBYCFG(STDBYCFG.BBIASxx).

Enumerator
SYSTEM_RAM_BACK_BIAS_RETENTION 

Retention Back biasing mode.

SYSTEM_RAM_BACK_BIAS_STANDBY 

Standby Back Biasing mode.

SYSTEM_RAM_BACK_BIAS_STANDBY_OFF 

Standby OFF mode.

SYSTEM_RAM_BACK_BIAS_OFF 

Always OFF mode.

Backup exit source after a backup reset occurs.

List of possible backup exit source.

Enumerator
SYSTEM_RESET_BACKKUP_EXIT_RTC 

The backup exit source was RTC interrupt.

SYSTEM_RESET_BACKKUP_EXIT_BBPS 

The backup exit source was battery backup power switch.

Reset causes of the system.

List of possible reset causes of the system.

Enumerator
SYSTEM_RESET_CAUSE_BACKUP 

The system was last reset by a backup reset.

SYSTEM_RESET_CAUSE_SOFTWARE 

The system was last reset by a software reset.

SYSTEM_RESET_CAUSE_WDT 

The system was last reset by the watchdog timer.

SYSTEM_RESET_CAUSE_EXTERNAL_RESET 

The system was last reset because the external reset line was pulled low.

SYSTEM_RESET_CAUSE_BOD33 

The system was last reset by the BOD VDD.

SYSTEM_RESET_CAUSE_BOD12 

The system was last reset by the BOD CORE.

SYSTEM_RESET_CAUSE_POR 

The system was last reset by the POR (Power on reset).

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 

IDLE sleep mode.

SYSTEM_SLEEPMODE_STANDBY 

STANDBY sleep mode.

SYSTEM_SLEEPMODE_BACKUP 

BACKUP sleep mode.

SYSTEM_SLEEPMODE_OFF 

OFF sleep mode.

Voltage reference.

List of available voltage references (VREF) that may be used within the device.

Enumerator
SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE 

Temperature sensor voltage reference.

SYSTEM_VOLTAGE_REFERENCE_OUTPUT 

Voltage reference output.

Voltage reference value.

Voltage references selection.

Enumerator
SYSTEM_VOLTAGE_REFERENCE_1V0 

1.0V voltage reference typical value

SYSTEM_VOLTAGE_REFERENCE_1V1 

1.1V voltage reference typical value

SYSTEM_VOLTAGE_REFERENCE_1V2 

1.2V voltage reference typical value

SYSTEM_VOLTAGE_REFERENCE_1V25 

1.25V voltage reference typical value

SYSTEM_VOLTAGE_REFERENCE_2V0 

2.0V voltage reference typical value

SYSTEM_VOLTAGE_REFERENCE_2V2 

2.2V voltage reference typical value

SYSTEM_VOLTAGE_REFERENCE_2V4 

2.4V voltage reference typical value

SYSTEM_VOLTAGE_REFERENCE_2V5 

2.5V voltage reference typical value

Low power efficiency.

Low power mode efficiency.

Enumerator
SYSTEM_VOLTAGE_REGULATOR_LOW_POWER_EFFICIENCY_DEFAULT 

The voltage regulator in Low power mode has the default efficiency and support the whole VDD range (1.62V to 3.6V)

SYSTEM_VOLTAGE_REGULATOR_LOW_POWER_EFFICIENCY_HIGHTEST 

The voltage regulator in Low power mode has the highest efficiency and support the limited VDD range (2.5V to 3.6V)

Voltage regulator.

Voltage regulators selection. In active mode, the voltage regulator can be chosen on the fly between a LDO or a Buck converter.

Enumerator
SYSTEM_VOLTAGE_REGULATOR_LDO 

The voltage regulator in active mode is a LDO voltage regulator.

SYSTEM_VOLTAGE_REGULATOR_BUCK 

The voltage regulator in active mode is a buck converter.

static void system_backup_pin_output_clear ( enum system_backup_pin  pin)
inlinestatic

Clear the backup pin.

Clear the corresponding output.

Parameters
[in]pinBackup pin index

References Assert, and SYSTEM_BACKUP_PIN_PSOK.

static void system_backup_pin_output_disable ( enum system_backup_pin  pin)
inlinestatic

Disable the backup pin output.

The output is not enabled.

Parameters
[in]pinBackup pin index

References SYSTEM_BACKUP_PIN_PSOK.

static void system_backup_pin_output_disable_rtc_toggle ( enum system_backup_pin  pin)
inlinestatic

Disable the backup pin toggle on RTC event.

Toggle output on RTC event is disabled.

Parameters
[in]pinBackup pin index

References Assert, and SYSTEM_BACKUP_PIN_PSOK.

static void system_backup_pin_output_enable ( enum system_backup_pin  pin)
inlinestatic

Enable the backup pin output.

The output is enabled and driven by the SUPC.

Parameters
[in]pinBackup pin index

References SYSTEM_BACKUP_PIN_PSOK.

static void system_backup_pin_output_enable_rtc_toggle ( enum system_backup_pin  pin)
inlinestatic

Enable the backup pin toggle on RTC event.

Toggle output on RTC event is enabled.

Parameters
[in]pinBackup pin index

References Assert, and SYSTEM_BACKUP_PIN_PSOK.

static bool system_backup_pin_output_get ( enum system_backup_pin  pin)
inlinestatic

Get the backup I/O input values.

Get the backup I/O data input values. If the corresponding pin is enabled, the I/O input value is given on the pin.

Parameters
[in]pinBackup pin index
Returns
The backup I/O input level value.

References Assert, and SYSTEM_BACKUP_PIN_PSOK.

static bool system_backup_pin_output_is_enabled ( enum system_backup_pin  pin)
inlinestatic

Check if backup pin output is enabled.

Parameters
[in]pinBackup pin index
Returns
The enabled status.
Return values
trueThe output is enabled
falseThe output is not enabled

References SYSTEM_BACKUP_PIN_PSOK.

static void system_backup_pin_output_set ( enum system_backup_pin  pin)
inlinestatic

Set the backup pin.

Set the corresponding output pin.

Parameters
[in]pinBackup pin index

References Assert, and SYSTEM_BACKUP_PIN_PSOK.

static void system_battery_backup_power_switch_get_config_defaults ( struct system_battery_backup_power_switch_config *const  config)
inlinestatic

Retrieve the default configuration for battery backup power switch control.

Fills a configuration structure with the default configuration:

  • The main Power Supply OK status is not available on the PSOK pin
  • The device is not woken up when switched from battery backup power to main power
  • The backup domain is always supplied by main power
Parameters
[out]configConfiguration structure to fill with default values

References Assert, system_battery_backup_power_switch_config::battery_power_switch, SYSTEM_BATTERY_POWER_SWITCH_NONE, and system_battery_backup_power_switch_config::wake_enabled.

static void system_battery_backup_power_switch_set_config ( struct system_battery_backup_power_switch_config *const  config)
inlinestatic

Configure battery backup power switch.

Configures battery backup power switch with the given configuration.

Parameters
[in]configBattery backup power switch configuration structure containing the new config

References Assert, system_battery_backup_power_switch_config::battery_power_switch, SYSTEM_BATTERY_POWER_SWITCH_AUTOMATIC, and system_battery_backup_power_switch_config::wake_enabled.

static void system_clear_performance_level_status ( void  )
inlinestatic

Clear performance level status.

Clear performance level status.

static enum system_reset_backup_exit_source system_get_backup_exit_source ( void  )
inlinestatic

Get the backup exit source.

Get the backup exit source when a backup reset occurs.

Returns
An enum value indicating the latest backup exit source.
static uint32_t system_get_device_id ( void  )
inlinestatic

Retrieve the device identification signature.

Retrieves the signature of the current device.

Returns
Device ID signature as a 32-bit integer.
static enum system_performance_level system_get_performance_level ( void  )
inlinestatic

Get performance level.

Get performance level.

Returns
Current performance level.
static uint8_t system_get_performance_level_status ( void  )
inlinestatic

Get performance level status.

Get performance level status.

Returns
Performance level status: Written to one when the performance level is ready.
static enum system_reset_cause system_get_reset_cause ( void  )
inlinestatic

Get the reset cause.

Retrieves the cause of the last system reset.

Returns
An enum value indicating 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:

  • System clock initialization (via the SYSTEM CLOCK sub-module)
  • Board hardware initialization (via the Board module)
  • Event system driver initialization (via the EVSYS module)
  • External Interrupt driver initialization (via the EXTINT module)

References _system_events_init(), _system_extint_init(), and system_clock_init().

static void system_io_retension_disable ( void  )
inlinestatic

Disable I/O retention.

Disable IO retention. After waking up from Backup mode, I/O lines are not held.

static void system_io_retension_enable ( void  )
inlinestatic

Enable I/O retention.

Enable I/O retention. After waking up from Backup mode, I/O lines are held until the bit is written to 0.

static bool system_is_debugger_present ( void  )
inlinestatic

Check if debugger is present.

Check if debugger is connected to the onboard debug system (DAP).

Returns
A bool identifying if a debugger is present.
Return values
trueDebugger is connected to the system
falseDebugger is not connected to the system

Referenced by _i2c_slave_set_config(), _spi_set_config(), and _usart_set_config().

static void system_reset ( void  )
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.

static void system_set_sleepmode ( const enum system_sleepmode  sleep_mode)
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.

Parameters
[in]sleep_modeSleep mode to configure for the next sleep operation
static void system_sleep ( void  )
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. Further, a WFI (Wait For Interrupt) instruction is executed to place the device into the sleep mode specified by system_set_sleepmode.

static void system_standby_get_config_defaults ( struct system_standby_config *const  config)
inlinestatic

Retrieve the default configuration for standby.

Fills a configuration structure with the default configuration for standby:

  • Retention back biasing mode for HMCRAMCLP
  • Retention back biasing mode for HMCRAMCHS
  • Power domains PD0/PD1/PD2 are not linked
  • Automatic VREG switching is used
  • Dynamic power gating for power domain 1 is disabled
  • Dynamic power gating for power domain 0 is disabled
  • All power domains switching are handled by hardware
Parameters
[out]configConfiguration structure to fill with default values

References Assert, system_standby_config::hmcramchs_back_bias, system_standby_config::hmcramclp_back_bias, and SYSTEM_RAM_BACK_BIAS_RETENTION.

static void system_standby_set_config ( struct system_standby_config *const  config)
inlinestatic

Configure standby mode.

Configures standby with the given configuration.

Parameters
[in]configStandby configuration structure containing the new config

References Assert, system_standby_config::hmcramchs_back_bias, and system_standby_config::hmcramclp_back_bias.

static enum status_code system_switch_performance_level ( const enum system_performance_level  performance_level)
inlinestatic

Switch performance level.

The bus frequency must be reduced prior to scaling down the performance level, in order to not exceed the maximum frequency allowed for the performance level.

When scaling up the performance level (for example from PL0 to PL2), the bus frequency can be increased first when the performance level transition is completed. Check the performance level status before increasing the frequency.

Parameters
[in]performance_levelPerformance level to switch
Return values
STATUS_ERR_INVALID_ARGInvalid parameter
STATUS_OKSuccessfully

References STATUS_ERR_INVALID_ARG, and STATUS_OK.

Referenced by system_clock_init().

static void system_voltage_reference_disable ( const enum system_voltage_reference  vref)
inlinestatic

Disable the selected voltage reference.

Disables the selected voltage reference source.

Parameters
[in]vrefVoltage reference to disable

References Assert, SYSTEM_VOLTAGE_REFERENCE_OUTPUT, and SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE.

static void system_voltage_reference_enable ( const enum system_voltage_reference  vref)
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.

Parameters
[in]vrefVoltage reference to enable

References Assert, SYSTEM_VOLTAGE_REFERENCE_OUTPUT, and SYSTEM_VOLTAGE_REFERENCE_TEMPSENSE.

Referenced by adc_init(), and dac_enable().

static void system_voltage_reference_get_config_defaults ( struct system_voltage_references_config *const  config)
inlinestatic

Retrieve the default configuration for voltage reference.

Fill a configuration structure with the default configuration:

  • 1.0V voltage reference typical value
  • On demand control disabled
  • The voltage reference and the temperature sensor are halted during standby sleep mode
Parameters
[out]configConfiguration 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_1V0.

static void system_voltage_reference_set_config ( struct system_voltage_references_config *const  config)
inlinestatic

Configure voltage reference.

Configures voltage reference with the given configuration.

Parameters
[in]configVoltage 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.

static void system_voltage_regulator_disable ( void  )
inlinestatic

Disable the selected voltage regulator.

Disables the selected voltage regulator.

static void system_voltage_regulator_enable ( void  )
inlinestatic

Enable the selected voltage regulator.

Enables the selected voltage regulator source.

static void system_voltage_regulator_get_config_defaults ( struct system_voltage_regulator_config *const  config)
inlinestatic

Retrieve the default configuration for voltage regulator.

Fills a configuration structure with the default configuration:

  • Voltage scaling period is 1μs
  • Voltage scaling voltage step is 2*min_step
  • The voltage regulator is in low power mode in Standby sleep mode
  • The voltage regulator in active mode is an LDO voltage regulator
  • The voltage regulator in Low power mode has the default efficiency
Parameters
[out]configConfiguration structure to fill with default values

References Assert, system_voltage_regulator_config::low_power_efficiency, system_voltage_regulator_config::regulator_sel, system_voltage_regulator_config::run_in_standby, SYSTEM_VOLTAGE_REGULATOR_LDO, SYSTEM_VOLTAGE_REGULATOR_LOW_POWER_EFFICIENCY_DEFAULT, system_voltage_regulator_config::voltage_scale_period, and system_voltage_regulator_config::voltage_scale_step.

static void system_voltage_regulator_set_config ( struct system_voltage_regulator_config *const  config)
inlinestatic

Configure voltage regulator.

Configures voltage regulator with the given configuration.

Parameters
[in]configVoltage regulator configuration structure containing the new config

References Assert, system_voltage_regulator_config::low_power_efficiency, system_voltage_regulator_config::regulator_sel, system_voltage_regulator_config::run_in_standby, system_voltage_regulator_config::voltage_scale_period, and system_voltage_regulator_config::voltage_scale_step.