//配置时钟
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
//GPIO配置
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//main函数配置
void main(void)
{
u8 ReadValue;
RCC_Configuration();
FLASH_Configuration();
GPIO_Configuration();
while(1)
{
ReadValue = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_8);
if(0x00 == ReadValue)
{
delay_ms(10);
if (0x00 == ReadValue)
GPIO_SetBits(GPIOA,GPIO_Pin_15);
}
else
GPIO_ResetBits(GPIOA,GPIO_Pin_15);
}
} |