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< void > try_probe () const
 Probes the device.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_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< void > try_transmit (Buffers... buffers)
 Transmits data from multiple buffers in a single I2C transaction.
 
result< void > try_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< void > try_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< void > try_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< void > try_transmit (const uint8_t *buf, size_t size)
 Transmits data to the device.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_change_address (uint16_t new_address)
 Changes the I2C address used for subsequent operations.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_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< void > try_execute_operations (std::span< const operation > ops)
 Executes a custom sequence of I2C operations.
 
template<typename Rep , typename Period >
result< void > try_execute_operations (std::span< const operation > ops, const std::chrono::duration< Rep, Period > &timeout)
 Executes a custom sequence of I2C operations.
 
std::vector< uint8_t > receive (size_t size)
 Receives data from the device.
 
template<typename Rep , typename Period >
std::vector< uint8_t > receive (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< void > try_receive (uint8_t *buf, size_t size)
 Receives data from the device.
 
template<typename Rep , typename Period >
result< void > try_receive (uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
 Receives data from the device.
 
result< void > try_receive (std::span< uint8_t > buf)
 Receives data from the device.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_write_register (uint16_t reg, std::span< const uint8_t > buf)
 Writes data to a register.
 
template<typename Rep , typename Period >
result< void > try_write_register (uint16_t reg, std::span< const uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Writes data to a register.
 
result< void > try_write_register (uint16_t reg, const uint8_t *buf, size_t size)
 Writes data to a register.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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< void > try_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_t > read_register (uint16_t reg, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
std::vector< uint8_t > read_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< void > try_read_register (uint16_t reg, std::span< uint8_t > buf)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< void > try_read_register (uint16_t reg, std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
 Reads data from a register.
 
result< void > try_read_register (uint16_t reg, uint8_t *buf, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< void > try_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_t > read_register (uint8_t high, uint8_t low, size_t size)
 Reads data from a register.
 
template<typename Rep , typename Period >
std::vector< uint8_t > read_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< void > try_read_register (uint8_t high, uint8_t low, std::span< uint8_t > buf)
 Reads data from a register.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_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< void > try_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. A moved-from object must not be used: any operation other than destruction or assignment is undefined behavior.

Definition at line 420 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:420
master_bus & bus() const
Returns the parent bus.
Definition master.hpp:524

◆ 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 533 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 524 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 798 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 813 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;
uint8_t buf[4];
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 907 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 919 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 530 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 542 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 553 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 1649 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 1667 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 1680 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 1693 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 1707 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 1721 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 1822 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 1841 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 1856 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 1873 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 963 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 977 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 1015 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 1027 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 990 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 1003 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 862 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 610 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 668 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 681 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 625 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 655 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 589 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 637 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 828 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 845 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 934 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 948 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 563 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 573 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 1734 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 1749 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 1762 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 1776 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 1789 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 1805 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 1893 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 1909 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 1923 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 1938 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 1957 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 1973 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 1039 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 1051 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 1090 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 1101 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 1064 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 1079 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 709 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 767 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 782 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 724 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 755 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 693 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 738 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 1198 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 1213 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 1170 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 1185 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 1340 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 1356 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 1306 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 1321 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 1613 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 1628 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 1581 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 1595 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 1545 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 1560 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 1513 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 1527 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 1142 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 1157 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 1115 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 1128 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 1269 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 1286 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 1233 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 1249 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 1479 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 1495 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 1446 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 1461 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 1409 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 1425 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 1376 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 1391 of file master.hpp.

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


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