|
HRI board firmware
v2.1
Microcontroller firmware of the board used during the HRI labs.
|
Driver for the I2C bus communication peripheral. More...
Functions | |
| void | i2c_Init (void) |
| Initializes the I2C bus. More... | |
| void | i2c_WriteRegister (uint8_t slaveAddress, uint8_t registerAddress, uint8_t registerValue, bool *ok) |
| Writes a 8-bit value to a register. More... | |
| void | i2c_WriteMultiBytesRegister (uint8_t slaveAddress, uint8_t registerAddress, uint8_t const *registerValue, uint8_t registerSize, bool *ok) |
| Writes several bytes to a register. More... | |
| uint8_t | i2c_ReadRegister (uint8_t slaveAddress, uint8_t registerAddress, bool *ok) |
| Reads a 8-bit value from a register. More... | |
| void | i2c_ReadMultiBytesRegister (uint8_t slaveAddress, uint8_t registerAddress, uint8_t *readData, uint8_t registerSize, bool *ok) |
| Reads a multi bytes value from a register. More... | |
Driver for the I2C bus communication peripheral.
This driver controls the I2C peripheral of the STM32, that is accessible from the digital extension connector of the HRI board.
Call i2c_Init() first in the initialization code. Then, the communication function i2c_readRegister() or i2c_writeRegister() can be used. Note that both functions are synchronous, hence blocking the execution until the operation completes.
| void i2c_Init | ( | void | ) |
Initializes the I2C bus.
| void i2c_ReadMultiBytesRegister | ( | uint8_t | slaveAddress, |
| uint8_t | registerAddress, | ||
| uint8_t * | readData, | ||
| uint8_t | registerSize, | ||
| bool * | ok | ||
| ) |
Reads a multi bytes value from a register.
| slaveAddress | 7-bit I2C slave address. |
| registerAddress | 8-bit register address. |
| readData | array that will hold the read data. Its size should be at least registerSize. |
| registerSize | number of bytes to read. |
| ok | the value pointed will be set to true if the operation completed successfully, or to false if an error occured. If a NULL pointer is given, then it is ignored. |
| uint8_t i2c_ReadRegister | ( | uint8_t | slaveAddress, |
| uint8_t | registerAddress, | ||
| bool * | ok | ||
| ) |
Reads a 8-bit value from a register.
| slaveAddress | 7-bit I2C slave address. |
| registerAddress | 8-bit register address. |
| ok | the value pointed will be set to true if the operation completed successfully, or to false if an error occured. If a NULL pointer is given, then it is ignored. |
| void i2c_WriteMultiBytesRegister | ( | uint8_t | slaveAddress, |
| uint8_t | registerAddress, | ||
| uint8_t const * | registerValue, | ||
| uint8_t | registerSize, | ||
| bool * | ok | ||
| ) |
Writes several bytes to a register.
| slaveAddress | 7-bit I2C slave address. |
| registerAddress | 8-bit register address. |
| registerValue | values array to write to the 8-bit register. |
| registerSize | number of bytes to write. |
| ok | the value pointed will be set to true if the operation completed successfully, or to false if an error occured. If a NULL pointer is given, then it is ignored. |
| void i2c_WriteRegister | ( | uint8_t | slaveAddress, |
| uint8_t | registerAddress, | ||
| uint8_t | registerValue, | ||
| bool * | ok | ||
| ) |
Writes a 8-bit value to a register.
| slaveAddress | 7-bit I2C slave address. |
| registerAddress | 8-bit register address. |
| registerValue | value to write to the 8-bit register. |
| ok | the value pointed will be set to true if the operation completed successfully, or to false if an error occured. If a NULL pointer is given, then it is ignored. |
1.8.13