arduino-emulator
|
GPIO hardware abstraction for Raspberry Pi in the Arduino emulator. More...
#include <HardwareGPIO_RPI.h>
Public Member Functions | |
HardwareGPIO_RPI ()=default | |
Constructor for HardwareGPIO_RPI. | |
HardwareGPIO_RPI (const char *devName) | |
Constructor for HardwareGPIO_RPI with custom device name. | |
~HardwareGPIO_RPI () | |
Destructor for HardwareGPIO_RPI. | |
int | analogRead (pin_size_t pinNumber) override |
Read an analog value from a pin (if supported). | |
void | analogReference (uint8_t mode) override |
Set the analog reference mode. | |
void | analogWrite (pin_size_t pinNumber, int value) override |
Write an analog value (PWM) to a pin. | |
void | analogWriteFrequency (uint8_t pin, uint32_t freq) |
Set PWM frequency for a pin. | |
void | begin () |
Initialize the GPIO hardware interface for Raspberry Pi. | |
PinStatus | digitalRead (pin_size_t pinNumber) override |
Read a digital value from a GPIO pin. | |
void | digitalWrite (pin_size_t pinNumber, PinStatus status) override |
Write a digital value to a GPIO pin. | |
void | noTone (uint8_t _pin) override |
Stop tone generation on a pin. | |
operator bool () | |
void | pinMode (pin_size_t pinNumber, PinMode pinMode) override |
Set the mode of a GPIO pin (INPUT, OUTPUT, etc). | |
unsigned long | pulseIn (uint8_t pin, uint8_t state, unsigned long timeout=1000000L) override |
Measure pulse duration on a pin. | |
unsigned long | pulseInLong (uint8_t pin, uint8_t state, unsigned long timeout=1000000L) override |
Measure long pulse duration on a pin. | |
void | tone (uint8_t _pin, unsigned int frequency, unsigned long duration=0) override |
Generate a tone on a pin. | |
GPIO hardware abstraction for Raspberry Pi in the Arduino emulator.
This class implements the Arduino-style GPIO interface for Raspberry Pi platforms, allowing digital and analog I/O, PWM, and timing functions to be used in a manner compatible with Arduino code. It provides methods to configure pin modes, read and write digital/analog values, generate PWM signals, and perform timing operations such as pulse measurement and tone generation.
The class inherits from HardwareGPIO and is intended for use within the emulator when running on Raspberry Pi hardware. It manages pin state, analog reference, and PWM frequency settings for supported pins.
Constructor for HardwareGPIO_RPI with custom device name.
devName | Name of the GPIO chip device (e.g., "gpiochip0"). |
|
overridevirtual |
Read an analog value from a pin (if supported).
Implements arduino::HardwareGPIO.
Set the analog reference mode.
Implements arduino::HardwareGPIO.
Write an analog value (PWM) to a pin.
Implements arduino::HardwareGPIO.
void arduino::HardwareGPIO_RPI::begin | ( | ) |
Initialize the GPIO hardware interface for Raspberry Pi.
Opens the GPIO chip device and prepares the class for GPIO operations. Should be called before using any GPIO functions.
|
overridevirtual |
Read a digital value from a GPIO pin.
Implements arduino::HardwareGPIO.
|
overridevirtual |
Write a digital value to a GPIO pin.
Implements arduino::HardwareGPIO.
Stop tone generation on a pin.
Implements arduino::HardwareGPIO.
|
overridevirtual |
Set the mode of a GPIO pin (INPUT, OUTPUT, etc).
Implements arduino::HardwareGPIO.
|
overridevirtual |
Measure pulse duration on a pin.
pin | Pin number |
state | Pin state to measure |
timeout | Timeout in microseconds (default 1000000) |
Implements arduino::HardwareGPIO.
|
overridevirtual |
Measure long pulse duration on a pin.
pin | Pin number |
state | Pin state to measure |
timeout | Timeout in microseconds (default 1000000) |
Implements arduino::HardwareGPIO.
|
overridevirtual |
Generate a tone on a pin.
_pin | Pin number |
frequency | Frequency in Hz |
duration | Duration in ms (optional) |
Implements arduino::HardwareGPIO.