#ifndef __LED_H #define __LED_H #include // #define GPIOC_CRL *(volatile unsigned int *)(0x40011000 + 0x00) // #define GPIOC_ODR *(volatile unsigned int *)(0x40011000 + 0x0C) // 定义一个无符号类型的 4 字节整数的别名 uint32_t typedef unsigned int uint32_t; // 定义一个无符号类型的 2 字节整数的别名 uint16_t typedef unsigned short int uint16_t; typedef struct { uint32_t CRL; // offset 0x00 uint32_t CRH; // offset 0x04 uint32_t IDR; // offset 0x08 uint32_t ODR; // offset 0x0c uint32_t BSRR; // offset 0x10 uint32_t BRR; // offset 0x14 uint32_t LCKR; // offset 0x18 } GPIO_typedef; // 定义 GPIOC 的基地址是 0x40011000 #define GPIOC_base (0x40011000) // 定义一个 GPIO_typedef 类型指针 GPIOc 指向 0x40011000 #define GPIOc ((GPIO_typedef *)GPIOC_base) // 初始化 LED void led_init(void); // 让编号为 nu 的 LED 点亮, nu 为0,1,2 代表 LED0, LED1,LED2 void led_on(int nu); // 让编号为 nu 的 LED 熄灭 void led_off(int nu); // 获取编号为 nu 的 LED 的状态值 int led_get_status(int nu); // 设置编号为 nu 的 LED 的状态值 status, 0:熄灭, 1:点亮 void led_set_status(int nu, int status); #endif // __LED_H