|
| | BBI2C (PinIO scl, PinIO sda) |
| | Constructor for the I2C peripheral module.
|
| |
| void | setup (uint32_t maxBusSpeed) |
| | Setup the I2C peripheral interface.
|
| |
|
void | resetBus () |
| | Reset the I2C bus.
|
| |
| void | setNumAddressBytes (uint8_t numAddressBytes=1) |
| | Specify the register address size for a read or write transaction. A number of bytes, from 0 to 3, can be sent to specify an address up to 24-bit (3 bytes): 0 = none, 1 = 8-bits, 2 = 16-bits, 3 = 24-bits.
|
| |
| virtual Result_t | writeReg8 (uint8_t devAddr, uint32_t reg, uint8_t data) |
| | Write an 8-bit value to a I2C slave device register.
|
| |
| virtual Result_t | readReg8 (uint8_t devAddr, uint32_t reg, uint8_t &data) |
| | Read an 8-bit value form an I2C slave device register.
|
| |
| virtual Result_t | writeRegN (uint8_t devAddr, uint32_t reg, uint8_t *buf, uint32_t blen) |
| | Write a number of 8-bit values to an I2C slave to the specified register address.
|
| |
| virtual Result_t | readRegN (uint8_t devAddr, 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.
|
| |
| void | SetMaxBusDelay (uint16_t milliseconds) |
| | Set the maximum duration that the bus is allowed to be in use without being clocked before being forcibly reset.
|
| |
I2C Peripheral Class.
For I2C communication, you can choose the WireIntf class, or the I2C class. The WireIntf class is simpler to use, while the I2C class provides more low level control.
Note that the system automatically instantiates I2C and WireIntf objects for each of the I2C peripheral modules. The WireIntf objects can be accessed with: Wire, Wire1 and Wire2. The I2C objects can be accessed with I2C[0], I2C[1] and I2C[2].
| void BBI2C::setNumAddressBytes |
( |
uint8_t | numAddressBytes = 1 | ) |
|
|
inline |
Specify the register address size for a read or write transaction. A number of bytes, from 0 to 3, can be sent to specify an address up to 24-bit (3 bytes): 0 = none, 1 = 8-bits, 2 = 16-bits, 3 = 24-bits.
If you are using a single I2C device, or all devices use the same address size, this function only needs to be called once. If you have multiple I2C devices with different address/register bit sizes, then this function should be called before each read/write operation for each different device.
- Parameters
-
| numAddressBytes | The number of address bytes to send: 0 - 3. The default value is 1 byte. |