C/C++ API Reference
Loading...
Searching...
No Matches
pw::i2c::Initiator Class Reference

Overview

The common, base driver interface for initiating thread-safe transactions with devices on an I2C bus. Other documentation may call this style of interface an I2C "master", "central", or "controller".

pw::i2c::Initiator isn't required to support 10-bit addressing. If only 7-bit addressing is supported, pw::i2c::Initiator fails a runtime assertion if given a Message with the kTenBitAddress flag, or when given an address that is out of 7-bit address range.

The implementer of TransferFor() (or DoWriteReadFor()) is responsible for ensuring thread safety and enabling functionality such as initialization, configuration, enabling and disabling, unsticking SDA, and detecting device address registration collisions.

Note
pw::i2c::Initiator uses internal synchronization, so it's safe to initiate transactions from multiple threads. Each call to this class will be executed in a single bus transaction using repeated starts.

Furthermore, devices may require specific sequences of transactions, and application logic must provide the synchronization to execute these sequences correctly.

Inheritance diagram for pw::i2c::Initiator:
pw::i2c::GmockInitiator pw::i2c::LinuxInitiator pw::i2c::MockInitiator pw::i2c::MockMessageInitiator

Public Types

enum class  Feature : int { kStandard = 0 , kTenBit = (1 << 0) , kNoStart = (1 << 1) }
 Defined set of supported i2c features.
 

Public Member Functions

constexpr Initiator ()
 
constexpr Initiator (Feature supported_features)
 
Status WriteReadFor (Address device_address, ConstByteSpan tx_buffer, ByteSpan rx_buffer, chrono::SystemClock::duration timeout)
 
Status TransferFor (span< const Message > messages, chrono::SystemClock::duration timeout)
 
Status WriteReadFor (Address device_address, const void *tx_buffer, size_t tx_size_bytes, void *rx_buffer, size_t rx_size_bytes, chrono::SystemClock::duration timeout)
 
Status WriteFor (Address device_address, ConstByteSpan tx_buffer, chrono::SystemClock::duration timeout)
 
Status WriteFor (Address device_address, const void *tx_buffer, size_t tx_size_bytes, chrono::SystemClock::duration timeout)
 
Status ReadFor (Address device_address, ByteSpan rx_buffer, chrono::SystemClock::duration timeout)
 
Status ReadFor (Address device_address, void *rx_buffer, size_t rx_size_bytes, chrono::SystemClock::duration timeout)
 
Status ProbeDeviceFor (Address device_address, chrono::SystemClock::duration timeout)
 

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