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: m24sr/m24sr_class.cpp
- Revision:
- 6:96389fb79676
- Parent:
- 4:cb1b4304a93e
- Child:
- 7:19fc04b8fec6
--- a/m24sr/m24sr_class.cpp Tue Dec 22 08:30:06 2015 +0000
+++ b/m24sr/m24sr_class.cpp Tue Dec 22 15:34:24 2015 +0000
@@ -1,7 +1,8 @@
/**
******************************************************************************
* @file m24sr_class.cpp
- * @date 05/11/2015
+ * @author ST Central Labs
+ * @date 05 Nov 2015
* @brief This file provides a set of functions to interface with the M24SR
* device.
******************************************************************************
@@ -1230,4 +1231,79 @@
Error: return NFC_IO_ERROR_I2CTIMEOUT;
}
+////////////////////////hight level utility function //////////////////////////
+
+NFC_StatusTypeDef M24SR::enableReadPassword(const uint8_t* pCurrentWritePassword,
+ const uint8_t* pNewPassword) {
+ errchk(Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword));
+ /* Set new password */
+ errchk(ChangeReferenceData(M24SR::ReadPwd, pNewPassword));
+ return EnableVerificationRequirement(M24SR::ReadPwd);
+}
+
+NFC_StatusTypeDef M24SR::disableReadPassword(const uint8_t* pCurrentWritePassword) {
+ errchk(Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword));
+ return DisableVerificationRequirement(M24SR::ReadPwd);
+}
+
+NFC_StatusTypeDef M24SR::enableWritePassword(const uint8_t* pCurrentWritePassword,
+ uint8_t* pNewPassword) {
+ /* check we have the good password */
+ errchk(Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword));
+ /* Set new password */
+ errchk(ChangeReferenceData(M24SR::WritePwd, pNewPassword));
+ return EnableVerificationRequirement(M24SR::WritePwd);
+}
+
+NFC_StatusTypeDef M24SR::disableWritePassword(const uint8_t* pCurrentWritePassword) {
+ errchk(Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword));
+ return(DisableVerificationRequirement(M24SR::WritePwd));
+}
+
+NFC_StatusTypeDef M24SR::disableAllPassword(const uint8_t* pSuperUserPassword){
+ errchk(Verify(M24SR::I2CPwd, 0x10, pSuperUserPassword));
+
+ errchk(DisablePermanentState(M24SR::ReadPwd));
+ errchk(DisablePermanentState(M24SR::WritePwd));
+
+ errchk(DisableVerificationRequirement(M24SR::ReadPwd));
+ errchk(DisableVerificationRequirement(M24SR::WritePwd));
+
+ /* reset password */
+ errchk(ChangeReferenceData(M24SR::ReadPwd, M24SR::DEFAULT_PASSWORD));
+ return(ChangeReferenceData(M24SR::WritePwd, M24SR::DEFAULT_PASSWORD));
+}
+
+NFC_StatusTypeDef M24SR::enableReadOnly(const uint8_t* pCurrentWritePassword){
+
+ errchk(Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword));
+ /* lock write to have read only */
+ return EnablePermanentState(M24SR::WritePwd);
+}
+
+NFC_StatusTypeDef M24SR::disableReadOnly() {
+
+ errchk(Verify(M24SR::I2CPwd, 0x10, M24SR::DEFAULT_PASSWORD));
+ /* disable write protection to disable read only mode */
+ errchk(DisablePermanentState(M24SR::WritePwd));
+ return(DisableVerificationRequirement(M24SR::WritePwd));
+}
+
+
+NFC_StatusTypeDef M24SR::enableWriteOnly(const uint8_t* pCurrentWritePassword) {
+
+ errchk(Verify(M24SR::WritePwd, 0x10, pCurrentWritePassword));
+ /* disable read access and keep write */
+ return(EnablePermanentState(M24SR::ReadPwd));
+
+}
+
+NFC_StatusTypeDef M24SR::disableWriteOnly() {
+
+ errchk(Verify(M24SR::I2CPwd, 0x10, M24SR::DEFAULT_PASSWORD));
+ /* disable write only -> enable write acces */
+ errchk(DisablePermanentState(M24SR::ReadPwd))
+ return DisableVerificationRequirement(M24SR::ReadPwd);
+}
+
/******************* (C) COPYRIGHT 2013 STMicroelectronics *****END OF FILE****/

X-NUCLEO-NFC01A1 Dynamic NFC Tag