You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
741 B
36 lines
741 B
2 years ago
|
#ifndef __LED_H
|
||
|
#define __LED_H
|
||
|
|
||
|
#include "stdint.h"
|
||
|
#include "main.h"
|
||
|
#define LED_MAX_NUM 4
|
||
|
|
||
|
// 回调需要这个参数,控制时开关还是闪烁,闪烁快慢
|
||
|
enum led_state{
|
||
|
LED_STATE_ON,
|
||
|
LED_STATE_FLICKER_SLOW,
|
||
|
LED_STATE_FLICKER_MEDIUM,
|
||
|
LED_STATE_FLICKER_QUICK,
|
||
|
LED_STATE_OFF
|
||
|
|
||
|
};
|
||
|
|
||
|
// 标准库的 GPIO_TypeDef, 改为HAL库
|
||
|
struct led
|
||
|
{
|
||
|
enum led_state state;
|
||
|
GPIO_TypeDef *gpio;
|
||
|
uint16_t pin;
|
||
|
uint16_t level_on;
|
||
|
};
|
||
|
|
||
|
// 依据GPIO 信息注册
|
||
|
int led_register(struct led *led, GPIO_TypeDef *gpio, uint16_t pin, enum led_state state, uint16_t level_on );
|
||
|
|
||
|
// 初始化状态
|
||
|
int led_set_state(struct led *led,enum led_state state);
|
||
|
|
||
|
// 执行 -- 由状态决定
|
||
|
void led_callback(void);
|
||
|
#endif
|