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
14
namespace
foresthub
{
15
namespace
platform
{
16
21
using
PinId
= uint32_t;
22
27
enum class
PinMode
: uint8_t {
28
kInput
= 0,
29
kOutput
= 1,
30
kInputPullup
= 2,
31
};
32
34
struct
PwmConfig
{
35
uint32_t
frequency_hz
= 1000;
36
uint8_t
resolution_bits
= 8;
37
};
38
44
class
GpioInterface
{
45
public
:
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
foresthub::platform::GpioInterface
Abstract interface for general-purpose pin I/O.
Definition
gpio.hpp:44
foresthub::platform::GpioInterface::AnalogRead
virtual int AnalogRead(PinId pin) const =0
Read the raw ADC value from an analog input pin.
foresthub::platform::GpioInterface::DigitalRead
virtual int DigitalRead(PinId pin) const =0
Read the current logic level of a digital input pin.
foresthub::platform::GpioInterface::SetPinMode
virtual void SetPinMode(PinId pin, PinMode mode)=0
Configure a pin's direction and pull mode.
foresthub::platform::GpioInterface::DigitalWrite
virtual void DigitalWrite(PinId pin, int value)=0
Set a digital output pin to the given logic level.
foresthub::platform::GpioInterface::ConfigurePwm
virtual std::string ConfigurePwm(PinId pin, const PwmConfig &config)=0
Attach and configure a PWM peripheral on the given pin.
foresthub::platform::GpioInterface::PwmWrite
virtual void PwmWrite(PinId pin, int duty)=0
Set the duty cycle on a previously configured PWM pin.
foresthub::config
Client and provider configuration types.
foresthub::platform
Hardware abstraction layer: network, console, time, crypto, and GPIO interfaces.
foresthub::platform::PinId
uint32_t PinId
32-bit pin identifier.
Definition
gpio.hpp:21
foresthub::platform::PinMode
PinMode
Direction and pull configuration of a pin.
Definition
gpio.hpp:27
foresthub::platform::PinMode::kInputPullup
@ kInputPullup
Input with internal pull-up resistor enabled.
Definition
gpio.hpp:30
foresthub::platform::PinMode::kInput
@ kInput
High-impedance input (floating).
Definition
gpio.hpp:28
foresthub::platform::PinMode::kOutput
@ kOutput
Push-pull output.
Definition
gpio.hpp:29
foresthub
Top-level namespace for the ForestHub SDK.
foresthub::platform::PwmConfig
Configuration for a PWM output channel.
Definition
gpio.hpp:34
foresthub::platform::PwmConfig::resolution_bits
uint8_t resolution_bits
Duty-cycle resolution in bits (e.g. 8 = 0..255).
Definition
gpio.hpp:36
foresthub::platform::PwmConfig::frequency_hz
uint32_t frequency_hz
PWM frequency in hertz.
Definition
gpio.hpp:35
include
foresthub
platform
gpio.hpp
Generated by
1.14.0