feat: 新增LED的CPP支持,优化LED的C模块结构,新增interface
This commit is contained in:
@@ -5,10 +5,28 @@
|
||||
#ifndef CLION_STM32_LED_H
|
||||
#define CLION_STM32_LED_H
|
||||
|
||||
void led_on(void);
|
||||
|
||||
#include "main.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
|
||||
|
||||
void led_off(void);
|
||||
#endif
|
||||
typedef struct {
|
||||
GPIO_TypeDef *port;
|
||||
uint16_t pin;
|
||||
} led_t;
|
||||
|
||||
void led_init(const led_t *led);
|
||||
|
||||
void led_on(const led_t *led);
|
||||
|
||||
void led_off(const led_t *led);
|
||||
|
||||
void led_toggle(const led_t *led);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //CLION_STM32_LED_H
|
||||
|
||||
29
Core/driver/led/include/led_cpp.h
Normal file
29
Core/driver/led/include/led_cpp.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by Wind on 2025/11/9.
|
||||
//
|
||||
|
||||
#ifndef CLION_STM32_LED_CPP_H
|
||||
#define CLION_STM32_LED_CPP_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "gpio_base.hpp"
|
||||
|
||||
class LED : public Gpio {
|
||||
public:
|
||||
LED(GPIO_TypeDef *port, uint16_t pin);
|
||||
|
||||
~LED();
|
||||
|
||||
void ledOn() const;
|
||||
|
||||
void ledOff() const;
|
||||
|
||||
void ledToggle() const;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif //CLION_STM32_LED_CPP_H
|
||||
Reference in New Issue
Block a user