X_NUCLEO_NFC02A1 library for M24LR
Dependencies: ST_INTERFACES
Dependents: HelloWorld_NFC02A1_mbedOS HelloWorld_NFC02A1laatste HelloWorld_NFC02A1
Fork of X_NUCLEO_NFC02A1 by
X-NUCLEO-NFC02A1 Dynamic NFC Tag Expansion Board Firmware Package
Introduction
This firmware package includes Components Device Drivers, Board Support Package and example applications for STMicroelectronics X-NUCLEO-NFC02A1 Dynamic NFC Tag Expansion Board based on M24LR.
Firmware Library
Class X_NUCLEO_NFC02A1 is intended to represent the Dynamic NFC Tag Expansion Board with the same name.
It provides an API to access to the M24LR component and to the three onboard LEDs.
It is intentionally implemented as a singleton because only one X_NUCLEO_NFC02A1 at a time might be deployed in a HW component stack.
The library also provides an implementation of the NDEF library API for M24LR, providing an simple way to read/write NDEF formatted messages from/to the M24LR dynamic NFC tag.
Example application
Hello World is a simple application to program and read an URI from the NFC tag.
Revision 7:b876cdcf095a, committed 2017-07-11
- Comitter:
- Davidroid
- Date:
- Tue Jul 11 15:23:56 2017 +0000
- Parent:
- 6:8c1eca41b3a9
- Child:
- 8:7c4cf671960b
- Commit message:
- Updating with the new mbed library.
Changed in this revision
--- a/XNucleoNFC02A1.cpp Fri May 19 07:51:32 2017 +0000
+++ b/XNucleoNFC02A1.cpp Tue Jul 11 15:23:56 2017 +0000
@@ -51,7 +51,7 @@
XNucleoNFC02A1 *XNucleoNFC02A1::mInstance = NULL;
-XNucleoNFC02A1* XNucleoNFC02A1::instance(DevI2C &devI2C,
+XNucleoNFC02A1* XNucleoNFC02A1::instance(DevI2C *devI2C,
const PinName &gpoName,
const PinName &RFDisableName, const PinName &led1Name,
const PinName &led2Name, const PinName &led3Name) {
--- a/XNucleoNFC02A1.h Fri May 19 07:51:32 2017 +0000 +++ b/XNucleoNFC02A1.h Tue Jul 11 15:23:56 2017 +0000 @@ -73,7 +73,7 @@ * @param led2Name Pin to control the led1 status. * @param led3Name Pin to control the led1 status. */ - XNucleoNFC02A1(DevI2C &devI2C, + XNucleoNFC02A1(DevI2C *devI2C, const PinName &gpoName, const PinName &RFDisableName, const PinName &led1Name, const PinName &led2Name, const PinName &led3Name): @@ -99,7 +99,7 @@ * @param led2Name Pin to control the led1 status. * @param led3Name Pin to control the led1 status. */ - static XNucleoNFC02A1* instance(DevI2C &devI2C, + static XNucleoNFC02A1* instance(DevI2C *devI2C, const PinName &gpoName = DEFAULT_GPO_PIN, const PinName &RFDisableName = DEFAULT_RF_DISABLE_PIN, const PinName &led1Name = DEFAULT_LED1_PIN,
--- a/m24lr/M24LR.cpp Fri May 19 07:51:32 2017 +0000
+++ b/m24lr/M24LR.cpp Tue Jul 11 15:23:56 2017 +0000
@@ -140,7 +140,7 @@
char buffer;
while (status != 0) {
/* for device is ready address in M24Lr is M24LR_ADDR_DATA_I2C */
- status = dev_I2C.read(i2c_address_data, &buffer, 1, false);
+ status = dev_I2C->read(i2c_address_data, &buffer, 1, false);
}
if ( status == 0 )
return NFCTAG_OK;
@@ -242,7 +242,7 @@
}
/* Rosarium : To check M24LR_ADDR_DATA_I2C is this case */
/* return M24lr_IO_MemRead( pData, M24LR_ADDR_DATA_I2C, TarAddr, NbByte ); */
- status = dev_I2C.i2c_read(pData, i2c_address_data, TarAddr, NbByte);
+ status = dev_I2C->i2c_read(pData, i2c_address_data, TarAddr, NbByte);
if ( status == 0 )
return NFCTAG_OK;
else
@@ -290,7 +290,7 @@
/* Write align_mem_offset bytes in memory */
/* Rosarium to Check as the address here is 0xA6 rather than 0xAE */
/* Rosarium dev_I2C.i2c_write(pdata_index, M24LR_ADDR_DATA_I2C, mem_addr, align_mem_offset); */
- status = dev_I2C.i2c_write(pdata_index, i2c_address_data, mem_addr, align_mem_offset);
+ status = dev_I2C->i2c_write(pdata_index, i2c_address_data, mem_addr, align_mem_offset);
/* update index, dest address, size for next write */
pdata_index += align_mem_offset;
@@ -324,7 +324,7 @@
return NFCTAG_TIMEOUT;
}
/* Read actual value of register */
- status = dev_I2C.i2c_read(pData, i2c_address_syst, TarAddr, NbByte);
+ status = dev_I2C->i2c_read(pData, i2c_address_syst, TarAddr, NbByte);
if ( status == 0 )
return NFCTAG_OK;
@@ -370,7 +370,7 @@
}
/* Write align_mem_offset bytes in register */
// status = M24lr_IO_MemWrite( pdata_index, M24LR_ADDR_SYST_I2C, mem_addr, align_mem_offset );
- status = dev_I2C.i2c_write(pdata_index, i2c_address_syst, mem_addr, align_mem_offset);
+ status = dev_I2C->i2c_write(pdata_index, i2c_address_syst, mem_addr, align_mem_offset);
/* update index, dest address, size for next write */
pdata_index += align_mem_offset;
mem_addr += align_mem_offset;
@@ -701,7 +701,7 @@
int status;
/* Read actual value of CFG register */
- status = dev_I2C.i2c_read( ®_value, i2c_address_syst, (uint16_t)M24LR_CFG_REG, 1 );
+ status = dev_I2C->i2c_read( ®_value, i2c_address_syst, (uint16_t)M24LR_CFG_REG, 1 );
if( status != 0 )
{
return NFCTAG_TIMEOUT;
--- a/m24lr/M24LR.h Fri May 19 07:51:32 2017 +0000
+++ b/m24lr/M24LR.h Tue Jul 11 15:23:56 2017 +0000
@@ -262,7 +262,7 @@
return i2c_write_data( pDataToWrite, Offset, NbByteToWrite );
}
- M24LR(uint8_t const address, uint8_t const addressData, DevI2C &devI2C ):
+ M24LR(uint8_t const address, uint8_t const addressData, DevI2C *devI2C ):
NDefTagUtil(*this), i2c_address_syst(address), i2c_address_data(addressData), dev_I2C(devI2C) {}
@@ -290,7 +290,7 @@
uint8_t i2c_address_syst;
uint8_t i2c_address_data;
- DevI2C dev_I2C;
+ DevI2C *dev_I2C;
};

X-NUCLEO-NFC02A1 Dynamic NFC tag