返回值 先决条件 被调用函数 例: 无 无 __WFI(), /* Put the system in STANDBY mode */ PWR_EnterSTANDBYMode(); 函数原型如下:
void PWR_EnterSTANDBYMode(void) {
/* Clear Wake-up flag */
PWR->CR |= CR_CWUF_Set;// 0x00000004,清除PWR->CSR.WUF(bit0)
/* Select STANDBY mode */
PWR->CR |= CR_PDDS_Set;// 0x00000002:0—停机;1—待机
/* Set SLEEPDEEP bit of Cortex System Control Register */ *(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPDEEP_Set;
//SCB->SCR. SLEEPDEEP(bit2),用地址直接访问,避免调用SCB库函数。 //&SCB_SysCtrl = 0xE000ED10;SysCtrl_SLEEPDEEP_Set = 0x00000004
/* Request Wait For Interrupt */ __WFI(); }
14.2.8 函数PWR_GetFlagStatus
Table 333. 函数PWR_GetFlagStatus 函数名 PWR_GetFlagStatus 函数原形 FlagStatus PWR_GetFlagStatus(u32 PWR_FLAG) 功能描述 检查指定PWR标志位设置与否 输入参数 PWR_FLAG:待检查的PWR标志位 输出参数 无 返回值 PWR_FLAG的新状态(SET或RESET) 先决条件 无 被调用函数 无 PWR_FLAG:给出了所有可以被函数PWR_ GetFlagStatus检查的标志位列表 Table 334. PWR_FLAG值 PWR_FLAG 描述/PWR->CSR #define Val 备注 PWR_FLAG_WU 唤醒标志位 0x00000001 bit0 PWR_FLAG_SB 待命(Standby)标志位 0x00000002 bit1 PWR_FLAG_PVDO PVD输出(1) 0x00000004 bit2 1. 该标志位为只读,不能被清除 例:
/* Test if the StandBy flag is set or not */ FlagStatus Status;
Status = PWR_GetFlagStatus(PWR_FLAG_SB); if(Status == RESET) { ... } else { ... } 函数原型如下:
FlagStatus PWR_GetFlagStatus(u32 PWR_FLAG) {
FlagStatus bitstatus = RESET;
/* Check the parameters */
assert_param(IS_PWR_GET_FLAG(PWR_FLAG));
if ((PWR->CSR & PWR_FLAG) != (u32)RESET) {
bitstatus = SET; } else {
bitstatus = RESET; }
/* Return the flag status */ return bitstatus;
}
14.2.9 函数PWR_ClearFlag
Table 335. 函数PWR_ClearFlag 函数名 PWR_ClearFlag 函数原形 void PWR_ClearFlag(u32 PWR_FLAG) 功能描述 清除PWR的待处理标志位 输入参数 PWR_FLAG:待清除的PWR待处理标志位 输出参数 无 返回值 无 先决条件 无 被调用函数 无 例: /* Clear the StandBy pending flag */ PWR_ClearFlag(PWR_FLAG_SB); 函数原型如下:
void PWR_ClearFlag(u32 PWR_FLAG) {
/* Check the parameters */
assert_param(IS_PWR_CLEAR_FLAG(PWR_FLAG));//见“14.2.8 函数PWR_GetFlagStatus”的Flag取值
PWR->CR |= PWR_FLAG << 2;//CSR的标志位在CSR的bit0-3,在CR的控制位为bit2-4。故要“<<2”。 }
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库STM32F10x_PWR(2)在线全文阅读。
相关推荐: