|
| I2CDevice (I2C &pInterface, uint8_t deviceAddress, uint8_t numAddressBytes=1) |
| Initialize the I2C module.
|
|
uint8_t | getI2CAddress () |
| Get device's I2C address.
|
|
void | setup (uint32_t busSpeed) |
| Setup the I2C peripheral module.
|
|
void | resetBus () |
| Reset the I2C bus.
|
|
I2C::Result_t | writeReg8 (uint32_t reg, uint8_t data) |
| Write an 8-bit value to an I2C slave device register.
|
|
I2C::Result_t | readReg8 (uint32_t reg, uint8_t &data) |
| Read an 8-bit value form an I2C slave device register.
|
|
I2C::Result_t | writeRegN (uint32_t reg, const uint8_t *buf, uint32_t blen) |
| Write a number of 8-bit values to an I2C slave to the specified register address.
|
|
I2C::Result_t | readRegN (uint32_t reg, uint8_t *buf, uint32_t blen) |
| Read a number of 8-bit values from an I2C slave at the specified register address.
|
|
I2C Device Class (recommended)
For I2C communication, you can choose the I2CDevice class, the I2C class, or the WireIntf class. The recommended interface is the I2CDevice class.
For example, to create an object for an analog to digital converter:
I2CDevice AdcDevice(i2c[I2C_MODULE_NUM], I2C_ADC_ADDRESS);
I2C Device Class (recommended)
Definition i2c.h:442
To read a 16 bit value:
uint8_t I2CStat = AdcDevice.readRegN(0x00, buf, 2);
uint8_t I2CDevice::getI2CAddress |
( |
| ) |
|
|
inline |
Get device's I2C address.
Note that the return address will be just the I2C address bits, not including the read/write bit. If your device data sheet specifies the address byte to include the read/write bit, that value would be this address left shifted by 1. For example, if a device data sheet specifies the address as 0xA2 and includes the read/write bit, the actual address would be 0x51.
- Returns
- The device's I2C address