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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers XNucleoNFC02A1.cpp Source File

XNucleoNFC02A1.cpp

00001 /**
00002   ******************************************************************************
00003   * @file       XNucleoNFC02A1.h
00004   * @author     AMG Central Lab
00005   * @version    V2.0.0
00006   * @date       19 May 2017
00007   * @brief      Singleton class that controls all the electronics inside the 
00008   *             XNucleoNFC02A1 expansion board
00009   ******************************************************************************
00010   *
00011   * COPYRIGHT(c) 2016 STMicroelectronics
00012   *
00013   * Redistribution and use in source and binary forms, with or without modification,
00014   * are permitted provided that the following conditions are met:
00015   *   1. Redistributions of source code must retain the above copyright notice,
00016   *      this list of conditions and the following disclaimer.
00017   *   2. Redistributions in binary form must reproduce the above copyright notice,
00018   *      this list of conditions and the following disclaimer in the documentation
00019   *      and/or other materials provided with the distribution.
00020   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00021   *      may be used to endorse or promote products derived from this software
00022   *      without specific prior written permission.
00023   *
00024   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00025   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00026   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00027   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00028   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00029   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00030   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00032   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034   *
00035   ******************************************************************************
00036   */
00037 
00038 #include <XNucleoNFC02A1.h>
00039 
00040 const uint8_t  XNucleoNFC02A1::M24LR_ADDR= 0xAE; //0xAC; //rp
00041 const uint8_t  XNucleoNFC02A1::M24LR_ADDR_DATA = 0xA6;
00042 const PinName  XNucleoNFC02A1::DEFAULT_SDA_PIN=D14;
00043 const PinName  XNucleoNFC02A1::DEFAULT_SDL_PIN=D15;
00044 
00045 
00046 const PinName XNucleoNFC02A1::DEFAULT_GPO_PIN=D12;
00047 const PinName XNucleoNFC02A1::DEFAULT_RF_DISABLE_PIN=D11;
00048 const PinName XNucleoNFC02A1::DEFAULT_LED1_PIN=D5;
00049 const PinName XNucleoNFC02A1::DEFAULT_LED2_PIN=D4;
00050 const PinName XNucleoNFC02A1::DEFAULT_LED3_PIN=D2;
00051 
00052 XNucleoNFC02A1 *XNucleoNFC02A1::mInstance = NULL;
00053 
00054 XNucleoNFC02A1* XNucleoNFC02A1::instance(DevI2C &devI2C,
00055         const PinName &gpoName,
00056         const PinName &RFDisableName, const PinName &led1Name,
00057         const PinName &led2Name, const PinName &led3Name) {
00058     if (mInstance == NULL) { // the first time
00059         mInstance = new XNucleoNFC02A1(devI2C,gpoName,
00060                 RFDisableName,led1Name,led2Name,led3Name);
00061         if (mInstance != NULL) { //allocation ok
00062             const int status = mInstance->mM24LR.initialization();
00063             //if (status != NFC_SUCCESS) { //initialization failed
00064                         if (status != 0) {
00065                 delete mInstance;
00066                 error(
00067                         "Failed to init XNucleoNFC02A1 expansion board!\r\nError:0x%X\r\n",
00068                         status);
00069             } //if init
00070         } //if instance !=NULL
00071     } //if instance
00072     return mInstance;
00073 }
00074 
00075 
00076 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/