stm32f10x_pwr.c
Go to the documentation of this file.
1 
22 /* Includes ------------------------------------------------------------------*/
23 #include "stm32f10x_pwr.h"
24 #include "stm32f10x_rcc.h"
25 
47 /* --------- PWR registers bit address in the alias region ---------- */
48 #define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
49 
50 /* --- CR Register ---*/
51 
52 /* Alias word address of DBP bit */
53 #define CR_OFFSET (PWR_OFFSET + 0x00)
54 #define DBP_BitNumber 0x08
55 #define CR_DBP_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (DBP_BitNumber * 4))
56 
57 /* Alias word address of PVDE bit */
58 #define PVDE_BitNumber 0x04
59 #define CR_PVDE_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PVDE_BitNumber * 4))
60 
61 /* --- CSR Register ---*/
62 
63 /* Alias word address of EWUP bit */
64 #define CSR_OFFSET (PWR_OFFSET + 0x04)
65 #define EWUP_BitNumber 0x08
66 #define CSR_EWUP_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (EWUP_BitNumber * 4))
67 
68 /* ------------------ PWR registers bit mask ------------------------ */
69 
70 /* CR register bit mask */
71 #define CR_DS_MASK ((uint32_t)0xFFFFFFFC)
72 #define CR_PLS_MASK ((uint32_t)0xFFFFFF1F)
73 
74 
112 void PWR_DeInit(void)
113 {
116 }
117 
125 {
126  /* Check the parameters */
128  *(__IO uint32_t *) CR_DBP_BB = (uint32_t)NewState;
129 }
130 
138 {
139  /* Check the parameters */
141  *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)NewState;
142 }
143 
158 void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel)
159 {
160  uint32_t tmpreg = 0;
161  /* Check the parameters */
162  assert_param(IS_PWR_PVD_LEVEL(PWR_PVDLevel));
163  tmpreg = PWR->CR;
164  /* Clear PLS[7:5] bits */
165  tmpreg &= CR_PLS_MASK;
166  /* Set PLS[7:5] bits according to PWR_PVDLevel value */
167  tmpreg |= PWR_PVDLevel;
168  /* Store the new value */
169  PWR->CR = tmpreg;
170 }
171 
179 {
180  /* Check the parameters */
182  *(__IO uint32_t *) CSR_EWUP_BB = (uint32_t)NewState;
183 }
184 
197 void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry)
198 {
199  uint32_t tmpreg = 0;
200  /* Check the parameters */
201  assert_param(IS_PWR_REGULATOR(PWR_Regulator));
202  assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry));
203 
204  /* Select the regulator state in STOP mode ---------------------------------*/
205  tmpreg = PWR->CR;
206  /* Clear PDDS and LPDS bits */
207  tmpreg &= CR_DS_MASK;
208  /* Set LPDS bit according to PWR_Regulator value */
209  tmpreg |= PWR_Regulator;
210  /* Store the new value */
211  PWR->CR = tmpreg;
212  /* Set SLEEPDEEP bit of Cortex System Control Register */
213  SCB->SCR |= SCB_SCR_SLEEPDEEP;
214 
215  /* Select STOP mode entry --------------------------------------------------*/
216  if(PWR_STOPEntry == PWR_STOPEntry_WFI)
217  {
218  /* Request Wait For Interrupt */
219  __WFI();
220  }
221  else
222  {
223  /* Request Wait For Event */
224  __WFE();
225  }
226 
227  /* Reset SLEEPDEEP bit of Cortex System Control Register */
228  SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP);
229 }
230 
237 {
238  /* Clear Wake-up flag */
239  PWR->CR |= PWR_CR_CWUF;
240  /* Select STANDBY mode */
241  PWR->CR |= PWR_CR_PDDS;
242  /* Set SLEEPDEEP bit of Cortex System Control Register */
243  SCB->SCR |= SCB_SCR_SLEEPDEEP;
244 /* This option is used to ensure that store operations are completed */
245 #if defined ( __CC_ARM )
246  __force_stores();
247 #endif
248  /* Request Wait For Interrupt */
249  __WFI();
250 }
251 
261 FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG)
262 {
263  FlagStatus bitstatus = RESET;
264  /* Check the parameters */
265  assert_param(IS_PWR_GET_FLAG(PWR_FLAG));
266 
267  if ((PWR->CSR & PWR_FLAG) != (uint32_t)RESET)
268  {
269  bitstatus = SET;
270  }
271  else
272  {
273  bitstatus = RESET;
274  }
275  /* Return the flag status */
276  return bitstatus;
277 }
278 
287 void PWR_ClearFlag(uint32_t PWR_FLAG)
288 {
289  /* Check the parameters */
290  assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));
291 
292  PWR->CR |= PWR_FLAG << 2;
293 }
294 
307 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
void PWR_DeInit(void)
Deinitializes the PWR peripheral registers to their default reset values.
FlagStatus
Definition: stm32f4xx.h:706
void PWR_BackupAccessCmd(FunctionalState NewState)
Enables or disables access to the RTC and backup registers.
FunctionalState
Definition: stm32f4xx.h:708
void PWR_WakeUpPinCmd(FunctionalState NewState)
Enables or disables the WakeUp Pin functionality.
#define IS_PWR_CLEAR_FLAG(FLAG)
This file contains all the functions prototypes for the PWR firmware library.
void assert_param(int val)
#define PWR_CR_CWUF
Definition: stm32f4xx.h:8354
#define IS_PWR_PVD_LEVEL(LEVEL)
Definition: stm32f4xx_pwr.h:68
void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel)
Configures the voltage threshold detected by the Power Voltage Detector(PVD).
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f4xx.h:709
#define CR_PLS_MASK
Definition: stm32f10x_pwr.c:72
#define IS_PWR_STOP_ENTRY(ENTRY)
Definition: stm32f4xx_pwr.h:95
Definition: stm32f4xx.h:706
#define SCB
Definition: core_cm0.h:503
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
#define CSR_EWUP_BB
Definition: stm32f10x_pwr.c:66
#define __IO
Definition: core_cm0.h:198
void PWR_EnterSTANDBYMode(void)
Enters STANDBY mode.
#define CR_DBP_BB
Definition: stm32f10x_pwr.c:55
#define CR_PVDE_BB
Definition: stm32f10x_pwr.c:59
#define SCB_SCR_SLEEPDEEP
Definition: stm32f10x.h:3182
void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry)
Enters STOP mode.
This file contains all the functions prototypes for the RCC firmware library.
void PWR_PVDCmd(FunctionalState NewState)
Enables or disables the Power Voltage Detector(PVD).
#define PWR
Definition: stm32f4xx.h:2074
void PWR_ClearFlag(uint32_t PWR_FLAG)
Clears the PWR&#39;s pending flags.
#define CR_DS_MASK
Definition: stm32f10x_pwr.c:71
#define PWR_CR_PDDS
Definition: stm32f4xx.h:8353
#define IS_PWR_REGULATOR(REGULATOR)
Definition: stm32f4xx_pwr.h:83
#define PWR_STOPEntry_WFI
Definition: stm32f4xx_pwr.h:93
FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG)
Checks whether the specified PWR flag is set or not.
#define IS_PWR_GET_FLAG(FLAG)


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:19