feat: 模块化开发c语言led
This commit is contained in:
11
Core/driver/led/CMakeLists.txt
Normal file
11
Core/driver/led/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
option(FEATURE_LED "Build LED Module" ON)
|
||||
if (FEATURE_LED)
|
||||
add_library(led_lib INTERFACE)
|
||||
|
||||
target_sources(led_lib PUBLIC led.c)
|
||||
target_include_directories(led_lib INTERFACE ./include)
|
||||
target_compile_definitions(led_lib INTERFACE FEATURE_LED)
|
||||
endif ()
|
||||
|
||||
|
||||
|
||||
14
Core/driver/led/include/led.h
Normal file
14
Core/driver/led/include/led.h
Normal file
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// Created by Wind on 2025/11/2.
|
||||
//
|
||||
|
||||
#ifndef CLION_STM32_LED_H
|
||||
#define CLION_STM32_LED_H
|
||||
|
||||
void led_on(void);
|
||||
|
||||
|
||||
|
||||
void led_off(void);
|
||||
|
||||
#endif //CLION_STM32_LED_H
|
||||
16
Core/driver/led/led.c
Normal file
16
Core/driver/led/led.c
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// Created by Wind on 2025/11/2.
|
||||
//
|
||||
|
||||
#include "led.h"
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
void led_on(void) {
|
||||
HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_SET);
|
||||
}
|
||||
|
||||
void led_off(void) {
|
||||
HAL_GPIO_WritePin(LED_GPIO_Port,LED_Pin,GPIO_PIN_RESET);
|
||||
}
|
||||
Reference in New Issue
Block a user