feat: 新增LED的CPP支持,优化LED的C模块结构,新增interface

This commit is contained in:
2025-11-10 00:19:57 +08:00
parent c6365a7548
commit a49d1df0d5
12 changed files with 317 additions and 103 deletions

View File

@@ -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

View 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