Firmware library for the X-NUCLEO-NFC01A1 Dynamic NFC Tag board.
Dependencies: M24SR
Dependents: NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more
Fork of X_NUCLEO_NFC01A1 by
X-NUCLEO-NFC01A1 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-NFC01A1 Dynamic NFC Tag Expansion Board based on M24SR.
Firmware Library
Class X_NUCLEO_NFC01A1 is intended to represent the Dynamic NFC Tag Expansion Board with the same name.
It provides an API to access to the M24SR component and to the three onboard LEDs.
It is intentionally implemented as a singleton because only one X_NUCLEO_NFC01A1 at a time might be deployed in a HW component stack.
The library also provides an implementation of the NDEF library API for M24SR, providing an simple way to read/write NDEF formatted messages from/to the M24SR dynamic NFC tag.
Example applications
1. Hello World
2. Asynchronous Hello World
Revision 12:d1f5eaa85deb, committed 2016-01-14
- Comitter:
- giovannivisentini
- Date:
- Thu Jan 14 09:16:40 2016 +0000
- Parent:
- 10:482175f7ae66
- Child:
- 14:7e3d436b19ee
- Commit message:
- nfc_class not require m24sr.h
Changed in this revision
--- a/Interfaces/Nfc_class.h Thu Jan 14 08:41:19 2016 +0000
+++ b/Interfaces/Nfc_class.h Thu Jan 14 09:16:40 2016 +0000
@@ -48,7 +48,7 @@
/* Includes ------------------------------------------------------------------*/
#include "Component_class.h"
-
+#include "nfc.h"
/* Classes ------------------------------------------------------------------*/
@@ -63,9 +63,9 @@
* Possible password to set.
*/
typedef enum{
- ReadPwd=READ_PWD, //!< Password to use before read the tag
- WritePwd=WRITE_PWD,//!< Password to use before write the tag
- I2CPwd=I2C_PWD, //!< Root password, used only thought nfc
+ ReadPwd, //!< Password to use before read the tag
+ WritePwd, //!< Password to use before write the tag
+ I2CPwd, //!< Root password, used only thought nfc
}PasswordType_t;
--- a/m24sr/NDefNfcTagM24SR.cpp Thu Jan 14 08:41:19 2016 +0000 +++ b/m24sr/NDefNfcTagM24SR.cpp Thu Jan 14 09:16:40 2016 +0000 @@ -36,7 +36,7 @@ */ #include "NDefNfcTagM24SR.h" -#include "m24sr_class.h" + /* wait 1sec, driver is configured to let 200ms for command to complete */ /* which is enough for all commands except GetSession if RF session is already opened */ /* Smartphone generally releases the session within the second, anyway the user can modify this value */
--- a/m24sr/NDefNfcTagM24SR.h Thu Jan 14 08:41:19 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.h Thu Jan 14 09:16:40 2016 +0000
@@ -41,7 +41,7 @@
#include "NDefLib/NDefNfcTag.h"
-class M24SR;
+#include "Nfc_class.h"
/**
* Implement all NDefLib abstract methods. */
@@ -52,7 +52,7 @@
* Create the object.
* @param Device device to write the Ndef tags into.
*/
- NDefNfcTagM24SR(M24SR &device) :
+ NDefNfcTagM24SR(Nfc &device) :
mDevice(device), mMaxReadBytes(0xFF), mMaxWriteBytes(
0xFF) {
}
@@ -105,7 +105,7 @@
private:
- M24SR &mDevice;
+ Nfc &mDevice;
/**
* Max length for a read operation
--- a/m24sr/m24sr_class.h Thu Jan 14 08:41:19 2016 +0000
+++ b/m24sr/m24sr_class.h Thu Jan 14 09:16:40 2016 +0000
@@ -165,26 +165,26 @@
virtual NFC_StatusTypeDef Verify(PasswordType_t pwdId, uint8_t NbPwdByte,
const uint8_t *pPwd) {
- return (NFC_StatusTypeDef) M24SR_Verify((uint16_t) pwdId,
+ return (NFC_StatusTypeDef) M24SR_Verify(passwordTypeToConst(pwdId),
(uint8_t) NbPwdByte, pPwd);
}
virtual NFC_StatusTypeDef ChangeReferenceData(PasswordType_t pwdId,
const uint8_t *pPwd) {
- return (NFC_StatusTypeDef) M24SR_ChangeReferenceData((uint16_t) pwdId,
+ return (NFC_StatusTypeDef) M24SR_ChangeReferenceData(passwordTypeToConst(pwdId),
(uint8_t *) pPwd);
}
virtual NFC_StatusTypeDef EnableVerificationRequirement(
PasswordType_t uReadOrWrite) {
return (NFC_StatusTypeDef) M24SR_EnableVerificationRequirement(
- (uint16_t) uReadOrWrite);
+ passwordTypeToConst(uReadOrWrite));
}
virtual NFC_StatusTypeDef DisableVerificationRequirement(
PasswordType_t uReadOrWrite) {
return (NFC_StatusTypeDef) M24SR_DisableVerificationRequirement(
- (uint16_t) uReadOrWrite);
+ passwordTypeToConst(uReadOrWrite));
}
////////////////////// ST proprietary //////////////////////////////////
@@ -197,12 +197,12 @@
virtual NFC_StatusTypeDef EnablePermanentState(PasswordType_t uReadOrWrite) {
return (NFC_StatusTypeDef) M24SR_EnablePermanentState(
- (uint16_t) uReadOrWrite);
+ passwordTypeToConst(uReadOrWrite));
}
virtual NFC_StatusTypeDef DisablePermanentState(PasswordType_t uReadOrWrite) {
return (NFC_StatusTypeDef) M24SR_DisablePermanentState(
- (uint16_t) uReadOrWrite);
+ passwordTypeToConst(uReadOrWrite));
}
///////////////////// chip configuration /////////////////////////////////
@@ -472,6 +472,25 @@
* Object implementing the interface to use the NDefLib.
*/
NDefNfcTagM24SR NDefTagUtil;
+
+private:
+
+ /**
+ * Convert a generic enum to the value used by the M24SR chip.
+ * @param type Password type.
+ * @return equivalent value used inside the m24sr chip */
+ uint16_t passwordTypeToConst(const PasswordType_t &type)const{
+ switch(type){
+ case ReadPwd:
+ return READ_PWD;
+ case WritePwd:
+ return WRITE_PWD;
+ case I2CPwd:
+ default:
+ return I2C_PWD;
+ }
+ }//passwordTypeToConst
+
};
#endif // __M24SR_CLASS_H

X-NUCLEO-NFC01A1 Dynamic NFC Tag