This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.

Dependencies:   NDefLib X_NUCLEO_NFC01A1 mbed

Fork of X-MBED-NFC1 by Giovanni Visentini

This application provides a set of demos with X-NUCLEO-NFC01A1 expansion board.

The available demos are:

  • SAMPLE_WRITE_URL: write a tag with the ST home page URL
  • SAMPLE_COUNT_CLICK: create a custom tag to count and report the user button clicks.
  • SAMPLE_WRITE_AND_CHANGE_ALL: write a tag with all the supported records and update the tag contents when the user button is pressed.
  • SAMPLE_LOCK_TAG_CONTENT: use the M24SR component API to set the NFC tag as read-only.

To enable the different demos comment/uncomment the SAMPLE_* macros provided in main.cpp .

Revision:
2:0648c1561eb2
Parent:
1:6d202b62ed68
--- a/m24sr/m24sr_class.h	Fri Nov 27 15:10:25 2015 +0000
+++ b/m24sr/m24sr_class.h	Tue Dec 01 08:30:54 2015 +0000
@@ -36,14 +36,10 @@
  ******************************************************************************
  */
 
-/* Generated with Stm32CubeTOO -----------------------------------------------*/
-
 /* Revision ------------------------------------------------------------------*/
 /*
- Repository:       http://svn.x-nucleodev.codex.cro.st.com/svnroot/X-NucleoDev
- Branch/Trunk/Tag: trunk
  Based on:         X-CUBE-MEMS1/trunk/Drivers/BSP/Components/m24sr/m24sr.h
- Revision:         402
+ Revision:         M24SR Driver V1.0.0
  */
 
 /* Define to prevent recursive inclusion -------------------------------------*/
@@ -53,22 +49,10 @@
 
 /* Includes ------------------------------------------------------------------*/
 
-/* ACTION 1 ------------------------------------------------------------------*
- * Include here platform specific header files.                               *
- *----------------------------------------------------------------------------*/
 #include "mbed.h"
 #include "I2C.h"
-/* ACTION 2 ------------------------------------------------------------------*
- * Include here component specific header files.                              *
- *----------------------------------------------------------------------------*/
+
 #include "m24sr.h"
-/* ACTION 3 ------------------------------------------------------------------*
- * Include here interface specific header files.                              *
- *                                                                            *
- * Example:                                                                   *
- *   #include "../Interfaces/Humidity_class.h"                                *
- *   #include "../Interfaces/Temperature_class.h"                             *
- *----------------------------------------------------------------------------*/
 #include "Interfaces/Nfc_class.h"
 
 /* Classes -------------------------------------------------------------------*/
@@ -92,16 +76,7 @@
 			Nfc(), address(address), dev_i2c(i2c), GPOPin(GPOPinName), RFDisablePin(
 					RFDISPinName), answerReadyInterrupt(GPOPinName), interruptIsFired(
 					false) {
-		/* ACTION 4 ----------------------------------------------------------*
-		 * Initialize here the component's member variables, one variable per *
-		 * line.                                                              *
-		 *                                                                    *
-		 * Example:                                                           *
-		 *   T0_out = 0;                                                      *
-		 *   T1_out = 0;                                                      *
-		 *   T0_degC = 0;                                                     *
-		 *   T1_degC = 0;                                                     *
-		 *--------------------------------------------------------------------*/
+
 		memset(uM24SRbuffer, 0, 0xFF * sizeof(int8_t));
 		syncMode = M24SR_WAITINGTIME_POLLING;
 		uDIDbyte = 0;
@@ -121,27 +96,6 @@
 	}
 
 	/*** Public Component Related Methods ***/
-
-	/* ACTION 5 --------------------------------------------------------------*
-	 * Implement here the component's public methods, as wrappers of the C    *
-	 * component's functions.                                                 *
-	 * They should be:                                                        *
-	 *   + Methods with the same name of the C component's virtual table's    *
-	 *     functions (1);                                                     *
-	 *   + Methods with the same name of the C component's extended virtual   *
-	 *     table's functions, if any (2).                                     *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   virtual int GetValue(float *pData) //(1)                             *
-	 *   {                                                                    *
-	 *     return COMPONENT_GetValue(float *pfData);                          *
-	 *   }                                                                    *
-	 *                                                                        *
-	 *   virtual int EnableFeature(void) //(2)                                *
-	 *   {                                                                    *
-	 *     return COMPONENT_EnableFeature();                                  *
-	 *   }                                                                    *
-	 *------------------------------------------------------------------------*/
 	virtual int Init(void *ptr) {
 		return (NFC_StatusTypeDef) M24SR_Init((NFC_InitTypeDef*)ptr);
 	}
@@ -217,7 +171,7 @@
 				(uint16_t) uReadOrWrite);
 	}
 
-	/** st propietary */
+	/** st proprietary */
 	virtual NFC_StatusTypeDef STReadBinary(uint16_t Offset,
 			uint8_t NbByteToRead, uint8_t *pBufferRead) {
 		return (NFC_StatusTypeDef) M24SR_STReadBinary((uint16_t) Offset,
@@ -253,61 +207,15 @@
 		return (NFC_StatusTypeDef) M24SR_RFConfig((uint8_t) OnOffChoice);
 	}
 
+	/*** Public Interrupt Related Methods ***/
 	virtual NFC_StatusTypeDef SendInterrupt(void) {
 		return (NFC_StatusTypeDef) M24SR_SendInterrupt();
 	}
 
-	/*** Public Interrupt Related Methods ***/
-
-	/* ACTION 6 --------------------------------------------------------------*
-	 * Implement here interrupt related methods, if any.                      *
-	 * Note that interrupt handling is platform dependent, e.g.:              *
-	 *   + mbed:                                                              *
-	 *     InterruptIn feature_int(pin); //Interrupt object.                  *
-	 *     feature_int.rise(callback);   //Attach a callback.                 *
-	 *     feature_int.mode(PullNone);   //Set interrupt mode.                *
-	 *     feature_int.enable_irq();     //Enable interrupt.                  *
-	 *     feature_int.disable_irq();    //Disable interrupt.                 *
-	 *   + Arduino:                                                           *
-	 *     attachInterrupt(pin, callback, RISING); //Attach a callback.       *
-	 *     detachInterrupt(pin);                   //Detach a callback.       *
-	 *                                                                        *
-	 * Example (mbed):                                                        *
-	 *   void Attach_Feature_IRQ(void (*fptr) (void))                         *
-	 *   {                                                                    *
-	 *     feature_int.rise(fptr);                                            *
-	 *   }                                                                    *
-	 *                                                                        *
-	 *   void Enable_Feature_IRQ(void)                                        *
-	 *   {                                                                    *
-	 *     feature_int.enable_irq();                                          *
-	 *   }                                                                    *
-	 *                                                                        *
-	 *   void Disable_Feature_IRQ(void)                                       *
-	 *   {                                                                    *
-	 *     feature_int.disable_irq();                                         *
-	 *   }                                                                    *
-	 *------------------------------------------------------------------------*/
-
 protected:
 
 	/*** Protected Component Related Methods ***/
 
-	/* ACTION 7 --------------------------------------------------------------*
-	 * Declare here the component's specific methods.                         *
-	 * They should be:                                                        *
-	 *   + Methods with the same name of the C component's virtual table's    *
-	 *     functions (1);                                                     *
-	 *   + Methods with the same name of the C component's extended virtual   *
-	 *     table's functions, if any (2);                                     *
-	 *   + Helper methods, if any, like functions declared in the component's *
-	 *     source files but not pointed by the component's virtual table (3). *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   DrvStatusTypeDef COMPONENT_GetValue(float* pfData); //(1)            *
-	 *   DrvStatusTypeDef COMPONENT_EnableFeature(void);     //(2)            *
-	 *   DrvStatusTypeDef COMPONENT_ComputeAverage(void);    //(3)            *
-	 *------------------------------------------------------------------------*/
 	NFC_StatusTypeDef M24SR_Init(NFC_InitTypeDef *);
 	NFC_StatusTypeDef M24SR_ReadID(uint8_t *nfc_id);
 	NFC_StatusTypeDef M24SR_GetSession(void);
@@ -339,15 +247,10 @@
 	NFC_StatusTypeDef M24SR_RFConfig(uint8_t OnOffChoice);
 	NFC_StatusTypeDef M24SR_FWTExtension(uint8_t FWTbyte);
 
-	/* ACTION 8 --------------------------------------------------------------*
-	 * Implement here other I/O methods beyond those already implemented      *
-	 * above, which are declared extern within the component's header file.   *
-	 *------------------------------------------------------------------------*/
 
+	// platform specific IO method
 	NFC_StatusTypeDef M24SR_IO_IsAnswerReady(void);
-
 	NFC_StatusTypeDef M24SR_IO_SendI2Ccommand(uint8_t NbByte, uint8_t *pBuffer);
-
 	NFC_StatusTypeDef M24SR_IO_ReceiveI2Cresponse(uint8_t NbByte,
 			uint8_t *pBuffer);
 
@@ -371,6 +274,9 @@
 		syncMode = mode;
 	}
 
+	/**
+	 * callback trigger when the chip finish to do a command
+	 */
 	void M24SR_AnswerReadyInterruptCallback() {
 		interruptIsFired = true;
 		answerReadyInterrupt.disable_irq();
@@ -381,14 +287,10 @@
 	/* Identity */
 	uint8_t who_am_i;
 
-	/* ACTION 9 --------------------------------------------------------------*
-	 * There should be only a unique identifier for each component, which     *
-	 * should be the "who_am_i" parameter, hence this parameter is optional.  *
-	 *------------------------------------------------------------------------*/
 	/* Type. */
 	uint8_t type;
 
-	/* Configuration. */
+	/* I2C address */
 	uint8_t address;
 
 	/* IO Device. */
@@ -396,34 +298,36 @@
 
 	/* GPIO */
 	DigitalIn GPOPin;
+
+	/**
+	 * pin used for disable the rf chip functionality
+	 */
 	DigitalOut RFDisablePin;
+
+	/**
+	 * pin used as interrupt
+	 */
 	InterruptIn answerReadyInterrupt;
+
+	/**
+	 * method used for wait the chip response
+	 */
 	M24SR_WAITINGTIME_MGMT syncMode;
 
-	/* Interrupts. */
-	/* ACTION 10 -------------------------------------------------------------*
-	 * Put here interrupt related objects, if needed.                         *
-	 * Note that interrupt handling is platform dependent, see                *
-	 * "Interrupt Related Methods" above.                                     *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   + mbed:                                                              *
-	 *     InterruptIn feature_int;                                           *
-	 *------------------------------------------------------------------------*/
+	/**
+	 * buffer used for build the command to send to the chip
+	 */
+	uint8_t uM24SRbuffer[0xFF];
 
-	/* Data. */
-	/* ACTION 11 -------------------------------------------------------------*
-	 * Declare here the component's data, one variable per line.              *
-	 *                                                                        *
-	 * Example:                                                               *
-	 *   int T0_out;                                                          *
-	 *   int T1_out;                                                          *
-	 *   float T0_degC;                                                       *
-	 *   float T1_degC;                                                       *
-	 *------------------------------------------------------------------------*/
-	uint8_t uM24SRbuffer[0xFF];
+	/**
+	 * ???
+	 */
 	uint8_t uDIDbyte;
-	bool interruptIsFired;
+
+	/**
+	 * state variable change when the interrupt is fired
+	 */
+	volatile bool interruptIsFired;
 };
 
 #endif // __M24SR_CLASS_H