RCC_MSIRangeConfig(RCC_MSIRange_6);
RCC_HSEConfig(RCC_HSE_OFF);
if(RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET )
{ while(1); }
/* Enable comparator clock LCD and PWR mngt */
//RCC_APB1PeriphClockCmd(RCC_APB1Periph_LCD | RCC_APB1Periph_PWR, ENABLE);
/* Enable ADC clock & SYSCFG */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_SYSCFG |
RCC_APB2Periph_USART1 , ENABLE);
}
void Init_GPIOs (void)
{ GPIO_InitTypeDef GPIO_InitStructure;
/* Enable GPIOs clock */
RCC_AHBPeriphClockCmd(LD_GPIO_PORT_CLK|USERBUTTON_GPIO_CLK, ENABLE);
/* Configure User Button pin as input */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2;//USERBUTTON_GPIO_PIN
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_Init(USERBUTTON_GPIO_PORT, &GPIO_InitStructure);
/* Configure the GPIO_LED pins LD3 & LD4*/
GPIO_InitStructure.GPIO_Pin = LD_GREEN_GPIO_PIN | LD_BLUE_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(LD_GPIO_PORT, &GPIO_InitStructure);
//GPIO_LOW(LD_GPIO_PORT, LD_GREEN_GPIO_PIN);
//GPIO_LOW(LD_GPIO_PORT, LD_BLUE_GPIO_PIN);
/*Configure the USART1_GPIO_PORT */
/* Connect PA9 to USART1_Tx */
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);
/* Connect PA10 to USART1_Rx*/
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
/* Configure USART1_Tx and USART1_Rx as alternate function */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Enable all GPIOs clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB |
评论0
最新资源