stm32l1xx_hal_pwr_ex.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. /* Includes ------------------------------------------------------------------*/
  43. #include "stm32l1xx_hal.h"
  44. /** @addtogroup STM32L1xx_HAL_Driver
  45. * @{
  46. */
  47. /** @defgroup PWREx PWREx
  48. * @brief PWR HAL module driver
  49. * @{
  50. */
  51. #ifdef HAL_PWR_MODULE_ENABLED
  52. /* Private typedef -----------------------------------------------------------*/
  53. /* Private define ------------------------------------------------------------*/
  54. /* Private macro -------------------------------------------------------------*/
  55. /* Private variables ---------------------------------------------------------*/
  56. /* Private function prototypes -----------------------------------------------*/
  57. /* Private functions ---------------------------------------------------------*/
  58. /** @defgroup PWREx_Exported_Functions PWREx Exported Functions
  59. * @{
  60. */
  61. /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions
  62. * @brief Low Power modes configuration functions
  63. *
  64. @verbatim
  65. ===============================================================================
  66. ##### Peripheral extended features functions #####
  67. ===============================================================================
  68. @endverbatim
  69. * @{
  70. */
  71. /**
  72. * @brief Enables the Fast WakeUp from Ultra Low Power mode.
  73. * @note This bit works in conjunction with ULP bit.
  74. * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when
  75. * exiting from low power mode.
  76. * @retval None
  77. */
  78. void HAL_PWREx_EnableFastWakeUp(void)
  79. {
  80. /* Enable the fast wake up */
  81. *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;
  82. }
  83. /**
  84. * @brief Disables the Fast WakeUp from Ultra Low Power mode.
  85. * @retval None
  86. */
  87. void HAL_PWREx_DisableFastWakeUp(void)
  88. {
  89. /* Disable the fast wake up */
  90. *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;
  91. }
  92. /**
  93. * @brief Enables the Ultra Low Power mode
  94. * @retval None
  95. */
  96. void HAL_PWREx_EnableUltraLowPower(void)
  97. {
  98. /* Enable the Ultra Low Power mode */
  99. *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;
  100. }
  101. /**
  102. * @brief Disables the Ultra Low Power mode
  103. * @retval None
  104. */
  105. void HAL_PWREx_DisableUltraLowPower(void)
  106. {
  107. /* Disable the Ultra Low Power mode */
  108. *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;
  109. }
  110. /**
  111. * @brief Enters the Low Power Run mode.
  112. * @note Low power run mode can only be entered when VCORE is in range 2.
  113. * In addition, the dynamic voltage scaling must not be used when Low
  114. * power run mode is selected. Only Stop and Sleep modes with regulator
  115. * configured in Low power mode is allowed when Low power run mode is
  116. * selected.
  117. * @note In Low power run mode, all I/O pins keep the same state as in Run mode.
  118. * @retval None
  119. */
  120. void HAL_PWREx_EnableLowPowerRunMode(void)
  121. {
  122. /* Enters the Low Power Run mode */
  123. *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;
  124. *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE;
  125. }
  126. /**
  127. * @brief Exits the Low Power Run mode.
  128. * @retval None
  129. */
  130. void HAL_PWREx_DisableLowPowerRunMode(void)
  131. {
  132. /* Exits the Low Power Run mode */
  133. *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE;
  134. *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;
  135. }
  136. /**
  137. * @}
  138. */
  139. /**
  140. * @}
  141. */
  142. #endif /* HAL_PWR_MODULE_ENABLED */
  143. /**
  144. * @}
  145. */
  146. /**
  147. * @}
  148. */
  149. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/