ForestHub SDK 0.1.0
C++14 LLM SDK for PC and embedded platforms
Loading...
Searching...
No Matches
foresthub::platform::GpioInterface Class Referenceabstract

Abstract interface for general-purpose pin I/O. More...

#include <gpio.hpp>

Public Member Functions

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 int DigitalRead (PinId pin) const =0
 Read the current logic level of a digital input pin.
virtual int AnalogRead (PinId pin) const =0
 Read the raw ADC value from an analog input pin.
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.

Detailed Description

Abstract interface for general-purpose pin I/O.

Covers digital input/output, analog-to-digital conversion, and pulse-width modulation. Platform implementations translate calls to the underlying peripheral hardware.

Member Function Documentation

◆ AnalogRead()

virtual int foresthub::platform::GpioInterface::AnalogRead ( PinId pin) const
pure virtual

Read the raw ADC value from an analog input pin.

Parameters
pinTarget pin identifier (must support analog input).
Returns
Raw ADC reading; range depends on hardware resolution.

◆ ConfigurePwm()

virtual std::string foresthub::platform::GpioInterface::ConfigurePwm ( PinId pin,
const PwmConfig & config )
pure virtual

Attach and configure a PWM peripheral on the given pin.

Parameters
pinTarget pin identifier (must support PWM output).
configFrequency and resolution settings.
Returns
Empty string on success, error message on failure.

◆ DigitalRead()

virtual int foresthub::platform::GpioInterface::DigitalRead ( PinId pin) const
pure virtual

Read the current logic level of a digital input pin.

Parameters
pinTarget pin identifier.
Returns
0 for low, 1 for high.

◆ DigitalWrite()

virtual void foresthub::platform::GpioInterface::DigitalWrite ( PinId pin,
int value )
pure virtual

Set a digital output pin to the given logic level.

Parameters
pinTarget pin identifier (must be configured as output).
valueLogic level to drive (0 = low, 1 = high).

◆ PwmWrite()

virtual void foresthub::platform::GpioInterface::PwmWrite ( PinId pin,
int duty )
pure virtual

Set the duty cycle on a previously configured PWM pin.

Parameters
pinTarget pin identifier (must have been configured via ConfigurePwm).
dutyDuty-cycle value in the range [0, 2^resolution_bits - 1].

◆ SetPinMode()

virtual void foresthub::platform::GpioInterface::SetPinMode ( PinId pin,
PinMode mode )
pure virtual

Configure a pin's direction and pull mode.

Parameters
pinTarget pin identifier.
modeDesired direction and pull configuration.

The documentation for this class was generated from the following file: