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:
Tue Feb 02 16:04:24 2016 +0000
Parent:
23:d07138541feb
Child:
25:caa16fd0e50b
Commit message:
update docs

Changed in this revision

Interfaces/Nfc_class.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/NDefNfcTagM24SR.h 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/Interfaces/Nfc_class.h	Mon Feb 01 15:32:40 2016 +0000
+++ b/Interfaces/Nfc_class.h	Tue Feb 02 16:04:24 2016 +0000
@@ -53,16 +53,16 @@
 /* Classes  ------------------------------------------------------------------*/
 
 /**
- * An abstract class for Nfc components.
- * This component has two operation mode, sync or async.
- * In the sync mode each function will return only when the command is complete.
- * In the async mode the function will only send the command and the answer will be notify
- * thought a callback.
- * The default behavior is sync mode.
- * For enable the async mode you have to call the ManageI2CGPO(I2C_ANSWER_READY) function.
- * When the component notify an interrupt you have to call the  {@link ManageInterrupt} function.
- * Note that when you call ManageI2CGPO with other parameters the component will return in sync mode.
- */
+* An abstract class for Nfc components. 
+* This component has two operation modes, sync or async.
+* In sync mode each function call returns only after the command has completed.
+* In async mode each function call returns immediately and the answer will be notified
+* through a callback.
+* The default behavior is sync mode.
+* To enable the async mode ManageI2CGPO(I2C_ANSWER_READY) function must be called.
+* When the component notifies an interrupt user must call  {@link ManageEvent} function.
+* Note that passing a parameter other than I2C_ANSWER_READY to ManageI2CGPO initialize the component in sync mode.
+*/
 class Nfc : public Component
 {
 public:
@@ -71,9 +71,9 @@
 	 * Possible password to set.
 	 */
 	typedef enum{
-		ReadPwd,   //!< Password to use before read the tag
-		WritePwd,  //!< Password to use before write the tag
-		I2CPwd,    //!< Root password, used only thought nfc
+		ReadPwd,   //!< Password to use before reading the tag
+		WritePwd,  //!< Password to use before writing the tag
+		I2CPwd,    //!< Root password, used only through nfc
 	}PasswordType_t;
 
 	/**
@@ -83,13 +83,13 @@
 	typedef void(*gpoEventCallback)(void);
 
 	/**
-	 * Object that contains all the callback fired by this class, each command has its own callback.
+	 * Object that contains all the callbacks fired by this class, each command has its own callback.
 	 * The callback default implementation is an empty function.
 	 */
-	class Callback{
+	class Callbacks{
 	public:
 
-		/** call when GetSession or KillSession finish */
+		/** called when GetSession or KillSession finish */
 		virtual void onSessionOpen(Nfc *nfc,NFC_StatusTypeDef status){
 			(void)nfc; (void)status;
 		}
@@ -124,7 +124,7 @@
 			(void)nfc; (void)status; (void)writeByte; (void)nWriteByte; (void)offset;
 		}
 
-		virtual void onVerifyed(Nfc *nfc,NFC_StatusTypeDef status,PasswordType_t uPwdId,
+		virtual void onVerified(Nfc *nfc,NFC_StatusTypeDef status,PasswordType_t uPwdId,
 				const uint8_t *pwd){
 			(void)nfc; (void)status;(void)uPwdId;(void)pwd;
 		}
@@ -198,7 +198,7 @@
 			(void)nfc; (void)status;
 		}
 
-		virtual ~Callback(){};
+		virtual ~Callbacks(){};
 	};
 
 	Nfc():mCallback(&defaultCallback),
@@ -364,7 +364,7 @@
 	 * Change the function to call when a command ends.
 	 * @param commandCallback Object containing the callback, if NULL it will use empty callback
 	 */
-	void SetCallback(Callback *commandCallback){
+	void SetCallback(Callbacks *commandCallback){
 		if(commandCallback!=NULL)
 			mCallback = commandCallback;
 		else
@@ -378,7 +378,7 @@
 	virtual NFC_StatusTypeDef ManageEvent()=0;
 
 
-	///////////////////////HIGHT LEVEL /UTILITY FUNCTION ////////////////////////////////////
+	///////////////////////HIGH LEVEL / UTILITY FUNCTIONS ////////////////////////////////////
 
 	/**
 	 * Enable the request of a password before reading the tag.
@@ -509,21 +509,21 @@
 	virtual ~Nfc(){};
 
 protected:
-		/** object containing the callback to use*/
-		Callback *mCallback;
+		/** object containing the callbacks to use*/
+		Callbacks *mCallback;
 
 		/**
-		 * Object with private callback used for hide height level commands
-		 * that require more than one low level command.
-		 * This object has an height priority comparing the user callback
+		 * Object with private callbacks used to hide high level commands each
+		 * calling multiple low level commands. This callbacks object has 
+		 * higher priority comparing to the user callbacks.
 		 */
-		Nfc::Callback *mComponentCallback;
+		Nfc::Callbacks *mComponentCallback;
 
 		/**
 		 * get the callback object to use
 		 * @return callback object to use
 		 */
-		Nfc::Callback * getCallback(){
+		Nfc::Callbacks * getCallback(){
 			if(mComponentCallback!=NULL)
 				return mComponentCallback;
 			return mCallback;
@@ -531,12 +531,12 @@
 
 private:
 	/** object containing empty callback to use in the default case*/
-	Callback defaultCallback;
+	Callbacks defaultCallback;
 
 
 	/**
-	 * This class permit to enable/disable the password request to read/write into the tag
-	 * This class is equivalent to call the method:
+	 * This class permits to enable/disable the password request to read/write into the tag
+	 * This class is equivalent to calling the methods:
 	 * To enable the request:
 	 * <ul>
 	 *   <li> Verify </li>
@@ -549,12 +549,12 @@
 	 *   <li> DisableVerificationRequirement </li>
 	 * </ul>
 	 */
-	class ChangePasswordRequestStatusCallback : public Nfc::Callback{
+	class ChangePasswordRequestStatusCallback : public Nfc::Callbacks{
 
 		public:
 
 			/**
-			 * Build the chain of callback.
+			 * Build the chain of callbacks.
 			 * @param parent object where send the command
 			 */
 			ChangePasswordRequestStatusCallback():
@@ -571,7 +571,7 @@
 				mEnable=newPwd!=NULL;
 			}//setTask
 
-			virtual void onVerifyed(Nfc *nfc, NFC_StatusTypeDef status,PasswordType_t ,
+			virtual void onVerified(Nfc *nfc, NFC_StatusTypeDef status,PasswordType_t ,
 					const uint8_t *){
 				if(status!=NFC_SUCCESS)
 					return onFinishCommand(nfc,status);
@@ -604,7 +604,7 @@
 		private:
 
 			/**
-			 * Remove the private callback and call the user callback.
+			 * Remove the private callbacks and call the user callback.
 			 * @param nfc Object where the command is run.
 			 * @param status Command status.
 			 */
@@ -638,8 +638,8 @@
 		friend class ChangePasswordRequestStatusCallback;
 
 		/**
-		 * This class permit to disable all the password request to read/write into the tag
-		 * This class is equivalent to call the methods:
+		 * This class permits to disable all the password requests to read/write into the tag
+		 * This class is equivalent to calling the methods:
 		 * <ul>
 		 *   <li> Verify(i2c) </li>
 		 *   <li> DisablePermanentState(Read) </li>
@@ -650,7 +650,7 @@
 		 *   <li> ChangeReferenceData(write) </li>
 		 * </ul>
 		 */
-		class RemoveAllPasswordCallback : public Nfc::Callback{
+		class RemoveAllPasswordCallback : public Nfc::Callbacks{
 
 			/**
 			 * Store the default password used for open a super user session
@@ -661,12 +661,12 @@
 			public:
 
 				/**
-				 * Build the chain of callback.
-				 * @param parent object where send the command
+				 * Build the chain of callbacks.
+				 * @param parent object where to send the command
 				 */
 				RemoveAllPasswordCallback():mI2CPwd(NULL){}
 
-				virtual void onVerifyed(Nfc *nfc,NFC_StatusTypeDef status,
+				virtual void onVerified(Nfc *nfc,NFC_StatusTypeDef status,
 						PasswordType_t,const uint8_t* data){
 					if(status!=NFC_SUCCESS)
 						return onFinishCommand(nfc,status);
@@ -721,14 +721,14 @@
 
 
 		/**
-		 * Object containing the callback chain needed remove the password request
+		 * Object containing the callback chain needed to remove the password request
 		 */
 		RemoveAllPasswordCallback mRemoveAllPasswordCallback;
 		friend class RemoveAllPasswordCallback;
 
 		/**
-		 * This class permit set the tag as read/write only
-		 * This class is equivalent to call the methods:
+		 * This class permits to set the tag as read/write only
+		 * This class is equivalent to calling the methods:
 		 * <ul>
 		 *   <li> Verify(i2c) </li>
 		 *   <li> EnablePermanentState(Read/write) </li>
@@ -740,7 +740,7 @@
 		 *   <li> DisableVerificationRequirement(Read/write) </li>
 		 * </ul>
 		 */
-		class ChangeAccessStateCallback : public Nfc::Callback{
+		class ChangeAccessStateCallback : public Nfc::Callbacks{
 
 			public:
 
@@ -750,22 +750,22 @@
 				}AccessType_t;
 
 				/**
-				 * Build the chain of callback.
-				 * @param parent object where send the command
+				 * Build the chain of callbacks.
+				 * @param parent object where to send the command
 				 */
 				ChangeAccessStateCallback():mType(WRITE),mEnable(false){}
 
 				/**
-				 * Set the access to enable/disable.
-				 * @param type Type to enable or disable.
-				 * @param enable true for enable the state, false for disable it.
+				 * Set the access to enable/disable an access type.
+				 * @param type Access type.
+				 * @param enable True to enable the state, False to disable it.
 				 */
 				void changeAccessState(AccessType_t type,bool enable){
 					mType=type;
 					mEnable=enable;
 				}
 
-				virtual void onVerifyed(Nfc *nfc,NFC_StatusTypeDef status,
+				virtual void onVerified(Nfc *nfc,NFC_StatusTypeDef status,
 						PasswordType_t,const uint8_t*){
 					if(status!=NFC_SUCCESS)
 						return onFinishCommand(nfc,status);
--- a/m24sr/NDefNfcTagM24SR.cpp	Mon Feb 01 15:32:40 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.cpp	Tue Feb 02 16:04:24 2016 +0000
@@ -4,7 +4,7 @@
   * @author  	ST Central Labs
   * @version 	V1.0.0
   * @date       05 Nov 2015
-  * @brief      wrapper class for use the NDefLib library for write/read ndef message
+  * @brief      Wrapper class of the NDefLib library to write/read NDEF messages
   ******************************************************************************
   * @attention
   *
--- a/m24sr/NDefNfcTagM24SR.h	Mon Feb 01 15:32:40 2016 +0000
+++ b/m24sr/NDefNfcTagM24SR.h	Tue Feb 02 16:04:24 2016 +0000
@@ -112,7 +112,7 @@
 		 * Class containing the callback needed to open a session and read the max
 		 * read/write size
 		 */
-		class OpenSessionCallBack: public Nfc::Callback{
+		class OpenSessionCallBack: public Nfc::Callbacks{
 			public:
 				OpenSessionCallBack(NDefNfcTagM24SR &sender);
 
@@ -146,7 +146,7 @@
 		/**
 		 * Class containing the callback needed to close a session
 		 */
-		class CloseSessionCallBack : public Nfc::Callback{
+		class CloseSessionCallBack : public Nfc::Callbacks{
 			public:
 				CloseSessionCallBack(NDefNfcTagM24SR &sender):
 					mSender(sender){}
@@ -174,7 +174,7 @@
 		/**
 		 * Class containing the callback needed to write a buffer
 		 */
-		class WriteByteCallback : public Nfc::Callback{
+		class WriteByteCallback : public Nfc::Callbacks{
 			public:
 
 				/**
@@ -233,7 +233,7 @@
 		/**
 		 * Class containing the callback needed to read a buffer
 		 */
-		class ReadByteCallback : public Nfc::Callback{
+		class ReadByteCallback : public Nfc::Callbacks{
 			public:
 
 				/**
--- a/m24sr/m24sr_class.cpp	Mon Feb 01 15:32:40 2016 +0000
+++ b/m24sr/m24sr_class.cpp	Tue Feb 02 16:04:24 2016 +0000
@@ -917,7 +917,7 @@
 
 	/*check the parameters */
 	if ((uPwdId > 0x0003)|| ((NbPwdByte != 0x00) && (NbPwdByte != 0x10))) {
-		getCallback()->onVerifyed(this,NFC_IO_ERROR_PARAMETER,constToPasswordType(uPwdId),pPwd);
+		getCallback()->onVerified(this,NFC_IO_ERROR_PARAMETER,constToPasswordType(uPwdId),pPwd);
 		return NFC_IO_ERROR_PARAMETER;
 	}
 
@@ -946,7 +946,7 @@
 	/* send the request */
 	status = M24SR_IO_SendI2Ccommand(NbByte, pBuffer);
 	if(status!=NFC_SUCCESS){
-		getCallback()->onVerifyed(this,status,constToPasswordType(uPwdId),pPwd);
+		getCallback()->onVerified(this,status,constToPasswordType(uPwdId),pPwd);
 		return status;
 	}
 	mLastCommandSend=VERIFY;
@@ -960,7 +960,7 @@
 			return M24SR_ReceiveVerify();
 		else{
 			mLastCommandSend = NONE;
-			getCallback()->onVerifyed(this,status,constToPasswordType(uPwdId),pPwd);
+			getCallback()->onVerified(this,status,constToPasswordType(uPwdId),pPwd);
 			return status;
 		}
 	}
@@ -979,12 +979,12 @@
 	status=M24SR_IO_ReceiveI2Cresponse (sizeof(respBuffer),respBuffer);
 
 	if(status !=NFC_SUCCESS){
-		getCallback()->onVerifyed(this,status,type,data);
+		getCallback()->onVerified(this,status,type,data);
 		return status;
 	}
 
 	status = M24SR_IsCorrectCRC16Residue(respBuffer, M24SR_STATUSRESPONSE_NBBYTE);
-	getCallback()->onVerifyed(this,status,type,data);
+	getCallback()->onVerified(this,status,type,data);
 	return status;
 }
 
--- a/m24sr/m24sr_class.h	Mon Feb 01 15:32:40 2016 +0000
+++ b/m24sr/m24sr_class.h	Tue Feb 02 16:04:24 2016 +0000
@@ -81,7 +81,7 @@
 	 * @brief Constructor.
 	 * @param address I2C address of the component.
 	 * @param I2C     I2C device to be used for communication.
-	 * @param eventCallback Function that will be called when the gpo pin status change.
+	 * @param eventCallback Function that will be called when the gpo pin status changes.
 	 * @param GPOPinName Pin used as GPIO.
 	 * @param RFDISPinName Pin used to disable the RF function.
 	 */
@@ -423,12 +423,12 @@
 	}M24SR_command_t;
 
 	/**
-	 * User parameter used invoke the command, it is used for remember the data between a
-	 * command and a rensponse
+ 	 * User parameter used to invoke a command,
+ 	 * it is used to provide the data back with the response
 	 */
 	typedef struct{
 		uint8_t *data; //!< data
-		uint16_t length; //!< number of byte in the data array
+		uint16_t length; //!< number of bytes in the data array
 		uint16_t offset; //!< offset parameter used in the read/write command
 	}M24SR_command_data_t;
 
@@ -436,27 +436,27 @@
 	 * Communication mode used by this device
 	 */
 	typedef enum{
-		SYNC,//!< SYNC wait the command response before return
-		ASYNC//!< ASYNC use a callback for notify the end of a command
+		SYNC,//!< SYNC wait the command response before returning
+		ASYNC//!< ASYNC use a callback to notify the end of a command
 	}M24SR_communication_t;
 
 	/**
-	 * Type of communication that we are using
+	 * Type of communication being used
 	 */
 	M24SR_communication_t mCommunicationType;
 
 	/**
-	 * The class is wait the answer of this command
+	 * Last pending command
 	 */
 	M24SR_command_t mLastCommandSend;
 
 	/**
-	 * Parameter used for invoke the last command
+	 * Parameter used to invoke the last command
 	 */
 	M24SR_command_data_t mLastCommandData;
 
 	/**
-	 * Interrupt object fired when the gpo status change
+	 * Interrupt object fired when the gpo status changes
 	 */
 	InterruptIn mGpoEventInterrupt;
 private:
@@ -464,30 +464,30 @@
 
 	/**
 	 * Object with the callback used to send a ManageGPO command.
-	 * This class is equivalent to call the method:
+	 * This class is equivalent to calling the methods:
 	 * <ul>
 	 *   <li> SelectedApplication </li>
 	 *   <li> SelectSystemfile </li>
 	 *   <li> ReadBinar: read the old value </li>
-	 *   <li> onVerifyed </li>
+	 *   <li> onVerified </li>
 	 *   <li> onUpdatedBinary: write the new value</li>
 	 * </ul>
 	 */
-	class ManageGPOCallback : public Nfc::Callback{
+	class ManageGPOCallback : public Nfc::Callbacks{
 
 	public:
 
 		/**
-		 * Create the MamageGpoCallback command chain.
-		 * @param parent component where run the command.
+		 * Build the chain of callbacks.
+		 * @param parent Parent component to run the command on.
 		 */
 		ManageGPOCallback(M24SR &parent):mParent(parent),
 				mGpoConfig(HIGH_IMPEDANCE),mReadGpoConfig(0),mI2CGpo(true){}
 
 
 		/**
-		 * Command parameters
-		 * @param i2cGpo true if you want change the i2c gpo, false for change the rf gpo.
+		 * Command parameters.
+		 * @param i2cGpo true to change the i2c gpo, false for the rf gpo.
 		 * @param newConfig new gpo function.
 		 */
 		void setNewGpoConfig(bool i2cGpo,NFC_GPO_MGMT newConfig){
@@ -517,7 +517,7 @@
 				onFinishCommand(nfc,status);
 		}
 
-		virtual void onVerifyed(Nfc *nfc,NFC_StatusTypeDef status,PasswordType_t, const uint8_t*){
+		virtual void onVerified(Nfc *nfc,NFC_StatusTypeDef status,PasswordType_t, const uint8_t*){
 			if(status!=NFC_SUCCESS)
 				return onFinishCommand(nfc,status);
 
@@ -545,9 +545,9 @@
 	private:
 
 		/**
-		 * Remove the private callback and call the user callback
-		 * @param nfc Object where the command complete
-		 * @param status Command status
+		 * Remove the private callback and call the user callback.
+		 * @param nfc Object where the command was send.
+		 * @param status Command status.
 		 */
 		void onFinishCommand(Nfc *nfc,NFC_StatusTypeDef status){
 			mParent.mComponentCallback=NULL;
@@ -559,7 +559,7 @@
 		}//onFinishCommand
 
 		/**
-		 * component where run the command
+		 * Component where send the commands
 		 */
 		M24SR &mParent;
 
@@ -567,12 +567,12 @@
 		NFC_GPO_MGMT mGpoConfig;
 
 		/**
-		 * variable where store the read gpo configuration
+		 * variable where storeing the read gpo configuration
 		 */
 		uint8_t mReadGpoConfig;
 
 		/**
-		 * true for change the i2c gpo, false for change the rf gpo
+		 * true to change the i2c gpo, false to change the rf gpo
 		 */
 		bool mI2CGpo;
 
@@ -586,25 +586,25 @@
 
 	/**
 	 * Object with the callback used to read the component ID
-	 * This class is equivalent to call the method:
+	 * This class is equivalent to calling the methods:
 	 * <ul>
 	 *   <li> SelectedApplication </li>
 	 *   <li> SelectSystemfile </li>
 	 *   <li> ReadBinary </li>
 	 * </ul>
 	 */
-	class ReadIDCallback : public Nfc::Callback{
+	class ReadIDCallback : public Nfc::Callbacks{
 
 	public:
 
 		/**
-		 * build the chain of callback
-		 * @param parent object where send the command
+		 * Build the chain of callbacks.
+		 * @param parent object where to send the command to.
 		 */
 		ReadIDCallback(M24SR &parent):mParent(parent),mIdPtr(NULL){}
 
 		/**
-		 * set the location where write the result
+		 * Set the variable containing the result
 		 * @param idPtr
 		 */
 		void readIdOn(uint8_t *idPtr){
@@ -634,9 +634,9 @@
 	private:
 
 		/**
-		 * remove the private callback and call the user onReadId function
-		 * @param nfc object where the command run
-		 * @param status command status
+		 * Remove the private callback and call the user onReadId function.
+		 * @param nfc Object where the command was send.
+		 * @param status Command status.
 		 */
 		void onFinishCommand(Nfc *nfc,NFC_StatusTypeDef status){
 			mParent.mComponentCallback=NULL;
@@ -646,16 +646,17 @@
 		M24SR& mParent;
 
 		/**
-		 * location where write the read id
+		 * pointer to read id
 		 */
 		uint8_t *mIdPtr;
 	};
 
-	friend class ReadIDCallback;
+
 	/**
 	 * Object containing the callback chain needed to read the component id
 	 */
 	ReadIDCallback mReadIDCallback;
+	friend class ReadIDCallback;
 
 	/**
 	 * Convert a generic enum to the value used by the M24SR chip.