|
NetBurner 3.5.7
PDF Version |
Arduino-compatible TwoWire I2C controller/target interface. More...
Topics | |
| Wire Result Codes | |
Classes | |
| class | TwoWire |
| Arduino Wire-compatible I2C controller/target interface. More... | |
| class | TwoWireObject |
| Convenience wrapper binding a TwoWire instance and device address. More... | |
Typedefs | |
| typedef void | slave_rx_handler(int num_rx) |
| Callback type for target (slave) receive events. | |
| typedef void | slave_rq_handler() |
| Callback type for target (slave) request events. | |
Variables | |
| class TwoWire | Wire |
| Pre-declared global TwoWire instance using platform default pins. | |
Arduino-compatible TwoWire I2C controller/target interface.
#include< Wire.h>
The Wire interface provides an Arduino-compatible API for communicating with I2C devices using the TwoWire class. It supports both hardware I2C peripherals and, when BBI2C is defined, a software bit-banged fallback for arbitrary pin pairs.
Key features:
Basic usage flow:
TwoWire Wire; or TwoWire Wire(sclPin, sdaPin);Wire.setClock(400000);Wire.begin();Wire.end();Each platform defines a valid_i2c[] table listing all supported SCL/SDA pin combinations and their associated hardware I2C modules. The parameterless TwoWire constructor selects the first entry (index 0) of this table.
If BBI2C is defined and the requested pins don't match any hardware entry, software bit-banged I2C is used automatically.
For full per-platform pin tables see examples/TwoWire_I2C_Pin_Reference.md.
| Platform | CPU | Default SCL | Default SDA | I2C Module |
|---|---|---|---|---|
| SOMRT1061 | i.MX RT1061 | Pins[9] (EMC_12) | Pins[10] (EMC_11) | LPI2C4 |
| MODM7AE70 | SAME70 | P2[42] (PA4) | P2[39] (PA3) | TWIHS0 |
| MOD5441X | MCF5441X | J2[42] | J2[39] | I2C0 |
| NANO54415 | MCF5441X | Pins[22] | Pins[20] | I2C1 |
| SB800EX | MCF5441X | Pins[5] | Pins[4] | I2C4 |
See examples in your NNDK under examples/I2C/Wire
| typedef void slave_rq_handler() |
#include <Wire.h>
Callback type for target (slave) request events.
Called when the controller requests data from this device. The handler should call TwoWire::write() to queue response bytes.
| typedef void slave_rx_handler(int num_rx) |
#include <Wire.h>
Callback type for target (slave) receive events.
| num_rx | Number of bytes received from the controller |