You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/02/27 02:26:30 UTC

[28/51] [abbrv] [partial] incubator-mynewt-larva git commit: Arduino zero BSP and Atmel MCU in a different repository.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a280628a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/reset/reset_sam_l/reset.h
----------------------------------------------------------------------
diff --git a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/reset/reset_sam_l/reset.h b/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/reset/reset_sam_l/reset.h
deleted file mode 100755
index 72ffd62..0000000
--- a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/reset/reset_sam_l/reset.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/**
- * \file
- *
- * \brief SAM Reset functionality
- *
- * Copyright (C) 2014-2015 Atmel Corporation. All rights reserved.
- *
- * \asf_license_start
- *
- * \page License
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *
- * 3. The name of Atmel may not be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * 4. This software may only be redistributed and used in connection with an
- *    Atmel microcontroller product.
- *
- * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
- * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * \asf_license_stop
- *
- */
-/*
- * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
- */
-#ifndef RESET_H_INCLUDED
-#define RESET_H_INCLUDED
-
-#include <compiler.h>
-#include <clock.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \addtogroup asfdoc_sam0_system_group
- * @{
- */
-
-/**
- * \brief Reset causes of the system.
- *
- * List of possible reset causes of the system.
- */
-enum system_reset_cause {
-	/** The system was last reset by a backup reset */
-	SYSTEM_RESET_CAUSE_BACKUP         = RSTC_RCAUSE_BACKUP,
-	/** The system was last reset by a software reset */
-	SYSTEM_RESET_CAUSE_SOFTWARE       = RSTC_RCAUSE_SYST,
-	/** The system was last reset by the watchdog timer */
-	SYSTEM_RESET_CAUSE_WDT            = RSTC_RCAUSE_WDT,
-	/** The system was last reset because the external reset line was pulled low */
-	SYSTEM_RESET_CAUSE_EXTERNAL_RESET = RSTC_RCAUSE_EXT,
-#if SAML21
-	/** The system was last reset by the BOD33. */
-	SYSTEM_RESET_CAUSE_BOD33          = RSTC_RCAUSE_BOD33,
-	/** The system was last reset by the BOD12 */
-	SYSTEM_RESET_CAUSE_BOD12          = RSTC_RCAUSE_BOD12,
-#else
-	/** The system was last reset by the BOD VDD. */
-	SYSTEM_RESET_CAUSE_BOD33          = RSTC_RCAUSE_BODVDD,
-	/** The system was last reset by the BOD CORE. */
-	SYSTEM_RESET_CAUSE_BOD12          = RSTC_RCAUSE_BODCORE,
-#endif
-	/** The system was last reset by the POR (Power on reset). */
-	SYSTEM_RESET_CAUSE_POR            = RSTC_RCAUSE_POR,
-};
-
-/**
- * \brief Backup exit source after a backup reset occurs.
- *
- * List of possible backup exit source.
- */
-enum system_reset_backup_exit_source {
-#if SAML21
-	/** The backup exit source was external wakeup. */
-	SYSTEM_RESET_BACKKUP_EXIT_EXTWAKE    = RSTC_BKUPEXIT_EXTWAKE,
-#endif
-	/** The backup exit source was RTC interrupt. */
-	SYSTEM_RESET_BACKKUP_EXIT_RTC        = RSTC_BKUPEXIT_RTC,
-	/** The backup exit source was battery backup power switch */
-	SYSTEM_RESET_BACKKUP_EXIT_BBPS       = RSTC_BKUPEXIT_BBPS,
-};
-
-#if SAML21
-/**
- * \brief Wakeup debounce counter value.
- *
- * Wakeup debounce counter value when waking up by external wakeup pin from backup mode.
- */
-enum system_wakeup_debounce_count {
-	/** No debouncing */
-	SYSTEM_WAKEUP_DEBOUNCE_OFF         = RSTC_WKDBCONF_WKDBCNT_OFF,
-	/** Input pin shall be active for at least two 32KHz clock period. */
-	SYSTEM_WAKEUP_DEBOUNCE_2CK32       = RSTC_WKDBCONF_WKDBCNT_2CK32,
-	/** Input pin shall be active for at least three 32KHz clock period. */
-	SYSTEM_WAKEUP_DEBOUNCE_3CK32       = RSTC_WKDBCONF_WKDBCNT_3CK32,
-	/** Input pin shall be active for at least 32 32KHz clock periods */
-	SYSTEM_WAKEUP_DEBOUNCE_32CK32      = RSTC_WKDBCONF_WKDBCNT_32CK32,
-	/** Input pin shall be active for at least 512 32KHz clock periods */
-	SYSTEM_WAKEUP_DEBOUNCE_512CK32     = RSTC_WKDBCONF_WKDBCNT_512CK32,
-	/** Input pin shall be active for at least 4096 32KHz clock periods */
-	SYSTEM_WAKEUP_DEBOUNCE_4096CK32    = RSTC_WKDBCONF_WKDBCNT_4096CK32,
-	/** Input pin shall be active for at least 32768 32KHz clock periods */
-	SYSTEM_WAKEUP_DEBOUNCE_32768CK32   = RSTC_WKDBCONF_WKDBCNT_32768CK32,
-};
-#endif
-
-/**
- * \name Reset Control
- * @{
- */
-
-/**
- * \brief 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 inline void system_reset(void)
-{
-	NVIC_SystemReset();
-}
-
-/**
- * \brief Get the reset cause.
- *
- * Retrieves the cause of the last system reset.
- *
- * \return An enum value indicating the cause of the last system reset.
- */
-static inline enum system_reset_cause system_get_reset_cause(void)
-{
-	return (enum system_reset_cause)RSTC->RCAUSE.reg;
-}
-
-/**
- * @}
- */
-
-/**
- * \name Backup Exit Control
- * @{
- */
-
-/**
- * \brief Get the backup exit source.
- *
- * Get the backup exit source when a backup reset occurs.
- *
- * \return An enum value indicating the latest backup exit source.
- */
-static inline enum system_reset_backup_exit_source system_get_backup_exit_source(void)
-{
-	return (enum system_reset_backup_exit_source)RSTC->BKUPEXIT.reg;
-}
-
-#if SAML21
-/**
- * \brief Set wakeup debounce counter.
- *
- * Set the wakeup debounce counter value with the given count.
- *
- * \param[in] wakeup_debounce_count Wakeup debounce counter value
- */
-static inline void system_set_pin_wakeup_debounce_counter(
-					const enum system_wakeup_debounce_count wakeup_debounce_count)
-{
-	RSTC->WKDBCONF.reg = wakeup_debounce_count;
-}
-
-/**
- * \brief Set low polarity of wakeup input pin.
- *
- * Set low polarity with the given wakeup input pin mask.
- *
- * \param[in] pin_mask Input pin mask
- */
-static inline void system_set_pin_wakeup_polarity_low(const uint16_t pin_mask)
-{
-	RSTC->WKPOL.reg &= ~(RSTC_WKPOL_WKPOL(pin_mask));
-}
-
-/**
- * \brief Set high polarity of wakeup input pin.
- *
- * Set high polarity with the given wakeup input pin mask.
- *
- * \param[in] pin_mask Input pin mask
- */
-static inline void system_set_pin_wakeup_polarity_high(const uint16_t pin_mask)
-{
-	RSTC->WKPOL.reg |= RSTC_WKPOL_WKPOL(pin_mask);
-}
-
-/**
- * \brief Enable wakeup of input pin from the backup mode.
- *
- * Enable pin wakeup from the backup mode with the given pin mask.
- *
- * \param[in] pin Input pin mask
- */
-static inline void system_enable_pin_wakeup(const uint16_t pin_mask)
-{
-	RSTC->WKEN.reg |= RSTC_WKEN_WKEN(pin_mask);
-}
-
-/**
- * \brief Disable wakeup of input pin from the backup mode.
- *
- * Disable pin wakeup from the backup mode with the given pin mask.
- *
- * \param[in] pin Input pin mask
- */
-static inline void system_disable_pin_wakeup(const uint16_t pin_mask)
-{
-	RSTC->WKEN.reg &= ~(RSTC_WKEN_WKEN(pin_mask));
-}
-
-/**
- * \brief Check whether any of the enabled wake up pins are active and caused the wakeup.
- *
- * Check whether any of the enabled wake up pins are active and caused the wakeup
- *  from backup sleep mode when exiting backup mode.
- *
- * \return Pin mask, the corresponding pin is active when its pin mask is 1.
- */
-static inline uint16_t system_get_pin_wakeup_cause(void)
-{
-	return (RSTC_WKCAUSE_MASK & (RSTC->WKCAUSE.reg >> RSTC_WKCAUSE_WKCAUSE_Pos));
-}
-#endif
-/**
- * @}
- */
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* RESET_H_INCLUDED */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a280628a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.c
----------------------------------------------------------------------
diff --git a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.c b/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.c
deleted file mode 100755
index e092281..0000000
--- a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * \file
- *
- * \brief SAM System related functionality
- *
- * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.
- *
- * \asf_license_start
- *
- * \page License
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *
- * 3. The name of Atmel may not be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * 4. This software may only be redistributed and used in connection with an
- *    Atmel microcontroller product.
- *
- * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
- * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * \asf_license_stop
- *
- */
-/*
- * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
- */
-
-#include <system.h>
-
-/**
- * \internal
- * Dummy initialization function, used as a weak alias target for the various
- * init functions called by \ref system_init().
- */
-void _system_dummy_init(void);
-void _system_dummy_init(void)
-{
-	return;
-}
-
-#if !defined(__DOXYGEN__)
-#  if defined(__GNUC__)
-void system_clock_init(void) WEAK __attribute__((alias("_system_dummy_init")));
-void system_board_init(void) WEAK __attribute__((alias("_system_dummy_init")));
-void _system_events_init(void) WEAK __attribute__((alias("_system_dummy_init")));
-void _system_extint_init(void) WEAK __attribute__((alias("_system_dummy_init")));
-void _system_divas_init(void) WEAK __attribute__((alias("_system_dummy_init")));
-#  elif defined(__ICCARM__)
-void system_clock_init(void);
-void system_board_init(void);
-void _system_events_init(void);
-void _system_extint_init(void);
-void _system_divas_init(void);
-#    pragma weak system_clock_init=_system_dummy_init
-#    pragma weak system_board_init=_system_dummy_init
-#    pragma weak _system_events_init=_system_dummy_init
-#    pragma weak _system_extint_init=_system_dummy_init
-#    pragma weak _system_divas_init=_system_dummy_init
-#  endif
-#endif
-
-/**
- * \brief 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)
- */
-void system_init(void)
-{
-	/* Configure GCLK and clock sources according to conf_clocks.h */
-	system_clock_init();
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/a280628a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.h
----------------------------------------------------------------------
diff --git a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.h b/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.h
deleted file mode 100755
index c6dd6e8..0000000
--- a/hw/mcu/atmel/samd21xx/src/sam0/drivers/system/system.h
+++ /dev/null
@@ -1,728 +0,0 @@
-/**
- * \file
- *
- * \brief SAM System related functionality
- *
- * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.
- *
- * \asf_license_start
- *
- * \page License
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *
- * 3. The name of Atmel may not be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * 4. This software may only be redistributed and used in connection with an
- *    Atmel microcontroller product.
- *
- * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
- * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * \asf_license_stop
- *
- */
-/*
- * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
- */
-#ifndef SYSTEM_H_INCLUDED
-#define SYSTEM_H_INCLUDED
-
-#include <compiler.h>
-#include <clock.h>
-#include <gclk.h>
-#include <pinmux.h>
-#include <power.h>
-#include <reset.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \defgroup asfdoc_sam0_system_group SAM System (SYSTEM) Driver
- *
- * This driver for Atmel&reg; | SMART ARM&reg;-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:
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- *  - PM (Power Manager)
- *  - RSTC (Reset Controller)
- *  - SUPC (Supply Controller)
- * \endif
- * \if DEVICE_SAMC21_SYSTEM_SUPPORT
- *  - PM (Power Manager)
- *  - RSTC (Reset Controller)
- *  - SUPC (Supply Controller)
- * \endif
- * \if DEVICE_SAMD21_SYSTEM_SUPPORT
- *  - SYSCTRL (System Control)
- *  - PM (Power Manager)
- * \endif
- *
- * The following devices can use this module:
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- *  - Atmel | SMART SAM L21
- * \endif
- * \if DEVICE_SAMC21_SYSTEM_SUPPORT
- *  - Atmel | SMART SAM C20/C21
- * \endif
- * \if DEVICE_SAMD21_SYSTEM_SUPPORT
- *  - Atmel | SMART SAM D20/D21
- *  - Atmel | SMART SAM R21
- *  - Atmel | SMART SAM D09/D10/D11
- *  - Atmel | SMART SAM DA1
- * \endif
- *
- * The outline of this documentation is as follows:
- *  - \ref asfdoc_sam0_system_prerequisites
- *  - \ref asfdoc_sam0_system_module_overview
- *  - \ref asfdoc_sam0_system_special_considerations
- *  - \ref asfdoc_sam0_system_extra_info
- *  - \ref asfdoc_sam0_system_examples
- *  - \ref asfdoc_sam0_system_api_overview
- *
- *
- * \section asfdoc_sam0_system_prerequisites Prerequisites
- *
- * There are no prerequisites for this module.
- *
- *
- * \section asfdoc_sam0_system_module_overview 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:
- *
- * - System Core (this module)
- * - \ref asfdoc_sam0_system_clock_group "System Clock Control" (sub-module)
- * - \ref asfdoc_sam0_system_interrupt_group "System Interrupt Control" (sub-module)
- * - \ref asfdoc_sam0_system_pinmux_group "System Pin Multiplexer Control" (sub-module)
- *
- *
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- * \subsection asfdoc_sam0_system_module_overview_vreg_l21 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.
- *
- * \subsection asfdoc_sam0_system_module_overview_bbps 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.
- * \endif
- *
- * \if DEVICE_SAMC21_SYSTEM_SUPPORT
- * \subsection asfdoc_sam0_system_module_overview_vreg_c21 Voltage Regulator
- * 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.
- * \endif
- *
- * \subsection asfdoc_sam0_system_module_overview_vref 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.
- *
- * \subsection asfdoc_sam0_system_module_overview_reset_cause 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.
- *
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- * There are three groups of reset sources:
- *   - Power supply reset: Resets caused by an electrical issue. It covers POR and BOD reset.
- *   - User reset: Resets caused by the application. It covers external reset,
- *             system reset, and watchdog reset.
- *   - Backup reset: Resets caused by a backup mode exit condition.
- *
- * \subsection asfdoc_sam0_system_module_overview_performance_level 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 \ref 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.
- *
- * \anchor asfdoc_sam0_system_performance_level_transition_figure
- * \image html performance_level_transition.svg "Performance Level Transition"
- *
- * \subsection asfdoc_sam0_system_module_overview_power_domain 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:
- *
- * - Active state: The power domain is powered on.
- * - Retention state: The main voltage supply for the power domain is switched off,
- * while maintaining a secondary low-power supply for the sequential cells. The
- * logic context is restored when waking up.
- * - Off state: The power domain is entirely powered off. The logic context is lost.
- *
- * 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:
- * - Default with no sleepwalking peripherals: A power domain is automatically set
- * to retention state in standby sleep mode if no activity require it. The application
- * can force all power domains to remain in active state during standby sleep mode
- * in order to accelerate wakeup time.
- * - Default with sleepwalking peripherals: If one or more peripherals are enabled
- * to perform sleepwalking tasks in standby sleep mode, the corresponding power
- * domain (PDn) remains in active state as well as all inferior power domains (<PDn).
- * - Sleepwalking with dynamic power domain gating: During standby sleep mode, a
- * power domain (PDn) in active can wake up a superior power domain (>PDn) in order
- * to perform a sleepwalking task. The superior power domain is then automatically
- * set to active state. At the end of the sleepwalking task, the device can either
- * be woken up or the superior power domain can return to retention state.
- *
- * 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.
- *
- * \ref asfdoc_sam0_system_power_domain_overview_table illustrates the
- * four cases to consider in standby mode.
- *
- * \anchor asfdoc_sam0_system_power_domain_overview_table
- * <table>
- *  <caption>Sleep Mode versus Power Domain State Overview</caption>
- *  <tr>
- *      <th>Sleep mode</th>
- *      <th>PD0</th>
- *      <th>PD1</th>
- *      <th>PD2</th>
- *      <th>PDTOP</th>
- *      <th>PDBACKUP</th>
- *  </tr>
- *  <tr>
- *      <td>Idle</td>
- *      <td>active</td>
- *      <td>active</td>
- *      <td>active</td>
- *      <td>active</td>
- *      <td>active</td>
- *  </tr>
- *  <tr>
- *      <td>Standby - Case 1</td>
- *      <td>active</td>
- *      <td>active</td>
- *      <td>active</td>
- *      <td>active</td>
- *      <td>active</td>
- *  </tr>
- *  <tr>
- *      <td>Standby - Case 2</td>
- *      <td>active</td>
- *      <td>active</td>
- *      <td>retention</td>
- *      <td>active</td>
- *      <td>active</td>
- *  </tr>
- *  <tr>
- *      <td>Standby - Case 3</td>
- *      <td>active</td>
- *      <td>retention</td>
- *      <td>retention</td>
- *      <td>active</td>
- *      <td>active</td>
- *  </tr>
- *  <tr>
- *      <td>Standby - Case 4</td>
- *      <td>retention</td>
- *      <td>retention</td>
- *      <td>retention</td>
- *      <td>active</td>
- *      <td>active</td>
- *  </tr>
- *  <tr>
- *      <td>Backup</td>
- *      <td>off</td>
- *      <td>off</td>
- *      <td>off</td>
- *      <td>off</td>
- *      <td>active</td>
- *  </tr>
- *  <tr>
- *      <td>Off</td>
- *      <td>off</td>
- *      <td>off</td>
- *      <td>off</td>
- *      <td>off</td>
- *      <td>off</td>
- *  </tr>
- * </table>
- *
- * \subsection asfdoc_sam0_system_module_overview_ram_state 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.
- * \ref asfdoc_sam0_system_power_ram_state_table lists RAMs low power mode.
- *
- * \anchor asfdoc_sam0_system_power_ram_state_table
- * <table>
- *  <caption>RAM Back-biasing Mode</caption>
- *  <tr>
- *      <th>RAM mode</th>
- *      <th>Description</th>
- *  </tr>
- *  <tr>
- *      <td>Retention Back-biasing mode</td>
- *      <td>RAM is back-biased if its power domain is in retention mode</td>
- *  </tr>
- *  <tr>
- *      <td>Standby Back-biasing mode</td>
- *      <td>RAM is back-biased if the device is in standby mode</td>
- *  </tr>
- *  <tr>
- *      <td>Standby OFF mode</td>
- *      <td>RAM is OFF if the device is in standby mode</td>
- *  </tr>
- *  <tr>
- *      <td>Always OFF mode</td>
- *      <td>RAM is OFF if the device is in RET mode</td>
- *  </tr>
- * </table>
- *
- * \endif
- *
- * \subsection asfdoc_sam0_system_module_overview_sleep_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.
- * \ref asfdoc_sam0_system_module_sleep_mode_table "The table below" lists the
- * clock settings of the different sleep modes.
- *
- * \anchor asfdoc_sam0_system_module_sleep_mode_table
- * <table>
- *  <caption>SAM Device Sleep Modes</caption>
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- *  <tr>
- *      <th>Sleep mode</th>
- *      <th>System clock</th>
- *      <th>CPU clock</th>
- *      <th>AHB/AHB clock</th>
- *      <th>GCLK clocks</th>
- *      <th>Oscillators (ONDEMAND  = 0)</th>
- *      <th>Oscillators (ONDEMAND  = 1)</th>
- *      <th>Regulator mode</th>
- *      <th>RAM mode</th>
- *  </tr>
- *  <tr>
- *      <td>Idle</td>
- *      <td>Run</td>
- *      <td>Stop</td>
- *      <td>Run if requested</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Run if requested</td>
- *      <td>Normal</td>
- *      <td>Normal</td>
- *  </tr>
- *  <tr>
- *      <td>Standby</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Run if requested</td>
- *      <td>Run if requested</td>
- *      <td>Run if requested or RUNSTDBY  = 1</td>
- *      <td>Run if requested</td>
- *      <td>Low pwer</td>
- *      <td>Low pwer</td>
- *  </tr>
- *  <tr>
- *      <td>Backup</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Backup</td>
- *      <td>Off</td>
- *  </tr>
- *  <tr>
- *      <td>Off</td>
- *      <td>Off</td>
- *      <td>Off</td>
- *      <td>Off</td>
- *      <td>Off</td>
- *      <td>Off</td>
- *      <td>Off</td>
- *      <td>Off</td>
- *      <td>Off</td>
- *  </tr>
- * \else
- *  <tr>
- *      <th>Sleep mode</th>
- *      <th>CPU clock</th>
- *      <th>AHB clock</th>
- *      <th>APB clocks</th>
- *      <th>Clock sources</th>
- *      <th>System clock</th>
- *      <th>32KHz</th>
- *      <th>Reg mode</th>
- *      <th>RAM mode</th>
- *  </tr>
- *  <tr>
- *      <td>Idle 0</td>
- *      <td>Stop</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Normal</td>
- *      <td>Normal</td>
- *  </tr>
- *  <tr>
- *      <td>Idle 1</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Normal</td>
- *      <td>Normal</td>
- *  </tr>
- *  <tr>
- *      <td>Idle 2</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Run</td>
- *      <td>Normal</td>
- *      <td>Normal</td>
- *  </tr>
- *  <tr>
- *      <td>Standby</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Stop</td>
- *      <td>Low Power</td>
- *      <td>Source/Drain biasing</td>
- *  </tr>
- * \endif
- * </table>
- *
- * 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.
- *
- *
- * \section asfdoc_sam0_system_special_considerations Special Considerations
- *
- * Most of the functions in this driver have device specific restrictions and
- * caveats; refer to your device datasheet.
- *
- *
- * \section asfdoc_sam0_system_extra_info Extra Information
- *
- * For extra information, see \ref asfdoc_sam0_system_extra. This includes:
- *  - \ref asfdoc_sam0_system_extra_acronyms
- *  - \ref asfdoc_sam0_system_extra_dependencies
- *  - \ref asfdoc_sam0_system_extra_errata
- *  - \ref asfdoc_sam0_system_extra_history
- *
- *
- * \section asfdoc_sam0_system_examples Examples
- *
- * For SYSTEM module related examples, refer to the sub-modules listed in
- * the \ref asfdoc_sam0_system_module_overview "Module Overview".
- *
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- * For a list of examples related to this driver, see
- * \ref asfdoc_sam0_drivers_power_exqsg.
- * \endif
- *
- *
- * \section asfdoc_sam0_system_api_overview API Overview
- * @{
- */
-
-/**
- * \name System Debugger
- * @{
- */
-
-/**
- * \brief Check if debugger is present.
- *
- * Check if debugger is connected to the onboard debug system (DAP).
- *
- * \return A bool identifying if a debugger is present.
- *
- * \retval true  Debugger is connected to the system
- * \retval false Debugger is not connected to the system
- *
- */
-static inline bool system_is_debugger_present(void)
-{
-	return DSU->STATUSB.reg & DSU_STATUSB_DBGPRES;
-}
-
-/**
- * @}
- */
-
-/**
- * \name System Identification
- * @{
- */
-
-/**
- * \brief Retrieve the device identification signature.
- *
- * Retrieves the signature of the current device.
- *
- * \return Device ID signature as a 32-bit integer.
- */
-static inline uint32_t system_get_device_id(void)
-{
-	return DSU->DID.reg;
-}
-
-/**
- * @}
- */
-
-/**
- * \name System Initialization
- * @{
- */
-
-void system_init(void);
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
-/**
- *
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- * \page asfdoc_sam0_drivers_power_exqsg Examples for SYSTEM Driver
- *
- * This is a list of the available Quick Start Guides (QSGs) and example
- * applications for \ref asfdoc_sam0_system_group. QSGs are simple examples with step-by-step instructions to
- * configure and use this driver in a selection of
- * use cases. Note that a QSG can be compiled as a standalone application or be
- * added to the user application.
- *
- *  - \subpage asfdoc_sam0_power_basic_use_case
- * \endif
- *
- * \page asfdoc_sam0_system_extra Extra Information for SYSTEM Driver
- *
- * \section asfdoc_sam0_system_extra_acronyms Acronyms
- * Below is a table listing the acronyms used in this module, along with their
- * intended meanings.
- *
- * <table>
- *  <tr>
- *      <th>Acronym</th>
- *      <th>Definition</th>
- *  </tr>
- *  <tr>
- *      <td>PM</td>
- *      <td>Power Manager</td>
- *  </tr>
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>SUPC</td>
- *      <td>Supply Controller</td>
- *  </tr>
- *  <tr>
- *      <td>RSTC</td>
- *      <td>Reset Controller</td>
- *  </tr>
- * \endif
- * \if DEVICE_SAMC21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>SUPC</td>
- *      <td>Supply Controller</td>
- *  </tr>
- *  <tr>
- *      <td>RSTC</td>
- *      <td>Reset Controller</td>
- *  </tr>
- * \endif
- * \if DEVICE_SAMD21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>SYSCTRL</td>
- *      <td>System control interface</td>
- *  </tr>
- * \endif
- * </table>
- *
- *
- * \section asfdoc_sam0_system_extra_dependencies Dependencies
- * This driver has the following dependencies:
- *
- *  - None
- *
- *
- * \section asfdoc_sam0_system_extra_errata Errata
- * There are no errata related to this driver.
- *
- *
- * \section asfdoc_sam0_system_extra_history Module History
- * An overview of the module history is presented in the table below, with
- * details on the enhancements and fixes made to the module since its first
- * release. The current version of this corresponds to the newest version in
- * the table.
- *
- * <table>
- *  <tr>
- *      <th>Changelog</th>
- *  </tr>
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>Initial Release</td>
- *  </tr>
- * \endif
- * \if DEVICE_SAMC21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>Initial Release</td>
- *  </tr>
- * \endif
- * \if DEVICE_SAMD21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>Added new \c system_reset() to reset the complete MCU with some exceptions</td>
- *  </tr>
- *  <tr>
- *      <td>Added new \c system_get_device_id() function to retrieved the device
- *          ID</td>
- *  </tr>
- *  <tr>
- *      <td>Initial Release</td>
- *  </tr>
- * \endif
- * </table>
- *
- * \page asfdoc_sam0_system_document_revision_history Document Revision History
- *
- * <table>
- * <tr>
- *      <th>Doc. Rev.</th>
- *      <th>Date</th>
- *      <th>Comments</th>
- *  </tr>
- * \if DEVICE_SAML21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>42449A</td>
- *      <td>07/2015</td>
- *      <td>Initial document release</td>
- * </tr>
- * \endif
- * \if DEVICE_SAMC21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>42484A</td>
- *      <td>12/2015</td>
- *      <td>Initial document release.</td>
- * </tr>
- * \endif
- * \if DEVICE_SAMD21_SYSTEM_SUPPORT
- *  <tr>
- *      <td>42120E</td>
- *      <td>12/2015</td>
- *      <td>Added support for SAM DA1 and SAM D09</td>
- * </tr>
- *  <tr>
- *      <td>42120D</td>
- *      <td>12/2014</td>
- *      <td>Added support for SAM R21 and SAM D10/D11</td>
- * </tr>
- * <tr>
- *      <td>42120C</td>
- *      <td>01/2014</td>
- *      <td>Added support for SAM D21</td>
- *  </tr>
- *  <tr>
- *      <td>42120B</td>
- *      <td>06/2013</td>
- *      <td>Corrected documentation typos</td>
- *  </tr>
- *  <tr>
- *      <td>42120A</td>
- *      <td>06/2013</td>
- *      <td>Initial document release</td>
- *  </tr>
- * \endif
- * </table>
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SYSTEM_H_INCLUDED */
-