ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
gpio.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (c) 2026 ForestHub. All rights reserved.
3// For commercial licensing, visit https://github.com/ForestHubAI/fh-sdk
4
5#ifndef FORESTHUB_PLATFORM_GPIO_HPP
6#define FORESTHUB_PLATFORM_GPIO_HPP
7
10
11#include <cstdint>
12#include <string>
13
14namespace foresthub {
15namespace platform {
16
21using PinId = uint32_t;
22
27enum class PinMode : uint8_t {
28 kInput = 0,
29 kOutput = 1,
31};
32
34struct PwmConfig {
35 uint32_t frequency_hz = 1000;
36 uint8_t resolution_bits = 8;
37};
38
45public:
46 virtual ~GpioInterface() = default;
47
51 virtual void SetPinMode(PinId pin, PinMode mode) = 0;
52
56 virtual void DigitalWrite(PinId pin, int value) = 0;
57
61 virtual int DigitalRead(PinId pin) const = 0;
62
66 virtual int AnalogRead(PinId pin) const = 0;
67
72 virtual std::string ConfigurePwm(PinId pin, const PwmConfig& config) = 0;
73
77 virtual void PwmWrite(PinId pin, int duty) = 0;
78};
79
80} // namespace platform
81} // namespace foresthub
82
83#endif // FORESTHUB_PLATFORM_GPIO_HPP
Abstract interface for general-purpose pin I/O.
Definition gpio.hpp:44
virtual int AnalogRead(PinId pin) const =0
Read the raw ADC value from an analog input pin.
virtual int DigitalRead(PinId pin) const =0
Read the current logic level of a digital input pin.
virtual void SetPinMode(PinId pin, PinMode mode)=0
Configure a pin's direction and pull mode.
virtual void DigitalWrite(PinId pin, int value)=0
Set a digital output pin to the given logic level.
virtual std::string ConfigurePwm(PinId pin, const PwmConfig &config)=0
Attach and configure a PWM peripheral on the given pin.
virtual void PwmWrite(PinId pin, int duty)=0
Set the duty cycle on a previously configured PWM pin.
Client and provider configuration types.
Hardware abstraction layer: network, console, time, crypto, and GPIO interfaces.
uint32_t PinId
32-bit pin identifier.
Definition gpio.hpp:21
PinMode
Direction and pull configuration of a pin.
Definition gpio.hpp:27
@ kInputPullup
Input with internal pull-up resistor enabled.
Definition gpio.hpp:30
@ kInput
High-impedance input (floating).
Definition gpio.hpp:28
@ kOutput
Push-pull output.
Definition gpio.hpp:29
Top-level namespace for the ForestHub SDK.
Configuration for a PWM output channel.
Definition gpio.hpp:34
uint8_t resolution_bits
Duty-cycle resolution in bits (e.g. 8 = 0..255).
Definition gpio.hpp:36
uint32_t frequency_hz
PWM frequency in hertz.
Definition gpio.hpp:35