- Introduction
- This is an example application demonstrating how to make use of the I2C Driver or the I2C bit-bang module
Three build configurations are defined:
SLAVE
- Implements I2C slave functionality using the I2C HW block
MASTER_HW
- Implements I2C master functionality using the I2C HW block
MASTER_BB
- Implements I2C master functionality using the I2C bit-bang module
- SLAVE
- When setting the Debug configuration Debug_SLAVE active, the code from the source file
slave.c
will be compiled. The resulting application is an I2C slave, listening on I2C_SLAVE_ADDRESS, and providing a portion of a text to the I2C master upon each transfer.
While I2C communication is ongoing, a LED is lit.
- MASTER_HW
- When setting the Debug configuration Debug_MASTER_HW active, the code from the source file
master_hw.c
will be compiled. The resulting application is an I2C master, using the HW I2C block.
The program will perpetually retrieve a portion of a text, dump the retrieved bytes in a single-record NDEF message, wait some time, and repeat the process.
While I2C communication is ongoing, a LED is lit.
- MASTER_BB
- When setting the Debug configuration Debug_MASTER_BB active, the code from the source file
master_bb.c
will be compiled. The resulting application is an I2C master, using the I2C bit-bang module.
The program will behave identical to MASTER_HW
, except that the I2C communication will be slower. Any two PIOs can be used for I2C communication using this bit-bang module, but PIO0_4 and PIO0_5 are chosen in this application to make it trivial switching between MASTER_HW
and MASTER_BB
, both w.r.t. the source code and the HW setup.
- Note
- The NHS3100W8 gold bump version packages does not bring out the I2C pins connected to the HW I2C block. The I2C bit-bang module, is then available for use to include I2C functionality in your programs. Diversity settings are available to remap the
CLK
and DAT
lines to two of PIO0_0, PIO0_6, PIO0_10 and PIO0_11.
- Setup
- To demonstrate, two standard demo boards can be used. The NHS3100TEMODB boards "NHS3100 Temperature Monitoring
Demo Board" can be bought directly on https://www.nxp.com/NTAGSMARTSENSOR or via several distributors. For any I2C communication, external pull-ups must be provided. The NHS3100TEMODB boards have provisions to use two additional PIOs to fulfill this role:
- One NHS3100TEMODB board can act as a slave device. No adaptations to the board are required.
- A second NHS3100TEMODB board can act as a master device. The locations
R3
and R4
on the board must be stuffed with a 10K resistor each. PIO0_3 is configured in the application code, providing the pull-up functionality to PIO0_4 and PIO0_5.
See also the schematics of the board, available in the SDK under the docs folder.
With R3
and R4
stuffed on one board, connect pin PIO0_4 of each board to each other, and connect pin PIO0_5 of each board to each other.
Flash the unchanged board with the build from Debug_SLAVE
, and the other board with the build from either Debug_MASTER_HW
or Debug_MASTER_BB
. When firmware is running on both, use a tag reader to read out the ever-changing textual data on the master device, received via I2C from the slave device.
- Note
- The slave device does not provide any NDEF message via its NFC interface, only the master device.
- Tag reader
- on Android: any NFC-enabled Android phone can be used to read out the textual data generated by the tag without any APP installed or active.
- on iOS: NXP's NFC TagInfo APP can be used to read out the data generated by the tag.
- on Windows and macOS: the NTAG SmartSensor Automator application, available in the SDK under sw/crossplatform/comm, can be used to read out the data generated by the tag.