SystemInit()函數(shù)的結(jié)構(gòu)分析
總結(jié):開始是在keil4里看代碼,很混亂,后來把他粘到Notepad編輯器,一點(diǎn)擊就可以看出這個(gè)子函數(shù)到哪結(jié)束
本文引用地址:http://m.butianyuan.cn/article/201611/320445.htm[cpp]view plaincopy
- #ifdefined(STM32F10X_LD_VL)||(definedSTM32F10X_MD_VL)||(definedSTM32F10X_HD_VL)
- /*#defineSYSCLK_FREQ_HSEHSE_VALUE*/
- #defineSYSCLK_FREQ_24MHz24000000
- #else
- /*#defineSYSCLK_FREQ_HSEHSE_VALUE*/
- /*#defineSYSCLK_FREQ_24MHz24000000*/
- /*#defineSYSCLK_FREQ_36MHz36000000*/
- /*#defineSYSCLK_FREQ_48MHz48000000*/
- /*#defineSYSCLK_FREQ_56MHz56000000*/
- #defineSYSCLK_FREQ_72MHz72000000
- #endif
下面定義的SystemCoreClock 變量是為了方便取出幾種情況下系統(tǒng)時(shí)鐘的實(shí)際值,例SYSCLK_FREQ_24MHz 也就是24000000。
[cpp]view plaincopy
- #ifdefSYSCLK_FREQ_HSE
- uint32_tSystemCoreClock=SYSCLK_FREQ_HSE;/*!
equency(CoreClock)*/ - #elifdefinedSYSCLK_FREQ_24MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_24MHz;/*!
- #elifdefinedSYSCLK_FREQ_36MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_36MHz;/*!
- #elifdefinedSYSCLK_FREQ_48MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_48MHz;/*!
- #elifdefinedSYSCLK_FREQ_56MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_56MHz;/*!
- #elifdefinedSYSCLK_FREQ_72MHz
- uint32_tSystemCoreClock=SYSCLK_FREQ_72MHz;/*!
- #else/*!
- uint32_tSystemCoreClock=HSI_VALUE;/*!
- #endif
[cpp]view plaincopy
- staticvoidSetSysClock(void)
- {
- #ifdefSYSCLK_FREQ_HSE
- SetSysClockToHSE();
- #elifdefinedSYSCLK_FREQ_24MHz
- SetSysClockTo24();
- #elifdefinedSYSCLK_FREQ_36MHz
- SetSysClockTo36();
- #elifdefinedSYSCLK_FREQ_48MHz
- SetSysClockTo48();
- #elifdefinedSYSCLK_FREQ_56MHz
- SetSysClockTo56();
- #elifdefinedSYSCLK_FREQ_72MHz
- SetSysClockTo72();
- #endif
- /*Ifnoneofthedefineaboveisenabled,theHSIisusedasSystemclock
- source(defaultafterreset)*/
- }
[cpp]view plaincopy
- #ifdefSYSCLK_FREQ_HSE
- /**
- *@briefSelectsHSEasSystemclocksourceandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockToHSE(void)
- {
- ......
- }
[cpp]view plaincopy
- #elifdefinedSYSCLK_FREQ_24MHz
- /**
- *@briefSetsSystemclockfrequencyto24MHzandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockTo24(void)
- {
- ........
- }
[cpp]view plaincopy
- #elifdefinedSYSCLK_FREQ_36MHz
- /**
- *@briefSetsSystemclockfrequencyto36MHzandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockTo36(void)
- {
- ......
- }
[cpp]view plaincopy
- #elifdefinedSYSCLK_FREQ_72MHz
- /**
- *@briefSetsSystemclockfrequencyto72MHzandconfigureHCLK,PCLK2
- *andPCLK1prescalers.
- *@noteThisfunctionshouldbeusedonlyafterreset.
- *@paramNone
- *@retvalNone
- */
- staticvoidSetSysClockTo72(void)
- {
- .......
- }
評(píng)論