]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L1/stm32l1xx_hal_pwr_ex.c
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L1 / stm32l1xx_hal_pwr_ex.c
1 /**
2   ******************************************************************************
3   * @file    stm32l1xx_hal_pwr_ex.c
4   * @author  MCD Application Team
5   * @version V1.0.0
6   * @date    5-September-2014
7   * @brief   Extended PWR HAL module driver.
8   *          This file provides firmware functions to manage the following
9   *          functionalities of the Power Controller (PWR) peripheral:
10   *           + Extended Initialization and de-initialization functions
11   *           + Extended Peripheral Control functions
12   *         
13   ******************************************************************************
14   * @attention
15   *
16   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
17   *
18   * Redistribution and use in source and binary forms, with or without modification,
19   * are permitted provided that the following conditions are met:
20   *   1. Redistributions of source code must retain the above copyright notice,
21   *      this list of conditions and the following disclaimer.
22   *   2. Redistributions in binary form must reproduce the above copyright notice,
23   *      this list of conditions and the following disclaimer in the documentation
24   *      and/or other materials provided with the distribution.
25   *   3. Neither the name of STMicroelectronics nor the names of its contributors
26   *      may be used to endorse or promote products derived from this software
27   *      without specific prior written permission.
28   *
29   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
33   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39   *
40   ******************************************************************************
41   */
42
43 /* Includes ------------------------------------------------------------------*/
44 #include "stm32l1xx_hal.h"
45
46 /** @addtogroup STM32L1xx_HAL_Driver
47   * @{
48   */
49
50 /** @defgroup PWREx PWREx
51   * @brief    PWR HAL module driver
52   * @{
53   */
54
55 #ifdef HAL_PWR_MODULE_ENABLED
56
57 /* Private typedef -----------------------------------------------------------*/
58 /* Private define ------------------------------------------------------------*/
59 /* Private macro -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private function prototypes -----------------------------------------------*/
62 /* Private functions ---------------------------------------------------------*/
63
64 /** @defgroup PWREx_Exported_Functions PWREx Exported Functions
65   * @{
66   */
67
68 /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions
69   * @brief    Low Power modes configuration functions
70   *
71 @verbatim
72
73  ===============================================================================
74                  ##### Peripheral extended features functions #####
75  ===============================================================================
76 @endverbatim
77   * @{
78   */
79
80 /**
81   * @brief  Enables the Fast WakeUp from Ultra Low Power mode.
82   * @note   This bit works in conjunction with ULP bit. 
83   *         Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when 
84   *         exiting from low power mode.
85   * @retval None
86   */
87 void HAL_PWREx_EnableFastWakeUp(void)
88 {
89   /* Enable the fast wake up */
90   *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;
91 }
92
93 /**
94   * @brief  Disables the Fast WakeUp from Ultra Low Power mode.
95   * @retval None
96   */
97 void HAL_PWREx_DisableFastWakeUp(void)
98 {
99   /* Disable the fast wake up */
100   *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;
101 }
102
103 /**
104   * @brief  Enables the Ultra Low Power mode
105   * @retval None
106   */
107 void HAL_PWREx_EnableUltraLowPower(void)
108 {
109   /* Enable the Ultra Low Power mode */
110   *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;
111 }
112
113 /**
114   * @brief  Disables the Ultra Low Power mode
115   * @retval None
116   */
117 void HAL_PWREx_DisableUltraLowPower(void)
118 {
119   /* Disable the Ultra Low Power mode */
120   *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;
121 }
122
123 /**
124   * @brief  Enters the Low Power Run mode.
125   * @note   Low power run mode can only be entered when VCORE is in range 2.
126   *         In addition, the dynamic voltage scaling must not be used when Low
127   *         power run mode is selected. Only Stop and Sleep modes with regulator
128   *         configured in Low power mode is allowed when Low power run mode is 
129   *         selected.
130   * @note   In Low power run mode, all I/O pins keep the same state as in Run mode.
131   * @retval None
132   */
133 void HAL_PWREx_EnableLowPowerRunMode(void)
134 {
135   /* Enters the Low Power Run mode */
136   *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;
137   *(__IO uint32_t *) CR_LPRUN_BB  = (uint32_t)ENABLE;
138 }
139
140 /**
141   * @brief  Exits the Low Power Run mode.
142   * @retval None
143   */
144 void HAL_PWREx_DisableLowPowerRunMode(void)
145 {
146   /* Exits the Low Power Run mode */
147   *(__IO uint32_t *) CR_LPRUN_BB  = (uint32_t)DISABLE;
148   *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;
149 }
150
151 /**
152   * @}
153   */
154
155 /**
156   * @}
157   */
158
159 #endif /* HAL_PWR_MODULE_ENABLED */
160 /**
161   * @}
162   */
163
164 /**
165   * @}
166   */
167
168 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/