
A simple application providing an example of asynchronous access to the X-NUCLEO_NFC01A1 Dynamic NFC Tag board.
Dependencies: NDefLib X_NUCLEO_NFC01A1 mbed
Fork of HelloWord_Async_NFC01A1 by
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.
Example Application
The application provides a simple example of asynchronous access to the X-NUCLEO-NFC01A1 Dynamic NFC Tag Expansion Board. The program writes a URI link to the M24SR dynamic tag using the asynchronous programming model. The URI can then be retrieved from an NFC enabled smartphone/tablet.
A simpler example providing synchronous access to the tag is also available.
main.cpp@6:01e1182e2320, 2017-05-18 (annotated)
- Committer:
- giovannivisentini
- Date:
- Thu May 18 14:37:39 2017 +0000
- Revision:
- 6:01e1182e2320
- Parent:
- 5:adf7d29c9431
- Child:
- 7:cd34abf10350
move to Arm mbed coding style + update libs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
giovannivisentini | 0:79807a600c87 | 1 | /** |
giovannivisentini | 0:79807a600c87 | 2 | ****************************************************************************** |
giovannivisentini | 0:79807a600c87 | 3 | * @file Sample_async.cpp |
giovannivisentini | 0:79807a600c87 | 4 | * @date 22/01/2016 |
giovannivisentini | 0:79807a600c87 | 5 | * @brief Test the async comunication api |
giovannivisentini | 0:79807a600c87 | 6 | ****************************************************************************** |
giovannivisentini | 0:79807a600c87 | 7 | * |
giovannivisentini | 0:79807a600c87 | 8 | * COPYRIGHT(c) 2015 STMicroelectronics |
giovannivisentini | 0:79807a600c87 | 9 | * |
giovannivisentini | 0:79807a600c87 | 10 | * Redistribution and use in source and binary forms, with or without modification, |
giovannivisentini | 0:79807a600c87 | 11 | * are permitted provided that the following conditions are met: |
giovannivisentini | 0:79807a600c87 | 12 | * 1. Redistributions of source code must retain the above copyright notice, |
giovannivisentini | 0:79807a600c87 | 13 | * this list of conditions and the following disclaimer. |
giovannivisentini | 0:79807a600c87 | 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
giovannivisentini | 0:79807a600c87 | 15 | * this list of conditions and the following disclaimer in the documentation |
giovannivisentini | 0:79807a600c87 | 16 | * and/or other materials provided with the distribution. |
giovannivisentini | 0:79807a600c87 | 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
giovannivisentini | 0:79807a600c87 | 18 | * may be used to endorse or promote products derived from this software |
giovannivisentini | 0:79807a600c87 | 19 | * without specific prior written permission. |
giovannivisentini | 0:79807a600c87 | 20 | * |
giovannivisentini | 0:79807a600c87 | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
giovannivisentini | 0:79807a600c87 | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
giovannivisentini | 0:79807a600c87 | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
giovannivisentini | 0:79807a600c87 | 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
giovannivisentini | 0:79807a600c87 | 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
giovannivisentini | 0:79807a600c87 | 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
giovannivisentini | 0:79807a600c87 | 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
giovannivisentini | 0:79807a600c87 | 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
giovannivisentini | 0:79807a600c87 | 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
giovannivisentini | 0:79807a600c87 | 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
giovannivisentini | 0:79807a600c87 | 31 | * |
giovannivisentini | 0:79807a600c87 | 32 | ****************************************************************************** |
giovannivisentini | 0:79807a600c87 | 33 | */ |
giovannivisentini | 0:79807a600c87 | 34 | |
giovannivisentini | 0:79807a600c87 | 35 | #include "mbed.h" |
giovannivisentini | 0:79807a600c87 | 36 | |
giovannivisentini | 6:01e1182e2320 | 37 | #include "XNucleoNFC01A1.h" |
giovannivisentini | 0:79807a600c87 | 38 | #include "m24sr/NDefNfcTagM24SR.h" |
giovannivisentini | 0:79807a600c87 | 39 | #include "NDefLib/RecordType/RecordURI.h" |
giovannivisentini | 6:01e1182e2320 | 40 | |
giovannivisentini | 4:416db8919ca4 | 41 | /** variable set to true when we receive an interrupt from the nfc component*/ |
giovannivisentini | 4:416db8919ca4 | 42 | static volatile bool nfcInterruptFlag=false; |
giovannivisentini | 6:01e1182e2320 | 43 | |
giovannivisentini | 4:416db8919ca4 | 44 | /** variable set to true when the user press the board user button*/ |
giovannivisentini | 4:416db8919ca4 | 45 | static volatile bool buttonPress=false; |
giovannivisentini | 6:01e1182e2320 | 46 | |
giovannivisentini | 4:416db8919ca4 | 47 | /** Nfc ISR called when the nfc component has a message ready*/ |
giovannivisentini | 6:01e1182e2320 | 48 | static void nfc_interrupt_callback(){ |
giovannivisentini | 4:416db8919ca4 | 49 | nfcInterruptFlag=true; |
giovannivisentini | 4:416db8919ca4 | 50 | }//nfcInterruptCallback |
giovannivisentini | 6:01e1182e2320 | 51 | |
giovannivisentini | 6:01e1182e2320 | 52 | static void set_button_press(){ |
giovannivisentini | 4:416db8919ca4 | 53 | buttonPress=true; |
giovannivisentini | 4:416db8919ca4 | 54 | }//if buttonPress |
giovannivisentini | 6:01e1182e2320 | 55 | |
giovannivisentini | 0:79807a600c87 | 56 | /** |
giovannivisentini | 0:79807a600c87 | 57 | * Chain of callback that will crate a Uri record and write it. |
giovannivisentini | 0:79807a600c87 | 58 | * After each operation the class will switch on a led |
giovannivisentini | 0:79807a600c87 | 59 | */ |
giovannivisentini | 2:48e58c5086e8 | 60 | class WriteUriCallbacks : public NDefLib::NDefNfcTag::Callbacks{ |
giovannivisentini | 6:01e1182e2320 | 61 | |
giovannivisentini | 0:79807a600c87 | 62 | DigitalOut &mOnOpenSession; |
giovannivisentini | 0:79807a600c87 | 63 | DigitalOut &mOnWrite; |
giovannivisentini | 0:79807a600c87 | 64 | DigitalOut &mOnCloseSession; |
giovannivisentini | 4:416db8919ca4 | 65 | NDefLib::Message msg; |
giovannivisentini | 6:01e1182e2320 | 66 | |
giovannivisentini | 0:79807a600c87 | 67 | public: |
giovannivisentini | 6:01e1182e2320 | 68 | |
giovannivisentini | 0:79807a600c87 | 69 | /** |
giovannivisentini | 0:79807a600c87 | 70 | * create the callback chain |
giovannivisentini | 0:79807a600c87 | 71 | * @param onOpenSession led to switch on when the session open |
giovannivisentini | 0:79807a600c87 | 72 | * @param onWrite led to switch on when the write end |
giovannivisentini | 0:79807a600c87 | 73 | * @param onCloseSession led to switch on when the session end |
giovannivisentini | 0:79807a600c87 | 74 | */ |
giovannivisentini | 0:79807a600c87 | 75 | WriteUriCallbacks(DigitalOut &onOpenSession,DigitalOut &onWrite, |
giovannivisentini | 0:79807a600c87 | 76 | DigitalOut &onCloseSession):mOnOpenSession(onOpenSession), |
giovannivisentini | 0:79807a600c87 | 77 | mOnWrite(onWrite),mOnCloseSession(onCloseSession){}; |
giovannivisentini | 6:01e1182e2320 | 78 | |
giovannivisentini | 0:79807a600c87 | 79 | /** |
giovannivisentini | 0:79807a600c87 | 80 | * crate the new message and write it |
giovannivisentini | 0:79807a600c87 | 81 | * @param tag tag where write the message |
giovannivisentini | 0:79807a600c87 | 82 | * @param success true if the session correctly open |
giovannivisentini | 0:79807a600c87 | 83 | */ |
giovannivisentini | 6:01e1182e2320 | 84 | virtual void on_session_open(NDefLib::NDefNfcTag *tag,bool success){ |
giovannivisentini | 0:79807a600c87 | 85 | if(!success){ |
giovannivisentini | 2:48e58c5086e8 | 86 | printf("Error opening the session\r\n"); |
giovannivisentini | 0:79807a600c87 | 87 | }//else |
giovannivisentini | 2:48e58c5086e8 | 88 | printf("Session opened\r\n"); |
giovannivisentini | 0:79807a600c87 | 89 | //ask to have an interrupt when the command finish |
giovannivisentini | 0:79807a600c87 | 90 | mOnOpenSession=1; |
giovannivisentini | 4:416db8919ca4 | 91 | |
giovannivisentini | 0:79807a600c87 | 92 | NDefLib::RecordURI rUri(NDefLib::RecordURI::HTTP_WWW,"http://www.st.com"); |
giovannivisentini | 6:01e1182e2320 | 93 | msg.add_record(&rUri); |
giovannivisentini | 6:01e1182e2320 | 94 | |
giovannivisentini | 0:79807a600c87 | 95 | tag->write(msg); |
giovannivisentini | 0:79807a600c87 | 96 | } |
giovannivisentini | 6:01e1182e2320 | 97 | |
giovannivisentini | 0:79807a600c87 | 98 | /** |
giovannivisentini | 0:79807a600c87 | 99 | * request to close the session |
giovannivisentini | 0:79807a600c87 | 100 | * @param tag tag where close the session |
giovannivisentini | 0:79807a600c87 | 101 | * @param success true if the message is correctly wrote |
giovannivisentini | 0:79807a600c87 | 102 | * @param message wrote |
giovannivisentini | 0:79807a600c87 | 103 | */ |
giovannivisentini | 6:01e1182e2320 | 104 | virtual void on_message_write(NDefLib::NDefNfcTag *tag,bool success, |
giovannivisentini | 0:79807a600c87 | 105 | const NDefLib::Message&){ |
giovannivisentini | 6:01e1182e2320 | 106 | |
giovannivisentini | 0:79807a600c87 | 107 | if(!success) |
giovannivisentini | 2:48e58c5086e8 | 108 | printf("Error writing tag!\r\n"); |
giovannivisentini | 0:79807a600c87 | 109 | else{ |
giovannivisentini | 2:48e58c5086e8 | 110 | printf("Tag written!\r\n"); |
giovannivisentini | 0:79807a600c87 | 111 | mOnWrite=1; |
giovannivisentini | 0:79807a600c87 | 112 | }//if-else |
giovannivisentini | 6:01e1182e2320 | 113 | tag->close_session(); |
giovannivisentini | 0:79807a600c87 | 114 | } |
giovannivisentini | 6:01e1182e2320 | 115 | |
giovannivisentini | 0:79807a600c87 | 116 | /** |
giovannivisentini | 0:79807a600c87 | 117 | * switch on the led |
giovannivisentini | 0:79807a600c87 | 118 | * @param tag where the session is closed |
giovannivisentini | 0:79807a600c87 | 119 | * @param success true if the session is correctly close |
giovannivisentini | 0:79807a600c87 | 120 | */ |
giovannivisentini | 6:01e1182e2320 | 121 | virtual void on_session_close(NDefLib::NDefNfcTag*,bool success){ |
giovannivisentini | 0:79807a600c87 | 122 | if(success){ |
giovannivisentini | 4:416db8919ca4 | 123 | printf("Session closed\r\n"); |
giovannivisentini | 4:416db8919ca4 | 124 | mOnCloseSession=1; |
giovannivisentini | 4:416db8919ca4 | 125 | }else |
giovannivisentini | 2:48e58c5086e8 | 126 | printf("Error closing the session\r\n"); |
giovannivisentini | 4:416db8919ca4 | 127 | } |
giovannivisentini | 6:01e1182e2320 | 128 | |
giovannivisentini | 4:416db8919ca4 | 129 | }; |
giovannivisentini | 6:01e1182e2320 | 130 | |
giovannivisentini | 4:416db8919ca4 | 131 | /** |
giovannivisentini | 4:416db8919ca4 | 132 | * Chain of callback that will read a NDef Message and print all the |
giovannivisentini | 4:416db8919ca4 | 133 | * record of type URI. |
giovannivisentini | 4:416db8919ca4 | 134 | * After each operation the class will switch on a led |
giovannivisentini | 4:416db8919ca4 | 135 | */ |
giovannivisentini | 4:416db8919ca4 | 136 | class ReadUriCallbacks : public NDefLib::NDefNfcTag::Callbacks{ |
giovannivisentini | 6:01e1182e2320 | 137 | |
giovannivisentini | 4:416db8919ca4 | 138 | DigitalOut &mOnOpenSession; |
giovannivisentini | 4:416db8919ca4 | 139 | DigitalOut &mOnRead; |
giovannivisentini | 4:416db8919ca4 | 140 | DigitalOut &mOnCloseSession; |
giovannivisentini | 6:01e1182e2320 | 141 | |
giovannivisentini | 4:416db8919ca4 | 142 | NDefLib::Message mMsg; |
giovannivisentini | 6:01e1182e2320 | 143 | |
giovannivisentini | 4:416db8919ca4 | 144 | public: |
giovannivisentini | 6:01e1182e2320 | 145 | |
giovannivisentini | 4:416db8919ca4 | 146 | /** |
giovannivisentini | 4:416db8919ca4 | 147 | * create the callback chain |
giovannivisentini | 4:416db8919ca4 | 148 | * @param onOpenSession led to switch on when the session open |
giovannivisentini | 4:416db8919ca4 | 149 | * @param onWrite led to switch on when the write end |
giovannivisentini | 4:416db8919ca4 | 150 | * @param onCloseSession led to switch on when the session end |
giovannivisentini | 4:416db8919ca4 | 151 | */ |
giovannivisentini | 4:416db8919ca4 | 152 | ReadUriCallbacks(DigitalOut &onOpenSession,DigitalOut &onRead, |
giovannivisentini | 4:416db8919ca4 | 153 | DigitalOut &onCloseSession):mOnOpenSession(onOpenSession), |
giovannivisentini | 4:416db8919ca4 | 154 | mOnRead(onRead),mOnCloseSession(onCloseSession){}; |
giovannivisentini | 6:01e1182e2320 | 155 | |
giovannivisentini | 4:416db8919ca4 | 156 | /** |
giovannivisentini | 4:416db8919ca4 | 157 | * crate the new message and write it |
giovannivisentini | 4:416db8919ca4 | 158 | * @param tag tag where write the message |
giovannivisentini | 4:416db8919ca4 | 159 | * @param success true if the session correctly open |
giovannivisentini | 4:416db8919ca4 | 160 | */ |
giovannivisentini | 6:01e1182e2320 | 161 | virtual void on_session_open(NDefLib::NDefNfcTag *tag,bool success){ |
giovannivisentini | 4:416db8919ca4 | 162 | if(!success){ |
giovannivisentini | 4:416db8919ca4 | 163 | printf("Error opening the session\r\n"); |
giovannivisentini | 4:416db8919ca4 | 164 | }//else |
giovannivisentini | 4:416db8919ca4 | 165 | printf("Session opened\r\n"); |
giovannivisentini | 4:416db8919ca4 | 166 | //ask to have an interrupt when the command finish |
giovannivisentini | 4:416db8919ca4 | 167 | mOnOpenSession=1; |
giovannivisentini | 4:416db8919ca4 | 168 | |
giovannivisentini | 4:416db8919ca4 | 169 | tag->read(&mMsg); |
giovannivisentini | 4:416db8919ca4 | 170 | } |
giovannivisentini | 6:01e1182e2320 | 171 | |
giovannivisentini | 4:416db8919ca4 | 172 | /** |
giovannivisentini | 4:416db8919ca4 | 173 | * request to close the session |
giovannivisentini | 4:416db8919ca4 | 174 | * @param tag tag where close the session |
giovannivisentini | 4:416db8919ca4 | 175 | * @param success true if the message is correctly wrote |
giovannivisentini | 4:416db8919ca4 | 176 | * @param message wrote |
giovannivisentini | 4:416db8919ca4 | 177 | */ |
giovannivisentini | 6:01e1182e2320 | 178 | virtual void on_message_read(NDefLib::NDefNfcTag *tag,bool success, |
giovannivisentini | 4:416db8919ca4 | 179 | const NDefLib::Message*){ |
giovannivisentini | 6:01e1182e2320 | 180 | |
giovannivisentini | 4:416db8919ca4 | 181 | if(!success) |
giovannivisentini | 4:416db8919ca4 | 182 | printf("Error Reading tag!\r\n"); |
giovannivisentini | 4:416db8919ca4 | 183 | else{ |
giovannivisentini | 6:01e1182e2320 | 184 | const uint32_t nRecords =mMsg.get_N_records(); |
giovannivisentini | 4:416db8919ca4 | 185 | printf("Read %d records!\r\n",nRecords); |
giovannivisentini | 4:416db8919ca4 | 186 | for(uint32_t i=0;i<nRecords;i++){ |
giovannivisentini | 6:01e1182e2320 | 187 | if(mMsg[i]->get_type()== NDefLib::Record::TYPE_URI){ |
giovannivisentini | 4:416db8919ca4 | 188 | NDefLib::RecordURI *rUri = (NDefLib::RecordURI *)mMsg[i]; |
giovannivisentini | 4:416db8919ca4 | 189 | printf("UriType: %x\r\nUriContent: %s\r\n", |
giovannivisentini | 6:01e1182e2320 | 190 | rUri->get_uri_id(), |
giovannivisentini | 6:01e1182e2320 | 191 | rUri->get_content().c_str()); |
giovannivisentini | 4:416db8919ca4 | 192 | }//if |
giovannivisentini | 4:416db8919ca4 | 193 | }//for |
giovannivisentini | 6:01e1182e2320 | 194 | NDefLib::Message::remove_and_delete_all_record(mMsg); |
giovannivisentini | 4:416db8919ca4 | 195 | mOnRead=1; |
giovannivisentini | 4:416db8919ca4 | 196 | }//if-else |
giovannivisentini | 6:01e1182e2320 | 197 | tag->close_session(); |
giovannivisentini | 4:416db8919ca4 | 198 | } |
giovannivisentini | 6:01e1182e2320 | 199 | |
giovannivisentini | 4:416db8919ca4 | 200 | /** |
giovannivisentini | 4:416db8919ca4 | 201 | * switch on the led |
giovannivisentini | 4:416db8919ca4 | 202 | * @param tag where the session is closed |
giovannivisentini | 4:416db8919ca4 | 203 | * @param success true if the session is correctly close |
giovannivisentini | 4:416db8919ca4 | 204 | */ |
giovannivisentini | 6:01e1182e2320 | 205 | virtual void on_session_close(NDefLib::NDefNfcTag*,bool success){ |
giovannivisentini | 4:416db8919ca4 | 206 | if(success){ |
giovannivisentini | 4:416db8919ca4 | 207 | printf("Session closed\r\n"); |
giovannivisentini | 0:79807a600c87 | 208 | mOnCloseSession=1; |
giovannivisentini | 0:79807a600c87 | 209 | }else |
giovannivisentini | 2:48e58c5086e8 | 210 | printf("Error opening the session\r\n"); |
giovannivisentini | 0:79807a600c87 | 211 | } |
giovannivisentini | 6:01e1182e2320 | 212 | |
giovannivisentini | 0:79807a600c87 | 213 | }; |
giovannivisentini | 6:01e1182e2320 | 214 | |
giovannivisentini | 6:01e1182e2320 | 215 | |
giovannivisentini | 0:79807a600c87 | 216 | int main(int argc,char *args[]){ |
giovannivisentini | 0:79807a600c87 | 217 | (void)argc; (void)args; |
giovannivisentini | 6:01e1182e2320 | 218 | |
giovannivisentini | 4:416db8919ca4 | 219 | #if defined(TARGET_STM) |
giovannivisentini | 4:416db8919ca4 | 220 | InterruptIn userButton(USER_BUTTON); |
giovannivisentini | 6:01e1182e2320 | 221 | userButton.fall(set_button_press); |
giovannivisentini | 4:416db8919ca4 | 222 | #endif |
giovannivisentini | 6:01e1182e2320 | 223 | |
giovannivisentini | 0:79807a600c87 | 224 | //create the nfc component |
giovannivisentini | 6:01e1182e2320 | 225 | I2C i2cChannel(XNucleoNFC01A1::DEFAULT_SDA_PIN,XNucleoNFC01A1::DEFAULT_SDL_PIN); |
giovannivisentini | 0:79807a600c87 | 226 | |
giovannivisentini | 6:01e1182e2320 | 227 | XNucleoNFC01A1 *nfcNucleo = XNucleoNFC01A1::instance(i2cChannel,&nfc_interrupt_callback, |
giovannivisentini | 6:01e1182e2320 | 228 | XNucleoNFC01A1::DEFAULT_GPO_PIN,XNucleoNFC01A1::DEFAULT_RF_DISABLE_PIN, |
giovannivisentini | 6:01e1182e2320 | 229 | XNucleoNFC01A1::DEFAULT_LED1_PIN,XNucleoNFC01A1::DEFAULT_LED2_PIN, |
giovannivisentini | 6:01e1182e2320 | 230 | XNucleoNFC01A1::DEFAULT_LED3_PIN); |
giovannivisentini | 6:01e1182e2320 | 231 | |
giovannivisentini | 0:79807a600c87 | 232 | //No call back needed since default behavior is sync |
giovannivisentini | 6:01e1182e2320 | 233 | nfcNucleo->get_M24SR().get_session(); |
giovannivisentini | 6:01e1182e2320 | 234 | nfcNucleo->get_M24SR().manage_I2C_GPO(M24SR::I2C_ANSWER_READY); //switch to async mode |
giovannivisentini | 6:01e1182e2320 | 235 | |
giovannivisentini | 6:01e1182e2320 | 236 | NDefLib::NDefNfcTag &tag = nfcNucleo->get_M24SR().get_NDef_tag(); |
giovannivisentini | 0:79807a600c87 | 237 | printf("System Init done!\n\r"); |
giovannivisentini | 6:01e1182e2320 | 238 | |
giovannivisentini | 0:79807a600c87 | 239 | //crate the callback to use for write a tag |
giovannivisentini | 6:01e1182e2320 | 240 | WriteUriCallbacks NDefWriteCallback(nfcNucleo->get_led1(),nfcNucleo->get_led2(),nfcNucleo->get_led3()); |
giovannivisentini | 6:01e1182e2320 | 241 | ReadUriCallbacks NDefReadCallback(nfcNucleo->get_led1(),nfcNucleo->get_led2(),nfcNucleo->get_led3()); |
giovannivisentini | 6:01e1182e2320 | 242 | tag.set_callback(&NDefWriteCallback); //set the callback |
giovannivisentini | 6:01e1182e2320 | 243 | tag.open_session(); //start the callback chain |
giovannivisentini | 6:01e1182e2320 | 244 | |
giovannivisentini | 0:79807a600c87 | 245 | printf("Start Main Loop\n\r"); |
giovannivisentini | 0:79807a600c87 | 246 | while(true){ |
giovannivisentini | 0:79807a600c87 | 247 | if(nfcInterruptFlag){ |
giovannivisentini | 0:79807a600c87 | 248 | nfcInterruptFlag=false; |
giovannivisentini | 0:79807a600c87 | 249 | //manage an async event from the nfc component |
giovannivisentini | 6:01e1182e2320 | 250 | nfcNucleo->get_M24SR().manage_event(); |
giovannivisentini | 6:01e1182e2320 | 251 | |
giovannivisentini | 0:79807a600c87 | 252 | }//if |
giovannivisentini | 4:416db8919ca4 | 253 | #if defined(TARGET_STM) |
giovannivisentini | 4:416db8919ca4 | 254 | if(buttonPress){ |
giovannivisentini | 4:416db8919ca4 | 255 | buttonPress=false; |
giovannivisentini | 4:416db8919ca4 | 256 | printf("Pressed"); |
giovannivisentini | 6:01e1182e2320 | 257 | tag.set_callback(&NDefReadCallback); |
giovannivisentini | 6:01e1182e2320 | 258 | tag.open_session(); |
giovannivisentini | 4:416db8919ca4 | 259 | } |
giovannivisentini | 4:416db8919ca4 | 260 | #endif |
giovannivisentini | 0:79807a600c87 | 261 | __WFE(); |
giovannivisentini | 0:79807a600c87 | 262 | }//while |
giovannivisentini | 6:01e1182e2320 | 263 | |
giovannivisentini | 0:79807a600c87 | 264 | //return 0; |
giovannivisentini | 6:01e1182e2320 | 265 | } |