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
Diff: Interfaces/Nfc_class.h
- Revision:
- 19:0b65a5813059
- Parent:
- 12:d1f5eaa85deb
- Child:
- 21:ccc4f3fed4b3
--- a/Interfaces/Nfc_class.h Fri Jan 22 09:04:51 2016 +0000
+++ b/Interfaces/Nfc_class.h Thu Jan 28 14:01:18 2016 +0000
@@ -48,12 +48,20 @@
/* Includes ------------------------------------------------------------------*/
#include "Component_class.h"
-#include "nfc.h"
+#include "../Common/nfc.h"
/* 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.
+ * Then when an interrupt happen you have to call the {@link ManageInterrupt} function.
+ * Note that when you call ManageI2CGPO with other parameters the component will return in sync mode.
*/
class Nfc : public Component
{
@@ -68,6 +76,127 @@
I2CPwd, //!< Root password, used only thought nfc
}PasswordType_t;
+ typedef void(*gpoEventCallback)(void);
+
+ /**
+ * Object that contains all the callback fired by this class, each command has its own callback.
+ * The callback default implementation is an empty function.
+ */
+ class Callback{
+ public:
+
+ /** call when GetSession or KillSession finish */
+ virtual void onSessionOpen(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onDeselect(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onSelectedApplication(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onSelectedCCFile(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onSelectedNDEFFile(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onSelectedSystemFile(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onReadByte(Nfc *nfc,NFC_StatusTypeDef status,
+ uint16_t offset,uint8_t *readByte, uint16_t nReadByte){
+ (void)nfc; (void)status;(void)offset; (void)readByte; (void)nReadByte;
+ }
+
+ virtual void onUpdatedBinary(Nfc *nfc,NFC_StatusTypeDef status,uint16_t offset,
+ uint8_t *writeByte,uint16_t nWriteByte){
+ (void)nfc; (void)status; (void)writeByte; (void)nWriteByte; (void)offset;
+ }
+
+ virtual void onVerifyed(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onManageI2CGPO(Nfc *nfc,NFC_StatusTypeDef status,NFC_GPO_MGMT newStatus){
+ (void)nfc; (void)status;(void)newStatus;
+ }
+
+ virtual void onManageRFGPO(Nfc *nfc,NFC_StatusTypeDef status,NFC_GPO_MGMT newStatus){
+ (void)nfc; (void)status;(void)newStatus;
+ }
+
+ virtual void onChangeReferenceData(Nfc *nfc ,NFC_StatusTypeDef status,PasswordType_t type,
+ uint8_t *data){
+ (void)nfc; (void)status;(void)type;(void)data;
+ }
+
+ virtual void onEnableVerificationRequirement(Nfc *nfc ,NFC_StatusTypeDef status,PasswordType_t type){
+ (void)nfc; (void)status;(void)type;
+ }
+
+ virtual void onDisableVerificationRequirement(Nfc *nfc , NFC_StatusTypeDef status,PasswordType_t type){
+ (void)nfc; (void)status;(void)type;
+ }
+
+ virtual void onEnablePermanentState(Nfc *nfc, NFC_StatusTypeDef status, PasswordType_t type){
+ (void)nfc; (void)status;(void)type;
+ }
+
+ virtual void onDisablePermanentState(Nfc *nfc, NFC_StatusTypeDef status, PasswordType_t type){
+ (void)nfc; (void)status;(void)type;
+ }
+
+ virtual void onReadId(Nfc *nfc, NFC_StatusTypeDef status, uint8_t *id){
+ (void)nfc; (void)status;(void)id;
+ }
+
+ virtual void onEnableReadPassword(Nfc *nfc, NFC_StatusTypeDef status,const uint8_t *newPwd){
+ (void)nfc; (void)status;(void)newPwd;
+ }
+
+ virtual void onEnableWritePassword(Nfc *nfc, NFC_StatusTypeDef status,const uint8_t *newPwd){
+ (void)nfc; (void)status;(void)newPwd;
+ }
+
+ virtual void onDisableReadPassword(Nfc *nfc, NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onDisableWritePassword(Nfc *nfc, NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onDisableAllPassword(Nfc *nfc, NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onEnableReadOnly(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onEnableWriteOnly(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onDisableReadOnly(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual void onDisableWriteOnly(Nfc *nfc,NFC_StatusTypeDef status){
+ (void)nfc; (void)status;
+ }
+
+ virtual ~Callback(){};
+ };
+
+ Nfc():mCallback(&defaultCallback){ }
/**
* Open a I2C connection with the tag if an RF connection isn't already open.
@@ -200,7 +329,7 @@
* @param GPO_I2Cconfig GPO configuration to set.
* @return NFC_SUCCESS if no errors
*/
- virtual NFC_StatusTypeDef ManageI2CGPO(uint8_t GPO_I2Cconfig) = 0;
+ virtual NFC_StatusTypeDef ManageI2CGPO(NFC_GPO_MGMT GPO_I2Cconfig) = 0;
/**
* @brief This function configures GPO for RF session.
@@ -216,7 +345,40 @@
*/
virtual NFC_StatusTypeDef RFConfig(uint8_t OnOffChoice) = 0;
+ /**
+ * Generates a negative pulse on the GPO pin.
+ * Pulse starts immediately after the command is issued and ends at the end of the RF response.
+ * @return NFC_SUCCESS if no errors
+ */
+ virtual NFC_StatusTypeDef SendInterrupt(void)=0;
+
+ /**
+ * Change the function to call when a command ends
+ * @param commandCallback object containings the callback, if NULL it will use empty callback
+ */
+ void SetCallBack(Callback *commandCallback){
+ if(commandCallback!=NULL)
+ mCallback = commandCallback;
+ else
+ mCallback = &defaultCallback;
+ }
+
+ /**
+ * function to call when the component fire an interrupt
+ * @return last operation status
+ */
+ virtual NFC_StatusTypeDef ManageEvent()=0;
+
virtual ~Nfc(){};
+
+private:
+ /** object containing empty callback to use in the default case*/
+ Callback defaultCallback;
+
+protected:
+ /** object containing the callback to use*/
+ Callback *mCallback;
+
};
#endif /* __NFC_CLASS_H */

X-NUCLEO-NFC01A1 Dynamic NFC Tag