赞
踩
1.LED独立按键代码部分:
a:LED.c代码
#include "stm32f10x.h" // Device header
void LED_Init(void)//LED初始化函数
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_1|GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_1|GPIO_Pin_2);//此行代码是使默认变为高电平,灯不亮的情况
}
void LED1_ON(void)//打开LED1
{
GPIO_ResetBits(GPIOA,GPIO_Pin_1);
}
void LED1_OFF(void)//关闭LED1
{
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。