Linux userspace implementation for pw_i2c. Main docs: https://pigweed.dev/pw_i2c_linux.
◆ DoTransferFor()
Implement pw::i2c::Initiator with the following additional requriements:
- Asserts that
device_address
is a 7-bit address.
messages
must be not empty. Otherwise, returns InvalidArgument.
- Note
- The timeout is used both for getting an exclusive lock on the initiator and for getting exclusive use of a multi-controller bus. If the timeout is zero or negative, the transaction will only execute if there is no contention at either level.
Reimplemented from pw::i2c::Initiator.
◆ LinuxInitiator()
pw::i2c::LinuxInitiator::LinuxInitiator |
( |
int |
fd | ) |
|
Construct an instantiator using an open file descriptor. The file descriptor is closed during destruction.
- Parameters
-
[in] | fd | Valid file descriptor for an I2C device node. |
◆ OpenI2cBus()
static Result< int > pw::i2c::LinuxInitiator::OpenI2cBus |
( |
const char * |
bus_path | ) |
|
|
static |
Open an I2C bus and validate that full I2C functionality is supported.
- Parameters
-
[in] | bus_path | Path to the I2C bus device node. |
- Return values
-
OK | The device node was opened successfully. |
InvalidArgument | Failed to open the device node or to validate I2C functionality. |
- Returns
- The open file descriptor on success.