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 Oct 27 07:38:00 2016 +0000
Parent:
27:3881985097bb
Child:
29:7a2dfd06cb29
Commit message:
manage the case of pins configured as "Not Connected"

Changed in this revision

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/m24sr/m24sr_class.cpp	Fri Sep 30 12:33:20 2016 +0000
+++ b/m24sr/m24sr_class.cpp	Thu Oct 27 07:38:00 2016 +0000
@@ -250,19 +250,22 @@
 		mCommunicationType(SYNC),
 		mLastCommandSend(NONE),
 		mGpoEventInterrupt(GPOPinName),
-		mManageGPOCallback(*this),
 		mCallback(&defaultCallback),
 		mComponentCallback(NULL),
 		mNDefTagUtil(new NDefNfcTagM24SR(*this)),
+		mManageGPOCallback(*this),
 		mReadIDCallback(*this){
 		//mNDefTagUtil(NULL){
 	memset(uM24SRbuffer, 0, 0xFF * sizeof(int8_t));
 	uDIDbyte = 0;
-	RFDisablePin = 0;
-	if(eventCallback!=NULL)
-		mGpoEventInterrupt.fall(eventCallback);
-	mGpoEventInterrupt.mode(PullUp);
-	mGpoEventInterrupt.disable_irq();
+	if(RFDisablePin.is_connected()!=0)
+		RFDisablePin = 0;
+	if(GPOPin.is_connected()!=0){
+		if(eventCallback!=NULL)
+			mGpoEventInterrupt.fall(eventCallback);
+		mGpoEventInterrupt.mode(PullUp);
+		mGpoEventInterrupt.disable_irq();
+	}
 }
 
 M24SR::~M24SR(){
@@ -322,18 +325,23 @@
 	if(status!= M24SR_SUCCESS)
 		return status;
 	//leave the gpo always up
-	status = M24SR_ManageI2CGPO(DEFAULT_GPO_STATUS);
-	if(status!= M24SR_SUCCESS)
+	if(GPOPin.is_connected()!=0){
+		status = M24SR_ManageI2CGPO(DEFAULT_GPO_STATUS);
+		if(status!= M24SR_SUCCESS)
 			return status;
-	status = M24SR_ManageRFGPO(DEFAULT_GPO_STATUS);
-	if(status!= M24SR_SUCCESS)
+	}
+	if(RFDisablePin.is_connected()!=0){
+		status = M24SR_ManageRFGPO(DEFAULT_GPO_STATUS);
+		if(status!= M24SR_SUCCESS)
 			return status;
+	}
 	//close the session
 	status = M24SR_Deselect();
 	if(status!= M24SR_SUCCESS)
-			return status;
-
-	mGpoEventInterrupt.enable_irq();
+		return status;
+	if(GPOPin.is_connected()!=0){
+		mGpoEventInterrupt.enable_irq();
+	}
 	return M24SR_SUCCESS;
 }
 
@@ -1142,7 +1150,7 @@
 	/* copy the Password Id */
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
-	/* build the I²C command */
+	/* build the I2C command */
 	M24SR_BuildIBlockCommand( M24SR_CMDSTRUCT_ENABLEVERIFREQ, &command,
 			uDIDbyte, &NbByte, pBuffer);
 
@@ -1370,7 +1378,7 @@
 	/* copy the Password Id */
 	command.Header.P1 = GETMSB(uReadOrWrite);
 	command.Header.P2 = GETLSB(uReadOrWrite);
-	/* build the I²C command */
+	/* build the I2C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_DISABLEVERIFREQ, &command,
 			uDIDbyte, &NbByte, pBuffer);
 
@@ -1432,7 +1440,10 @@
 	uint16_t uP1P2 = 0x001E;
 	uint16_t NbByte;
 
-	M24SR_ManageI2CGPO(INTERRUPT);
+
+	StatusTypeDef status = M24SR_ManageI2CGPO(INTERRUPT);
+	if(status!=M24SR_SUCCESS)
+		return status;
 
 	/* build the command */
 	command.Header.CLA = C_APDU_CLA_ST;
@@ -1441,7 +1452,7 @@
 	command.Header.P1 = GETMSB(uP1P2);
 	command.Header.P2 = GETLSB(uP1P2);
 	command.Body.LC = 0x00;
-	/* build the I²C command */
+	/* build the I2C command */
 	M24SR_BuildIBlockCommand(M24SR_CMDSTRUCT_SENDINTERRUPT, &command, uDIDbyte,
 			&NbByte, pBuffer);
 
@@ -1473,7 +1484,10 @@
 		return M24SR_IO_ERROR_PARAMETER;
 	}
 
-	M24SR_ManageI2CGPO(STATE_CONTROL);
+
+	StatusTypeDef status = M24SR_ManageI2CGPO(STATE_CONTROL);
+	if(status == M24SR_SUCCESS)
+		return status;
 
 	/* build the command */
 	command.Header.CLA = C_APDU_CLA_ST;
@@ -1504,6 +1518,9 @@
 
 M24SR::StatusTypeDef M24SR::M24SR_ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
 
+	if(GPOPin.is_connected()==0){
+		return M24SR_IO_PIN_NOT_CONNECTED;
+	}
 	if (GPO_I2Cconfig > STATE_CONTROL) {
 		return M24SR_IO_ERROR_PARAMETER;
 	}
@@ -1518,6 +1535,9 @@
 
 M24SR::StatusTypeDef M24SR::M24SR_ManageRFGPO(NFC_GPO_MGMT GPO_I2Cconfig) {
 
+	if(RFDisablePin.is_connected()==0){
+		return M24SR_IO_PIN_NOT_CONNECTED;
+	}
 	if (GPO_I2Cconfig > STATE_CONTROL) {
 		return M24SR_IO_ERROR_PARAMETER;
 	}
@@ -1531,6 +1551,9 @@
 }
 
 M24SR::StatusTypeDef M24SR::M24SR_RFConfig(uint8_t OnOffChoice) {
+	if(RFDisablePin.is_connected()==0){
+		return M24SR_IO_PIN_NOT_CONNECTED;
+	}
 	/* Disable RF */
 	if (OnOffChoice != 0) {
 		M24SR_IO_RFDIS_WritePin(GPIO_PIN_RESET);
--- a/m24sr/m24sr_class.h	Fri Sep 30 12:33:20 2016 +0000
+++ b/m24sr/m24sr_class.h	Thu Oct 27 07:38:00 2016 +0000
@@ -105,7 +105,8 @@
 		M24SR_IO_ERROR_NACK=0x0013,
 		M24SR_IO_ERROR_PARAMETER=0x0014,
 		M24SR_IO_ERROR_NBATEMPT=0x0015,
-		M24SR_IO_NOACKNOWLEDGE=0x0016
+		M24SR_IO_NOACKNOWLEDGE=0x0016,
+		M24SR_IO_PIN_NOT_CONNECTED=0x0017
 	} StatusTypeDef;
 
 	/**