原理图:
实现代码
light.h
#ifndef __LIGHT_H
#define __LIGHT_H
#include <sys.h>
#define LED1 PDout(0)
#define LED2 PDout(1)
#define LED3 PDout(3)
void LED_init(void);
#endif
light.c
#include "sys.h"
#include "light.h"
void LED_init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);//´ò¿ªÊ±ÖÓ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//Êä³ö¹¦ÄÜ
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//ÍÆÍìÊäÈë
GPIO_InitStructure.GPIO_S