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 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

X_NUCLEO_NFC01A1.h

Committer:
giovannivisentini
Date:
2015-12-21
Revision:
3:fa914de381ae
Parent:
1:15d4a123ef6b
Child:
6:96389fb79676

File content as of revision 3:fa914de381ae:

/**
  ******************************************************************************
  * @file       X_NUCLEO_NFC01A1.h
  * @date       05/11/2015
  * @brief      singleton class that controls all the electronics inside the 
  * 			X_NUCLEO_NFC01A1 expansion board
  ******************************************************************************
  *
  * 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 X_NUCLEO_NFC01A1_H_
#define X_NUCLEO_NFC01A1_H_
#include <stdint.h>

#include "mbed.h"

#include "m24sr/m24sr_class.h"

/**
 * singleton class that controls all the electronics inside the X_NUCLEO_NFC01A1 expansion board
 */
class X_NUCLEO_NFC01A1 {

private:
	/**
	 * ponter to the singleton instance, NULL if we did't build one
	 */
	static X_NUCLEO_NFC01A1 *mInstance;
	/**
	 * i2c address of the m24sr chip
	 */
	static const uint8_t M24SR_ADDR;

	/**
	 * constructor
	 * @param devI2C i2c channel used for communicate with the board
	 * @param gpoName pin of the gpio pin of the M24SR chip
	 * @param RFDisableName pin for disable the rf antenna
	 * @param led1Name pin for control the led1 status
	 * @param led2Name pin for control the led1 status
	 * @param led3Name pin for control the led1 status
	 */
	X_NUCLEO_NFC01A1(I2C &devI2C, const PinName &gpoName,
 			const PinName &RFDisableName, const PinName &led1Name,
 			const PinName &led2Name, const PinName &led3Name):
 				mM24SR(M24SR_ADDR,devI2C,gpoName,RFDisableName),
				mNfcLed1(led1Name),mNfcLed2(led2Name),mNfcLed3(led3Name){}

public:
	static const PinName DEFAULT_SDA_PIN;
	static const PinName DEFAULT_SDL_PIN;
	static const PinName DEFAULT_GPO_PIN;
	static const PinName DEFAULT_RF_DISABLE_PIN;
	static const PinName DEFAULT_LED1_PIN;
	static const PinName DEFAULT_LED2_PIN;
	static const PinName DEFAULT_LED3_PIN;

	static X_NUCLEO_NFC01A1* Instance(I2C &devI2C,
			const PinName &gpoName = DEFAULT_GPO_PIN,
 			const PinName &RFDisableName = DEFAULT_RF_DISABLE_PIN,
 			const PinName &led1Name = DEFAULT_LED1_PIN,
 			const PinName &led2Name = DEFAULT_LED2_PIN,
 			const PinName &led3Name = DEFAULT_LED3_PIN);

	/**
	 * @return board led1
	 */
	DigitalOut& getLed1() {
		return mNfcLed1;
	}

	/**
	 * @return board led2
	 */
	DigitalOut& getLed2() {
		return mNfcLed2;
	}

	/**
	 * @return board led3
	 */
	DigitalOut& getLed3() {
		return mNfcLed3;
	}

	/**
	 * @return NFC Chip
	 */
	M24SR& getM24SR() {
		return mM24SR;
	}

	virtual ~X_NUCLEO_NFC01A1() {
	}

private:

	M24SR mM24SR;
	DigitalOut mNfcLed1;
	DigitalOut mNfcLed2;
	DigitalOut mNfcLed3;

};

#endif /* X_NUCLEO_NFC01A1_H_ */