FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Generic Future that can be used to write to an I2C device register. More...
#include <fastarduino/i2c_device_utilities.h>
Public Member Functions | |
TWriteRegisterFuture (const ARG_TYPE &value=ARG_TYPE{}, future::FutureNotification notification=future::FutureNotification::NONE) | |
Create a TWriteRegisterFuture future. More... | |
Public Member Functions inherited from i2c::WriteRegisterFuture< MANAGER, T, FUNCTOR > | |
WriteRegisterFuture (uint8_t reg, const ARG_TYPE &value, future::FutureNotification notification=future::FutureNotification::NONE) | |
Create a WriteRegisterFuture future for a given device register reg . More... | |
Generic Future that can be used to write to an I2C device register.
Most I2C devices have registers, accessible by a byte address; register values may be one or more bytes long; these may be integral types or not. TWriteRegisterFuture can be used in any I2C device supporting class (subclass of i2c::I2CDevice
) in almost all situations where you need to write to a register, whatever its type. TWriteRegisterFuture supports conversion of argument passed to constructor to a transformed value that fits the device register, thanks to its use of functors. Standard functors are provided for e.g. endianness conversion, if the I2C device uses big endian (while ATmel MCU are little-endian). Typical usage is through using
statement as in the following snippet:
MANAGER | the type of I2C Manager used to handle I2C communication |
REGISTER | the address of the register to write in the I2C device |
T | the type of the register to write to |
FUNCTOR | the type of an adequate functor to transform the value passed to this future constructor to a more suitable value for the device register; defaults to functor::Identity<T> which does nothing. |
Definition at line 269 of file i2c_device_utilities.h.
|
inlineexplicit |
Create a TWriteRegisterFuture future.
This future can then be used to write a value to the register.
value | the value to write to the register in the I2C device |
notification | determines if and which notifications should be dispatched by this TWriteRegisterFuture; default is none. |
Definition at line 282 of file i2c_device_utilities.h.