-
Notifications
You must be signed in to change notification settings - Fork 25
PN7150 Interface
This part defines a class which implements the I2C interface between your microcontroller and the PN7150. For I2C, the PN7150 is always the slave, the microcontroller is the master. On top of the standard I2C signals (SDA, SCL), the PN7150 requires two extra general purpose I/O signals:
- IRQ : (output from the PN7150, input to the MCU) By driving this pin High, the PN7150 indicates that is has data to be read.
- VEN : (output from MCU, input to the PN7150) Driving VEN low and then back high, makes the PN7150 perform a reset, so you need this to properly reset the PN7150.
You need to create one, global object instance of this class, eg.
PN7150Interface theInterface = PN7150Interface(14, 13); // creates a global NFC device interface object, attached to MCU pins 14 (IRQ) and 13 (VEN) and using the default I2C address 0x28
initialize(void);
initialize the extra pins IRQ and VEN, perform a PN7150 Reset and initialize the I2C
uint8_t write(uint8_t data[], uint32_t dataLength);
write data to the PN7150. Returns a result code, mainly returning I2C errors if any
uint32_t read(uint8_t data[]);
read from the PN7150. The PN7150's NCI messages have their payload in the 3rd byte, so we read the first 3 bytes, and then we read some more depending on the contents of the payload length byte
bool hasMessage();
does the PN7150 indicate it has data for the DeviceHost to be read, IRQ == high