EVERYTHING FROM THE OTHER REPO
This commit is contained in:
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
#ifndef FAN_PWM_H
|
||||
#define FAN_PWM_H
|
||||
|
||||
/* Sets the pwm speed of the robots fan device */
|
||||
void set_fanPWM(int pwm);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef TROPOSHPERE_API_H
|
||||
#define TROPOSHPERE_API_H
|
||||
|
||||
typedef struct{
|
||||
|
||||
|
||||
void (*setFanSpeed)(int pwm);
|
||||
|
||||
|
||||
} Troposphere_API;
|
||||
|
||||
extern const Troposphere_API troposphere_api;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
CC = arm-none-linux-gnueabihf-gcc
|
||||
|
||||
# Compiler flags (-Iinclude tells it where your headers are)
|
||||
CFLAGS = -Wall -fPIC -O2 -mcpu=cortex-a15 -mfloat-abi=hard -mfpu=vfpv4 -Iinclude
|
||||
|
||||
# Directory configuration
|
||||
SRC_DIR = src
|
||||
BUILD_DIR = build
|
||||
|
||||
# Find all .c files in src/ and src/dev/
|
||||
SRCS = $(wildcard $(SRC_DIR)/*.c) $(wildcard $(SRC_DIR)/dev/*.c)
|
||||
|
||||
# Convert source file paths to build file paths
|
||||
# Example: src/dev/fan_pwm.c -> build/dev/fan_pwm.o
|
||||
OBJS = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRCS))
|
||||
|
||||
# The final library output location
|
||||
TARGET = $(BUILD_DIR)/libtroposphere.so
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
# Link the shared library from the object files inside the build directory
|
||||
$(TARGET): $(OBJS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) -shared -o $@ $(OBJS)
|
||||
@echo "Successfully built target: $@"
|
||||
|
||||
# Rule to compile .c files into .o files inside the build directory
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
@echo "Cleaning build directory..."
|
||||
rm -rf $(BUILD_DIR)
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "../../include/dev/fan_pwm.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#define FAN_DEVICE "/sys/devices/platform/pwm-fan.6/hwmon/hwmon5/pwm1"
|
||||
|
||||
|
||||
void set_fanPWM(int pwm){
|
||||
|
||||
if (pwm > 255) {
|
||||
pwm = 255;
|
||||
} else if (pwm < 100) {
|
||||
pwm = 100;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FILE *fan_file = fopen(FAN_DEVICE, "w");
|
||||
if (fan_file != NULL){
|
||||
|
||||
fprintf(fan_file, "%d", pwm);
|
||||
fclose(fan_file);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
#include "../include/dev/fan_pwm.h"
|
||||
#include "../include/troposphere_lib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
const Troposphere_API troposphere_api = {
|
||||
|
||||
.setFanSpeed = set_fanPWM,
|
||||
|
||||
|
||||
};
|
||||
Binary file not shown.
Reference in New Issue
Block a user