Subversion Repositories EngineBay2

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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