]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_M3_NUCLEO_L152RE_GCC/ST_Code/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr_ex.c
Add MPU demo project for Nulceo-L152RE which is Coretx-M3.
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M3_NUCLEO_L152RE_GCC / ST_Code / Drivers / STM32L1xx_HAL_Driver / Src / stm32l1xx_hal_pwr_ex.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_hal_pwr_ex.c\r
4   * @author  MCD Application Team\r
5   * @brief   Extended PWR HAL module driver.\r
6   *          This file provides firmware functions to manage the following\r
7   *          functionalities of the Power Controller (PWR) peripheral:\r
8   *           + Extended Initialization and de-initialization functions\r
9   *           + Extended Peripheral Control functions\r
10   *\r
11   ******************************************************************************\r
12   * @attention\r
13   *\r
14   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.\r
15   * All rights reserved.</center></h2>\r
16   *\r
17   * This software component is licensed by ST under BSD 3-Clause license,\r
18   * the "License"; You may not use this file except in compliance with the\r
19   * License. You may obtain a copy of the License at:\r
20   *                        opensource.org/licenses/BSD-3-Clause\r
21   *\r
22   ******************************************************************************\r
23   */\r
24 \r
25 /* Includes ------------------------------------------------------------------*/\r
26 #include "stm32l1xx_hal.h"\r
27 \r
28 /** @addtogroup STM32L1xx_HAL_Driver\r
29   * @{\r
30   */\r
31 \r
32 /** @defgroup PWREx PWREx\r
33   * @brief    PWR HAL module driver\r
34   * @{\r
35   */\r
36 \r
37 #ifdef HAL_PWR_MODULE_ENABLED\r
38 \r
39 /* Private typedef -----------------------------------------------------------*/\r
40 /* Private define ------------------------------------------------------------*/\r
41 /* Private macro -------------------------------------------------------------*/\r
42 /* Private variables ---------------------------------------------------------*/\r
43 /* Private function prototypes -----------------------------------------------*/\r
44 /* Private functions ---------------------------------------------------------*/\r
45 \r
46 /** @defgroup PWREx_Exported_Functions PWREx Exported Functions\r
47   * @{\r
48   */\r
49 \r
50 /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions\r
51   * @brief    Low Power modes configuration functions\r
52   *\r
53 @verbatim\r
54 \r
55  ===============================================================================\r
56                  ##### Peripheral extended features functions #####\r
57  ===============================================================================\r
58 @endverbatim\r
59   * @{\r
60   */\r
61 \r
62 /**\r
63   * @brief Return Voltage Scaling Range.\r
64   * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3)\r
65   */\r
66 uint32_t HAL_PWREx_GetVoltageRange(void)\r
67 {\r
68   return  (PWR->CR & PWR_CR_VOS);\r
69 }\r
70 \r
71 \r
72 /**\r
73   * @brief  Enables the Fast WakeUp from Ultra Low Power mode.\r
74   * @note   This bit works in conjunction with ULP bit.\r
75   *         Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when\r
76   *         exiting from low power mode.\r
77   * @retval None\r
78   */\r
79 void HAL_PWREx_EnableFastWakeUp(void)\r
80 {\r
81   /* Enable the fast wake up */\r
82   *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;\r
83 }\r
84 \r
85 /**\r
86   * @brief  Disables the Fast WakeUp from Ultra Low Power mode.\r
87   * @retval None\r
88   */\r
89 void HAL_PWREx_DisableFastWakeUp(void)\r
90 {\r
91   /* Disable the fast wake up */\r
92   *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;\r
93 }\r
94 \r
95 /**\r
96   * @brief  Enables the Ultra Low Power mode\r
97   * @retval None\r
98   */\r
99 void HAL_PWREx_EnableUltraLowPower(void)\r
100 {\r
101   /* Enable the Ultra Low Power mode */\r
102   *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;\r
103 }\r
104 \r
105 /**\r
106   * @brief  Disables the Ultra Low Power mode\r
107   * @retval None\r
108   */\r
109 void HAL_PWREx_DisableUltraLowPower(void)\r
110 {\r
111   /* Disable the Ultra Low Power mode */\r
112   *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;\r
113 }\r
114 \r
115 /**\r
116   * @brief  Enters the Low Power Run mode.\r
117   * @note   Low power run mode can only be entered when VCORE is in range 2.\r
118   *         In addition, the dynamic voltage scaling must not be used when Low\r
119   *         power run mode is selected. Only Stop and Sleep modes with regulator\r
120   *         configured in Low power mode is allowed when Low power run mode is\r
121   *         selected.\r
122   * @note   In Low power run mode, all I/O pins keep the same state as in Run mode.\r
123   * @retval None\r
124   */\r
125 void HAL_PWREx_EnableLowPowerRunMode(void)\r
126 {\r
127   /* Enters the Low Power Run mode */\r
128   *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;\r
129   *(__IO uint32_t *) CR_LPRUN_BB  = (uint32_t)ENABLE;\r
130 }\r
131 \r
132 /**\r
133   * @brief  Exits the Low Power Run mode.\r
134   * @retval None\r
135   */\r
136 HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)\r
137 {\r
138   /* Exits the Low Power Run mode */\r
139   *(__IO uint32_t *) CR_LPRUN_BB  = (uint32_t)DISABLE;\r
140   *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;\r
141   return HAL_OK;\r
142 }\r
143 \r
144 /**\r
145   * @}\r
146   */\r
147 \r
148 /**\r
149   * @}\r
150   */\r
151 \r
152 #endif /* HAL_PWR_MODULE_ENABLED */\r
153 /**\r
154   * @}\r
155   */\r
156 \r
157 /**\r
158   * @}\r
159   */\r
160 \r
161 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r