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 ST Expansion SW Team

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

Files at this revision

API Documentation at this revision

Comitter:
giovannivisentini
Date:
Thu Jan 28 16:38:30 2016 +0000
Parent:
19:0b65a5813059
Child:
21:ccc4f3fed4b3
Commit message:
fix reading and password managment

Changed in this revision

X_NUCLEO_NFC01A1.cpp Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_NFC01A1.h Show annotated file Show diff for this revision Revisions of this file
m24sr/NDefNfcTagM24SR.cpp Show annotated file Show diff for this revision Revisions of this file
m24sr/m24sr_class.cpp Show annotated file Show diff for this revision Revisions of this file
m24sr/m24sr_class.h Show annotated file Show diff for this revision Revisions of this file
--- a/X_NUCLEO_NFC01A1.cpp	Thu Jan 28 14:01:18 2016 +0000
+++ b/X_NUCLEO_NFC01A1.cpp	Thu Jan 28 16:38:30 2016 +0000
@@ -50,7 +50,8 @@
 X_NUCLEO_NFC01A1 *X_NUCLEO_NFC01A1::mInstance = NULL;
 
 X_NUCLEO_NFC01A1* X_NUCLEO_NFC01A1::Instance(I2C &devI2C,
-		Nfc::gpoEventCallback gpoEventCallback,	const PinName &gpoName,
+		Nfc::gpoEventCallback gpoEventCallback,
+		const PinName &gpoName,
 		const PinName &RFDisableName, const PinName &led1Name,
 		const PinName &led2Name, const PinName &led3Name) {
 	if (mInstance == NULL) { // the first time
--- a/X_NUCLEO_NFC01A1.h	Thu Jan 28 14:01:18 2016 +0000
+++ b/X_NUCLEO_NFC01A1.h	Thu Jan 28 16:38:30 2016 +0000
@@ -98,7 +98,7 @@
 	 * @param led3Name Pin to control the led1 status.
 	 */
 	static X_NUCLEO_NFC01A1* Instance(I2C &devI2C,
-			Nfc::gpoEventCallback eventCallback,
+			Nfc::gpoEventCallback eventCallback=NULL,
 			const PinName &gpoName = DEFAULT_GPO_PIN,
  			const PinName &RFDisableName = DEFAULT_RF_DISABLE_PIN,
  			const PinName &led1Name = DEFAULT_LED1_PIN,
--- a/m24sr/NDefNfcTagM24SR.cpp	Thu Jan 28 14:01:18 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.cpp	Thu Jan 28 16:38:30 2016 +0000
@@ -193,4 +193,3 @@
 	}//if-else
 
 }
-
--- a/m24sr/m24sr_class.cpp	Thu Jan 28 14:01:18 2016 +0000
+++ b/m24sr/m24sr_class.cpp	Thu Jan 28 16:38:30 2016 +0000
@@ -555,7 +555,7 @@
 	/* copy the number of byte of the data field */
 	command.Body.LC = sizeof(pDataOut);
 	command.Body.pData = pDataOut;
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SELECTCCFILE, &command, uDIDbyte,
 			&NbByte, pBuffer);
 
@@ -707,6 +707,7 @@
 	mLastCommandSend=READ;
 	mLastCommandData.data=pBufferRead;
 	mLastCommandData.length=NbByteToRead;
+	mLastCommandData.offset=Offset;
 
 	if(mCommunicationType==M24SR::SYNC){
 		status = M24SR_IO_PollI2C();
@@ -1010,7 +1011,7 @@
 	command.Body.LC = M24SR_PASSWORD_NBBYTE;
 	/* copy the password */
 	command.Body.pData = pPwd;
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_CHANGEREFDATA, &command, uDIDbyte,
 			&NbByte, pBuffer);
 
@@ -1089,7 +1090,7 @@
 	/* copy the Password Id */
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_ENABLEVERIFREQ, &command,
 			uDIDbyte, &NbByte, pBuffer);
 
@@ -1167,7 +1168,7 @@
 	/* copy the Password Id */
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_DISABLEVERIFREQ, &command,
 			uDIDbyte, &NbByte, pBuffer);
 
@@ -1246,7 +1247,7 @@
 	/* copy the Password Id */
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_ENABLEVERIFREQ, &command, uDIDbyte,
 			&NbByte, pBuffer);
 
@@ -1323,7 +1324,7 @@
 	/* copy the Password Id */
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_DISABLEVERIFREQ, &command,
 			uDIDbyte, &NbByte, pBuffer);
 
@@ -1397,7 +1398,7 @@
 	command.Header.P1 = GETMSB(uP1P2);
 	command.Header.P2 = GETLSB(uP1P2);
 	command.Body.LC = 0x00;
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SENDINTERRUPT, &command, uDIDbyte,
 			&NbByte, pBuffer);
 
@@ -1448,7 +1449,7 @@
 	/* copy the data */
 	//memcpy(command.Body.pData , &uSetOrReset, 0x01 );
 	//command.Body.LE = 0x00 ;
-	/* build the I²C command */
+	/* build the I²C command */
 	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_GPOSTATE, &command, uDIDbyte,
 			&NbByte, pBuffer);
 
@@ -1604,7 +1605,7 @@
 }
 
 NFC_StatusTypeDef M24SR::disableAllPassword(const uint8_t* pSuperUserPassword){
-	mComponentCallback = &mChangePasswordRequestStatusCallback;
+	mComponentCallback = &mRemoveAllPasswordCallback;
 	return Verify(M24SR::I2CPwd, 0x10, pSuperUserPassword);
 }
 
--- a/m24sr/m24sr_class.h	Thu Jan 28 14:01:18 2016 +0000
+++ b/m24sr/m24sr_class.h	Thu Jan 28 16:38:30 2016 +0000
@@ -108,10 +108,12 @@
 		memset(uM24SRbuffer, 0, 0xFF * sizeof(int8_t));
 		uDIDbyte = 0;
 		RFDisablePin = 0;
-
-		mGpoEventInterrupt.fall(eventCallback);
+		printf("init\n\r");
+		if(eventCallback!=NULL)
+			mGpoEventInterrupt.fall(eventCallback);
 		mGpoEventInterrupt.mode(PullUp);
 		mGpoEventInterrupt.disable_irq();
+		printf("init End\n\r");
 	}
 
 	/**
@@ -976,9 +978,18 @@
 					return onFinishCommand(nfc,status);
 
 				if(mEnable){
-					nfc->EnablePermanentState(mType==WRITE? WritePwd : ReadPwd);
+					nfc->DisablePermanentState(mType==WRITE? WritePwd : ReadPwd);
 				}else
-					nfc->DisableVerificationRequirement(mType==WRITE? WritePwd : ReadPwd);
+					nfc->EnablePermanentState(mType==WRITE? WritePwd : ReadPwd);
+
+			}
+
+			virtual void onDisablePermanentState(Nfc *nfc, NFC_StatusTypeDef status,
+					PasswordType_t type ){
+				if(status!=NFC_SUCCESS)
+					return onFinishCommand(nfc,status);
+
+				nfc->DisableVerificationRequirement(type);
 			}
 
 			virtual void onDisableVerificationRequirement(Nfc *nfc , NFC_StatusTypeDef status,