本次样例,是利用 Led 灯来作为红外对管的显示,串口打印作为协助
stm32F407开发板上有两个led灯,DS0和DS1
所以需要编写的代码涉及:led.h、led.c、hong.c、hong.h、main.c (串口代码已集成)
直接上代码:
led.h
#ifndef __LED_H
#define __LED_H
void LED_Init();
#endif
hong.h
#ifndef __HONG_H
#define __HONG_H
void Hong_Init();
#endif
led.c
#include "stm32f4xx.h"
#include "led.h"
void LED_Init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOF,&GPIO_InitStructure);
GPIO_SetBits