|
modm API documentation
|
#include <modm/architecture/interface/i2c_transaction.hpp>
Public Typedefs | |
| using | ConfigurationHandler = void (*)() |
| The signature of the configuration function. | |
Public Types | |
| enum | DetachCause : uint8_t { DetachCause::NormalStop, DetachCause::ErrorCondition, DetachCause::FailedToAttach } |
| enum | TransactionState : uint8_t { TransactionState::Idle, TransactionState::Busy, TransactionState::Error } |
| State of a I2c Transaction. More... | |
| enum | Operation : uint8_t { Operation::Stop = 0, Operation::Restart = 1, Operation::Write = 2, Operation::Read = 3 } |
| All possible I2C Operations. More... | |
| enum | OperationAfterRead : uint8_t { OperationAfterRead::Stop = uint8_t(Operation::Stop), OperationAfterRead::Restart = uint8_t(Operation::Restart) } |
| Further operations after read operation. More... | |
| enum | OperationAfterStart : uint8_t { OperationAfterStart::Stop = uint8_t(Operation::Stop), OperationAfterStart::Write = uint8_t(Operation::Write), OperationAfterStart::Read = uint8_t(Operation::Read) } |
| Further operations after start operation. More... | |
| enum | OperationAfterWrite : uint8_t { OperationAfterWrite::Stop = uint8_t(Operation::Stop), OperationAfterWrite::Restart = uint8_t(Operation::Restart), OperationAfterWrite::Write = uint8_t(Operation::Write) } |
| Further operations after write operation. More... | |
Public Member Functions | |
| I2cReadTransaction (uint8_t address) | |
| bool | configurePing () |
| bool | configureWriteRead (const uint8_t *, std::size_t, uint8_t *, std::size_t) |
| bool | configureWrite (uint8_t *, std::size_t) |
| bool | configureRead (uint8_t *buffer, std::size_t size) |
| virtual bool | attaching () |
| virtual void | detaching (DetachCause cause) |
| TransactionState | getState () const |
| bool | isBusy () const |
| void | setAddress (uint8_t address) |
Static Public Member Functions | |
| template<class Scl > | |
| static void | resetDevices (uint32_t baudrate=100'000) |
Static Public Attributes | |
| static constexpr uint8_t | Read = 0x01 |
| Add the Read bit to the slave address. | |
| static constexpr uint8_t | Write = 0x00 |
| Add the Write bit to the slave address. | |
Protected Member Functions | |
| Starting | starting () override |
| Writing | writing () override |
| Reading | reading () override |
Protected Attributes | |
| std::size_t | size |
| uint8_t * | buffer |
| uint8_t | address |
| volatile TransactionState | state |
This class is an implementation of modm::I2cTransaction which, when passed to an i2c driver, performs the sequence: start - address - read - stop.
After initialization and performing operation this class remains holding references to passed buffers and may be reused again without reinitialization as long the passed buffers remain valid.
|
inheritedstrong |
This tells the I2cTransaction why it was detached
| Enum Values | Documentation |
|---|---|
| NormalStop | All operations finished normally. |
| ErrorCondition | A bus error occurred and the bus was reset. |
| FailedToAttach | The I2cTransaction failed to attach to the I2cMaster. |
|
inheritedstrong |
All possible I2C Operations.
I2C Operations that the I2cTransaction can give the master on callback
| Enum Values | Documentation |
|---|---|
| Stop | Generate a Stop Condition. |
| Restart | Generate a Restart. |
| Write | Write data to the slave. |
| Read | Read data from the slave. |
|
inheritedstrong |
|
inheritedstrong |
|
inheritedstrong |
Further operations after write operation.
| Enum Values | Documentation |
|---|---|
| Stop | Generate a Stop Condition. |
| Restart | Generate a Restart. |
| Write | Write data to the slave. |
|
inheritedstrong |
State of a I2c Transaction.
| Enum Values | Documentation |
|---|---|
| Idle | No error occurred, detached normally. |
| Busy | The transaction object is busy with data transfer. |
| Error | An error occurred, check the masters |
|
inheritedinlinevirtual |
|
inheritedinlinevirtual |
This is called when all transmissions finished and transaction object is about to be detached. The I2cMaster will not be free until this method returns.
| cause | specifies whether the detachment was expected (NormalStop), or a error occurred (ErrorCondition), which can, but does not need to be reacted upon. |
|
inheritedinline |
Busy while an I2C operation is ongoing. Reinitialization is not permitted during this phase.
|
inheritedinline |
true while adapter is busy
|
inlineoverrideprotectedvirtual |
This method is called before the I2cMaster begins a read operation.
Reading struct containing the read buffer and size and next operation Implements modm::I2cTransaction.
|
inheritedinlinestatic |
Reset all slave devices connected to an I2C bus.
During normal operation, I2C slave device may pull the SDA line low. However, if the master is reset during a transaction, the I2C clock may stop while the slave is outputting a low data bit and the slave will continue to hold this bit (forever, and ever and ever). The I2C master is then unable to generate a I2C start condition, since SDA is still held low by the slave device, resulting in a deadlock.
"You can always get it back to standby mode by allowing the SDA line to float high and give it 9 clocks. This assures that the device will not receive the acknowledge bit at the end the current byte and will abort the command and go to standby."
| Scl | The clock pin of the bus to be reset. |
|
inheritedinline |
| address | the slave address not yet shifted left (address < 128). |
|
inlineoverrideprotectedvirtual |
This method is called when the I2cMaster is ready to (re-)start an operation.
Starting struct containing slave address and the next operation Implements modm::I2cTransaction.
|
inlineoverrideprotectedvirtual |
This method is called before the I2cMaster begins a write operation.
Writing struct containing the write buffer and size and next operation Implements modm::I2cTransaction.