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