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/NDefNfcTagM24SR.h
- Revision:
- 6:96389fb79676
- Child:
- 7:19fc04b8fec6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/m24sr/NDefNfcTagM24SR.h Tue Dec 22 15:34:24 2015 +0000
@@ -0,0 +1,94 @@
+/**
+ ******************************************************************************
+ * @file Type4NfcTagM24SR.h
+ * @author ST Central Labs
+ * @date 05 Nov 2015
+ * @brief wrapper class for use the NDefLib library for write/read ndef message
+ ******************************************************************************
+ *
+ * COPYRIGHT(c) 2015 STMicroelectronics
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of STMicroelectronics nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ ******************************************************************************
+ */
+
+#ifndef NDEFNFCTAGSTM24_H_
+#define NDEFNFCTAGSTM24_H_
+#include <stdint.h>
+
+#include "NDefLib/NDefNfcTag.h"
+
+class M24SR;
+
+/**
+ * implement the abstract method for use the NDefLib,
+ * all method must be called after opening a session
+ */
+class NDefNfcTagM24SR: public NDefLib::NDefNfcTag {
+
+public:
+ /**
+ *
+ * @param device device where write the Ndef tags
+ */
+ NDefNfcTagM24SR(M24SR &device) :
+ mDevice(device), mMaxReadBytes(0xFF), mMaxWriteBytes(
+ 0xFF) {
+ }
+
+
+ virtual bool openSession(bool force = false);
+ virtual bool closeSession();
+
+ /**
+ * close the open session
+ */
+ virtual ~NDefNfcTagM24SR() {
+ if(isSessionOpen())
+ closeSession();
+ }//~Type4NfcTagM24SR
+
+
+
+protected:
+ virtual bool writeByte(const uint8_t *buffer, const uint16_t length, uint16_t offset);
+ virtual bool readByte(const uint16_t byteOffset, const uint16_t byteLength,
+ uint8_t *buffer);
+
+private:
+
+ M24SR &mDevice;
+
+ /**
+ * max length for a read operation
+ */
+ uint16_t mMaxReadBytes;
+
+ /**
+ * max length for a write operation
+ */
+ uint16_t mMaxWriteBytes;
+};
+
+#endif /* NDEFNFCTAGSTM24_H_ */

X-NUCLEO-NFC01A1 Dynamic NFC Tag