📄 stm32f10x_pwr.lst
字号:
132 tmpreg &= CR_PLS_Mask;
133
134 /* Set PLS[7:5] bits according to PWR_PVDLevel value */
135 tmpreg |= PWR_PVDLevel;
136
137 /* Store the new value */
138 PWR->CR = tmpreg;
139 }
140
141 /*******************************************************************************
142 * Function Name : PWR_WakeUpPinCmd
143 * Description : Enables or disables the WakeUp Pin functionality.
144 * Input : - NewState: new state of the WakeUp Pin functionality.
145 * This parameter can be: ENABLE or DISABLE.
146 * Output : None
147 * Return : None
148 *******************************************************************************/
149 void PWR_WakeUpPinCmd(FunctionalState NewState)
150 {
151 /* Check the parameters */
152 assert_param(IS_FUNCTIONAL_STATE(NewState));
153
154 *(vu32 *) CSR_EWUP_BB = (u32)NewState;
155 }
156
157 /*******************************************************************************
158 * Function Name : PWR_EnterSTOPMode
159 * Description : Enters STOP mode.
160 * Input : - PWR_Regulator: specifies the regulator state in STOP mode.
161 * This parameter can be one of the following values:
162 * - PWR_Regulator_ON: STOP mode with regulator ON
163 * - PWR_Regulator_LowPower: STOP mode with
164 * regulator in low power mode
165 * - PWR_STOPEntry: specifies if STOP mode in entered with WFI or
166 * WFE instruction.
167 * This parameter can be one of the following values:
168 * - PWR_STOPEntry_WFI: enter STOP mode with WFI instruction
169 * - PWR_STOPEntry_WFE: enter STOP mode with WFE instruction
170 * Output : None
171 * Return : None
172 *******************************************************************************/
173 void PWR_EnterSTOPMode(u32 PWR_Regulator, u8 PWR_STOPEntry)
174 {
175 u32 tmpreg = 0;
176
177 /* Check the parameters */
178 assert_param(IS_PWR_REGULATOR(PWR_Regulator));
179 assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry));
180
181 /* Select the regulator state in STOP mode ---------------------------------*/
182 tmpreg = PWR->CR;
183
184 /* Clear PDDS and LPDS bits */
185 tmpreg &= CR_DS_Mask;
186
187 /* Set LPDS bit according to PWR_Regulator value */
188 tmpreg |= PWR_Regulator;
189
190 /* Store the new value */
191 PWR->CR = tmpreg;
192
193 /* Set SLEEPDEEP bit of Cortex System Control Register */
194 *(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPDEEP_Set;
195
196 /* Select STOP mode entry --------------------------------------------------*/
197 if(PWR_STOPEntry == PWR_STOPEntry_WFI)
198 {
199 /* Request Wait For Interrupt */
200 __WFI();
201 }
202 else
203 {
204 /* Request Wait For Event */
205 __WFE();
206 }
207 }
208
209 /*******************************************************************************
210 * Function Name : PWR_EnterSTANDBYMode
211 * Description : Enters STANDBY mode.
212 * Input : None
213 * Output : None
214 * Return : None
215 *******************************************************************************/
216 void PWR_EnterSTANDBYMode(void)
217 {
218 /* Clear Wake-up flag */
219 PWR->CR |= CR_CWUF_Set;
220
221 /* Select STANDBY mode */
222 PWR->CR |= CR_PDDS_Set;
223
224 /* Set SLEEPDEEP bit of Cortex System Control Register */
225 *(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPDEEP_Set;
226
227 /* Request Wait For Interrupt */
228 __WFI();
229 }
230
231 /*******************************************************************************
232 * Function Name : PWR_GetFlagStatus
233 * Description : Checks whether the specified PWR flag is set or not.
234 * Input : - PWR_FLAG: specifies the flag to check.
235 * This parameter can be one of the following values:
236 * - PWR_FLAG_WU: Wake Up flag
237 * - PWR_FLAG_SB: StandBy flag
238 * - PWR_FLAG_PVDO: PVD Output
239 * Output : None
240 * Return : The new state of PWR_FLAG (SET or RESET).
241 *******************************************************************************/
242 FlagStatus PWR_GetFlagStatus(u32 PWR_FLAG)
243 {
244 FlagStatus bitstatus = RESET;
245
246 /* Check the parameters */
247 assert_param(IS_PWR_GET_FLAG(PWR_FLAG));
248
249 if ((PWR->CSR & PWR_FLAG) != (u32)RESET)
250 {
251 bitstatus = SET;
252 }
253 else
254 {
255 bitstatus = RESET;
256 }
257
258 /* Return the flag status */
259 return bitstatus;
260 }
261
262 /*******************************************************************************
263 * Function Name : PWR_ClearFlag
264 * Description : Clears the PWR's pending flags.
265 * Input : - PWR_FLAG: specifies the flag to clear.
266 * This parameter can be one of the following values:
267 * - PWR_FLAG_WU: Wake Up flag
268 * - PWR_FLAG_SB: StandBy flag
269 * Output : None
270 * Return : None
271 *******************************************************************************/
272 void PWR_ClearFlag(u32 PWR_FLAG)
273 {
274 /* Check the parameters */
275 assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));
276
277 PWR->CR |= PWR_FLAG << 2;
278 }
279
280 /******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/
Errors: 5
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -