Pigweed
C/C++ API Reference
|
Public Member Functions | |
LinuxInitiator (int fd) | |
LinuxInitiator (const LinuxInitiator &)=delete | |
LinuxInitiator & | operator= (const LinuxInitiator &)=delete |
![]() | |
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) |
Static Public Member Functions | |
static Result< int > | OpenI2cBus (const char *bus_path) |
Private Member Functions | |
Status | DoTransferFor (span< const Message > messages, chrono::SystemClock::duration timeout) override |
Additional Inherited Members | |
![]() | |
enum class | Feature : int { kStandard = 0 , kTenBit = (1 << 0) , kNoStart = (1 << 1) } |
Defined set of supported i2c features. | |
Initiator interface implementation using the Linux userspace i2c-dev driver.
Takes exclusive control of an I2C bus device (ex. "/dev/i2c-0"). The user is responsible to open the device node prior to creating the initiator. The file descriptor is closed when the initiator object is destroyed.
The bus device must support the full I2C functionality. Users of the class are encouraged to use the OpenI2cBus
helper to ensure the bus is valid.
Access to the bus is guarded by an internal mutex, so this initiator can be safely used from multiple threads.
pw::i2c::LinuxInitiator::LinuxInitiator | ( | int | fd | ) |
Construct an instantiator using an open file descriptor. The file descriptor is closed during destruction.
[in] | fd | Valid file descriptor for an I2C device node. |
|
overrideprivatevirtual |
Implement pw::i2c::Initiator with the following additional requriements:
device_address
is a 7-bit address.messages
must be not empty. Otherwise, returns InvalidArgument.Reimplemented from pw::i2c::Initiator.
|
static |
Open an I2C bus and validate that full I2C functionality is supported.
[in] | bus_path | Path to the I2C bus device node. |
OK | The device node was opened successfully. |
InvalidArgument | Failed to open the device node or to validate I2C functionality. |