小学生
最后登录1970-1-1
在线时间 小时
注册时间2015-4-12
|
#include "stm32f10x.h"
//#include "bsp_led.h"
//#include "bsp_key.h"
void RCC_Configuration(void);
void GPIO_Configuration(void);
//u32 count;
void delay(u32 count);
int main(void)
{
RCC_Configuration();
GPIO_Configuration();
while(1)
{
if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_13)==0)
{
GPIO_SetBits(GPIOB,GPIO_Pin_0);
// delay(6000000);
}
else
{
GPIO_ResetBits(GPIOB,GPIO_Pin_0);
//delay(6000000);
}
}
}
/*********************************************END OF FILE**********************/
void RCC_Configuration(void)
{
//RCC_DeInit();
// RCC_HSEConfig(RCC_HSE_ON);//êÇÄüía2¿μĸßËùê±Öó
// while(RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET);//μè′yía2¿¸ßËùê±Öóê1Äü¾íD÷
//FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);//ê1ÄüPrefetchBuffer
//FLASH_SetLatency(FLASH_Latency_2);//Flash 2 wait state
// RCC_HCLKConfig(RCC_SYSCLK_Div1); //HCLK = SYSCLK2»·ÖÆμ
// RCC_PCLK2Config(RCC_SYSCLK_Div1);//HCLK2 = HCLK
// RCC_PCLK1Config(RCC_SYSCLK_Div2);//HCLK1 = HCLK/2
//RCC_PLLConfig(RCC_PLLSource_HSE_Div1,RCC_PLLMul_9);//PLLCLK = 8MHz*9 = 72MHz
//RCC_PLLCmd(ENABLE);//ê1ÄüPLLCLK
//while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);//Wait till PLLCLK is ready
//RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);//Select PLL as system clock
//while(RCC_GetSYSCLKSource() != 0x08); //Wait till PLL is used as system clock source
//′ò¿aÏàó|íaéèê±Öó
SystemInit();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB ,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC ,ENABLE);
}
void GPIO_Configuration(void)
{
//LED
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB,&GPIO_InitStructure);
//anjian
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOC,&GPIO_InitStructure);
}
void delay(u32 count)
{
for(;count!=0;count--);
}
|
|