main函数中
#include "led.h"
int main()
{
all_led_init();
while(1)
{
all_led_flash();
}
return 0;
}
自定义的led.h文件中
#ifndef __LED_H__
#define __LED_H__
//定义寄存器组织结构体
typedef struct{
unsigned int moder;
unsigned int otyper;
unsigned int ospeedr;
unsigned int pupdr;
unsigned int idr;
unsigned int odr;
}gpio_t;
//定义GPIOE和GPIOF
#define GPIOE ((gpio_t *)0X50006000)
#define GPIOF ((gpio_t *)0X50007000)
#define GPIOE_FAN ((gpio_t *)0X50006000) //风扇的结构体指针
#define GPIOB_SP1 ((gpio_t *)0x50003000) //蜂鸣器的结构体指针
#define RCC (*(volatile unsigned int *)0X50000A28)
void delay_ms(int ms);
void all_led_init();
void all_led_flash();
#endif
自定义的led.c文件中
#include"led.h"
//延时函数
void delay_ms(int ms)
{
int i,j;
for(i = 0; i < ms;i++)
for (j = 0; j < 1800; j++);
}
//led灯设置初始化
void all_led_init()
{
R