rt-thread/bsp/nv32f100x/lib/src/ics.c

1110 lines
28 KiB
C
Raw Normal View History

2017-09-20 14:21:18 +08:00
/*************************************************************!
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ۣ<EFBFBD>QQȺ 123763203
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>www.navota.com
*
* @file ics.c
* @brief ʱ<EFBFBD><EFBFBD>ģ<EFBFBD>ICS)<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @author Navota
* @date 2017-1-1
****************************************************************/
#include "common.h"
#include "ics.h"
/* <20><>λ<EFBFBD><CEBB>ICS<43><53>OSCģ<43><C4A3><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ */
#define ICS_C1_DEFAULT 0x04
#define ICS_C2_DEFAULT 0x20
#define ICS_C3_DEFAULT 0x54
#define ICS_C4_DEFAULT 0x00
#define ICS_S_DEFAULT 0x50
#define OSC_CR_DEFAULT 0
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEIģʽ<EFBFBD>л<EFBFBD>ΪFEEģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>Ƶ
* OSCģ<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> pConfig ָ<EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*****************************************************************************/
void FEI_to_FEE(ICS_ConfigType *pConfig)
{
/*
* ʹ<EFBFBD><EFBFBD>OSCģ<EFBFBD><EFBFBD>
*/
OSC_Init(&pConfig->oscConfig); /*OSCģ<43><C4A3><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> */
/*
* <EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>ο<EFBFBD>ʱ<EFBFBD>ӽ<EFBFBD><EFBFBD>з<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><EFBFBD>ⲿʱ<EFBFBD>ӷ<EFBFBD>Ƶ<EFBFBD><EFBFBD>31.25k~39.0625<EFBFBD><EFBFBD>
*/
ICS_SetClkDivider(pConfig->u32ClkFreq);
/*<2A><>FLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>Ϊ<EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
ICS->C1 = ICS->C1 & ~ICS_C1_IREFS_MASK;
/*<2A>ȴ<EFBFBD>FLL<4C>ο<EFBFBD>ʱ<EFBFBD>ӱ<EFBFBD>Ϊ<EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(ICS->S & ICS_S_IREFST_MASK);
/* <20>ȴ<EFBFBD>FLLʱ<4C>ӳ<EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
while(!(ICS->S & ICS_S_LOCK_MASK));
/*
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ӱ<EFBFBD>ʱ<EFBFBD><EFBFBD>Ƶ<EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>FLL<EFBFBD>ο<EFBFBD>ʱ<EFBFBD>ӷ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLL<EFBFBD>ı<EFBFBD>Ƶϵ<EFBFBD><EFBFBD>
* FLL<EFBFBD>ı<EFBFBD>Ƶϵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD>ο<EFBFBD><EFBFBD>ֲ<EFBFBD>
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>1<EFBFBD><31>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) == 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*
* <EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>ϵͳ/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ʱƵ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>Ŀ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>
*/
/*LOLS<4C><53>0*/
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEIģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBIģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>Ƶ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FEI_to_FBI(ICS_ConfigType *pConfig)
{
/*ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դѡ<D4B4><D1A1><EFBFBD>ڲ<EFBFBD><DAB2>ο<EFBFBD>ʱ<EFBFBD><CAB1>*/
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK)) | ICS_C1_CLKS(1);
ICS->C2 = ICS->C2 & ~(ICS_C2_LP_MASK);
/*<2A>ȴ<EFBFBD><C8B4>ڲ<EFBFBD>ʱ<EFBFBD>ӳ<EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(((ICS->S & ICS_S_CLKST_MASK) >> ICS_S_CLKST_SHIFT) !=1);
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ο<EFBFBD>ʱ<EFBFBD><EFBFBD>ΪICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
*/
#if defined(BUS_CLK_EQU_CORE_DIVIDE_BY_2)||defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK));
#endif
/*LOLS<4C><53><EFBFBD><EFBFBD>*/
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEIģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBEģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>Ƶ
* OSCģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD> .
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FEI_to_FBE(ICS_ConfigType *pConfig)
{
OSC_Init(&pConfig->oscConfig); /*<2A><>ʼ<EFBFBD><CABC>OSC ģ<><C4A3> */
/*<2A><><EFBFBD><EFBFBD>FLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>Ϊ<EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
ICS->C1 = ICS->C1 & ~(ICS_C1_IREFS_MASK);
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK)) | ICS_C1_CLKS(2);
ICS->C2 = ICS->C2 & ~(ICS_C2_LP_MASK);
/*<2A><><EFBFBD>ڲο<DAB2>ʱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(((ICS->S & ICS_S_CLKST_MASK) >> ICS_S_CLKST_SHIFT) !=2); /*<2A>ⲿʱ<E2B2BF>ӳ<EFBFBD>ΪICSʱ<53><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ*/
while(ICS->S & ICS_S_IREFST_MASK); /*FLL<4C>ο<EFBFBD>ʱ<EFBFBD>ӳ<EFBFBD>Ϊ<EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿʱ<EFBFBD>ӳ<EFBFBD>ΪICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>Ϊѡ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>Ƶ
*/
/* LOLS<4C><53><EFBFBD><EFBFBD> */
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEIģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBEģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>Ƶ
* OSC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>EXTAL<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD>ⲿʱ<EFBFBD><EFBFBD>Դ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FEI_to_FBE_OSC(ICS_ConfigType *pConfig)
{
OSC_Init(&pConfig->oscConfig); /* <20><>ʼ<EFBFBD><CABC>OSC */
/*
* <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>FLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>31.25k~39.0625k<EFBFBD><EFBFBD>Χ<EFBFBD>ڣ<EFBFBD>
*/
ICS_SetClkDivider(pConfig->u32ClkFreq);
/*<2A>ı<EFBFBD><C4B1>ο<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>FLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
ICS->C1 = ICS->C1 & ~(ICS_C1_IREFS_MASK);/*<2A><>FLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK)) | ICS_C1_CLKS(2); /*<2A><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դѡ<D4B4><D1A1><EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
ICS->C2 = ICS->C2 & ~(ICS_C2_LP_MASK);
/* <20>ȴ<EFBFBD><C8B4>ο<EFBFBD>ʱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(((ICS->S & ICS_S_CLKST_MASK) >> ICS_S_CLKST_SHIFT) !=2);/*<2A>ⲿʱ<E2B2BF>ӳ<EFBFBD>ΪICSʱ<53><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
while(ICS->S & ICS_S_IREFST_MASK); /*<2A>ⲿʱ<E2B2BF>ӳ<EFBFBD>ΪFLL<4C>ο<EFBFBD>ʱ<EFBFBD><CAB1>*/
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿʱ<EFBFBD>ӳ<EFBFBD>ΪFLL<EFBFBD>ο<EFBFBD>ʱ<EFBFBD>Ӻ<EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ƶ<EFBFBD>ʣ<EFBFBD>Ϊ<EFBFBD>ⲿ<EFBFBD>ο<EFBFBD>ʱ<EFBFBD>ӵ<EFBFBD>2<EFBFBD><EFBFBD>Ƶ
*/
/*LOLS <20><><EFBFBD><EFBFBD>*/
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEIģʽת<EFBFBD><EFBFBD>FEEģʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>Ƶ
* OSC<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>EXTAL<EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD><EFBFBD>ⲿʱ<EFBFBD><EFBFBD>Դ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FEI_to_FEE_OSC(ICS_ConfigType *pConfig)
{
OSC_Init(&pConfig->oscConfig); /* <20><>ʼ<EFBFBD><CABC>OSC */
/*
* <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>FLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>31.25k~39.0625k<EFBFBD><EFBFBD>Χ<EFBFBD><EFBFBD>
*/
ICS_SetClkDivider(pConfig->u32ClkFreq);
/* <20><>FLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ⲿʱ<E2B2BF><CAB1> */
ICS->C1 = ICS->C1 & ~(ICS_C1_IREFS_MASK);
/*<2A>ȴ<EFBFBD><C8B4>ο<EFBFBD>ʱ<EFBFBD>ӱ仯*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(ICS->S & ICS_S_IREFST_MASK); /*FLL<4C>ο<EFBFBD>ʱ<EFBFBD>ӱ<EFBFBD>Ϊ<EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
/*<2A>ȴ<EFBFBD>FLL<4C><4C>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ */
while(!(ICS->S & ICS_S_LOCK_MASK));
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Ƶ<EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD>ΪҪ<EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>Ŀ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>
*/
/* LOLS<4C><53><EFBFBD><EFBFBD> */
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEEģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FEIģʽ.
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FEE_to_FEI(ICS_ConfigType *pConfig)
{
/*ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>*/
ICS->C1 = ICS->C1 | (ICS_C1_IREFS_MASK);
/*<2A>ȴ<EFBFBD><C8B4>ο<EFBFBD>ʱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(!(ICS->S & ICS_S_IREFST_MASK)); /*FLL<4C>ο<EFBFBD>ʱ<EFBFBD>ӳ<EFBFBD>Ϊ<EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1>*/
/*FLLʱ<4C>ӳ<EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ */
while(!(ICS->S & ICS_S_LOCK_MASK));
/*LOLS<4C><53><EFBFBD><EFBFBD>*/
ICS->S |= ICS_S_LOLS_MASK;
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ/<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>Ӵ<EFBFBD>ԼΪ 16MHz
*/
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
OSC_Disable(); /* <20><><EFBFBD><EFBFBD> OSCģ<43><C4A3> */
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEEģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBIģʽ.
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FEE_to_FBI(ICS_ConfigType *pConfig)
{
/*LOLS<4C><53><EFBFBD><EFBFBD>*/
ICS->S |= ICS_S_LOLS_MASK;
/* ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ */
/* ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ΪFLL<4C>ο<EFBFBD>ʱ<EFBFBD><CAB1> */
/* LP = 0 <20><>bypassģʽFLL<4C><4C><EFBFBD><EFBFBD><E1B1BB>ֹ*/
ICS->C1 = ICS->C1 | (ICS_C1_IREFS_MASK);
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK)) | ICS_C1_CLKS(1);
ICS->C2 = ICS->C2 & ~(ICS_C2_LP_MASK);
/* <20>ȴ<EFBFBD><C8B4>ο<EFBFBD>ʱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD>ı<EFBFBD> */
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(!(ICS->S & ICS_S_IREFST_MASK)); /*FLL<4C>ο<EFBFBD>ʱ<EFBFBD>ӳ<EFBFBD>Ϊ<EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1>*/
while(((ICS->S & ICS_S_CLKST_MASK) >> ICS_S_CLKST_SHIFT) !=1); /*<2A>ڲ<EFBFBD>ʱ<EFBFBD><CAB1>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
#if defined(BUS_CLK_EQU_CORE_DIVIDE_BY_2)||defined(CPU_NV32)
/*<2A><><EFBFBD><EFBFBD>ѡ<EFBFBD>е<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK));
#endif
OSC_Disable();
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FEEģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBEģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FEE_to_FBE(ICS_ConfigType *pConfig)
{
/*LOLS<4C><53><EFBFBD><EFBFBD>*/
ICS->S |= ICS_S_LOLS_MASK;
/* LP = 0 */
/*ѡ<><D1A1><EFBFBD>ⲿʱ<E2B2BF><CAB1><EFBFBD><EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
/* LP = 0 <20><>bypassģʽFLL<4C><4C><EFBFBD><EFBFBD><E1B1BB>ֹ*/
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK)) | ICS_C1_CLKS(2);
ICS->C2 = ICS->C2 & ~(ICS_C2_LP_MASK);
/*<2A>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(((ICS->S & ICS_S_CLKST_MASK) >> ICS_S_CLKST_SHIFT) !=2);
/* <20><><EFBFBD><EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դѡ<D4B4><D1A1><EFBFBD>ⲿʱ<E2B2BF><CAB1>Դ
* ע<EFBFBD><EFBFBD>: ȷ<EFBFBD><EFBFBD><EFBFBD>ⲿʱ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>20MHz<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBIģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBEģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBI_to_FBE(ICS_ConfigType *pConfig)
{
OSC_Init(&pConfig->oscConfig); /*<2A><>ʼ<EFBFBD><CABC>OSC*/
/* ѡ<><D1A1><EFBFBD>ⲿʱ<E2B2BF><CAB1><EFBFBD><EFBFBD>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1> */
/*ѡ<><D1A1><EFBFBD>ⲿʱ<E2B2BF><CAB1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
ICS->C1 = ICS->C1 & ~(ICS_C1_IREFS_MASK);
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK)) | ICS_C1_CLKS(2);
/* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD> */
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(((ICS->S & ICS_S_CLKST_MASK) >> ICS_S_CLKST_SHIFT) !=2); /*<2A>ⲿʱ<E2B2BF>ӳ<EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
while((ICS->S & ICS_S_IREFST_MASK));/*<2A>ⲿʱ<E2B2BF>ӳ<EFBFBD>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>*/
/* <20><><EFBFBD><EFBFBD>ϵͳʱ<CDB3><CAB1>Դ<EFBFBD><D4B4><EFBFBD>ⲿ<EFBFBD>ο<EFBFBD>ʱ<EFBFBD><CAB1>
* ע<EFBFBD><EFBFBD>:ȷ<EFBFBD><EFBFBD><EFBFBD>ⲿʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>20MHz<EFBFBD><EFBFBD>
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
}
/*****************************************************************************//**
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBIģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FEEģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBI_to_FEE(ICS_ConfigType *pConfig)
{
OSC_Init(&pConfig->oscConfig); /*<2A><>ʼ<EFBFBD><CABC>OSC*/
/* ѡ<><D1A1><EFBFBD>ⲿʱ<E2B2BF><CAB1><EFBFBD><EFBFBD>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1> */
/* ѡ<><D1A1>FLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
ICS->C1 = ICS->C1 & ~(ICS_C1_IREFS_MASK);
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK));
/*<2A>ȴ<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while((ICS->S & ICS_S_CLKST_MASK)); /*FLLʱ<4C>ӳ<EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
while((ICS->S & ICS_S_IREFST_MASK)); /*<2A>ⲿʱ<E2B2BF>ӳ<EFBFBD>ΪFLL<4C>ο<EFBFBD>ʱ<EFBFBD><CAB1>*/
/* <20><><EFBFBD><EFBFBD>ϵͳʱ<CDB3><CAB1>ԴΪ<D4B4>ⲿʱ<E2B2BF><CAB1>
* ע<EFBFBD><EFBFBD>: ȷ<EFBFBD><EFBFBD><EFBFBD>ⲿʱ<EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>20MHz<EFBFBD><EFBFBD>
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*LOLS<4C><53><EFBFBD><EFBFBD>*/
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBIģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBIPģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig <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> ICS_ConfigType
*****************************************************************************/
void FBI_to_FBILP(ICS_ConfigType *pConfig)
{
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ8MHz<EFBFBD><EFBFBD><EFBFBD><EFBFBD>4MHz
*/
ICS->C2 |= ICS_C2_LP_MASK; /*<2A><><EFBFBD><EFBFBD><EFBFBD>͹<EFBFBD><CDB9><EFBFBD>ģʽ */
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBIģʽת<EFBFBD><EFBFBD>ΪFEIģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBI_to_FEI(ICS_ConfigType *pConfig)
{
/* ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1> */
/*ѡ<><D1A1>FLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
ICS->C1 = ICS->C1 | (ICS_C1_IREFS_MASK);
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK));
/*<2A>ȴ<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while((ICS->S & ICS_S_CLKST_MASK)); /*FLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
while(!(ICS->S & ICS_S_IREFST_MASK)); /*FLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>Ϊ<EFBFBD>ⲿʱ<E2B2BF><CAB1>*/
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ԴΪFLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*LOLS<4C><53><EFBFBD><EFBFBD> */
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBEģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBIģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBE_to_FBI(ICS_ConfigType *pConfig)
{
/*ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>*/
/*ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
ICS->C1 = ICS->C1 | (ICS_C1_IREFS_MASK);
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK)) | ICS_C1_CLKS(1);
/*<2A>ȴ<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(((ICS->S & ICS_S_CLKST_MASK) >> ICS_S_CLKST_SHIFT) != 1);/*<2A>ڲ<EFBFBD>ʱ<EFBFBD>ӳ<EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
while(!(ICS->S & ICS_S_IREFST_MASK)); /*<2A>ڲ<EFBFBD>ʱ<EFBFBD>ӳ<EFBFBD>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>*/
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ԴΪ<EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><EFBFBD>
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>OSCģ<EFBFBD><EFBFBD>
*/
OSC_Disable();
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBEģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FEEģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBE_to_FEE(ICS_ConfigType *pConfig)
{
/*ѡ<><D1A1>FLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK));
/*<2A>ȴ<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while(ICS->S & ICS_S_CLKST_MASK);
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ԴΪFLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* ע<EFBFBD><EFBFBD>: <EFBFBD>ⲿʱ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD> <= 20MHz
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/* LOLS<4C><53><EFBFBD><EFBFBD> */
ICS->S |= ICS_S_LOLS_MASK;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBEģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FEIģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBE_to_FEI(ICS_ConfigType *pConfig)
{
/* ѡ<><D1A1><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ΪFLL<4C>IJο<C4B2>ʱ<EFBFBD><CAB1>*/
/*ѡ<><D1A1>FLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
ICS->C1 = ICS->C1 | (ICS_C1_IREFS_MASK);
ICS->C1 = (ICS->C1 & ~(ICS_C1_CLKS_MASK));
/*<2A>ȴ<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD>ı<EFBFBD>*/
#if defined(IAR)
asm(
"nop \n"
"nop \n"
);
#elif defined(__MWERKS__)
asm{
nop
nop
};
#endif
while((ICS->S & ICS_S_CLKST_MASK)); /*FLL<4C><4C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪICS<43><53><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
while(!(ICS->S & ICS_S_IREFST_MASK)); /*<2A>ڲ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>г<EFBFBD>ΪFLL<4C>ο<EFBFBD>ʱ<EFBFBD><CAB1>*/
/*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪICS<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>Դ
*/
#if defined(CPU_NV32)
/*<2A><>ѡ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1>Դ<EFBFBD><D4B4>2<EFBFBD><32>Ƶ*/
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) != 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(1);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
/*LOLS<4C><53><EFBFBD><EFBFBD>*/
ICS->S |= ICS_S_LOLS_MASK;
/*
*<EFBFBD><EFBFBD><EFBFBD><EFBFBD>OSCģ<EFBFBD><EFBFBD>
*/
OSC_Disable();
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBEģʽת<EFBFBD><EFBFBD>ΪFBELPģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBE_to_FBELP(ICS_ConfigType *pConfig)
{
/* enter low power mode */
/*<2A><><EFBFBD><EFBFBD><EFBFBD>͹<EFBFBD><CDB9><EFBFBD>ģʽ*/
ICS->C2 = ICS->C2 | (ICS_C2_LP_MASK);
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBELPģʽת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBEģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBELP_to_FBE(ICS_ConfigType *pConfig)
{
/* enter low power mode */
/*<2A><><EFBFBD>õ͹<C3B5><CDB9><EFBFBD>ģʽ*/
ICS->C2 = ICS->C2 & ~(ICS_C2_LP_MASK);
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICS<EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD>ɵ<EFBFBD>ǰ<EFBFBD><EFBFBD>FBILPת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>FBIģʽ
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void FBILP_to_FBI(ICS_ConfigType *pConfig)
{
/* enter low power mode */
/*<2A><><EFBFBD>õ͹<C3B5><CDB9><EFBFBD>ģʽ*/
ICS->C2 = ICS->C2 & ~(ICS_C2_LP_MASK);
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ڲ<EFBFBD>ʱ<EFBFBD><EFBFBD> (IRC).
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> u16TrimValue <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*****************************************************************************/
void ICS_Trim(uint16_t u16TrimValue)
{
ICS->C3 = (uint8_t) u16TrimValue; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵд<D6B5><D0B4><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>*/
ICS->C4 = (ICS->C4 & ~(ICS_C4_SCFTRIM_MASK)) | ((u16TrimValue>>8) & 0x01);
while(!(ICS->S & ICS_S_LOCK_MASK));
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD>ο<EFBFBD>ʱ<EFBFBD>ӽ<EFBFBD><EFBFBD>з<EFBFBD>Ƶ<EFBFBD><EFBFBD>ʹ<EFBFBD>÷<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FLL<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>31.25k~39.0625k<EFBFBD><EFBFBD>
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> u32ClkFreqKHz <EFBFBD>ο<EFBFBD>ʱ<EFBFBD><EFBFBD>Ƶ<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*****************************************************************************/
void ICS_SetClkDivider(uint32_t u32ClkFreqKHz)
{
switch(u32ClkFreqKHz)
{
case 8000L:
case 10000L:
/* 8MHz or 10MHz*/
ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(3);
/*8MHz<48><7A>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 8000/256 = 31.25K */
/*10MHz<48><7A>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 8000/256 = 31.25K*/
break;
case 4000L:
/* 4MHz */
ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(2);
/*4MHz<48><7A>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 4000/128 = 31.25K*/
break;
case 12000L:
/* 12MHz */
ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(3);
/*12MHz<48><7A>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>12000/512 = 23.43K*/
break;
case 16000L:
/* 16MHz */
ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(4);
/* 16MHz<48><7A>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 16000/512 = 31.25K */
break;
case 20000L:
/* 20MHz */
ICS->C1 = (ICS->C1 & ~(ICS_C1_RDIV_MASK)) | ICS_C1_RDIV(4);
/*20MHz<48><7A>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 20000/512 = 39.0625K */
break;
case 32L:
/* 32KHz */
ICS->C1 &= ~(ICS_C1_RDIV_MASK);
break;
default:
break;
}
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ICSģ<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> pConfig ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>.
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @ <EFBFBD>ο<EFBFBD> ICS_ConfigType
*****************************************************************************/
void ICS_Init(ICS_ConfigType *pConfig)
{
if(pConfig->u8ClkMode == ICS_CLK_MODE_FEE)
{
pConfig->oscConfig.bIsCryst = 1; /* OSC<53><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ */
pConfig->oscConfig.bWaitInit = 1; /* <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
/*ѡ<><D1A1>FEEģʽ<C4A3><CABD>OSC<53><43><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
FEI_to_FEE(pConfig);
}
else if (pConfig->u8ClkMode == ICS_CLK_MODE_FEE_OSC)
{
pConfig->oscConfig.bIsCryst = 0; /*OSC<53><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>EEXTAL<41><4C><EFBFBD>ŵ<EFBFBD><C5B5>ⲿʱ<E2B2BF><CAB1>Դ*/
/*ѡ<><D1A1>FEE<45><45><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>OSC<53><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>EEXTAL<41><4C><EFBFBD>ŵ<EFBFBD><C5B5>ⲿʱ<E2B2BF><CAB1>Դ*/
FEI_to_FEE_OSC(pConfig);
}
else if (pConfig->u8ClkMode == ICS_CLK_MODE_FBE_OSC)
{
pConfig->oscConfig.bIsCryst = 0; /* is clock<63><6B>OSC<53><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>EXTAL<41><4C><EFBFBD>ŵ<EFBFBD><C5B5>ⲿʱ<E2B2BF><CAB1>Դ */
/* ѡ<><D1A1>FBE<42><45><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>OSC<53><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>EXTAL<41><4C><EFBFBD>ŵ<EFBFBD><C5B5>ⲿʱ<E2B2BF><CAB1>Դ*/
FEI_to_FBE_OSC(pConfig);
}
else if(pConfig->u8ClkMode == ICS_CLK_MODE_FBELP )
{
pConfig->oscConfig.bIsCryst = 1; /* OSC<53><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ */
pConfig->oscConfig.bWaitInit = 1; /*<2A>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
/* ѡ<><D1A1>FBEģʽ<C4A3><CABD>OSC<53><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Դ*/
FEI_to_FBE(pConfig); /*<2A><>ѡ<EFBFBD><D1A1>PBEģʽ*/
FBE_to_FBELP(pConfig); /*ѡ<><D1A1>FBELP*/
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
}
else if(pConfig->u8ClkMode == ICS_CLK_MODE_FBILP )
{
/* OSC<53><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>EXTAL<41><4C><EFBFBD>ŵ<EFBFBD><C5B5>ⲿʱ<E2B2BF><CAB1>Դ*/
pConfig->oscConfig.bIsCryst = 0;
/* ѡ<><D1A1>FBEģʽ<C4A3><CABD>OSC<53><43><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ѡ<EFBFBD><D1A1>EXTAL<41><4C><EFBFBD>ŵ<EFBFBD><C5B5>ⲿʱ<E2B2BF><CAB1>Դ*/
FEI_to_FBI(pConfig);
FBI_to_FBILP(pConfig);
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
}
else
{
/*ICSĬ<53>Ϲ<EFBFBD><CFB9><EFBFBD>ģʽFEIģʽ*/
#if defined(CPU_NV32)
if(((ICS->C2 & ICS_C2_BDIV_MASK)>>5) == 1)
{
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
}
#else
ICS->C2 = (ICS->C2 & ~(ICS_C2_BDIV_MASK)) | ICS_C2_BDIV(0);
#endif
}
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD>ICSģ<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> ICS_Init
*****************************************************************************/
void ICS_DeInit(void)
{
ICS->C1 = ICS_C1_DEFAULT;
ICS->C2 = ICS_C2_DEFAULT;
ICS->C3 = ICS_C3_DEFAULT;
ICS->C4 = ICS_C4_DEFAULT;
while(ICS->S != ICS_S_DEFAULT)
;
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>XOSC
*
* @ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> pConfig ָ<EFBFBD><EFBFBD>osc<EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD>
*
* @ <EFBFBD>޷<EFBFBD><EFBFBD><EFBFBD>
*
* @ <EFBFBD>ɹ<EFBFBD>/ʧ<EFBFBD>ܵı<EFBFBD>׼ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*****************************************************************************/
void OSC_Init(OSC_ConfigType *pConfig)
{
uint8 cr = 0;
/*
*
*/
if(pConfig->bGain) /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>*/
{
/* high gain<69><6E>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
cr |= OSC_CR_HGO_MASK ;
}
if(pConfig->bRange) /*Ƶ<>ʷ<EFBFBD>Χ<EFBFBD><CEA7>ѡ<EFBFBD><D1A1>*/
{
cr |= OSC_CR_RANGE_MASK; /*ѡ<><D1A1><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>Χ */
}
if(pConfig->bStopEnable) /*ֹͣģʽ<C4A3>µ<EFBFBD>OSCʹ<43><CAB9>*/
{
cr |= OSC_CR_OSCSTEN_MASK; /*OSC<53><43>ֹͣģʽ<C4A3>±<EFBFBD><C2B1><EFBFBD>ʹ<EFBFBD><CAB9>*/
}
if(pConfig->bIsCryst) /*OSC<53><43><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>*/
{
cr |= OSC_CR_OSCOS_MASK; /*ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>*/
}
if(pConfig->bEnable) /*OSCʹ<43><CAB9>*/
{
cr |= OSC_CR_OSCEN_MASK;
}
OSC->CR = cr; /*<2A><>ֵд<D6B5><D0B4><EFBFBD><EFBFBD><EFBFBD>ƼĴ<C6BC><C4B4><EFBFBD>*/
if(pConfig->bWaitInit)
{
/*
*<EFBFBD>ȴ<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
while(!(OSC->CR & OSC_CR_OSCINIT_MASK));
}
}
/*****************************************************************************//*!
*
* @ <EFBFBD><EFBFBD>Ҫ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>OSCģ<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> ICS_Init
*****************************************************************************/
void OSC_DeInit(void)
{
OSC->CR = OSC_CR_DEFAULT;
}