t
Fork of mbed-dev by
targets/TARGET_Atmel/TARGET_SAM_CortexM4/drivers/pmc/sleep.h@149:156823d33999, 2016-10-28 (annotated)
- Committer:
- <>
- Date:
- Fri Oct 28 11:17:30 2016 +0100
- Revision:
- 149:156823d33999
- Parent:
- targets/hal/TARGET_Atmel/TARGET_SAM_CortexM4/drivers/pmc/sleep.h@107:414e9c822e99
This updates the lib to the mbed lib v128
NOTE: This release includes a restructuring of the file and directory locations and thus some
include paths in your code may need updating accordingly.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 107:414e9c822e99 | 1 | /** |
mbed_official | 107:414e9c822e99 | 2 | * \file |
mbed_official | 107:414e9c822e99 | 3 | * |
mbed_official | 107:414e9c822e99 | 4 | * \brief Sleep mode access |
mbed_official | 107:414e9c822e99 | 5 | * |
mbed_official | 107:414e9c822e99 | 6 | * Copyright (c) 2012-2015 Atmel Corporation. All rights reserved. |
mbed_official | 107:414e9c822e99 | 7 | * |
mbed_official | 107:414e9c822e99 | 8 | * \asf_license_start |
mbed_official | 107:414e9c822e99 | 9 | * |
mbed_official | 107:414e9c822e99 | 10 | * \page License |
mbed_official | 107:414e9c822e99 | 11 | * |
mbed_official | 107:414e9c822e99 | 12 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 107:414e9c822e99 | 13 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 107:414e9c822e99 | 14 | * |
mbed_official | 107:414e9c822e99 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 107:414e9c822e99 | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 107:414e9c822e99 | 17 | * |
mbed_official | 107:414e9c822e99 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 107:414e9c822e99 | 19 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 107:414e9c822e99 | 20 | * and/or other materials provided with the distribution. |
mbed_official | 107:414e9c822e99 | 21 | * |
mbed_official | 107:414e9c822e99 | 22 | * 3. The name of Atmel may not be used to endorse or promote products derived |
mbed_official | 107:414e9c822e99 | 23 | * from this software without specific prior written permission. |
mbed_official | 107:414e9c822e99 | 24 | * |
mbed_official | 107:414e9c822e99 | 25 | * 4. This software may only be redistributed and used in connection with an |
mbed_official | 107:414e9c822e99 | 26 | * Atmel microcontroller product. |
mbed_official | 107:414e9c822e99 | 27 | * |
mbed_official | 107:414e9c822e99 | 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED |
mbed_official | 107:414e9c822e99 | 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
mbed_official | 107:414e9c822e99 | 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE |
mbed_official | 107:414e9c822e99 | 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR |
mbed_official | 107:414e9c822e99 | 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 107:414e9c822e99 | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
mbed_official | 107:414e9c822e99 | 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
mbed_official | 107:414e9c822e99 | 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
mbed_official | 107:414e9c822e99 | 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
mbed_official | 107:414e9c822e99 | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 107:414e9c822e99 | 38 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 107:414e9c822e99 | 39 | * |
mbed_official | 107:414e9c822e99 | 40 | * \asf_license_stop |
mbed_official | 107:414e9c822e99 | 41 | * |
mbed_official | 107:414e9c822e99 | 42 | */ |
mbed_official | 107:414e9c822e99 | 43 | /* |
mbed_official | 107:414e9c822e99 | 44 | * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> |
mbed_official | 107:414e9c822e99 | 45 | */ |
mbed_official | 107:414e9c822e99 | 46 | |
mbed_official | 107:414e9c822e99 | 47 | #ifndef SLEEP_H |
mbed_official | 107:414e9c822e99 | 48 | #define SLEEP_H |
mbed_official | 107:414e9c822e99 | 49 | |
mbed_official | 107:414e9c822e99 | 50 | #ifdef __cplusplus |
mbed_official | 107:414e9c822e99 | 51 | extern "C" { |
mbed_official | 107:414e9c822e99 | 52 | #endif |
mbed_official | 107:414e9c822e99 | 53 | |
mbed_official | 107:414e9c822e99 | 54 | #include <compiler.h> |
mbed_official | 107:414e9c822e99 | 55 | |
mbed_official | 107:414e9c822e99 | 56 | /** |
mbed_official | 107:414e9c822e99 | 57 | * \defgroup sleep_group Power Manager (PM) |
mbed_official | 107:414e9c822e99 | 58 | * |
mbed_official | 107:414e9c822e99 | 59 | * This is a stub on the SAM Power Manager Control (PMC) for the sleepmgr |
mbed_official | 107:414e9c822e99 | 60 | * service. |
mbed_official | 107:414e9c822e99 | 61 | * |
mbed_official | 107:414e9c822e99 | 62 | * \note To minimize the code overhead, these functions do not feature |
mbed_official | 107:414e9c822e99 | 63 | * interrupt-protected access since they are likely to be called inside |
mbed_official | 107:414e9c822e99 | 64 | * interrupt handlers or in applications where such protection is not |
mbed_official | 107:414e9c822e99 | 65 | * necessary. If such protection is needed, it must be ensured by the calling |
mbed_official | 107:414e9c822e99 | 66 | * code. |
mbed_official | 107:414e9c822e99 | 67 | * |
mbed_official | 107:414e9c822e99 | 68 | * @{ |
mbed_official | 107:414e9c822e99 | 69 | */ |
mbed_official | 107:414e9c822e99 | 70 | |
mbed_official | 107:414e9c822e99 | 71 | #if defined(__DOXYGEN__) |
mbed_official | 107:414e9c822e99 | 72 | /** |
mbed_official | 107:414e9c822e99 | 73 | * \brief Sets the MCU in the specified sleep mode |
mbed_official | 107:414e9c822e99 | 74 | * \param sleep_mode Sleep mode to set. |
mbed_official | 107:414e9c822e99 | 75 | */ |
mbed_official | 107:414e9c822e99 | 76 | #endif |
mbed_official | 107:414e9c822e99 | 77 | /* SAM3 and SAM4 series */ |
mbed_official | 107:414e9c822e99 | 78 | #if (SAM3S || SAM3N || SAM3XA || SAM3U || SAM4S || SAM4E || SAM4N || SAM4C || \ |
mbed_official | 107:414e9c822e99 | 79 | SAM4CM || SAM4CP || SAMG || SAMV71 || SAME70) |
mbed_official | 107:414e9c822e99 | 80 | |
mbed_official | 107:414e9c822e99 | 81 | #if (SAM3S || SAM3N || SAM3XA || SAM3U || SAM4S || SAM4E || SAM4N || SAM4C || \ |
mbed_official | 107:414e9c822e99 | 82 | SAM4CM || SAM4CP || SAMG55 || SAMV71 || SAME70) |
mbed_official | 107:414e9c822e99 | 83 | # define SAM_PM_SMODE_ACTIVE 0 /**< Active */ |
mbed_official | 107:414e9c822e99 | 84 | # define SAM_PM_SMODE_SLEEP_WFE 1 /**< Wait for Events */ |
mbed_official | 107:414e9c822e99 | 85 | # define SAM_PM_SMODE_SLEEP_WFI 2 /**< Wait for Interrupts */ |
mbed_official | 107:414e9c822e99 | 86 | # define SAM_PM_SMODE_WAIT_FAST 3 /**< Wait Mode, startup fast (in 3ms) */ |
mbed_official | 107:414e9c822e99 | 87 | # define SAM_PM_SMODE_WAIT 4 /**< Wait Mode */ |
mbed_official | 107:414e9c822e99 | 88 | # define SAM_PM_SMODE_BACKUP 5 /**< Backup Mode */ |
mbed_official | 107:414e9c822e99 | 89 | #else |
mbed_official | 107:414e9c822e99 | 90 | # define SAM_PM_SMODE_ACTIVE 0 /**< Active */ |
mbed_official | 107:414e9c822e99 | 91 | # define SAM_PM_SMODE_WAIT_FAST 1 /**< Wait Mode, startup fast (in 3ms) */ |
mbed_official | 107:414e9c822e99 | 92 | # define SAM_PM_SMODE_WAIT 2 /**< Wait Mode */ |
mbed_official | 107:414e9c822e99 | 93 | #endif |
mbed_official | 107:414e9c822e99 | 94 | |
mbed_official | 107:414e9c822e99 | 95 | /** (SCR) Sleep deep bit */ |
mbed_official | 107:414e9c822e99 | 96 | #define SCR_SLEEPDEEP (0x1 << 2) |
mbed_official | 107:414e9c822e99 | 97 | |
mbed_official | 107:414e9c822e99 | 98 | /** |
mbed_official | 107:414e9c822e99 | 99 | * Clocks restored callback function type. |
mbed_official | 107:414e9c822e99 | 100 | * Registered by routine pmc_wait_wakeup_clocks_restore() |
mbed_official | 107:414e9c822e99 | 101 | * Callback called when all clocks are restored. |
mbed_official | 107:414e9c822e99 | 102 | */ |
mbed_official | 107:414e9c822e99 | 103 | typedef void (*pmc_callback_wakeup_clocks_restored_t) (void); |
mbed_official | 107:414e9c822e99 | 104 | |
mbed_official | 107:414e9c822e99 | 105 | /** |
mbed_official | 107:414e9c822e99 | 106 | * Enter sleep mode |
mbed_official | 107:414e9c822e99 | 107 | * \param sleep_mode Sleep mode to enter |
mbed_official | 107:414e9c822e99 | 108 | */ |
mbed_official | 107:414e9c822e99 | 109 | void pmc_sleep(int sleep_mode); |
mbed_official | 107:414e9c822e99 | 110 | |
mbed_official | 107:414e9c822e99 | 111 | /** |
mbed_official | 107:414e9c822e99 | 112 | * Check if clocks are restored after wakeup |
mbed_official | 107:414e9c822e99 | 113 | * (For WAIT mode. In WAIT mode, clocks are switched to FASTRC. |
mbed_official | 107:414e9c822e99 | 114 | * After wakeup clocks should be restored, before that some of the |
mbed_official | 107:414e9c822e99 | 115 | * ISR should not be served, otherwise there may be timing or clock issue.) |
mbed_official | 107:414e9c822e99 | 116 | */ |
mbed_official | 107:414e9c822e99 | 117 | bool pmc_is_wakeup_clocks_restored(void); |
mbed_official | 107:414e9c822e99 | 118 | |
mbed_official | 107:414e9c822e99 | 119 | /** |
mbed_official | 107:414e9c822e99 | 120 | * \return true if start waiting |
mbed_official | 107:414e9c822e99 | 121 | */ |
mbed_official | 107:414e9c822e99 | 122 | void pmc_wait_wakeup_clocks_restore( |
mbed_official | 107:414e9c822e99 | 123 | pmc_callback_wakeup_clocks_restored_t callback); |
mbed_official | 107:414e9c822e99 | 124 | |
mbed_official | 107:414e9c822e99 | 125 | #endif |
mbed_official | 107:414e9c822e99 | 126 | |
mbed_official | 107:414e9c822e99 | 127 | //! @} |
mbed_official | 107:414e9c822e99 | 128 | |
mbed_official | 107:414e9c822e99 | 129 | #ifdef __cplusplus |
mbed_official | 107:414e9c822e99 | 130 | } |
mbed_official | 107:414e9c822e99 | 131 | #endif |
mbed_official | 107:414e9c822e99 | 132 | |
mbed_official | 107:414e9c822e99 | 133 | #endif /* SLEEP_H */ |