|
| | I2C (I2C_TypeDef *i2c, const miosix::GpioPin &scl, const miosix::GpioPin &sda) |
| | Constructor for the I2C high-level driver.
|
| |
| | I2C (const I2C &)=delete |
| |
| I2C & | operator= (const I2C &)=delete |
| |
| | I2C (I2C &&)=delete |
| |
| I2C & | operator= (I2C &&)=delete |
| |
| bool | read (const I2CDriver::I2CSlaveConfig &slaveConfig, void *buffer, const size_t nBytes) |
| | Non blocking read operation to read nBytes.
|
| |
| bool | write (const I2CDriver::I2CSlaveConfig &slaveConfig, const void *buffer, const size_t nBytes) |
| | Non blocking write operation to write nBytes.
|
| |
| bool | readRegister (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, uint8_t ®isterContent) |
| | Non blocking operation to read an 8-bit register from a slave.
|
| |
| bool | readRegister16 (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, uint16_t ®isterContent) |
| | Non blocking operation to read a 16-bit register from a slave.
|
| |
| bool | readRegister24 (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, uint32_t ®isterContent) |
| | Non blocking operation to read a 24-bit register from a slave.
|
| |
| bool | readRegister32 (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, uint32_t ®isterContent) |
| | Non blocking operation to read a 32-bit register from a slave.
|
| |
| bool | writeRegister (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, const uint8_t registerContent) |
| | Non blocking operation to write an 8-bit register from a slave.
|
| |
| bool | writeRegister16 (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, const uint16_t registerContent) |
| | Non blocking operation to write a 16-bit register from a slave.
|
| |
| bool | writeRegister24 (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, const uint32_t registerContent) |
| | Non blocking operation to write a 24-bit register from a slave.
|
| |
| bool | writeRegister32 (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, const uint32_t registerContent) |
| | Non blocking operation to write a 32-bit register from a slave.
|
| |
| bool | readFromRegister (const I2CDriver::I2CSlaveConfig &slaveConfig, const uint8_t registerAddress, void *buffer, const size_t nBytes) |
| | Non blocking operation to read n-bytes from register from a slave.
|
| |
| bool | probe (const I2CDriver::I2CSlaveConfig &slaveConfig) |
| | Non blocking operation to check if a slave is available.
|
| |
| uint16_t | getLastError () |
| | Returns the last errors happened in the communication.
|
| |
High level driver for the I2C peripherals.
This driver is NOT thread safe. It implements high level functionalities such as:
- Automatic bus recovery before each operation;
- Method in order to read a one-byte register without issuing a stop condition (unique transaction).
Definition at line 39 of file I2C.h.
Non blocking read operation to read nBytes.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| buffer | Data buffer where to store the data read. |
| nBytes | Number of bytes to read. |
- Returns
- True if the read is successful, false otherwise.
Definition at line 34 of file I2C.cpp.
| bool Boardcore::I2C::readFromRegister |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
void * |
buffer, |
|
|
const size_t |
nBytes |
|
) |
| |
Non blocking operation to read n-bytes from register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| buffer | Data buffer where to store the data read. |
| nBytes | Number of bytes to read. |
- Returns
- True if the read is successful, false otherwise.
Definition at line 189 of file I2C.cpp.
| bool Boardcore::I2C::readRegister |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
uint8_t & |
registerContent |
|
) |
| |
Non blocking operation to read an 8-bit register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | Where to store the content of the register. |
- Returns
- True if the read is successful, false otherwise.
Definition at line 48 of file I2C.cpp.
| bool Boardcore::I2C::readRegister16 |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
uint16_t & |
registerContent |
|
) |
| |
Non blocking operation to read a 16-bit register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | Where to store the content of the register. |
- Returns
- True if the read is successful, false otherwise.
Definition at line 56 of file I2C.cpp.
| bool Boardcore::I2C::readRegister24 |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
uint32_t & |
registerContent |
|
) |
| |
Non blocking operation to read a 24-bit register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | Where to store the content of the register. |
- Returns
- True if the read is successful, false otherwise.
Definition at line 73 of file I2C.cpp.
| bool Boardcore::I2C::readRegister32 |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
uint32_t & |
registerContent |
|
) |
| |
Non blocking operation to read a 32-bit register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | Where to store the content of the register. |
- Returns
- True if the read is successful, false otherwise.
Definition at line 91 of file I2C.cpp.
Non blocking write operation to write nBytes.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| buffer | Data buffer where to read the data to send. |
| nBytes | Number of bytes to send. |
- Returns
- True if the write is successful, false otherwise.
Definition at line 41 of file I2C.cpp.
| bool Boardcore::I2C::writeRegister |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
const uint8_t |
registerContent |
|
) |
| |
Non blocking operation to write an 8-bit register from a slave.
This method, if necessary, flushes the bus before the write operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | The content to write on the register. |
- Returns
- True if the write is successful, false otherwise.
Definition at line 111 of file I2C.cpp.
| bool Boardcore::I2C::writeRegister16 |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
const uint16_t |
registerContent |
|
) |
| |
Non blocking operation to write a 16-bit register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | The content to write on the register. |
- Returns
- True if the write is successful, false otherwise.
Definition at line 120 of file I2C.cpp.
| bool Boardcore::I2C::writeRegister24 |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
const uint32_t |
registerContent |
|
) |
| |
Non blocking operation to write a 24-bit register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | The content to write on the register. |
- Returns
- True if the write is successful, false otherwise.
Definition at line 141 of file I2C.cpp.
| bool Boardcore::I2C::writeRegister32 |
( |
const I2CDriver::I2CSlaveConfig & |
slaveConfig, |
|
|
const uint8_t |
registerAddress, |
|
|
const uint32_t |
registerContent |
|
) |
| |
Non blocking operation to write a 32-bit register from a slave.
This method, if necessary, flushes the bus before the read operation is performed. In case of an error during the communication, this method returns false immediately.
- Warning
- Check always if the operation succeeded or not!
- Parameters
-
| slaveConfig | The configuration struct of the slave device. |
| registerAddress | Byte that represents the address of the register. |
| registerContent | The content to write on the register. |
- Returns
- True if the write is successful, false otherwise.
Definition at line 164 of file I2C.cpp.