oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ove::I2c Class Reference

RAII wrapper around an oveRTOS I2C bus controller. More...

#include <i2c.hpp>

Public Member Functions

 I2c (const struct ove_i2c_cfg &cfg)
 Construct and initialise the I2C bus from cfg.
 
 I2c (const I2c &)=delete
 
I2coperator= (const I2c &)=delete
 
 I2c (I2c &&o) noexcept
 Move constructor — transfers handle; source becomes empty.
 
I2coperator= (I2c &&o) noexcept
 Move-assignment — destroys current bus, then takes o's handle.
 
Result< void > write (uint16_t addr, const void *data, size_t len, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Write len bytes to slave addr.
 
Result< void > read (uint16_t addr, void *buf, size_t len, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Read len bytes from slave addr into buf.
 
Result< void > write_read (uint16_t addr, const void *tx, size_t tx_len, void *rx, size_t rx_len, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Combined write-then-read transaction with a repeated start.
 
Result< void > reg_write (uint16_t addr, uint8_t reg, const void *data, size_t len, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Write len bytes to register reg on slave addr.
 
Result< void > reg_read (uint16_t addr, uint8_t reg, void *buf, size_t len, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Read len bytes from register reg on slave addr.
 
Result< void > probe (uint16_t addr, std::chrono::nanoseconds timeout=wait_forever) noexcept
 Probe slave addr — empty Result<void> if the device ACKs.
 
ove_i2c_t handle () const
 Returns the underlying C handle.
 

Detailed Description

RAII wrapper around an oveRTOS I2C bus controller.

Not copyable. Move-only when heap allocation is enabled.

Constructor & Destructor Documentation

◆ I2c()

ove::I2c::I2c ( const struct ove_i2c_cfg &  cfg)
inlineexplicit

Construct and initialise the I2C bus from cfg.

Parameters
[in]cfgBus configuration (pins, clock, mode).

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