/******************************************************************************* * Function Name : main * Description : Main program * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) {
/* Wait till PLL is ready [等待PLL时钟就绪]*/ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { }
/* Select PLL as system clock source [选择PLL作为系统时钟]*/ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source[等待PLL被作为系统时钟] */ while(RCC_GetSYSCLKSource() != 0x08) { } } /* TIM2 clock enable [TIM2定时器允许]*/ RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
#ifdef VECT_TAB_RAM /* Set the Vector Table base location at 0x20000000 [设置中断向量表的起始位置0x20000000]*/ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0); #else /* VECT_TAB_FLASH */ /* Set the Vector Table base location at 0x08000000[设置中断向量表的起始位置0x0x08000000] */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); #endif
/* Configure the NVIC Preemption Priority Bits[配置优先级组] */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/******************************************************************************* * Function Name : delay * Description : 延时 * Input : None * Output : None * Return : None *******************************************************************************/ void delay(void) { u32 i,j; for (i=0; i<0x0fffff; i++) { j ++; } } #ifdef DEBUG /******************************************************************************* * Function Name : assert_failed[断言失败] * Description : Reports the name of the source file and the source line number * where the assert error has occurred. * Input : - file: pointer to the source file name * - line: assert error line source number * Output : None * Return : None *******************************************************************************/ void assert_failed(u8* file, u32 line) { /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d
", file, line) */