找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3041|回复: 0
收起左侧

STM32F10x系列GPIO初始化(LED灯闪烁)

[复制链接]
ID:366791 发表于 2018-11-9 19:59 | 显示全部楼层 |阅读模式
LED.C
#include "led.h"

#include "stm32f10x.h"
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOE,ENABLE);

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);

GPIO_SetBits(GPIOA,GPIO_Pin_8);

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOD,&GPIO_InitStructure);

GPIO_SetBits(GPIOD,GPIO_Pin_2);
}

LED.H

#ifndef __LED_H
#define __LED_H
void LED_Init(void);
#define LED0 PAout(8)// PB5
#define LED1 PDout(2)// PE5
#endif



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表