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.
Diff: m24lr/M24LR.h
- Revision:
- 8:7c4cf671960b
- Parent:
- 7:b876cdcf095a
diff -r b876cdcf095a -r 7c4cf671960b m24lr/M24LR.h --- a/m24lr/M24LR.h Tue Jul 11 15:23:56 2017 +0000 +++ b/m24lr/M24LR.h Wed Jul 12 12:34:12 2017 +0000 @@ -204,12 +204,10 @@ uint8_t PassCtrl; } M24LR_SECTOR_SEC; - - /** - * @} - */ - -class M24LR : public Nfc { +/** + * @brief M24LR class. + */ +class M24LR : public Nfc { public: NFCTAG_StatusTypeDef i2c_init( void ); NFCTAG_StatusTypeDef i2c_read_id( uint8_t * const pICRef ); @@ -220,8 +218,7 @@ NFCTAG_StatusTypeDef i2c_write_data( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); NFCTAG_StatusTypeDef i2c_read_register( uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); NFCTAG_StatusTypeDef i2c_write_register( const uint8_t * const pData, const uint16_t TarAddr, const uint16_t NbByte ); - - + /* Extended Functions */ NFCTAG_StatusTypeDef i2c_read_UID( M24LR_UID * const pUid ); NFCTAG_StatusTypeDef i2c_read_DSFID( uint8_t * const pDsfid ); @@ -251,53 +248,42 @@ void enable_energy_harvesting( void ); NFCTAG_StatusTypeDef initialization( void ); - virtual int read_binary(uint16_t Offset, uint8_t NbByteToRead, - uint8_t *pBufferRead) { - return i2c_read_data( pBufferRead, Offset, NbByteToRead ); + virtual int read_binary(uint16_t Offset, uint8_t NbByteToRead, uint8_t *pBufferRead) { + return i2c_read_data( pBufferRead, Offset, NbByteToRead ); } - - virtual int update_binary(uint16_t Offset, - uint8_t NbByteToWrite,uint8_t *pDataToWrite) { - return i2c_write_data( pDataToWrite, Offset, NbByteToWrite ); + + virtual int update_binary(uint16_t Offset, uint8_t NbByteToWrite,uint8_t *pDataToWrite) { + 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) {} - - - NDefLib::NDefNfcTag& get_NDef_tag(){ + + NDefLib::NDefNfcTag& get_NDef_tag(){ return NDefTagUtil; - } - - - virtual int init(void *ptr) { - (void)ptr; + } + + virtual int init(void *ptr) { + (void)ptr; return i2c_init(); } - virtual int read_id(uint8_t *id) { + virtual int read_id(uint8_t *id) { return i2c_read_id(id); } - private: - static uint8_t NfctagInitialized; - - - /* - * Object implementing the interface to use the NDefLib. - */ - NDefNfcTagM24LR NDefTagUtil; - - uint8_t i2c_address_syst; - uint8_t i2c_address_data; - DevI2C *dev_I2C; + +private: + static uint8_t NfctagInitialized; + /* Object implementing the interface to use the NDefLib. */ + NDefNfcTagM24LR NDefTagUtil; + + uint8_t i2c_address_syst; + uint8_t i2c_address_data; + DevI2C &dev_I2C; }; - - - #endif /* __M24LR_H */ - -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/