Pigweed
 
Loading...
Searching...
No Matches
pw::i2c::Device Class Reference

#include <device.h>

Inheritance diagram for pw::i2c::Device:
pw::i2c::RegisterDevice

Public Member Functions

constexpr Device (Initiator &initiator, Address device_address)
 
 Device (const Device &)=delete
 
 Device (Device &&)=default
 
Status TransferFor (span< const Message > messages, chrono::SystemClock::duration timeout)
 Wraps pw::i2c::Initiator::TransferFor.
 
Status WriteReadFor (ConstByteSpan tx_buffer, ByteSpan rx_buffer, chrono::SystemClock::duration timeout)
 Wraps pw::i2c::Initiator::WriteReadFor.
 
Status WriteReadFor (const void *tx_buffer, size_t tx_size_bytes, void *rx_buffer, size_t rx_size_bytes, chrono::SystemClock::duration timeout)
 
Status WriteFor (ConstByteSpan tx_buffer, chrono::SystemClock::duration timeout)
 Wraps pw::i2c::Initiator::WriteFor.
 
Status WriteFor (const void *tx_buffer, size_t tx_size_bytes, chrono::SystemClock::duration timeout)
 
Status ReadFor (ByteSpan rx_buffer, chrono::SystemClock::duration timeout)
 Wraps pw::i2c::Initiator::ReadFor.
 
Status ReadFor (void *rx_buffer, size_t rx_size_bytes, chrono::SystemClock::duration timeout)
 
Status ProbeFor (chrono::SystemClock::duration timeout)
 Wraps pw::i2c::Initiator::ProbeDeviceFor.
 

Detailed Description

The common interface for generic I2C devices. Reads and writes arbitrary chunks of data over an I2C bus to an I2C device. This class contains pw::i2c::Address and wraps the pw::i2c::Initiator API. Only works with devices that have a single device address.

pw::i2c::Device is intended to represent ownership of a specific responder. Individual transactions are atomic but there's no synchronization for sequences of transactions. Therefore, shared access should be faciliated with higher-level application abstractions. To help enforce this, pw::i2c::Device instances are only movable and not copyable.

Constructor & Destructor Documentation

◆ Device()

constexpr pw::i2c::Device::Device ( Initiator initiator,
Address  device_address 
)
inlineconstexpr

Creates a pw::i2c::Device instance.

The address for the I2C device is set in this constructor and can't be modified later.

Parameters
[in]initiatorA reference to a pw::i2c::Initiator instance.
[in]device_addressThe address of the I2C device.
Returns
A pw::i2c::Device instance.

Member Function Documentation

◆ ReadFor()

Status pw::i2c::Device::ReadFor ( void *  rx_buffer,
size_t  rx_size_bytes,
chrono::SystemClock::duration  timeout 
)
inline

Wraps the variation of pw::i2c::Initiator::ReadFor that accepts an explicit size for the amount of bytes to read from the device.

◆ WriteFor()

Status pw::i2c::Device::WriteFor ( const void *  tx_buffer,
size_t  tx_size_bytes,
chrono::SystemClock::duration  timeout 
)
inline

Wraps the variation of pw::i2c::Initiator::WriteFor that accepts an explicit size for the amount of bytes to write to the device.

◆ WriteReadFor()

Status pw::i2c::Device::WriteReadFor ( const void *  tx_buffer,
size_t  tx_size_bytes,
void *  rx_buffer,
size_t  rx_size_bytes,
chrono::SystemClock::duration  timeout 
)
inline

Wraps the variation of pw::i2c::Initiator::WriteReadFor that accepts explicit sizes for the amount of bytes to write to the device and read from the device.


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