接上一篇文章。继续void Set_System(void)的分析。
1.2 RCC_APB2PeriphClockCmd()
位于USB_Example\Libraries\STM32F30x_StdPeriph_Driver\src\stm32f30x_rcc.c文件中。其主要功能也是使能或禁止外设时钟,不过是APB2总线上的。
/**
* @brief Enables or disables the High Speed APB (APB2) peripheral clock.
* @note After reset, the peripheral clock (used for registers read/write access)
* is disabled and the application software has to enable this clock before
* using it.
* @param RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.
* This parameter can be any combination of the following values:
* @arg RCC_APB2Periph_SYSCFG
* @arg RCC_APB2Periph_SPI1
* @arg RCC_APB2Periph_USART1
* @arg RCC_APB2Periph_TIM15
* @arg RCC_APB2Periph_TIM16
* @arg RCC_APB2Periph_TIM17
* @arg RCC_APB2Periph_TIM1
* @arg RCC_APB2Periph_TIM8
* @param NewState: new state of the specified peripheral clock.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
assert_param(IS_FUNCTIONAL_STATE(NewState));
* @brief Enables or disables the High Speed APB (APB2) peripheral clock.
* @note After reset, the peripheral clock (used for registers read/write access)
* is disabled and the application software has to enable this clock before
* using it.
* @param RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.
* This parameter can be any combination of the following values:
* @arg RCC_APB2Periph_SYSCFG
* @arg RCC_APB2Periph_SPI1
* @arg RCC_APB2Periph_USART1
* @arg RCC_APB2Periph_TIM15
* @arg RCC_APB2Periph_TIM16
* @arg RCC_APB2Periph_TIM17
* @arg RCC_APB2Periph_TIM1
* @arg RCC_APB2Periph_TIM8
* @param NewState: new state of the specified peripheral clock.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
assert_param(IS_FUNCTIONAL_STATE(NewState));
if (NewState != DISABLE)
{
RCC->APB2ENR |= RCC_APB2Periph;
}
else
{
RCC->APB2ENR &= ~RCC_APB2Periph;
}
}
{
RCC->APB2ENR |= RCC_APB2Periph;
}
else
{
RCC->APB2ENR &= ~RCC_APB2Periph;
}
}
RCC、APB3ENR的说明见前一篇文章,在此不再赘述。
“1. Set_System()”中调用RCC_APB2PeriphClockCmd()时传入的第一个参数RCC_APB2Periph_SYSCFG在USB_Example\Libraries\STM32F30x_StdPeriph_Driver\inc\stm32f30x_rcc.h中定义:
#define RCC_APB2Periph_SYSCFG ((uint32_t)0x00000001)
对应手册P120中"Bit 0 SYSCFGEN: SYSCFG clock enable"。
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); --------> 1.2 所实现功能如其注释所述,使能系统配置控制器时钟。