23#include <idfxx/intr_alloc>
29#include <frequency/frequency>
31#include <initializer_list>
57#if SOC_HP_I2C_NUM >= 2
60#if SOC_LP_I2C_NUM >= 1
75#if SOC_I2C_SUPPORT_APB
78#if SOC_I2C_SUPPORT_REF_TICK
81#if SOC_I2C_SUPPORT_XTAL
84#if SOC_I2C_SUPPORT_RTC
89#if SOC_LP_I2C_SUPPORTED
175#if SOC_LP_I2C_SUPPORTED
185#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
271 return _mux->try_lock();
309 template<
typename Rep,
typename Period>
311 return _scan_devices(std::chrono::ceil<std::chrono::milliseconds>(
timeout));
314#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
334 template<
typename Rep,
typename Period>
336 unwrap(_probe(address, std::chrono::ceil<std::chrono::milliseconds>(
timeout)));
357 template<
typename Rep,
typename Period>
359 return _probe(address, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
362#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
374 template<
typename Rep,
typename Period>
390 template<
typename Rep,
typename Period>
392 return _try_wait_all_done(std::chrono::ceil<std::chrono::milliseconds>(
timeout));
436 freq::hertz scl_speed{0};
438#if SOC_I2C_SUPPORT_10BIT_ADDR
441 bool disable_ack_check =
false;
444#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
536#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
553 template<
typename Rep,
typename Period>
573 template<
typename Rep,
typename Period>
575 if (_handle ==
nullptr) {
578 return _bus->try_probe(_address, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
581#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
609 template<std::convertible_to<std::span<const u
int8_t>>... Buffers>
610 requires(
sizeof...(Buffers) > 1)
637 template<
typename Rep,
typename Period>
638 void transmit(std::span<const uint8_t> data,
const std::chrono::duration<Rep, Period>&
timeout) {
654 template<
typename Rep,
typename Period>
681 template<
typename Rep,
typename Period>
708 template<std::convertible_to<std::span<const u
int8_t>>... Buffers>
709 requires(
sizeof...(Buffers) > 1)
711 std::array<std::span<const uint8_t>,
sizeof...(Buffers)>
arr{
buffers...};
712 return try_transmit(std::span<
const std::span<const uint8_t>>{
arr});
737 template<
typename Rep,
typename Period>
740 return try_transmit(data.data(), data.size(),
timeout);
754 template<
typename Rep,
typename Period>
757 return _try_multi_buffer_transmit(
buffers, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
781 template<
typename Rep,
typename Period>
784 return _try_transmit(
buf, size, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
787#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
813 template<
typename Rep,
typename Period>
844 template<
typename Rep,
typename Period>
847 return _try_change_address(
new_address, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
850#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
881#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
919 template<
typename Rep,
typename Period>
947 template<
typename Rep,
typename Period>
950 return _try_execute_operations(
ops, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
953#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
977 template<
typename Rep,
typename Period>
1003 template<
typename Rep,
typename Period>
1027 template<
typename Rep,
typename Period>
1050 template<
typename Rep,
typename Period>
1053 std::vector<uint8_t>
buf(size);
1054 return try_receive(
buf,
timeout).transform([&]() {
return buf; });
1078 template<
typename Rep,
typename Period>
1081 return _try_receive(
buf, size, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
1101 template<
typename Rep,
typename Period>
1106#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1128 template<
typename Rep,
typename Period>
1156 template<
typename Rep,
typename Period>
1184 template<
typename Rep,
typename Period>
1213 template<
typename Rep,
typename Period>
1218 const std::chrono::duration<Rep, Period>&
timeout
1220 return _try_write_register(
reg,
buf, size, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
1223#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1235 unwrap(try_write_register(high, low,
buf));
1249 template<
typename Rep,
typename Period>
1253 std::span<const uint8_t>
buf,
1254 const std::chrono::duration<Rep, Period>&
timeout
1271 unwrap(try_write_register(high, low,
buf, size));
1286 template<
typename Rep,
typename Period>
1292 const std::chrono::duration<Rep, Period>&
timeout
1321 template<
typename Rep,
typename Period>
1325 std::span<const uint8_t>
buf,
1326 const std::chrono::duration<Rep, Period>&
timeout
1328 return try_write_register(high, low,
buf.data(),
buf.size(),
timeout);
1356 template<
typename Rep,
typename Period>
1362 const std::chrono::duration<Rep, Period>&
timeout
1364 return _try_write_register(high, low,
buf, size, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
1367#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1391 template<
typename Rep,
typename Period>
1394 std::span<const uint8_t>
buf,
1395 const std::chrono::duration<Rep, Period>&
timeout
1425 template<
typename Rep,
typename Period>
1430 const std::chrono::duration<Rep, Period>&
timeout
1461 template<
typename Rep,
typename Period>
1463 std::initializer_list<uint16_t>
registers,
1464 std::span<const uint8_t>
buf,
1465 const std::chrono::duration<Rep, Period>&
timeout
1495 template<
typename Rep,
typename Period>
1497 std::initializer_list<uint16_t>
registers,
1500 const std::chrono::duration<Rep, Period>&
timeout
1527 template<
typename Rep,
typename Period>
1530 std::span<const uint8_t>
buf,
1531 const std::chrono::duration<Rep, Period>&
timeout
1560 template<
typename Rep,
typename Period>
1565 const std::chrono::duration<Rep, Period>&
timeout
1567 return _try_write_registers(
registers,
buf, size, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
1595 template<
typename Rep,
typename Period>
1597 std::initializer_list<uint16_t>
registers,
1598 std::span<const uint8_t>
buf,
1599 const std::chrono::duration<Rep, Period>&
timeout
1615 return try_write_registers(std::span<const uint16_t>{
registers.begin(),
registers.size()},
buf, size);
1628 template<
typename Rep,
typename Period>
1630 std::initializer_list<uint16_t>
registers,
1633 const std::chrono::duration<Rep, Period>&
timeout
1638#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1651 return unwrap(try_read_register(
reg, size));
1666 template<
typename Rep,
typename Period>
1693 template<
typename Rep,
typename Period>
1721 template<
typename Rep,
typename Period>
1748 template<
typename Rep,
typename Period>
1751 std::vector<uint8_t>
buf(size);
1752 return try_read_register(
reg,
buf,
timeout).transform([&]() {
return buf; });
1775 template<
typename Rep,
typename Period>
1804 template<
typename Rep,
typename Period>
1807 return _try_read_register(
reg,
buf, size, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
1810#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1824 return unwrap(try_read_register(high, low, size));
1840 template<
typename Rep,
typename Period>
1858 unwrap(try_read_register(high, low,
buf, size));
1873 template<
typename Rep,
typename Period>
1879 const std::chrono::duration<Rep, Period>&
timeout
1908 template<
typename Rep,
typename Period>
1911 std::vector<uint8_t>
buf(size);
1912 return try_read_register(high, low,
buf,
timeout).transform([&]() {
return buf; });
1938 template<
typename Rep,
typename Period>
1942 std::span<uint8_t>
buf,
1943 const std::chrono::duration<Rep, Period>&
timeout
1945 return try_read_register(high, low,
buf.data(),
buf.size(),
timeout);
1973 template<
typename Rep,
typename Period>
1979 const std::chrono::duration<Rep, Period>&
timeout
1981 return _try_read_register(high, low,
buf, size, std::chrono::ceil<std::chrono::milliseconds>(
timeout));
2035#if SOC_HP_I2C_NUM >= 2
2036 case i2c::port::i2c1:
2039#if SOC_LP_I2C_NUM >= 1
2040 case i2c::port::lp_i2c0:
2044 return "unknown(" + std::to_string(
static_cast<int>(
p)) +
")";
2050#include "sdkconfig.h"
2051#ifdef CONFIG_IDFXX_STD_FORMAT
2057struct formatter<
idfxx::i2c::port> {
2058 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
2060 template<
typename FormatContext>
2063 return std::copy(s.begin(), s.end(), ctx.out());
static constexpr gpio nc()
Returns a GPIO representing "not connected".
I2C master bus controller with thread-safe device access.
master_bus(enum port port, gpio sda, gpio scl, freq::hertz frequency)
Creates a new I2C master bus with default settings.
result< void > try_probe(uint16_t address) const
Probes for a device at the specified address.
std::vector< uint8_t > scan_devices() const
Scans for devices on the bus.
enum port port() const
Returns the I2C port.
std::vector< uint8_t > scan_devices(const std::chrono::duration< Rep, Period > &timeout) const
Scans for devices on the bus.
void probe(uint16_t address, const std::chrono::duration< Rep, Period > &timeout) const
Probes for a device at the specified address.
master_bus & operator=(const master_bus &)=delete
static result< master_bus > make(enum port port, gpio sda, gpio scl, freq::hertz frequency)
Creates a new I2C master bus with default settings.
void wait_all_done(const std::chrono::duration< Rep, Period > &timeout) const
Waits for all pending asynchronous operations on the bus to complete.
result< void > try_probe(uint16_t address, const std::chrono::duration< Rep, Period > &timeout) const
Probes for a device at the specified address.
static result< master_bus > make(enum port port, const struct config &config)
Creates a new I2C master bus.
i2c_master_bus_handle_t handle() const
Returns the underlying ESP-IDF bus handle.
freq::hertz frequency() const
Returns the bus clock frequency in Hz.
void unlock() const
Releases exclusive access to the bus.
master_bus(const master_bus &)=delete
master_bus(master_bus &&other) noexcept
bool try_lock() const noexcept
Tries to acquire exclusive access without blocking.
master_bus(enum port port, const struct config &config)
Creates a new I2C master bus.
void probe(uint16_t address) const
Probes for a device at the specified address.
result< void > try_wait_all_done(const std::chrono::duration< Rep, Period > &timeout) const
Waits for all pending asynchronous operations on the bus to complete.
void lock() const
Acquires exclusive access to the bus.
master_bus & operator=(master_bus &&other) noexcept
I2C device at a specific address with register operations.
void transmit(const uint8_t *buf, size_t size)
Transmits data to the device.
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_probe() const
Probes the device.
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.
void read_register(uint8_t high, uint8_t low, uint8_t *buf, size_t size)
Reads data from a register.
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.
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.
result< std::vector< uint8_t > > try_receive(size_t size, const std::chrono::duration< Rep, Period > &timeout)
Receives data from the device.
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.
void write_register(uint8_t high, uint8_t low, std::span< const uint8_t > buf)
Writes data to a register.
result< void > try_execute_operations(std::span< const operation > ops)
Executes a custom sequence of I2C operations.
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_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_register(uint16_t reg, const uint8_t *buf, size_t size)
Writes data to a register.
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.
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.
std::vector< uint8_t > read_register(uint16_t reg, size_t size, const std::chrono::duration< Rep, Period > &timeout)
Reads data from a register.
master_device(master_bus &bus, uint16_t address)
Creates a new device on the specified bus.
result< std::vector< uint8_t > > try_read_register(uint16_t reg, size_t size)
Reads data from a register.
void register_event_callbacks(std::move_only_function< bool() const > on_trans_done)
Registers a callback for transaction-done events.
void write_registers(std::initializer_list< uint16_t > registers, std::span< const uint8_t > buf)
Writes data to multiple registers.
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.
void write_register(uint16_t reg, std::span< const uint8_t > buf)
Writes data to a register.
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.
void 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_write_registers(std::initializer_list< uint16_t > registers, const uint8_t *buf, size_t size)
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.
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.
result< void > try_write_registers(std::span< const uint16_t > registers, const uint8_t *buf, size_t size)
Writes data to multiple registers.
result< void > try_read_register(uint16_t reg, std::span< uint8_t > buf)
Reads data from 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.
void transmit(std::span< const uint8_t > data, const std::chrono::duration< Rep, Period > &timeout)
Transmits data to the device.
void receive(uint8_t *buf, size_t size)
Receives data from the device.
result< void > try_register_event_callbacks(std::move_only_function< bool() const > on_trans_done)
Registers a callback for transaction-done events.
void probe() const
Probes the device.
result< void > try_read_register(uint8_t high, uint8_t low, uint8_t *buf, size_t size)
Reads data from a register.
void receive(uint8_t *buf, 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, const std::chrono::duration< Rep, Period > &timeout)
Receives data from the device.
void probe(const std::chrono::duration< Rep, Period > &timeout) const
Probes the device.
result< std::vector< uint8_t > > try_receive(size_t size)
Receives data from the device.
result< void > try_write_register(uint8_t high, uint8_t low, std::span< const uint8_t > buf)
Writes data to a register.
result< std::vector< uint8_t > > try_read_register(uint8_t high, uint8_t low, size_t size)
Reads data from a register.
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.
void execute_operations(std::span< const operation > ops)
Executes a custom sequence of I2C operations.
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.
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< void > try_read_register(uint8_t high, uint8_t low, std::span< uint8_t > buf)
Reads data from a register.
master_device(const master_device &)=delete
std::vector< uint8_t > read_register(uint8_t high, uint8_t low, size_t size)
Reads data from a register.
result< void > try_transmit(Buffers... buffers)
Transmits data from multiple buffers in a single I2C transaction.
result< void > try_write_register(uint16_t reg, std::span< const uint8_t > buf)
Writes data to a register.
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.
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.
void transmit(std::span< const uint8_t > data)
Transmits data to the device.
master_device(master_device &&other) noexcept
void write_registers(std::span< const uint16_t > registers, std::span< const uint8_t > buf)
Writes data to multiple registers.
static result< master_device > make(master_bus &bus, uint16_t address, const struct config &config)
Creates a new device on the specified bus.
void write_registers(std::initializer_list< uint16_t > registers, const uint8_t *buf, size_t size)
Writes data to multiple registers.
master_device(master_bus &bus, uint16_t address, const struct config &config)
Creates a new device on the specified bus.
void 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_transmit(std::span< const std::span< const uint8_t > > buffers)
Transmits data from multiple buffers in a single I2C transaction.
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.
uint16_t address() const
Returns the device address.
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.
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< void > try_transmit(const uint8_t *buf, size_t size)
Transmits data to the device.
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.
void change_address(uint16_t new_address)
Changes the I2C address used for subsequent operations.
result< void > try_receive(std::span< uint8_t > buf, 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.
i2c_master_dev_handle_t handle() const
Returns the underlying ESP-IDF device handle.
void read_register(uint16_t reg, std::span< uint8_t > buf)
Reads data from a register.
void transmit(std::span< const std::span< const uint8_t > > buffers)
Transmits data from multiple buffers in a single I2C transaction.
void transmit(const uint8_t *buf, size_t size, const std::chrono::duration< Rep, Period > &timeout)
Transmits data to the device.
result< void > try_write_register(uint16_t reg, const uint8_t *buf, size_t size)
Writes data to a register.
result< void > try_receive(std::span< uint8_t > buf)
Receives data from the device.
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.
result< void > try_read_register(uint16_t reg, uint8_t *buf, size_t size)
Reads data from a register.
result< void > try_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.
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.
std::vector< uint8_t > receive(size_t size)
Receives data from the device.
std::vector< uint8_t > read_register(uint16_t reg, size_t size)
Reads data from a register.
result< void > try_change_address(uint16_t new_address)
Changes the I2C address used for subsequent operations.
result< void > try_execute_operations(std::span< const operation > ops, const std::chrono::duration< Rep, Period > &timeout)
Executes a custom sequence of I2C operations.
result< void > try_write_registers(std::span< const uint16_t > registers, std::span< const uint8_t > buf)
Writes data to multiple registers.
result< void > try_transmit(std::span< const uint8_t > data, const std::chrono::duration< Rep, Period > &timeout)
Transmits data to the device.
std::vector< uint8_t > receive(size_t size, const std::chrono::duration< Rep, Period > &timeout)
Receives data from the device.
result< void > try_write_registers(std::initializer_list< uint16_t > registers, std::span< const uint8_t > buf)
Writes data to multiple registers.
master_device & operator=(const master_device &)=delete
master_device & operator=(master_device &&other) noexcept
void write_register(uint8_t high, uint8_t low, const uint8_t *buf, size_t size)
Writes data to a register.
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.
result< void > try_probe(const std::chrono::duration< Rep, Period > &timeout) const
Probes the device.
void receive(std::span< uint8_t > buf)
Receives data from the device.
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 read_register(uint16_t reg, uint8_t *buf, size_t size)
Reads data from a register.
result< void > try_change_address(uint16_t new_address, const std::chrono::duration< Rep, Period > &timeout)
Changes the I2C address used for subsequent operations.
master_bus & bus() const
Returns the parent bus.
void change_address(uint16_t new_address, const std::chrono::duration< Rep, Period > &timeout)
Changes the I2C address used for subsequent operations.
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_read_register(uint16_t reg, std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
Reads data from a register.
static result< master_device > make(master_bus &bus, uint16_t address)
Creates a new device on the specified bus.
void receive(std::span< uint8_t > buf, const std::chrono::duration< Rep, Period > &timeout)
Receives data from the device.
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
operation_command
I2C operation command type for custom transaction sequences.
struct i2c_master_bus_t * i2c_master_bus_handle_t
struct i2c_master_dev_t * i2c_master_dev_handle_t
ack_value
ACK value sent after a read operation.
clk_source
I2C master bus clock source.
port
I2C port identifiers.
static constexpr auto DEFAULT_TIMEOUT
Default timeout for I2C operations.
@ start
Send START or repeated-START condition.
@ read
Read data from the bus.
@ stop
Send STOP condition.
@ write
Write data to the bus.
@ ack
Acknowledge — request more data.
@ nack
Not-acknowledge — signal end of read.
@ default_source
Default clock source for the target.
I2C master driver classes.
intr_level
Hardware interrupt priority levels.
constexpr std::unexpected< std::error_code > error(E e) noexcept
Creates an unexpected error from an error code enum.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
@ invalid_state
Invalid state.
@ timeout
Operation timed out.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
I2C master bus configuration.
freq::hertz frequency
Clock frequency in Hz.
bool allow_pd
Allow powering down the bus during light sleep.
idfxx::gpio scl
GPIO pin for the SCL line.
idfxx::gpio sda
GPIO pin for the SDA line.
size_t trans_queue_depth
Depth of internal transfer queue for asynchronous transactions.
uint8_t glitch_ignore_cnt
Glitch filter count (0-7). Higher values filter more noise.
bool enable_internal_pullup
Enable internal pull-up resistors on SDA and SCL.
I2C device configuration.
Describes a single operation in a custom I2C transaction sequence.
bool ack_check
(write) Whether to check for ACK.
operation_command command
The operation to perform.
ack_value ack_type
(read) ACK value to send after reading.
std::span< const uint8_t > write_data
(write) Data to send.
std::span< uint8_t > read_data
(read) Buffer to receive into.