modm API documentation
|
#include <modm/architecture/interface/i2c_device.hpp>
Public Member Functions | |
I2cDevice (uint8_t address) | |
void | setAddress (uint8_t address) |
void | attachConfigurationHandler (I2c::ConfigurationHandler handler) |
modm::ResumableResult< bool > | ping () |
modm::ResumableResult< bool > | writeRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize) |
Starts a write-read transaction and waits until finished. | |
modm::ResumableResult< bool > | write (const uint8_t *buffer, std::size_t size) |
Starts a write transaction and waits until finished. | |
modm::ResumableResult< bool > | read (uint8_t *buffer, std::size_t size) |
Starts a write transaction and waits until finished. | |
Protected Member Functions | |
bool | startWriteRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize) |
Configures the transaction with a write/read operation and starts it. | |
bool | startWrite (const uint8_t *buffer, std::size_t size) |
Configures the transaction with a write operation and starts it. | |
bool | startRead (uint8_t *buffer, std::size_t size) |
Configures the transaction with a read operation and starts it. | |
bool | startTransaction () |
Starts the transaction with our own transaction object. | |
bool | startTransaction (modm::I2cTransaction *transaction) |
Starts the transaction with a separate transaction object. | |
bool | isTransactionRunning () |
bool | wasTransactionSuccessful () |
modm::ResumableResult< bool > | runTransaction () |
Starts our own transaction and waits until finished. | |
modm::ResumableResult< ReturnType > resumable | function (...) |
int8_t | getResumableDepth () const |
bool | isResumableRunning () const |
void | stopResumable () |
Force all resumable functions to stop running at the current nesting level. | |
Protected Attributes | |
Transaction | transaction |
Base class of an I2C Device.
This class provides functions for configuring the adapter and peripheral and starting transactions. It also provides a basic ping()
resumable function, which checks if the device responds to its address.
You need to provide the number of required nesting levels for your driver here. By default, 10 levels are chosen, which should be more than enough in any case.
You can choose to use your own custom I2c Transaction Adapter, by providing a class subclassed from an existing I2cAdapter or which implements the I2cTransaction interface manually.
I2cMaster | an I2cMaster conforming to the I2cMaster interface. |
NestingLevels | number of nesting levels required for your driver |
Transaction | a class conforming to the I2cTransaction interface. |
|
inline |
address | the slave address not yet shifted left (address < 128). |
|
inline |
Attaches a configuration handler, which is called before a transaction, whenever the configuration has to be changed.
|
inherited |
Run the resumable function.
You need to implement this method in you subclass yourself.
NestingError
if still running, <=NestingError
if it has finished.
|
inheritedinline |
|
inheritedinline |
true
if a resumable function is running at the current nesting level, else false
|
inlineprotected |
true
when transaction is busy.
|
inline |
true | device responds to address |
false | no device with address found |
|
inline |
Sets a new address of the slave device.
address | the slave address not yet shifted left (address < 128). |
|
inlineprotected |
true
when transaction did not return an error.