源文件名: ch32v20x_rcc.c
/********************************************************************* ?*?@fn??????RCC_PCLK1Config ?* ?*?@brief???Configures?the?Low?Speed?APB?clock?(PCLK1). ?* ?*?@param???RCC_HCLK?-?defines?the?APB1?clock?divider.?This?clock?is?derived?from ?*????????the?AHB?clock?(HCLK). ?*????????????RCC_HCLK_Div1?-?APB1?clock?=?HCLK. ?*????????????RCC_HCLK_Div2?-?APB1?clock?=?HCLK/2. ?*????????????RCC_HCLK_Div4?-?APB1?clock?=?HCLK/4. ?*????????????RCC_HCLK_Div8?-?APB1?clock?=?HCLK/8. ?*????????????RCC_HCLK_Div16?-?APB1?clock?=?HCLK/16. ?* ?*?@return??none ?*/ void?RCC_PCLK1Config(uint32_t?RCC_HCLK) { ??uint32_t?tmpreg?=?0; ??tmpreg?=?RCC->CFGR0; ??tmpreg?&=?CFGR0_PPRE1_Reset_Mask; ??tmpreg?|=?RCC_HCLK; ??RCC->CFGR0?=?tmpreg; } /********************************************************************* ?*?@fn??????RCC_PCLK2Config ?* ?*?@brief???Configures?the?High?Speed?APB?clock?(PCLK2). ?* ?*?@param???RCC_HCLK?-?defines?the?APB2?clock?divider.?This?clock?is?derived?from ?*????????the?AHB?clock?(HCLK). ?*????????????RCC_PCLK2_Div2?-?APB2?clock?=?HCLK. ?*????????????RCC_PCLK2_Div4?-?APB2?clock?=?HCLK/2. ?*????????????RCC_PCLK2_Div6?-?APB2?clock?=?HCLK/4. ?*????????????RCC_PCLK2_Div8?-?APB2?clock?=?HCLK/8. ?* ?*?@return??none ?*/ void?RCC_PCLK2Config(uint32_t?RCC_HCLK) { ??uint32_t?tmpreg?=?0; ??tmpreg?=?RCC->CFGR0; ??tmpreg?&=?CFGR0_PPRE2_Reset_Mask; ??tmpreg?|=?RCC_HCLK?<<?3; ??RCC->CFGR0?=?tmpreg; }
結(jié)合數(shù)據(jù)手冊的說明:
RCC_PCLK2Config 函數(shù)的注釋里針對RCC_HCLK的描述不正確,
這里可選的枚舉值應(yīng)該是同上面RCC_PCLK1Config的一樣, RCC_HCLK_ 前綴的才是正確的, 但是注釋寫的卻是RCC_PCLK2_前綴的.
熱門產(chǎn)品 :
CH585: 集成高速USB和NFC的藍(lán)牙MCU