Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
|
Class for handling GPIO operations in Rishka applications. More...
#include <gpio.h>
Static Public Member Functions | |
static void | pin_mode (u8 pin, gpio_pin_mode_t mode) |
Set the mode of a GPIO pin. More... | |
static gpio_mode_t | digital_read (u8 pin) |
Read the digital value of a GPIO pin. More... | |
static void | digital_write (u8 pin, gpio_mode_t mode) |
Write a digital value to a GPIO pin. More... | |
static u16 | analog_read (u8 pin) |
Read the analog value of a GPIO pin. More... | |
static void | analog_write (u8 pin, u16 value) |
Write an analog value to a GPIO pin. More... | |
static u64 | pulse_in (u8 pin, u8 state, u64 timeout) |
Measure the duration of a pulse on a GPIO pin. More... | |
static u64 | pulse_in_long (u8 pin, u8 state, u64 timeout) |
Measure the duration of a long pulse on a GPIO pin. More... | |
static u8 | shift_in (u8 data, u8 clock, u8 bit_order) |
Shift in data from a digital input pin. More... | |
static void | shift_out (u8 data, u8 clock, u8 bit_order, u8 value) |
Shift out data to a digital output pin. More... | |
static void | tone (u32 frequency, u64 duration) |
Generate a tone of the specified frequency and duration on GPIO25. More... | |
static void | no_tone () |
Stop generating a tone on GPIO25. More... | |
Class for handling GPIO operations in Rishka applications.
The Gpio class provides static methods for configuring and manipulating General Purpose Input/Output (GPIO) pins on ESP32-WROVER microcontrollers. It includes functionalities for setting pin modes, reading digital and analog values, generating pulses, and controlling digital communication protocols.
Read the analog value of a GPIO pin.
This method reads the analog value (0-1023) of the specified GPIO pin.
pin | The GPIO pin number. |
Write an analog value to a GPIO pin.
This method writes the analog value (0-255) to the specified GPIO pin.
pin | The GPIO pin number. |
value | The analog value to write to the GPIO pin (0-255). |
|
static |
Read the digital value of a GPIO pin.
This method reads the digital value (LOW or HIGH) of the specified GPIO pin.
pin | The GPIO pin number. |
|
static |
Write a digital value to a GPIO pin.
This method writes the digital value (LOW or HIGH) to the specified GPIO pin.
pin | The GPIO pin number. |
mode | The digital value to write to the GPIO pin (GPIO_LOW or GPIO_HIGH). |
|
static |
Stop generating a tone on GPIO25.
This method stops generating a tone on GPIO25.
|
static |
Set the mode of a GPIO pin.
This method sets the mode of the specified GPIO pin to the given mode.
pin | The GPIO pin number. |
mode | The mode to set for the GPIO pin (GPIO_INPUT, GPIO_OUTPUT, or GPIO_INPUT_PULLUP). |
Measure the duration of a pulse on a GPIO pin.
This method measures the duration of a pulse of the specified state (HIGH or LOW) on the specified GPIO pin, with the specified timeout in microseconds.
pin | The GPIO pin number. |
state | The state of the pulse to measure (GPIO_LOW or GPIO_HIGH). |
timeout | The timeout in microseconds. |
Measure the duration of a long pulse on a GPIO pin.
This method measures the duration of a long pulse of the specified state (HIGH or LOW) on the specified GPIO pin, with the specified timeout in microseconds.
pin | The GPIO pin number. |
state | The state of the pulse to measure (GPIO_LOW or GPIO_HIGH). |
timeout | The timeout in microseconds. |
Shift in data from a digital input pin.
This method shifts in data from a digital input pin using the specified clock pin and bit order (LSBFIRST or MSBFIRST).
data | The digital input pin number. |
clock | The clock pin number. |
bit_order | The bit order (LSBFIRST or MSBFIRST). |
Shift out data to a digital output pin.
This method shifts out data to a digital output pin using the specified clock pin, bit order (LSBFIRST or MSBFIRST), and data value.
data | The digital output pin number. |
clock | The clock pin number. |
bit_order | The bit order (LSBFIRST or MSBFIRST). |
value | The data value to shift out. |
Generate a tone of the specified frequency and duration on GPIO25.
This method generates a tone of the specified frequency and duration on the GPIO25 using pulse-width modulation (PWM).
frequency | The frequency of the tone in Hertz (Hz). |
duration | The duration of the tone in microseconds (0 for continuous). |