idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::i2c::master_device Class Reference

I2C device at a specific address with register operations. More...

Classes

struct  config
 I2C device configuration. More...
 

Public Member Functions

 master_device (master_bus &bus, uint16_t address, const struct config &config)
 Creates a new device on the specified bus.
 
 master_device (master_bus &bus, uint16_t address)
 Creates a new device on the specified bus.
 
 ~master_device ()
 
 master_device (const master_device &)=delete
 
master_deviceoperator= (const master_device &)=delete
 
 master_device (master_device &&other) noexcept
 
master_deviceoperator= (master_device &&other) noexcept
 
master_busbus () const
 Returns the parent bus.
 
i2c_master_dev_handle_t handle () const
 Returns the underlying ESP-IDF device handle.
 
uint16_t address () const
 Returns the device address.
 
void probe () const
 Probes the device.
 
template<typename Rep , typename Period >
void probe (const std::chrono::duration< Rep, Period > &timeout) const
 Probes the device.
 
result< voidtry_probe () const
 Probes the device.
 
template<typename Rep , typename Period >
result< voidtry_probe (const std::chrono::duration< Rep, Period > &timeout) const
 Probes the device.
 
void transmit (std::span< const uint8_t > data)
 Transmits data to the device.
 
template<std::convertible_to< std::span< const uint8_t > >... Buffers>
requires (sizeof...(Buffers) > 1)
void transmit (Buffers... buffers)
 Transmits data from multiple buffers in a single I2C transaction.
 
void transmit (std::span< const std::span< const uint8_t > > buffers)
 Transmits data from multiple buffers in a single I2C transaction.
 
template<typename Rep , typename Period >
void transmit (std::span< const uint8_t > data, const std::chrono::duration< Rep, Period > &timeout)
 Transmits data to the device.
 
template<typename Rep , typename Period >
void transmit (std::span< const std::span< const uint8_t > > buffers, const std::chrono::duration< Rep, Period > &timeout)
 Transmits data from multiple buffers in a single I2C transaction.
 
void transmit (const uint8_t *buf, size_t size)
 Transmits data to the device.
 
template<typename Rep , typename Period >
void transmit (const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Transmits data to the device.
 
result< voidtry_transmit (std::span< const uint8_t > data)
 Transmits data to the device.
 
template<std::convertible_to< std::span< const uint8_t > >... Buffers>
requires (sizeof...(Buffers) > 1)
result< voidtry_transmit (Buffers... buffers)
 Transmits data from multiple buffers in a single I2C transaction.
 
result< voidtry_transmit (std::span< const std::span< const uint8_t > > buffers)
 Transmits data from multiple buffers in a single I2C transaction.
 
template<typename Rep , typename Period >
result< voidtry_transmit (std::span< const uint8_t > data, const std::chrono::duration< Rep, Period > &timeout)
 Transmits data to the device.
 
template<typename Rep , typename Period >
result< voidtry_transmit (std::span< const std::span< const uint8_t > > buffers, const std::chrono::duration< Rep, Period > &timeout)
 Transmits data from multiple buffers in a single I2C transaction.
 
result< voidtry_transmit (const uint8_t *buf, size_t size)
 Transmits data to the device.
 
template<typename Rep , typename Period >
result< voidtry_transmit (const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Transmits data to the device.
 
void change_address (uint16_t new_address)
 Changes the I2C address used for subsequent operations.
 
template<typename Rep , typename Period >
void change_address (uint16_t new_address, const std::chrono::duration< Rep, Period > &timeout)
 Changes the I2C address used for subsequent operations.
 
result< voidtry_change_address (uint16_t new_address)
 Changes the I2C address used for subsequent operations.
 
template<typename Rep , typename Period >
result< voidtry_change_address (uint16_t new_address, const std::chrono::duration< Rep, Period > &timeout)
 Changes the I2C address used for subsequent operations.
 
void register_event_callbacks (std::move_only_function< bool() const > on_trans_done)
 Registers a callback for transaction-done events.
 
result< voidtry_register_event_callbacks (std::move_only_function< bool() const > on_trans_done)
 Registers a callback for transaction-done events.
 
void execute_operations (std::span< const operation > ops)
 Executes a custom sequence of I2C operations.
 
template<typename Rep , typename Period >
void execute_operations (std::span< const operation > ops, const std::chrono::duration< Rep, Period > &timeout)
 Executes a custom sequence of I2C operations.
 
result< voidtry_execute_operations (std::span< const operation > ops)
 Executes a custom sequence of I2C operations.
 
template<typename Rep , typename Period >
result< voidtry_execute_operations (std::span< const operation > ops, const std::chrono::duration< Rep, Period > &timeout)
 Executes a custom sequence of I2C operations.
 
std::vector< uint8_treceive (size_t size)
 Receives data from the device.
 
template<typename Rep , typename Period >
std::vector< uint8_treceive (size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Receives data from the device.
 
void receive (uint8_t *buf, size_t size)
 Receives data from the device.
 
template<typename Rep , typename Period >
void receive (uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Receives data from the device.
 
void receive (std::span< uint8_t > buf)
 Receives data from the device.
 
template<typename Rep , typename Period >
void receive (std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Receives data from the device.
 
result< std::vector< uint8_t > > try_receive (size_t size)
 Receives data from the device.
 
template<typename Rep , typename Period >
result< std::vector< uint8_t > > try_receive (size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Receives data from the device.
 
result< voidtry_receive (uint8_t *buf, size_t size)
 Receives data from the device.
 
template<typename Rep , typename Period >
result< voidtry_receive (uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Receives data from the device.
 
result< voidtry_receive (std::span< uint8_t > buf)
 Receives data from the device.
 
template<typename Rep , typename Period >
result< voidtry_receive (std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Receives data from the device.
 
void write_register (uint16_t reg, std::span< const uint8_t > buf)
 Writes data to a register.
 
template<typename Rep , typename Period >
void write_register (uint16_t reg, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
void write_register (uint16_t reg, const uint8_t *buf, size_t size)
 Writes data to a register.
 
template<typename Rep , typename Period >
void write_register (uint16_t reg, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
result< voidtry_write_register (uint16_t reg, std::span< const uint8_t > buf)
 Writes data to a register.
 
template<typename Rep , typename Period >
result< voidtry_write_register (uint16_t reg, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
result< voidtry_write_register (uint16_t reg, const uint8_t *buf, size_t size)
 Writes data to a register.
 
template<typename Rep , typename Period >
result< voidtry_write_register (uint16_t reg, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
void write_register (uint8_t high, uint8_t low, std::span< const uint8_t > buf)
 Writes data to a register.
 
template<typename Rep , typename Period >
void write_register (uint8_t high, uint8_t low, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
void write_register (uint8_t high, uint8_t low, const uint8_t *buf, size_t size)
 Writes data to a register.
 
template<typename Rep , typename Period >
void write_register (uint8_t high, uint8_t low, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
result< voidtry_write_register (uint8_t high, uint8_t low, std::span< const uint8_t > buf)
 Writes data to a register.
 
template<typename Rep , typename Period >
result< voidtry_write_register (uint8_t high, uint8_t low, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
result< voidtry_write_register (uint8_t high, uint8_t low, const uint8_t *buf, size_t size)
 Writes data to a register.
 
template<typename Rep , typename Period >
result< voidtry_write_register (uint8_t high, uint8_t low, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
void write_registers (std::span< const uint16_t > registers, std::span< const uint8_t > buf)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
void write_registers (std::span< const uint16_t > registers, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
void write_registers (std::span< const uint16_t > registers, const uint8_t *buf, size_t size)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
void write_registers (std::span< const uint16_t > registers, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
void write_registers (std::initializer_list< uint16_t > registers, std::span< const uint8_t > buf)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
void write_registers (std::initializer_list< uint16_t > registers, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
void write_registers (std::initializer_list< uint16_t > registers, const uint8_t *buf, size_t size)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
void write_registers (std::initializer_list< uint16_t > registers, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
result< voidtry_write_registers (std::span< const uint16_t > registers, std::span< const uint8_t > buf)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
result< voidtry_write_registers (std::span< const uint16_t > registers, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
result< voidtry_write_registers (std::span< const uint16_t > registers, const uint8_t *buf, size_t size)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
result< voidtry_write_registers (std::span< const uint16_t > registers, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
result< voidtry_write_registers (std::initializer_list< uint16_t > registers, std::span< const uint8_t > buf)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
result< voidtry_write_registers (std::initializer_list< uint16_t > registers, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
result< voidtry_write_registers (std::initializer_list< uint16_t > registers, const uint8_t *buf, size_t size)
 Writes data to multiple registers.
 
template<typename Rep , typename Period >
result< voidtry_write_registers (std::initializer_list< uint16_t > registers, const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to multiple registers.
 
std::vector< uint8_tread_register (uint16_t reg, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
std::vector< uint8_tread_register (uint16_t reg, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
void read_register (uint16_t reg, std::span< uint8_t > buf)
 Reads data from a register.
 
template<typename Rep , typename Period >
void read_register (uint16_t reg, std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
void read_register (uint16_t reg, uint8_t *buf, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
void read_register (uint16_t reg, uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
result< std::vector< uint8_t > > try_read_register (uint16_t reg, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< std::vector< uint8_t > > try_read_register (uint16_t reg, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
result< voidtry_read_register (uint16_t reg, std::span< uint8_t > buf)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< voidtry_read_register (uint16_t reg, std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
result< voidtry_read_register (uint16_t reg, uint8_t *buf, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< voidtry_read_register (uint16_t reg, uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
std::vector< uint8_tread_register (uint8_t high, uint8_t low, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
std::vector< uint8_tread_register (uint8_t high, uint8_t low, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
void read_register (uint8_t high, uint8_t low, uint8_t *buf, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
void read_register (uint8_t high, uint8_t low, uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
result< std::vector< uint8_t > > try_read_register (uint8_t high, uint8_t low, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< std::vector< uint8_t > > try_read_register (uint8_t high, uint8_t low, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
result< voidtry_read_register (uint8_t high, uint8_t low, std::span< uint8_t > buf)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< voidtry_read_register (uint8_t high, uint8_t low, std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
result< voidtry_read_register (uint8_t high, uint8_t low, uint8_t *buf, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< voidtry_read_register (uint8_t high, uint8_t low, uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 

Static Public Member Functions

static result< master_devicemake (master_bus &bus, uint16_t address, const struct config &config)
 Creates a new device on the specified bus.
 
static result< master_devicemake (master_bus &bus, uint16_t address)
 Creates a new device on the specified bus.
 

Detailed Description

I2C device at a specific address with register operations.

Represents a specific device on an I2C bus. Provides methods for raw data transfer and register-based read/write operations.

This type is non-copyable and move-only. Result-returning methods on a moved-from object return errc::invalid_state. Simple accessors return default/null values.

Definition at line 421 of file master.hpp.

Constructor & Destructor Documentation

◆ master_device() [1/4]

idfxx::i2c::master_device::master_device ( master_bus bus,
uint16_t  address,
const struct config config 
)
explicit

Creates a new device on the specified bus.

Does not take ownership of bus. It is the caller's responsibility to ensure that this device does not outlive the bus.

Parameters
busThe parent bus.
addressDevice address.
configDevice configuration.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.
.scl_speed = 400_kHz,
});
I2C device at a specific address with register operations.
Definition master.hpp:421
master_bus & bus() const
Returns the parent bus.
Definition master.hpp:525
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120

◆ master_device() [2/4]

idfxx::i2c::master_device::master_device ( master_bus bus,
uint16_t  address 
)
explicit

Creates a new device on the specified bus.

Does not take ownership of bus. It is the caller's responsibility to ensure that this device does not outlive the bus.

Parameters
busThe parent bus.
addressDevice address.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

◆ ~master_device()

idfxx::i2c::master_device::~master_device ( )

◆ master_device() [3/4]

idfxx::i2c::master_device::master_device ( const master_device )
delete

◆ master_device() [4/4]

idfxx::i2c::master_device::master_device ( master_device &&  other)
noexcept

Member Function Documentation

◆ address()

uint16_t idfxx::i2c::master_device::address ( ) const
inline

Returns the device address.

Definition at line 534 of file master.hpp.

◆ bus()

master_bus & idfxx::i2c::master_device::bus ( ) const
inline

Returns the parent bus.

Precondition
The object has not been moved from.

Definition at line 525 of file master.hpp.

◆ change_address() [1/2]

void idfxx::i2c::master_device::change_address ( uint16_t  new_address)
inline

Changes the I2C address used for subsequent operations.

Useful for devices whose address can change at runtime, such as after configuring an I2C multiplexer.

Parameters
new_addressThe new device address.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 799 of file master.hpp.

References idfxx::unwrap().

◆ change_address() [2/2]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::change_address ( uint16_t  new_address,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Changes the I2C address used for subsequent operations.

Useful for devices whose address can change at runtime, such as after configuring an I2C multiplexer.

Parameters
new_addressThe new device address.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 814 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ execute_operations() [1/2]

void idfxx::i2c::master_device::execute_operations ( std::span< const operation ops)
inline

Executes a custom sequence of I2C operations.

Performs the given sequence of START, WRITE, READ, and STOP operations. Useful for non-standard I2C protocols.

Parameters
opsOperations to execute.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.
uint8_t reg = 0x10;
device.execute_operations(std::array{
.write_data = std::span{&reg, 1}},
.read_data = std::span{buf},
});
@ start
Send START or repeated-START condition.
@ read
Read data from the bus.
@ stop
Send STOP condition.
@ write
Write data to the bus.
@ nack
Not-acknowledge — signal end of read.
Describes a single operation in a custom I2C transaction sequence.
Definition master.hpp:133
operation_command command
The operation to perform.
Definition master.hpp:134

Definition at line 908 of file master.hpp.

References idfxx::unwrap().

◆ execute_operations() [2/2]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::execute_operations ( std::span< const operation ops,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Executes a custom sequence of I2C operations.

Parameters
opsOperations to execute.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 920 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ handle()

i2c_master_dev_handle_t idfxx::i2c::master_device::handle ( ) const
inline

Returns the underlying ESP-IDF device handle.

Definition at line 531 of file master.hpp.

◆ make() [1/2]

static result< master_device > idfxx::i2c::master_device::make ( master_bus bus,
uint16_t  address 
)
static

Creates a new device on the specified bus.

Does not take ownership of bus. It is the caller's responsibility to ensure that this device does not outlive the bus.

Parameters
busThe parent bus.
addressDevice address.
Returns
The new master_device, or an error.

◆ make() [2/2]

static result< master_device > idfxx::i2c::master_device::make ( master_bus bus,
uint16_t  address,
const struct config config 
)
static

Creates a new device on the specified bus.

Does not take ownership of bus. It is the caller's responsibility to ensure that this device does not outlive the bus.

Parameters
busThe parent bus.
addressDevice address.
configDevice configuration.
Returns
The new master_device, or an error.
auto device = idfxx::i2c::master_device::make(bus, 0x3C, {
.scl_speed = 400_kHz,
});
static result< master_device > make(master_bus &bus, uint16_t address, const struct config &config)
Creates a new device on the specified bus.

◆ operator=() [1/2]

master_device & idfxx::i2c::master_device::operator= ( const master_device )
delete

◆ operator=() [2/2]

master_device & idfxx::i2c::master_device::operator= ( master_device &&  other)
noexcept

◆ probe() [1/2]

void idfxx::i2c::master_device::probe ( ) const
inline

Probes the device.

Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_errorif the device does not acknowledge or on error.

Definition at line 543 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT, and probe().

Referenced by probe().

◆ probe() [2/2]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::probe ( const std::chrono::duration< Rep, Period > &  timeout) const
inline

Probes the device.

Parameters
timeoutMaximum time to wait for response.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_errorif the device does not acknowledge or on error.

Definition at line 554 of file master.hpp.

References idfxx::timeout, idfxx::i2c::master_bus::try_probe(), and idfxx::unwrap().

◆ read_register() [1/10]

std::vector< uint8_t > idfxx::i2c::master_device::read_register ( uint16_t  reg,
size_t  size 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
sizeNumber of bytes to read.
Returns
Received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1650 of file master.hpp.

References idfxx::unwrap().

◆ read_register() [2/10]

template<typename Rep , typename Period >
std::vector< uint8_t > idfxx::i2c::master_device::read_register ( uint16_t  reg,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Returns
Received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1668 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ read_register() [3/10]

void idfxx::i2c::master_device::read_register ( uint16_t  reg,
std::span< uint8_t buf 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1681 of file master.hpp.

References idfxx::unwrap().

◆ read_register() [4/10]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::read_register ( uint16_t  reg,
std::span< uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1694 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ read_register() [5/10]

void idfxx::i2c::master_device::read_register ( uint16_t  reg,
uint8_t buf,
size_t  size 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
sizeNumber of bytes to read.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1708 of file master.hpp.

References idfxx::unwrap().

◆ read_register() [6/10]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::read_register ( uint16_t  reg,
uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1722 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ read_register() [7/10]

std::vector< uint8_t > idfxx::i2c::master_device::read_register ( uint8_t  high,
uint8_t  low,
size_t  size 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
sizeNumber of bytes to read.
Returns
Received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1823 of file master.hpp.

References idfxx::unwrap().

◆ read_register() [8/10]

template<typename Rep , typename Period >
std::vector< uint8_t > idfxx::i2c::master_device::read_register ( uint8_t  high,
uint8_t  low,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Returns
Received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1842 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ read_register() [9/10]

void idfxx::i2c::master_device::read_register ( uint8_t  high,
uint8_t  low,
uint8_t buf,
size_t  size 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufBuffer for received data.
sizeNumber of bytes to read.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1857 of file master.hpp.

References idfxx::unwrap().

◆ read_register() [10/10]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::read_register ( uint8_t  high,
uint8_t  low,
uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufBuffer for received data.
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1874 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ receive() [1/6]

std::vector< uint8_t > idfxx::i2c::master_device::receive ( size_t  size)
inline

Receives data from the device.

Parameters
sizeNumber of bytes to receive.
Returns
Received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 964 of file master.hpp.

References idfxx::unwrap().

◆ receive() [2/6]

template<typename Rep , typename Period >
std::vector< uint8_t > idfxx::i2c::master_device::receive ( size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Receives data from the device.

Parameters
sizeNumber of bytes to receive.
timeoutMaximum time to wait for completion.
Returns
Received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 978 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ receive() [3/6]

void idfxx::i2c::master_device::receive ( std::span< uint8_t buf)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1016 of file master.hpp.

References idfxx::unwrap().

◆ receive() [4/6]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::receive ( std::span< uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1028 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ receive() [5/6]

void idfxx::i2c::master_device::receive ( uint8_t buf,
size_t  size 
)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
sizeNumber of bytes to receive.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 991 of file master.hpp.

References idfxx::unwrap().

◆ receive() [6/6]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::receive ( uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
sizeNumber of bytes to receive.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1004 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ register_event_callbacks()

void idfxx::i2c::master_device::register_event_callbacks ( std::move_only_function< bool() const on_trans_done)
inline

Registers a callback for transaction-done events.

The callback runs in ISR context when an asynchronous transaction completes. It should return true if a higher-priority task was woken. Only useful when the bus was created with a non-zero trans_queue_depth.

Parameters
on_trans_doneTransaction-done callback.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron failure.

Definition at line 863 of file master.hpp.

References idfxx::unwrap().

◆ transmit() [1/7]

template<std::convertible_to< std::span< const uint8_t > >... Buffers>
requires (sizeof...(Buffers) > 1)
void idfxx::i2c::master_device::transmit ( Buffers...  buffers)
inline

Transmits data from multiple buffers in a single I2C transaction.

Convenience overload that accepts two or more buffers as separate arguments.

Template Parameters
BuffersTypes convertible to std::span<const uint8_t>.
Parameters
buffersBuffers to transmit, in order.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.
std::array<uint8_t, 1> reg{0x10};
std::array<uint8_t, 4> data{0x01, 0x02, 0x03, 0x04};
device.transmit(std::span{reg}, std::span{data});

Definition at line 611 of file master.hpp.

References idfxx::unwrap().

◆ transmit() [2/7]

void idfxx::i2c::master_device::transmit ( const uint8_t buf,
size_t  size 
)
inline

Transmits data to the device.

Parameters
bufData to transmit.
sizeNumber of bytes.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 669 of file master.hpp.

References idfxx::unwrap().

◆ transmit() [3/7]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::transmit ( const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Transmits data to the device.

Parameters
bufData to transmit.
sizeNumber of bytes.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 682 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ transmit() [4/7]

void idfxx::i2c::master_device::transmit ( std::span< const std::span< const uint8_t > >  buffers)
inline

Transmits data from multiple buffers in a single I2C transaction.

Performs a scatter-gather transmit, sending data from each buffer sequentially without intermediate stop conditions.

Parameters
buffersBuffers to transmit, in order.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 626 of file master.hpp.

References idfxx::unwrap().

◆ transmit() [5/7]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::transmit ( std::span< const std::span< const uint8_t > >  buffers,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Transmits data from multiple buffers in a single I2C transaction.

Performs a scatter-gather transmit, sending data from each buffer sequentially without intermediate stop conditions.

Parameters
buffersBuffers to transmit, in order.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 656 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ transmit() [6/7]

void idfxx::i2c::master_device::transmit ( std::span< const uint8_t data)
inline

Transmits data to the device.

Parameters
dataData to transmit.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 590 of file master.hpp.

References idfxx::unwrap().

◆ transmit() [7/7]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::transmit ( std::span< const uint8_t data,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Transmits data to the device.

Parameters
dataData to transmit.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 638 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ try_change_address() [1/2]

result< void > idfxx::i2c::master_device::try_change_address ( uint16_t  new_address)
inline

Changes the I2C address used for subsequent operations.

Useful for devices whose address can change at runtime, such as after configuring an I2C multiplexer.

Parameters
new_addressThe new device address.
Returns
Success, or an error.

Definition at line 829 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_change_address() [2/2]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_change_address ( uint16_t  new_address,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Changes the I2C address used for subsequent operations.

Useful for devices whose address can change at runtime, such as after configuring an I2C multiplexer.

Parameters
new_addressThe new device address.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 846 of file master.hpp.

References idfxx::timeout.

◆ try_execute_operations() [1/2]

result< void > idfxx::i2c::master_device::try_execute_operations ( std::span< const operation ops)
inline

Executes a custom sequence of I2C operations.

Performs the given sequence of START, WRITE, READ, and STOP operations. Useful for non-standard I2C protocols.

Parameters
opsOperations to execute.
Returns
Success, or an error.

Definition at line 935 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_execute_operations() [2/2]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_execute_operations ( std::span< const operation ops,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Executes a custom sequence of I2C operations.

Parameters
opsOperations to execute.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 949 of file master.hpp.

References idfxx::timeout.

◆ try_probe() [1/2]

result< void > idfxx::i2c::master_device::try_probe ( ) const
inline

Probes the device.

Returns
Success if the device acknowledges, or an error.

Definition at line 564 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT, and try_probe().

Referenced by try_probe().

◆ try_probe() [2/2]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_probe ( const std::chrono::duration< Rep, Period > &  timeout) const
inline

Probes the device.

Parameters
timeoutMaximum time to wait for response.
Returns
Success if the device acknowledges, or an error.

Definition at line 574 of file master.hpp.

References idfxx::error(), idfxx::invalid_state, and idfxx::timeout.

◆ try_read_register() [1/12]

result< std::vector< uint8_t > > idfxx::i2c::master_device::try_read_register ( uint16_t  reg,
size_t  size 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
sizeNumber of bytes to read.
Returns
Received data, or an error.

Definition at line 1735 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_read_register() [2/12]

template<typename Rep , typename Period >
result< std::vector< uint8_t > > idfxx::i2c::master_device::try_read_register ( uint16_t  reg,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Returns
Received data, or an error.

Definition at line 1750 of file master.hpp.

References idfxx::timeout.

◆ try_read_register() [3/12]

result< void > idfxx::i2c::master_device::try_read_register ( uint16_t  reg,
std::span< uint8_t buf 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
Returns
Success, or an error.

Definition at line 1763 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_read_register() [4/12]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_read_register ( uint16_t  reg,
std::span< uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
Returns
Success, or an error.

Definition at line 1777 of file master.hpp.

References idfxx::timeout.

◆ try_read_register() [5/12]

result< void > idfxx::i2c::master_device::try_read_register ( uint16_t  reg,
uint8_t buf,
size_t  size 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
sizeNumber of bytes to read.
Returns
Success, or an error.

Definition at line 1790 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_read_register() [6/12]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_read_register ( uint16_t  reg,
uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
regRegister address (16-bit, MSB first).
bufBuffer for received data.
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1806 of file master.hpp.

References idfxx::timeout.

◆ try_read_register() [7/12]

result< std::vector< uint8_t > > idfxx::i2c::master_device::try_read_register ( uint8_t  high,
uint8_t  low,
size_t  size 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
sizeNumber of bytes to read.
Returns
Received data, or an error.

Definition at line 1894 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_read_register() [8/12]

template<typename Rep , typename Period >
result< std::vector< uint8_t > > idfxx::i2c::master_device::try_read_register ( uint8_t  high,
uint8_t  low,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Returns
Received data, or an error.

Definition at line 1910 of file master.hpp.

References idfxx::timeout.

◆ try_read_register() [9/12]

result< void > idfxx::i2c::master_device::try_read_register ( uint8_t  high,
uint8_t  low,
std::span< uint8_t buf 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufBuffer for received data.
Returns
Success, or an error.

Definition at line 1924 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_read_register() [10/12]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_read_register ( uint8_t  high,
uint8_t  low,
std::span< uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufBuffer for received data.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1939 of file master.hpp.

References idfxx::timeout.

◆ try_read_register() [11/12]

result< void > idfxx::i2c::master_device::try_read_register ( uint8_t  high,
uint8_t  low,
uint8_t buf,
size_t  size 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufBuffer for received data.
sizeNumber of bytes to read.
Returns
Success, or an error.

Definition at line 1958 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_read_register() [12/12]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_read_register ( uint8_t  high,
uint8_t  low,
uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Reads data from a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufBuffer for received data.
sizeNumber of bytes to read.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1974 of file master.hpp.

References idfxx::timeout.

◆ try_receive() [1/6]

result< std::vector< uint8_t > > idfxx::i2c::master_device::try_receive ( size_t  size)
inline

Receives data from the device.

Parameters
sizeNumber of bytes to receive.
Returns
Received data, or an error.

Definition at line 1040 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT, and try_receive().

Referenced by try_receive().

◆ try_receive() [2/6]

template<typename Rep , typename Period >
result< std::vector< uint8_t > > idfxx::i2c::master_device::try_receive ( size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Receives data from the device.

Parameters
sizeNumber of bytes to receive.
timeoutMaximum time to wait for completion.
Returns
Received data, or an error.

Definition at line 1052 of file master.hpp.

References idfxx::timeout.

◆ try_receive() [3/6]

result< void > idfxx::i2c::master_device::try_receive ( std::span< uint8_t buf)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
Returns
Success, or an error.

Definition at line 1091 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT, and try_receive().

Referenced by try_receive().

◆ try_receive() [4/6]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_receive ( std::span< uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1102 of file master.hpp.

References idfxx::timeout.

◆ try_receive() [5/6]

result< void > idfxx::i2c::master_device::try_receive ( uint8_t buf,
size_t  size 
)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
sizeNumber of bytes to receive.
Returns
Success, or an error.

Definition at line 1065 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_receive() [6/6]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_receive ( uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Receives data from the device.

Parameters
bufBuffer for received data.
sizeNumber of bytes to receive.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1080 of file master.hpp.

References idfxx::timeout.

◆ try_register_event_callbacks()

result< void > idfxx::i2c::master_device::try_register_event_callbacks ( std::move_only_function< bool() const on_trans_done)

Registers a callback for transaction-done events.

The callback runs in ISR context when an asynchronous transaction completes. It should return true if a higher-priority task was woken. Only useful when the bus was created with a non-zero trans_queue_depth.

Parameters
on_trans_doneTransaction-done callback.
Returns
Success, or an error.

◆ try_transmit() [1/7]

template<std::convertible_to< std::span< const uint8_t > >... Buffers>
requires (sizeof...(Buffers) > 1)
result< void > idfxx::i2c::master_device::try_transmit ( Buffers...  buffers)
inline

Transmits data from multiple buffers in a single I2C transaction.

Convenience overload that accepts two or more buffers as separate arguments.

Template Parameters
BuffersTypes convertible to std::span<const uint8_t>.
Parameters
buffersBuffers to transmit, in order.
Returns
Success, or an error.

Definition at line 710 of file master.hpp.

◆ try_transmit() [2/7]

result< void > idfxx::i2c::master_device::try_transmit ( const uint8_t buf,
size_t  size 
)
inline

Transmits data to the device.

Parameters
bufData to transmit.
sizeNumber of bytes.
Returns
Success, or an error.

Definition at line 768 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_transmit() [3/7]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_transmit ( const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Transmits data to the device.

Parameters
bufData to transmit.
sizeNumber of bytes.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 783 of file master.hpp.

References idfxx::timeout.

◆ try_transmit() [4/7]

result< void > idfxx::i2c::master_device::try_transmit ( std::span< const std::span< const uint8_t > >  buffers)
inline

Transmits data from multiple buffers in a single I2C transaction.

Performs a scatter-gather transmit, sending data from each buffer sequentially without intermediate stop conditions.

Parameters
buffersBuffers to transmit, in order.
Returns
Success, or an error.

Definition at line 725 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_transmit() [5/7]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_transmit ( std::span< const std::span< const uint8_t > >  buffers,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Transmits data from multiple buffers in a single I2C transaction.

Performs a scatter-gather transmit, sending data from each buffer sequentially without intermediate stop conditions.

Parameters
buffersBuffers to transmit, in order.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 756 of file master.hpp.

References idfxx::timeout.

◆ try_transmit() [6/7]

result< void > idfxx::i2c::master_device::try_transmit ( std::span< const uint8_t data)
inline

Transmits data to the device.

Parameters
dataData to transmit.
Returns
Success, or an error.

Definition at line 694 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_transmit() [7/7]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_transmit ( std::span< const uint8_t data,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Transmits data to the device.

Parameters
dataData to transmit.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 739 of file master.hpp.

References idfxx::timeout.

◆ try_write_register() [1/8]

result< void > idfxx::i2c::master_device::try_write_register ( uint16_t  reg,
const uint8_t buf,
size_t  size 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
sizeNumber of bytes.
Returns
Success, or an error.

Definition at line 1199 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_write_register() [2/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_register ( uint16_t  reg,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
sizeNumber of bytes.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1214 of file master.hpp.

References idfxx::timeout.

◆ try_write_register() [3/8]

result< void > idfxx::i2c::master_device::try_write_register ( uint16_t  reg,
std::span< const uint8_t buf 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
Returns
Success, or an error.

Definition at line 1171 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_write_register() [4/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_register ( uint16_t  reg,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1186 of file master.hpp.

References idfxx::timeout.

◆ try_write_register() [5/8]

result< void > idfxx::i2c::master_device::try_write_register ( uint8_t  high,
uint8_t  low,
const uint8_t buf,
size_t  size 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
sizeNumber of bytes.
Returns
Success, or an error.

Definition at line 1341 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_write_register() [6/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_register ( uint8_t  high,
uint8_t  low,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
sizeNumber of bytes.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1357 of file master.hpp.

References idfxx::timeout.

◆ try_write_register() [7/8]

result< void > idfxx::i2c::master_device::try_write_register ( uint8_t  high,
uint8_t  low,
std::span< const uint8_t buf 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
Returns
Success, or an error.

Definition at line 1307 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_write_register() [8/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_register ( uint8_t  high,
uint8_t  low,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1322 of file master.hpp.

References idfxx::timeout.

◆ try_write_registers() [1/8]

result< void > idfxx::i2c::master_device::try_write_registers ( std::initializer_list< uint16_t registers,
const uint8_t buf,
size_t  size 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
Returns
Success, or an error.

Definition at line 1614 of file master.hpp.

◆ try_write_registers() [2/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_registers ( std::initializer_list< uint16_t registers,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1629 of file master.hpp.

References idfxx::timeout.

◆ try_write_registers() [3/8]

result< void > idfxx::i2c::master_device::try_write_registers ( std::initializer_list< uint16_t registers,
std::span< const uint8_t buf 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
Returns
Success, or an error.

Definition at line 1582 of file master.hpp.

◆ try_write_registers() [4/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_registers ( std::initializer_list< uint16_t registers,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1596 of file master.hpp.

References idfxx::timeout.

◆ try_write_registers() [5/8]

result< void > idfxx::i2c::master_device::try_write_registers ( std::span< const uint16_t registers,
const uint8_t buf,
size_t  size 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
Returns
Success, or an error.

Definition at line 1546 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_write_registers() [6/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_registers ( std::span< const uint16_t registers,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1561 of file master.hpp.

References idfxx::timeout.

◆ try_write_registers() [7/8]

result< void > idfxx::i2c::master_device::try_write_registers ( std::span< const uint16_t registers,
std::span< const uint8_t buf 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
Returns
Success, or an error.

Definition at line 1514 of file master.hpp.

References idfxx::i2c::DEFAULT_TIMEOUT.

◆ try_write_registers() [8/8]

template<typename Rep , typename Period >
result< void > idfxx::i2c::master_device::try_write_registers ( std::span< const uint16_t registers,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
timeoutMaximum time to wait for completion.
Returns
Success, or an error.

Definition at line 1528 of file master.hpp.

References idfxx::timeout.

◆ write_register() [1/8]

void idfxx::i2c::master_device::write_register ( uint16_t  reg,
const uint8_t buf,
size_t  size 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
sizeNumber of bytes.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1143 of file master.hpp.

References idfxx::unwrap().

◆ write_register() [2/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_register ( uint16_t  reg,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
sizeNumber of bytes.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1158 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ write_register() [3/8]

void idfxx::i2c::master_device::write_register ( uint16_t  reg,
std::span< const uint8_t buf 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1116 of file master.hpp.

References idfxx::unwrap().

◆ write_register() [4/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_register ( uint16_t  reg,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
regRegister address (16-bit, MSB first).
bufData to write.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1129 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ write_register() [5/8]

void idfxx::i2c::master_device::write_register ( uint8_t  high,
uint8_t  low,
const uint8_t buf,
size_t  size 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
sizeNumber of bytes.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1270 of file master.hpp.

References idfxx::unwrap().

◆ write_register() [6/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_register ( uint8_t  high,
uint8_t  low,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
sizeNumber of bytes.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1287 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ write_register() [7/8]

void idfxx::i2c::master_device::write_register ( uint8_t  high,
uint8_t  low,
std::span< const uint8_t buf 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1234 of file master.hpp.

References idfxx::unwrap().

◆ write_register() [8/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_register ( uint8_t  high,
uint8_t  low,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to a register.

Parameters
highHigh byte of register address.
lowLow byte of register address.
bufData to write.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1250 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ write_registers() [1/8]

void idfxx::i2c::master_device::write_registers ( std::initializer_list< uint16_t registers,
const uint8_t buf,
size_t  size 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1480 of file master.hpp.

◆ write_registers() [2/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_registers ( std::initializer_list< uint16_t registers,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1496 of file master.hpp.

References idfxx::timeout.

◆ write_registers() [3/8]

void idfxx::i2c::master_device::write_registers ( std::initializer_list< uint16_t registers,
std::span< const uint8_t buf 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1447 of file master.hpp.

◆ write_registers() [4/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_registers ( std::initializer_list< uint16_t registers,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1462 of file master.hpp.

References idfxx::timeout.

◆ write_registers() [5/8]

void idfxx::i2c::master_device::write_registers ( std::span< const uint16_t registers,
const uint8_t buf,
size_t  size 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1410 of file master.hpp.

References idfxx::unwrap().

◆ write_registers() [6/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_registers ( std::span< const uint16_t registers,
const uint8_t buf,
size_t  size,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
sizeNumber of bytes per register.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1426 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().

◆ write_registers() [7/8]

void idfxx::i2c::master_device::write_registers ( std::span< const uint16_t registers,
std::span< const uint8_t buf 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1377 of file master.hpp.

References idfxx::unwrap().

◆ write_registers() [8/8]

template<typename Rep , typename Period >
void idfxx::i2c::master_device::write_registers ( std::span< const uint16_t registers,
std::span< const uint8_t buf,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Writes data to multiple registers.

Parameters
registersRegister addresses.
bufData to write.
timeoutMaximum time to wait for completion.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled in menuconfig.
Exceptions
std::system_erroron error.

Definition at line 1392 of file master.hpp.

References idfxx::timeout, and idfxx::unwrap().


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