mbed OS 5 example application using X-NUCLEO-NFC02A1
Dependencies: NDefLib X_NUCLEO_NFC02A1
Fork of HelloWorld_NFC02A1 by
X_NUCLEO_NFC02A1/Interfaces/X_NUCLEO_NFC02A1.cpp@2:6f1b1f7f8d12, 2016-09-28 (annotated)
- Committer:
- rosarium
- Date:
- Wed Sep 28 11:26:49 2016 +0000
- Revision:
- 2:6f1b1f7f8d12
- Parent:
- 1:11ae12d41082
New Nfc interface file integrated.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| rosarium | 0:892175366555 | 1 | /** |
| rosarium | 0:892175366555 | 2 | ****************************************************************************** |
| rosarium | 0:892175366555 | 3 | * @file X_NUCLEO_NFC02A1.h |
| rosarium | 1:11ae12d41082 | 4 | * @author AMG Central Lab |
| rosarium | 1:11ae12d41082 | 5 | * @date 30 Aug 2016 |
| rosarium | 0:892175366555 | 6 | * @brief Singleton class that controls all the electronics inside the |
| rosarium | 0:892175366555 | 7 | * X_NUCLEO_NFC02A1 expansion board |
| rosarium | 0:892175366555 | 8 | ****************************************************************************** |
| rosarium | 0:892175366555 | 9 | * |
| rosarium | 1:11ae12d41082 | 10 | * COPYRIGHT(c) 2016 STMicroelectronics |
| rosarium | 0:892175366555 | 11 | * |
| rosarium | 0:892175366555 | 12 | * Redistribution and use in source and binary forms, with or without modification, |
| rosarium | 0:892175366555 | 13 | * are permitted provided that the following conditions are met: |
| rosarium | 0:892175366555 | 14 | * 1. Redistributions of source code must retain the above copyright notice, |
| rosarium | 0:892175366555 | 15 | * this list of conditions and the following disclaimer. |
| rosarium | 0:892175366555 | 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| rosarium | 0:892175366555 | 17 | * this list of conditions and the following disclaimer in the documentation |
| rosarium | 0:892175366555 | 18 | * and/or other materials provided with the distribution. |
| rosarium | 0:892175366555 | 19 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| rosarium | 0:892175366555 | 20 | * may be used to endorse or promote products derived from this software |
| rosarium | 0:892175366555 | 21 | * without specific prior written permission. |
| rosarium | 0:892175366555 | 22 | * |
| rosarium | 0:892175366555 | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| rosarium | 0:892175366555 | 24 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| rosarium | 0:892175366555 | 25 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| rosarium | 0:892175366555 | 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| rosarium | 0:892175366555 | 27 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| rosarium | 0:892175366555 | 28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| rosarium | 0:892175366555 | 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| rosarium | 0:892175366555 | 30 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| rosarium | 0:892175366555 | 31 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| rosarium | 0:892175366555 | 32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| rosarium | 0:892175366555 | 33 | * |
| rosarium | 0:892175366555 | 34 | ****************************************************************************** |
| rosarium | 0:892175366555 | 35 | */ |
| rosarium | 0:892175366555 | 36 | |
| rosarium | 0:892175366555 | 37 | #include <X_NUCLEO_NFC02A1.h> |
| rosarium | 0:892175366555 | 38 | |
| rosarium | 0:892175366555 | 39 | const uint8_t X_NUCLEO_NFC02A1::M24LR_ADDR= 0xAE; //0xAC; //rp |
| rosarium | 0:892175366555 | 40 | const uint8_t X_NUCLEO_NFC02A1::M24LR_ADDR_DATA = 0xA6; |
| rosarium | 0:892175366555 | 41 | const PinName X_NUCLEO_NFC02A1::DEFAULT_SDA_PIN=D14; |
| rosarium | 0:892175366555 | 42 | const PinName X_NUCLEO_NFC02A1::DEFAULT_SDL_PIN=D15; |
| rosarium | 0:892175366555 | 43 | |
| rosarium | 0:892175366555 | 44 | |
| rosarium | 0:892175366555 | 45 | const PinName X_NUCLEO_NFC02A1::DEFAULT_GPO_PIN=D12; |
| rosarium | 0:892175366555 | 46 | const PinName X_NUCLEO_NFC02A1::DEFAULT_RF_DISABLE_PIN=D11; |
| rosarium | 0:892175366555 | 47 | const PinName X_NUCLEO_NFC02A1::DEFAULT_LED1_PIN=D5; |
| rosarium | 0:892175366555 | 48 | const PinName X_NUCLEO_NFC02A1::DEFAULT_LED2_PIN=D4; |
| rosarium | 0:892175366555 | 49 | const PinName X_NUCLEO_NFC02A1::DEFAULT_LED3_PIN=D2; |
| rosarium | 0:892175366555 | 50 | |
| rosarium | 0:892175366555 | 51 | X_NUCLEO_NFC02A1 *X_NUCLEO_NFC02A1::mInstance = NULL; |
| rosarium | 0:892175366555 | 52 | |
| rosarium | 0:892175366555 | 53 | X_NUCLEO_NFC02A1* X_NUCLEO_NFC02A1::Instance(DevI2C &devI2C, |
| rosarium | 0:892175366555 | 54 | const PinName &gpoName, |
| rosarium | 0:892175366555 | 55 | const PinName &RFDisableName, const PinName &led1Name, |
| rosarium | 0:892175366555 | 56 | const PinName &led2Name, const PinName &led3Name) { |
| rosarium | 0:892175366555 | 57 | if (mInstance == NULL) { // the first time |
| rosarium | 0:892175366555 | 58 | mInstance = new X_NUCLEO_NFC02A1(devI2C,gpoName, |
| rosarium | 0:892175366555 | 59 | RFDisableName,led1Name,led2Name,led3Name); |
| rosarium | 0:892175366555 | 60 | if (mInstance != NULL) { //allocation ok |
| rosarium | 0:892175366555 | 61 | const int status = mInstance->mM24LR.Initialization(); |
| rosarium | 0:892175366555 | 62 | //if (status != NFC_SUCCESS) { //initialization failed |
| rosarium | 0:892175366555 | 63 | if (status != 0) { |
| rosarium | 0:892175366555 | 64 | delete mInstance; |
| rosarium | 0:892175366555 | 65 | error( |
| rosarium | 0:892175366555 | 66 | "Failed to init X_NUCLEO_NFC02A1 expansion board!\r\nError:0x%X\r\n", |
| rosarium | 0:892175366555 | 67 | status); |
| rosarium | 0:892175366555 | 68 | } //if init |
| rosarium | 0:892175366555 | 69 | } //if instance !=NULL |
| rosarium | 0:892175366555 | 70 | } //if instance |
| rosarium | 0:892175366555 | 71 | return mInstance; |
| rosarium | 0:892175366555 | 72 | } |
| rosarium | 0:892175366555 | 73 | |
| rosarium | 2:6f1b1f7f8d12 | 74 | |
| rosarium | 2:6f1b1f7f8d12 | 75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
