ST / X_NUCLEO_NFC01A1

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

Revision:
12:d1f5eaa85deb
Parent:
9:9f2e2e68d695
Child:
14:7e3d436b19ee
diff -r 482175f7ae66 -r d1f5eaa85deb m24sr/m24sr_class.h
--- a/m24sr/m24sr_class.h	Thu Jan 14 08:41:19 2016 +0000
+++ b/m24sr/m24sr_class.h	Thu Jan 14 09:16:40 2016 +0000
@@ -165,26 +165,26 @@
 	
 	virtual NFC_StatusTypeDef Verify(PasswordType_t pwdId, uint8_t NbPwdByte,
 			const uint8_t *pPwd) {
-		return (NFC_StatusTypeDef) M24SR_Verify((uint16_t) pwdId,
+		return (NFC_StatusTypeDef) M24SR_Verify(passwordTypeToConst(pwdId),
 				(uint8_t) NbPwdByte, pPwd);
 	}
 
 	virtual NFC_StatusTypeDef ChangeReferenceData(PasswordType_t pwdId,
 			const uint8_t *pPwd) {
-		return (NFC_StatusTypeDef) M24SR_ChangeReferenceData((uint16_t) pwdId,
+		return (NFC_StatusTypeDef) M24SR_ChangeReferenceData(passwordTypeToConst(pwdId),
 				(uint8_t *) pPwd);
 	}
 
 	virtual NFC_StatusTypeDef EnableVerificationRequirement(
 			PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_EnableVerificationRequirement(
-				(uint16_t) uReadOrWrite);
+				passwordTypeToConst(uReadOrWrite));
 	}
 
 	virtual NFC_StatusTypeDef DisableVerificationRequirement(
 			PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_DisableVerificationRequirement(
-				(uint16_t) uReadOrWrite);
+				passwordTypeToConst(uReadOrWrite));
 	}
 
     ////////////////////// ST proprietary //////////////////////////////////
@@ -197,12 +197,12 @@
 
 	virtual NFC_StatusTypeDef EnablePermanentState(PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_EnablePermanentState(
-				(uint16_t) uReadOrWrite);
+				passwordTypeToConst(uReadOrWrite));
 	}
 
 	virtual NFC_StatusTypeDef DisablePermanentState(PasswordType_t uReadOrWrite) {
 		return (NFC_StatusTypeDef) M24SR_DisablePermanentState(
-				(uint16_t) uReadOrWrite);
+				passwordTypeToConst(uReadOrWrite));
 	}
 
 	///////////////////// chip configuration /////////////////////////////////
@@ -472,6 +472,25 @@
 	 * Object implementing the interface to use the NDefLib.
 	 */
 	NDefNfcTagM24SR NDefTagUtil;
+	
+private:
+	
+	/**
+	 * Convert a generic enum to the value used by the M24SR chip.
+	 * @param type Password type.
+	 * @return equivalent value used inside the m24sr chip */
+	uint16_t passwordTypeToConst(const PasswordType_t &type)const{
+		switch(type){
+			case ReadPwd:
+				return READ_PWD;
+			case WritePwd:
+				return WRITE_PWD;
+			case I2CPwd:
+			default:
+				return I2C_PWD;
+		}
+	}//passwordTypeToConst
+	
 };
 
 #endif // __M24SR_CLASS_H