NetBurner 3.5.7
PDF Version
Wire Interface

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.
 

Detailed Description

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:

  1. Construct: TwoWire Wire; or TwoWire Wire(sclPin, sdaPin);
  2. Optionally set clock: Wire.setClock(400000);
  3. Initialize: Wire.begin();
  4. Transmit / request data
  5. Shut down: Wire.end();

I2C Pin Mapping Reference

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.

Quick Reference — Default Pins Per Platform

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 Documentation

◆ slave_rq_handler

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.

◆ slave_rx_handler

typedef void slave_rx_handler(int num_rx)

#include <Wire.h>

Callback type for target (slave) receive events.

Parameters
num_rxNumber of bytes received from the controller