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