rt-thread-official/bsp/essemi/es8p508x/libraries/Library/Source/lib_scu.c

388 lines
10 KiB
C
Raw Normal View History

2019-11-07 10:00:14 +08:00
/***************************************************************
*Copyright (C), 2017, Shanghai Eastsoft Microelectronics Co., Ltd
*<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lib_scu.c
*<EFBFBD><EFBFBD> <EFBFBD>ߣ<EFBFBD> Liut
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> V1.00
*<EFBFBD><EFBFBD> <EFBFBD>ڣ<EFBFBD> 2017/07/14
*<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ϵͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*<EFBFBD><EFBFBD> ע<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ES8P508xоƬ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧϰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾʹ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><EFBFBD>ջ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>κη<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ρ<EFBFBD>
***************************************************************/
#include "lib_scu.h"
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_OpenXTAL
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿʱ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ϵͳʱ<EFBFBD><EFBFBD>Դ
***************************************************************/
void SCU_OpenXTAL(void)
{
SCU_RegUnLock();
SCU->SCLKEN1.XTAL_EN = 1;
SCU->SCLKEN0.XTAL_LP = 0;
while(SCU->SCLKEN1.XTAL_RDY == 0); //<2F>ȴ<EFBFBD><C8B4>ⲿʱ<E2B2BF><CAB1><EFBFBD>ȶ<EFBFBD>
SCU_RegLock() ;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_NMISelect
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NMI<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void SCU_NMISelect(SCU_TYPE_NMICS NMI_Type)
{
SCU_RegUnLock();
SCU->NMICON.NMICS = NMI_Type;
SCU_RegLock() ;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_GetPWRCFlagStatus
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡPWRC<EFBFBD><EFBFBD>λ״̬<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ״̬
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>PWRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>RESET/SET
***************************************************************/
FlagStatus SCU_GetPWRCFlagStatus(SCU_TYPE_PWRC PWRC_Flag)
{
FlagStatus bitstatus = RESET;
if((SCU->PWRC.Word & (uint32_t)PWRC_Flag) != (uint32_t)RESET)
bitstatus = SET;
else
bitstatus = RESET;
return bitstatus;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_ClearPWRCFlagBit
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PWRC<EFBFBD><EFBFBD>λ״̬<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>PWRC<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void SCU_ClearPWRCFlagBit(SCU_TYPE_PWRC PWRC_Flag)
{
SCU_RegUnLock() ;
SCU->PWRC.Word &= ~((uint32_t)PWRC_Flag);
SCU_RegLock() ;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_GetLVDFlagStatus
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡLVDD<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ״̬
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>LVD<EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>RESET/SET
***************************************************************/
FlagStatus SCU_GetLVDFlagStatus(SCU_TYPE_LVD0CON LVD_Flag)
{
FlagStatus bitstatus = RESET;
if((SCU->LVDCON.Word & (uint32_t)LVD_Flag) != (uint32_t)RESET)
bitstatus = SET;
else
bitstatus = RESET;
return bitstatus;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_SysClkSelect
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>ϵͳʱ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void SCU_SysClkSelect(SCU_TYPE_SYSCLK Sysclk)
{
SCU_RegUnLock() ;
SCU->SCLKEN0.CLK_SEL = Sysclk;
SCU_RegLock() ;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_GetSysClk
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡϵͳʱ<EFBFBD><EFBFBD>Դ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>ϵͳʱ<EFBFBD><EFBFBD>Դ
***************************************************************/
SCU_TYPE_SYSCLK SCU_GetSysClk(void)
{
return (SCU_TYPE_SYSCLK)(SCU->SCLKEN0.CLK_SEL);
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_HRCReadyFlag
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡHRC<EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>־λ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>RESET<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>/SET<EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
FlagStatus SCU_HRCReadyFlag(void)
{
FlagStatus bitstatus = RESET;
if((SCU->SCLKEN1.HRC_RDY) != (uint32_t)RESET)
bitstatus = SET;
else
bitstatus = RESET;
return bitstatus;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_XTALReadyFlag
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡXTAL<EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>־λ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>RESET<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>/SET<EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
FlagStatus SCU_XTALReadyFlag(void)
{
FlagStatus bitstatus = RESET;
if((SCU->SCLKEN1.XTAL_RDY) != (uint32_t)RESET)
bitstatus = SET;
else
bitstatus = RESET;
return bitstatus;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SCU_LOSCReadyFlag
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡLOSC<EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>־λ
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>RESET<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>/SET<EFBFBD><EFBFBD><EFBFBD>ȶ<EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
FlagStatus SCU_PLLReadyFlag(void)
{
FlagStatus bitstatus = RESET;
if((SCU->SCLKEN1.PLL_RDY) != (uint32_t)RESET)
bitstatus = SET;
else
bitstatus = RESET;
return bitstatus;
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SystemClockConfig
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD>ӣ<EFBFBD>20MHZ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void SystemClockConfig(void)
{
uint32_t Prot_Temp;
Prot_Temp = SCU->PROT.PROT;
if(Prot_Temp != 0) //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SCU_RegUnLock(); //<2F><><EFBFBD><EFBFBD>
SCU_HRC_Enable(); //ʹ<><CAB9><EFBFBD>ڲ<EFBFBD>20MHZ
while(SCU_HRCReadyFlag() != SET); //<2F>ȴ<EFBFBD>ʱ<EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>
SCU_SysClkSelect(SCU_SysClk_HRC); //ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>20MHZΪϵͳʱ<CDB3><CAB1>
SCU_SysClk_Div1(); //ϵͳʱ<CDB3>Ӻ<EFBFBD><D3BA><EFBFBD>Ƶ1:1
SystemCoreClock = 20000000;
if(Prot_Temp != 0) //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SCU_RegLock(); //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DeviceClockAllEnable
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void DeviceClockAllEnable(void)
{
uint32_t Prot_Temp;
Prot_Temp = SCU->PROT.PROT;
if(Prot_Temp != 0) //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SCU_RegUnLock(); //<2F><><EFBFBD><EFBFBD>
SCU->PCLKEN0.Word = 0xFFFFFFFF;
SCU->PCLKEN1.Word = 0xFFFFFFFF; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
if(Prot_Temp != 0) //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SCU_RegLock(); //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DeviceClockAllDisable
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void DeviceClockAllDisable(void)
{
uint32_t Prot_Temp;
Prot_Temp = SCU->PROT.PROT;
if(Prot_Temp != 0) //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SCU_RegUnLock(); //<2F><><EFBFBD><EFBFBD>
SCU->PCLKEN0.Word = 0x00000000; //<2F>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ӣ<EFBFBD>scu<63>޷<EFBFBD><DEB7>ر<EFBFBD>
SCU->PCLKEN1.Word = 0x00000000;
if(Prot_Temp != 0) //д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SCU_RegLock(); //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>SystemClockConfig
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳʱ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>CLKx ϵͳʱ<EFBFBD><EFBFBD>Դѡ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void SystemClockSelect(SCU_TYPE_SYSCLK SYSCLKx , SCU_TYPE_CLK_SEL CLK_SEL)
{
SCU_RegUnLock(); //<2F><><EFBFBD><EFBFBD>
switch(SYSCLKx)
{
case 0:
SCU_HRC_Enable();
while(SCU_HRCReadyFlag() != SET);
break;
case 1:
SCU_XTAL_Enable();
while(SCU_XTALReadyFlag() != SET);
break;
case 2:
SCU_PLL_Enable();
while(SCU_PLLReadyFlag() != SET);
break;
default:break;
}
SCU->SCLKEN0.SYSCLK_DIV = 0;
SCU->SCLKEN0.CLK_SEL = CLK_SEL;
SCU_RegLock();
}
/***************************************************************
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PLLClock_Config
<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>PLLʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PLLʱ<EFBFBD><EFBFBD>Ϊϵͳʱ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>pll_en:<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>PLL<EFBFBD><EFBFBD>pll_origin<EFBFBD><EFBFBD>pllʱ<EFBFBD><EFBFBD>Դѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>pll_out<EFBFBD><EFBFBD>pll<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>sys_pll<EFBFBD><EFBFBD>ϵͳʱ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ʹ<EFBFBD><EFBFBD>PLLʱ<EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
***************************************************************/
void PLLClock_Config(TYPE_FUNCEN pll_en , SCU_PLL_Origin pll_origin ,SCU_PLL_Out pll_out,TYPE_FUNCEN sys_pll)
{
SCU_RegUnLock();
if(pll_en == DISABLE) //<2F><><EFBFBD><EFBFBD>PLL<4C><4C><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD>ֱ<EFBFBD>ӽ<EFBFBD>ֹPLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
SCU->SCLKEN0.PLL_MUX = 0;
SCU->SCLKEN1.PLL_BYLOCK = 0;
SCU->SCLKEN0.CLKFLT_BY = 0x00;
SCU->SCLKEN1.PLL_EN = 0;
return;
}
if((pll_origin == SCU_PLL_HRC)) //<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><E8BFAA><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
{
if(SCU->SCLKEN1.HRC_RDY == 0)
{
SCU->SCLKEN1.HRC_EN = 1;
while(SCU->SCLKEN1.HRC_RDY == 0); //<2F>ȴ<EFBFBD>HRC<52><43><EFBFBD><EFBFBD>
}
}
if((pll_origin == SCU_PLL_XTAL_32K)
|| (pll_origin == SCU_PLL_XTAL_4M)
||(pll_origin == SCU_PLL_XTAL_8M)
|| (pll_origin == SCU_PLL_XTAL_16M)
|| (pll_origin == SCU_PLL_XTAL_20M)) //<2F><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ⲿʱ<E2B2BF>ӣ<EFBFBD><D3A3><EFBFBD><E8BFAA><EFBFBD>ⲿʱ<E2B2BF><CAB1>
{
if(SCU->SCLKEN1.XTAL_RDY == 0)
{
SCU->SCLKEN1.XTAL_EN = 1;
SCU->SCLKEN0.XTAL_LP = 0;
while(SCU->SCLKEN1.XTAL_RDY == 0); //<2F>ȴ<EFBFBD>XTAL<41><4C><EFBFBD><EFBFBD>
}
}
switch(pll_origin)
{
case SCU_PLL_HRC:
SCU->SCLKEN1.PLL_REF_SEL = 0x00;
break;
case SCU_PLL_LRC:
SCU->SCLKEN1.PLL_REF_SEL = 0x02;
break;
case SCU_PLL_XTAL_32K:
SCU->SCLKEN1.PLL_REF_SEL = 0x03;
break;
case SCU_PLL_XTAL_4M:
SCU->SCLKEN1.PLL_REF_SEL = 0x04;
break;
case SCU_PLL_XTAL_8M:
SCU->SCLKEN1.PLL_REF_SEL = 0x05;
break;
case SCU_PLL_XTAL_16M:
SCU->SCLKEN1.PLL_REF_SEL = 0x06;
break;
case SCU_PLL_XTAL_20M:
SCU->SCLKEN1.PLL_REF_SEL = 0x07;
break;
default:
break;
}
SCU->SCLKEN1.PLL_48M_SEL = pll_out; //<2F><><EFBFBD><EFBFBD>PLL<4C><4C><EFBFBD><EFBFBD>Ϊ32<33><32>48Mhz
SCU->SCLKEN1.PLL_EN = 1;
while(SCU->SCLKEN1.PLL_RDY == 0);
if(sys_pll == ENABLE)
{
if(pll_out == SCU_PLL_32M)
{
SCU->SCLKEN0.CLKFLT_BY = 0;
}
else
{
SCU->SCLKEN0.CLKFLT_BY = 0x55; //48M ʱ<><CAB1><EFBFBD>˲<EFBFBD><CBB2><EFBFBD>·
}
SCU->SCLKEN1.PLL_BYLOCK = 1;
SCU->SCLKEN0.PLL_MUX = 1;
}
else
{
SCU->SCLKEN0.PLL_MUX = 0;
SCU->SCLKEN1.PLL_BYLOCK = 0;
SCU->SCLKEN0.CLKFLT_BY = 0x00;
}
SCU_RegLock();
}
/*************************END OF FILE**********************/