X_NUCLEO_NFC02A1 library for M24LR

Dependencies:   ST_INTERFACES

Dependents:   HelloWorld_NFC02A1_mbedOS HelloWorld_NFC02A1laatste HelloWorld_NFC02A1

Fork of X_NUCLEO_NFC02A1 by ST Expansion SW Team

X-NUCLEO-NFC02A1 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-NFC02A1 Dynamic NFC Tag Expansion Board based on M24LR.

Firmware Library

Class X_NUCLEO_NFC02A1 is intended to represent the Dynamic NFC Tag Expansion Board with the same name.
It provides an API to access to the M24LR component and to the three onboard LEDs.
It is intentionally implemented as a singleton because only one X_NUCLEO_NFC02A1 at a time might be deployed in a HW component stack.
The library also provides an implementation of the NDEF library API for M24LR, providing an simple way to read/write NDEF formatted messages from/to the M24LR dynamic NFC tag.

Example application

Hello World is a simple application to program and read an URI from the NFC tag.

Committer:
Davidroid
Date:
Wed Sep 28 12:26:49 2016 +0000
Revision:
2:dd4242314663
Parent:
Interfaces/X_NUCLEO_NFC02A1.h@0:71bff5ad0a49
Removed "Interfaces" folder.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rosarium 0:71bff5ad0a49 1 /**
rosarium 0:71bff5ad0a49 2 ******************************************************************************
rosarium 0:71bff5ad0a49 3 * @file X_NUCLEO_NFC02A1.cpp
rosarium 0:71bff5ad0a49 4 * @author AMG Central Lab
rosarium 0:71bff5ad0a49 5 * @version 1.0.0
rosarium 0:71bff5ad0a49 6 * @date 30 Aug 2016
rosarium 0:71bff5ad0a49 7 * @brief Singleton class that controls all the electronics inside the
rosarium 0:71bff5ad0a49 8 * X_NUCLEO_NFC02A1 expansion board.
rosarium 0:71bff5ad0a49 9 ******************************************************************************
rosarium 0:71bff5ad0a49 10 * @attention
rosarium 0:71bff5ad0a49 11 *
rosarium 0:71bff5ad0a49 12 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
rosarium 0:71bff5ad0a49 13 *
rosarium 0:71bff5ad0a49 14 * Redistribution and use in source and binary forms, with or without modification,
rosarium 0:71bff5ad0a49 15 * are permitted provided that the following conditions are met:
rosarium 0:71bff5ad0a49 16 * 1. Redistributions of source code must retain the above copyright notice,
rosarium 0:71bff5ad0a49 17 * this list of conditions and the following disclaimer.
rosarium 0:71bff5ad0a49 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
rosarium 0:71bff5ad0a49 19 * this list of conditions and the following disclaimer in the documentation
rosarium 0:71bff5ad0a49 20 * and/or other materials provided with the distribution.
rosarium 0:71bff5ad0a49 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
rosarium 0:71bff5ad0a49 22 * may be used to endorse or promote products derived from this software
rosarium 0:71bff5ad0a49 23 * without specific prior written permission.
rosarium 0:71bff5ad0a49 24 *
rosarium 0:71bff5ad0a49 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
rosarium 0:71bff5ad0a49 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
rosarium 0:71bff5ad0a49 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rosarium 0:71bff5ad0a49 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
rosarium 0:71bff5ad0a49 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
rosarium 0:71bff5ad0a49 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
rosarium 0:71bff5ad0a49 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
rosarium 0:71bff5ad0a49 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
rosarium 0:71bff5ad0a49 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
rosarium 0:71bff5ad0a49 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
rosarium 0:71bff5ad0a49 35 *
rosarium 0:71bff5ad0a49 36 ******************************************************************************
rosarium 0:71bff5ad0a49 37 */
rosarium 0:71bff5ad0a49 38
rosarium 0:71bff5ad0a49 39 #ifndef X_NUCLEO_NFC02A1_H_
rosarium 0:71bff5ad0a49 40 #define X_NUCLEO_NFC02A1_H_
rosarium 0:71bff5ad0a49 41 #include <stdint.h>
rosarium 0:71bff5ad0a49 42
rosarium 0:71bff5ad0a49 43 #include "mbed.h"
rosarium 0:71bff5ad0a49 44
rosarium 0:71bff5ad0a49 45 #include "m24lr/m24lr.h"
rosarium 0:71bff5ad0a49 46
rosarium 0:71bff5ad0a49 47 /**
rosarium 0:71bff5ad0a49 48 * Singleton class that controls all the electronics inside the X_NUCLEO_NFC02A1 expansion board.
rosarium 0:71bff5ad0a49 49 */
rosarium 0:71bff5ad0a49 50 class X_NUCLEO_NFC02A1 {
rosarium 0:71bff5ad0a49 51
rosarium 0:71bff5ad0a49 52 public:
rosarium 0:71bff5ad0a49 53
rosarium 0:71bff5ad0a49 54 private:
rosarium 0:71bff5ad0a49 55 /**
rosarium 0:71bff5ad0a49 56 * Ponter to the singleton instance, NULL if not allocated.
rosarium 0:71bff5ad0a49 57 */
rosarium 0:71bff5ad0a49 58 static X_NUCLEO_NFC02A1 *mInstance;
rosarium 0:71bff5ad0a49 59 /**
rosarium 0:71bff5ad0a49 60 * I2C address of the M24LR chip.
rosarium 0:71bff5ad0a49 61 */
rosarium 0:71bff5ad0a49 62 static const uint8_t M24LR_ADDR;
rosarium 0:71bff5ad0a49 63
rosarium 0:71bff5ad0a49 64 static const uint8_t M24LR_ADDR_DATA;
rosarium 0:71bff5ad0a49 65
rosarium 0:71bff5ad0a49 66 /**
rosarium 0:71bff5ad0a49 67 * Constructor
rosarium 0:71bff5ad0a49 68 * @param devI2C I2C channel used to communicate with the board.
rosarium 0:71bff5ad0a49 69 * @param eventCallback Function that will be called when the gpo pin status change.
rosarium 0:71bff5ad0a49 70 * @param gpoName Name of the gpio pin of the M24LR chip.
rosarium 0:71bff5ad0a49 71 * @param RFDisableName Pin that controls the rf antenna status.
rosarium 0:71bff5ad0a49 72 * @param led1Name Pin to control the led1 status.
rosarium 0:71bff5ad0a49 73 * @param led2Name Pin to control the led1 status.
rosarium 0:71bff5ad0a49 74 * @param led3Name Pin to control the led1 status.
rosarium 0:71bff5ad0a49 75 */
rosarium 0:71bff5ad0a49 76 X_NUCLEO_NFC02A1(DevI2C &devI2C,
rosarium 0:71bff5ad0a49 77 const PinName &gpoName, const PinName &RFDisableName,
rosarium 0:71bff5ad0a49 78 const PinName &led1Name, const PinName &led2Name,
rosarium 0:71bff5ad0a49 79 const PinName &led3Name):
rosarium 0:71bff5ad0a49 80 mM24LR(M24LR_ADDR, M24LR_ADDR_DATA, devI2C),
rosarium 0:71bff5ad0a49 81 mNfcLed1(led1Name),mNfcLed2(led2Name),mNfcLed3(led3Name){}
rosarium 0:71bff5ad0a49 82
rosarium 0:71bff5ad0a49 83 public:
rosarium 0:71bff5ad0a49 84 static const PinName DEFAULT_SDA_PIN; //!< Default pin used for the M24LR SDA signal.
rosarium 0:71bff5ad0a49 85 static const PinName DEFAULT_SDL_PIN; //!< Default pin used for the M24LR SDL signal.
rosarium 0:71bff5ad0a49 86 static const PinName DEFAULT_GPO_PIN; //!< Default pin used for the M24LR GPO signal.
rosarium 0:71bff5ad0a49 87 static const PinName DEFAULT_RF_DISABLE_PIN; //!< Default pin used for M24LR RF_DISABLE signal.
rosarium 0:71bff5ad0a49 88 static const PinName DEFAULT_LED1_PIN; //!< Default pin to control the led 1.
rosarium 0:71bff5ad0a49 89 static const PinName DEFAULT_LED2_PIN; //!< Default pin to control the led 2.
rosarium 0:71bff5ad0a49 90 static const PinName DEFAULT_LED3_PIN; //!< Default pin to control the led 3.
rosarium 0:71bff5ad0a49 91
rosarium 0:71bff5ad0a49 92 /**
rosarium 0:71bff5ad0a49 93 * Create or return an instance of X_NUCLEO_NFC02A1.
rosarium 0:71bff5ad0a49 94 * @param devI2C I2C channel used to communicate with the board.
rosarium 0:71bff5ad0a49 95 * @param eventCallback Function that will be called when the gpo pin status change.
rosarium 0:71bff5ad0a49 96 * @param gpoName Name of the gpio pin of the M24LR chip.
rosarium 0:71bff5ad0a49 97 * @param RFDisableName Pin that controls the rf antenna status.
rosarium 0:71bff5ad0a49 98 * @param led1Name Pin to control the led1 status.
rosarium 0:71bff5ad0a49 99 * @param led2Name Pin to control the led1 status.
rosarium 0:71bff5ad0a49 100 * @param led3Name Pin to control the led1 status.
rosarium 0:71bff5ad0a49 101 */
rosarium 0:71bff5ad0a49 102 static X_NUCLEO_NFC02A1* Instance(DevI2C &devI2C,
rosarium 0:71bff5ad0a49 103 const PinName &gpoName = DEFAULT_GPO_PIN,
rosarium 0:71bff5ad0a49 104 const PinName &RFDisableName = DEFAULT_RF_DISABLE_PIN,
rosarium 0:71bff5ad0a49 105 const PinName &led1Name = DEFAULT_LED1_PIN,
rosarium 0:71bff5ad0a49 106 const PinName &led2Name = DEFAULT_LED2_PIN,
rosarium 0:71bff5ad0a49 107 const PinName &led3Name = DEFAULT_LED3_PIN);
rosarium 0:71bff5ad0a49 108
rosarium 0:71bff5ad0a49 109 /**
rosarium 0:71bff5ad0a49 110 * @return board led1.
rosarium 0:71bff5ad0a49 111 */
rosarium 0:71bff5ad0a49 112 DigitalOut& getLed1() {
rosarium 0:71bff5ad0a49 113 return mNfcLed1;
rosarium 0:71bff5ad0a49 114 }
rosarium 0:71bff5ad0a49 115
rosarium 0:71bff5ad0a49 116 /**
rosarium 0:71bff5ad0a49 117 * @return board led2.
rosarium 0:71bff5ad0a49 118 */
rosarium 0:71bff5ad0a49 119 DigitalOut& getLed2() {
rosarium 0:71bff5ad0a49 120 return mNfcLed2;
rosarium 0:71bff5ad0a49 121 }
rosarium 0:71bff5ad0a49 122
rosarium 0:71bff5ad0a49 123 /**
rosarium 0:71bff5ad0a49 124 * @return board led3.
rosarium 0:71bff5ad0a49 125 */
rosarium 0:71bff5ad0a49 126 DigitalOut& getLed3() {
rosarium 0:71bff5ad0a49 127 return mNfcLed3;
rosarium 0:71bff5ad0a49 128 }
rosarium 0:71bff5ad0a49 129
rosarium 0:71bff5ad0a49 130 /**
rosarium 0:71bff5ad0a49 131 * @return NFC Chip.
rosarium 0:71bff5ad0a49 132 */
rosarium 0:71bff5ad0a49 133 M24LR& getNFCTagM24LR() {
rosarium 0:71bff5ad0a49 134 return mM24LR;
rosarium 0:71bff5ad0a49 135 }
rosarium 0:71bff5ad0a49 136
rosarium 0:71bff5ad0a49 137 M24LR& getM24LR() {
rosarium 0:71bff5ad0a49 138 return mM24LR;
rosarium 0:71bff5ad0a49 139 }
rosarium 0:71bff5ad0a49 140
rosarium 0:71bff5ad0a49 141 virtual ~X_NUCLEO_NFC02A1() {
rosarium 0:71bff5ad0a49 142 }
rosarium 0:71bff5ad0a49 143
rosarium 0:71bff5ad0a49 144 private:
rosarium 0:71bff5ad0a49 145 M24LR mM24LR;
rosarium 0:71bff5ad0a49 146
rosarium 0:71bff5ad0a49 147 DigitalOut mNfcLed1;
rosarium 0:71bff5ad0a49 148 DigitalOut mNfcLed2;
rosarium 0:71bff5ad0a49 149 DigitalOut mNfcLed3;
rosarium 0:71bff5ad0a49 150
rosarium 0:71bff5ad0a49 151 };
rosarium 0:71bff5ad0a49 152 #endif /* X_NUCLEO_NFC02A1_H_ */