Subversion Repositories EngineBay2

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**
  2.   ******************************************************************************
  3.   * @file    stm32l1xx_hal_pwr_ex.c
  4.   * @author  MCD Application Team
  5.   * @version V1.2.0
  6.   * @date    01-July-2016
  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) 2016 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 Return Voltage Scaling Range.  
  82.   * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3)
  83.   */  
  84. uint32_t HAL_PWREx_GetVoltageRange(void)
  85. {
  86.   return  (PWR->CR & PWR_CR_VOS);
  87. }
  88.  
  89.  
  90. /**
  91.   * @brief  Enables the Fast WakeUp from Ultra Low Power mode.
  92.   * @note   This bit works in conjunction with ULP bit.
  93.   *         Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when
  94.   *         exiting from low power mode.
  95.   * @retval None
  96.   */
  97. void HAL_PWREx_EnableFastWakeUp(void)
  98. {
  99.   /* Enable the fast wake up */
  100.   *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;
  101. }
  102.  
  103. /**
  104.   * @brief  Disables the Fast WakeUp from Ultra Low Power mode.
  105.   * @retval None
  106.   */
  107. void HAL_PWREx_DisableFastWakeUp(void)
  108. {
  109.   /* Disable the fast wake up */
  110.   *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;
  111. }
  112.  
  113. /**
  114.   * @brief  Enables the Ultra Low Power mode
  115.   * @retval None
  116.   */
  117. void HAL_PWREx_EnableUltraLowPower(void)
  118. {
  119.   /* Enable the Ultra Low Power mode */
  120.   *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;
  121. }
  122.  
  123. /**
  124.   * @brief  Disables the Ultra Low Power mode
  125.   * @retval None
  126.   */
  127. void HAL_PWREx_DisableUltraLowPower(void)
  128. {
  129.   /* Disable the Ultra Low Power mode */
  130.   *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;
  131. }
  132.  
  133. /**
  134.   * @brief  Enters the Low Power Run mode.
  135.   * @note   Low power run mode can only be entered when VCORE is in range 2.
  136.   *         In addition, the dynamic voltage scaling must not be used when Low
  137.   *         power run mode is selected. Only Stop and Sleep modes with regulator
  138.   *         configured in Low power mode is allowed when Low power run mode is
  139.   *         selected.
  140.   * @note   In Low power run mode, all I/O pins keep the same state as in Run mode.
  141.   * @retval None
  142.   */
  143. void HAL_PWREx_EnableLowPowerRunMode(void)
  144. {
  145.   /* Enters the Low Power Run mode */
  146.   *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;
  147.   *(__IO uint32_t *) CR_LPRUN_BB  = (uint32_t)ENABLE;
  148. }
  149.  
  150. /**
  151.   * @brief  Exits the Low Power Run mode.
  152.   * @retval None
  153.   */
  154. HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)
  155. {
  156.   /* Exits the Low Power Run mode */
  157.   *(__IO uint32_t *) CR_LPRUN_BB  = (uint32_t)DISABLE;
  158.   *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;
  159.   return HAL_OK;
  160. }
  161.  
  162. /**
  163.   * @}
  164.   */
  165.  
  166. /**
  167.   * @}
  168.   */
  169.  
  170. #endif /* HAL_PWR_MODULE_ENABLED */
  171. /**
  172.   * @}
  173.   */
  174.  
  175. /**
  176.   * @}
  177.   */
  178.  
  179. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  180.