Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
Gpio Class Referencefinal

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...
 

Detailed Description

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.

Member Function Documentation

◆ analog_read()

u16 Gpio::analog_read ( u8  pin)
static

Read the analog value of a GPIO pin.

This method reads the analog value (0-1023) of the specified GPIO pin.

Parameters
pinThe GPIO pin number.
Returns
The analog value of the GPIO pin (0-1023).

◆ analog_write()

void Gpio::analog_write ( u8  pin,
u16  value 
)
static

Write an analog value to a GPIO pin.

This method writes the analog value (0-255) to the specified GPIO pin.

Parameters
pinThe GPIO pin number.
valueThe analog value to write to the GPIO pin (0-255).

◆ digital_read()

gpio_mode_t Gpio::digital_read ( u8  pin)
static

Read the digital value of a GPIO pin.

This method reads the digital value (LOW or HIGH) of the specified GPIO pin.

Parameters
pinThe GPIO pin number.
Returns
The digital value of the GPIO pin (0 for LOW, 1 for HIGH).

◆ digital_write()

void Gpio::digital_write ( u8  pin,
gpio_mode_t  mode 
)
static

Write a digital value to a GPIO pin.

This method writes the digital value (LOW or HIGH) to the specified GPIO pin.

Parameters
pinThe GPIO pin number.
modeThe digital value to write to the GPIO pin (GPIO_LOW or GPIO_HIGH).

◆ no_tone()

void Gpio::no_tone ( )
static

Stop generating a tone on GPIO25.

This method stops generating a tone on GPIO25.

◆ pin_mode()

void Gpio::pin_mode ( u8  pin,
gpio_pin_mode_t  mode 
)
static

Set the mode of a GPIO pin.

This method sets the mode of the specified GPIO pin to the given mode.

Parameters
pinThe GPIO pin number.
modeThe mode to set for the GPIO pin (GPIO_INPUT, GPIO_OUTPUT, or GPIO_INPUT_PULLUP).

◆ pulse_in()

u64 Gpio::pulse_in ( u8  pin,
u8  state,
u64  timeout 
)
static

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.

Parameters
pinThe GPIO pin number.
stateThe state of the pulse to measure (GPIO_LOW or GPIO_HIGH).
timeoutThe timeout in microseconds.
Returns
The duration of the pulse in microseconds, or 0 if the timeout occurred.

◆ pulse_in_long()

u64 Gpio::pulse_in_long ( u8  pin,
u8  state,
u64  timeout 
)
static

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.

Parameters
pinThe GPIO pin number.
stateThe state of the pulse to measure (GPIO_LOW or GPIO_HIGH).
timeoutThe timeout in microseconds.
Returns
The duration of the long pulse in microseconds, or 0 if the timeout occurred.

◆ shift_in()

u8 Gpio::shift_in ( u8  data,
u8  clock,
u8  bit_order 
)
static

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).

Parameters
dataThe digital input pin number.
clockThe clock pin number.
bit_orderThe bit order (LSBFIRST or MSBFIRST).
Returns
The shifted-in data byte.

◆ shift_out()

void Gpio::shift_out ( u8  data,
u8  clock,
u8  bit_order,
u8  value 
)
static

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.

Parameters
dataThe digital output pin number.
clockThe clock pin number.
bit_orderThe bit order (LSBFIRST or MSBFIRST).
valueThe data value to shift out.

◆ tone()

void Gpio::tone ( u32  frequency,
u64  duration 
)
static

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).

Parameters
frequencyThe frequency of the tone in Hertz (Hz).
durationThe duration of the tone in microseconds (0 for continuous).

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