📄 pcu.c
字号:
/****************************************Copyright (c)**************************************************
**
** STR710 development team
**
**
** http://www.appchip.com
**
**--------------文件信息--------------------------------------------------------------------------------
** 文 件 名: pcu.c
** 创 建 人: lhl
** 创建日期: 2006年5月10日
** 描 述: 该文件提供所有的PCU软件操作功能
**
**--------------历史版本--------------------------------------------------------------------------------
** 创 建 人: lhl
** 版 本: V1.0
** 日 期: 2006年5月10日
** 描 述: 原始版本
**
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
#include "pcu.h"
#include "rccu.h"
#if EN_ARM_PCU > 0 //决定是否编译该文件
/*********************************************************************************************************
;** 函数名称: PCU_VRConfig
;** 功能描述: This routine is used to configure PCU voltage regultors
;**
;** 参 数: Xvr: MVR:Main voltage Regulator
;** LPR: Low Power Regulator
;** new_status:ENABLE : Enable the Voltage Regulator
;** DISABLE: Disable ( ByPass ) the VR
;**
;** 返 回 值: 无
;**
;** 作 者: lhl
;** 日 期: 2006年5月10日
;**-------------------------------------------------------------------------------------------------------
;** 修 改 人:
;** 日 期:
;**------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
void PCU_VRConfig(PCU_VR_T Xvr, CONFIG_STATUS_T new_status)
{
UWORD16 temp = PCU_PWRCR;
switch (Xvr)
{
case PCU_MVR : // Configure the Main Voltage Regulator
if (new_status == DISABLE)
temp |= PCU_MVR_MASK;
else
temp &= ~PCU_MVR_MASK;
break;
case PCU_LPR : // Configure the Low power Voltage Regulator
if (new_status == DISABLE)
temp |= PCU_LPR_MASK;
else
temp &= ~PCU_LPR_MASK;
break;
}
// Unlock Power Control Register
PCU_PWRCR |= PCU_WREN_MASK;
PCU_PWRCR = temp | PCU_WREN_MASK;
}
/*********************************************************************************************************
;** 函数名称: PCU_WFIEnter
;** 功能描述: This routine is used to force the Device to enter in WFI mode
;**
;** 参 数: Xclock: CLOCK2_16 : Clock2_16 as system clock for WFI mode
;** EXTERNAL : external clock as system clock for WFI mode
;**
;** Xlpr : ENABLE : Enable Low Power Regulator during Wait For Interrupt Mode
;** DISABLE: Disable Low Power Regulator during Wait For Interrupt Mode
;** Xlpm : Enable Low Power Mode during Wait For Interrupt Mode
;** DISABLE: Disable Low Power Mode during Wait For Interrupt Mode
;**
;** 返 回 值: 无
;**
;** 作 者: lhl
;** 日 期: 2006年5月10日
;**-------------------------------------------------------------------------------------------------------
;** 修 改 人:
;** 日 期:
;**------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
void PCU_WFIEnter(WFI_CLOCKS_T Xclock, CONFIG_STATUS_T Xlpr, CONFIG_STATUS_T Xlpm)
{
UWORD32 temp;
//Enable Low Power Regulator in WFI mode
temp = PCU_PWRCR;
PCU_PWRCR |= PCU_WREN_MASK; // Unlock Power Control Register
PCU_PWRCR = Xlpr == DISABLE ? temp & ~PCU_LPRWFI_MASK : temp | PCU_LPRWFI_MASK;
//WFI Clock Selection
temp = RCCU_CCR;
RCCU_CCR = Xclock == WFI_CLOCK2_16 ? temp & ~PCU_WFI_CKSEL_MASK : temp | PCU_WFI_CKSEL_MASK;
// Low Power Mode during WFI mode
temp = RCCU_CCR;
RCCU_CCR = Xlpm == DISABLE ? temp & ~PCU_LPOWFI_MASK : temp | PCU_LPOWFI_MASK;
//Enter WFI Mode
RCCU_SMR &= ~0x0001;
}
/*********************************************************************************************************
;** 函数名称: PCU_LPMEnter
;** 功能描述: This routine is used to force the device to enter in low power modes
;**
;** 参 数: Xmode: PCU_SLOW : Slow Mode
;** PCU_STOP : Stop Mode
;** PCU_STANDBY : StandBy Mode
;**
;** 返 回 值: 无
;**
;** 作 者: lhl
;** 日 期: 2006年5月10日
;**-------------------------------------------------------------------------------------------------------
;** 修 改 人:
;** 日 期:
;**------------------------------------------------------------------------------------------------------
;********************************************************************************************************/
void PCU_LPMEnter (LPM_MODES_T Xmode)
{
switch ( Xmode )
{
case PCU_SLOW: //Slow Mode
{
RCCU_PLL1CR |= 0x87;
RCCU_RCLKConfig(RCCU_PLL1_OUTPUT);
break;
}
case PCU_STOP: //Stop Mode
{
RCCU_CCR |= PCU_STOP_EN_MASK; //Enable Stop EN bit
XTI_CTRL |= 0x04; //Write '1' to Stop Bit
XTI_CTRL &= 0x03; //Write '0' to Stop Bit
XTI_CTRL |= 0x04; //Write '1' to Stop Bit
//Wait a while
__asm
{
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
}
break;
// test if the Device entred in a Stop Mode.
}
case PCU_STANDBY: // PCU_STANDBY Mode
{
PCU_PWRCR |= PCU_WREN_MASK; // Unlock Power Control Register
PCU_PWRCR |= PCU_PWRDWN_MASK; // Set the Power Down flag
break;
}
}
}
#endif //EN_ARM_PCU > 0
/****************************************end of file*******************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -