Rishka
RISC-V virtual runtime in C/C++ made for ESP32-WROVER
|
Class for handling I2C operations in Rishka applications. More...
#include <i2c.h>
Static Public Member Functions | |
static bool | begin (u8 address) |
Initialize the I2C communication with the specified address. More... | |
static bool | end () |
End the I2C communication. More... | |
static bool | pins (u8 sda, u8 scl) |
Set the SDA and SCL pins for the I2C communication. More... | |
static void | flush () |
Flush the I2C buffer. More... | |
static void | begin_transmission (u8 address) |
Begin an I2C transmission to the specified device address. More... | |
static u8 | end_transmission (bool stop_bit) |
End an I2C transmission with an optional stop bit. More... | |
static usize | write (u8 *data, usize size) |
Write data to the I2C bus. More... | |
static usize | slave_write (u8 *data, usize size) |
Write data to the I2C bus as a slave device. More... | |
static usize | set_buffersize (usize size) |
Set the buffer size for I2C transactions. More... | |
static i32 | read () |
Read data from the I2C bus. More... | |
static i32 | peek () |
Peek at the next byte on the I2C bus. More... | |
static i32 | available () |
Get the number of bytes available for reading on the I2C bus. More... | |
static usize | request (u8 address, usize size, bool stop_bit) |
Request data from a remote I2C device. More... | |
static void | on_receive (void(*callback)(int)) |
Register a callback function for I2C receive events. More... | |
static void | on_request (void(*callback)(void)) |
Register a callback function for I2C request events. More... | |
static void | set_timeout (u16 timeout) |
Set the timeout for I2C operations. More... | |
static u16 | get_timeout () |
Get the current timeout for I2C operations. More... | |
static bool | set_clock (u32 clock) |
Set the clock frequency for I2C communication. More... | |
static u32 | get_clock () |
Get the current clock frequency for I2C communication. More... | |
Class for handling I2C operations in Rishka applications.
The I2C class provides static methods for initializing, configuring, and communicating with I2C devices on ESP32-WROVER microcontrollers. It includes functionalities for setting up the I2C bus, beginning and ending I2C transactions, reading and writing data, registering callbacks for I2C events, and setting the clock frequency and timeout.
|
static |
|
static |
Initialize the I2C communication with the specified address.
This method initializes the I2C communication with the specified 7-bit address. It should be called before any other I2C communication functions are used.
address | The 7-bit address of the I2C device. |
|
static |
|
static |
|
static |
End an I2C transmission with an optional stop bit.
This method ends an I2C transmission with an optional stop bit. If the stop_bit parameter is true, a stop condition will be generated on the bus after the transmission is complete.
stop_bit | True to generate a stop condition, false otherwise. |
|
static |
|
static |
|
static |
|
static |
Register a callback function for I2C receive events.
This method registers a callback function to be called when data is received on the I2C bus as a slave device. The callback function should take an integer parameter representing the number of bytes received.
callback | Pointer to the callback function. |
|
static |
|
static |
Set the SDA and SCL pins for the I2C communication.
This method sets the SDA (data) and SCL (clock) pins for the I2C communication. It should be called to configure the GPIO pins used for I2C communication.
sda | The pin number for the SDA (data) line. |
scl | The pin number for the SCL (clock) line. |
|
static |
Read data from the I2C bus.
This method reads data from the I2C bus received from the device specified in the begin_transmission() method.
Request data from a remote I2C device.
This method requests data from a remote I2C device with the specified address and size, optionally generating a stop condition after the request.
address | The 7-bit address of the remote I2C device. |
size | The number of bytes to request. |
stop_bit | True to generate a stop condition after the request, false otherwise. |
|
static |
|
static |
Write data to the I2C bus.
This method writes data to the I2C bus for transmission to the device specified in the begin_transmission() method.
data | Pointer to the data buffer. |
size | The number of bytes to write. |