打印

如何生存 Led.c 和Led.h 文件

[复制链接]
272|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
社畜一枚|  楼主 | 2018-6-30 21:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
LED, pi, gp, GPIO, IO
int main(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOF,ENABLE); //使能GPIOB和GPIOF端口;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;         //GPIO设置为推挽模式
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;         //GPIO管脚的速度为50MHZ;
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;                                    //LED1 链接PB0
GPIO_Init(GPIOB,&GPIO_InitStruct);            //初始化GPIOB
GPIO_SetBits(GPIOB, GPIO_Pin_0);                                          //初始化状态的时候LED1是熄灭的
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;                                    //LED2 链接PF7管脚
GPIO_Init(GPIOF,&GPIO_InitStruct);            //初始化GPIOB
GPIO_SetBits(GPIOF, GPIO_Pin_7);                                          //初始化状态的时候LED2是熄灭的
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8;                                    //LED3 链接PF8管脚
GPIO_Init(GPIOF,&GPIO_InitStruct);            //初始化GPIOB
GPIO_SetBits(GPIOF, GPIO_Pin_8);                                          //初始化状态的时候LED2是熄灭的
   while(1)
{
  GPIO_ResetBits(GPIOB,GPIO_Pin_0);           //点亮LED1灯
  Delay(3000000);
     GPIO_ResetBits(GPIOF,GPIO_Pin_7);           //点亮LED2灯
  Delay(3000000);
  GPIO_ResetBits(GPIOF,GPIO_Pin_8);           //点亮LED3灯
  Delay(3000000);
  GPIO_SetBits(GPIOB, GPIO_Pin_0);                                          //熄灭LED1灯
  Delay(3000000);
  GPIO_SetBits(GPIOF, GPIO_Pin_7);                                          //熄灭LED2灯
  Delay(3000000);
  GPIO_SetBits(GPIOF, GPIO_Pin_8);                                          //熄灭LED3灯
  Delay(3000000);
}
   /* add your code here ^_^. */
}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

397

主题

401

帖子

0

粉丝