![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
grove nfc_tag sample program
Dependencies: mbed
Revision 1:c492babe8dc3, committed 2017-03-31
- Comitter:
- superphil06
- Date:
- Fri Mar 31 11:20:13 2017 +0000
- Parent:
- 0:b939441bcdc7
- Commit message:
- grove nfc tag example programm
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
nfc_tag.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r b939441bcdc7 -r c492babe8dc3 main.cpp --- a/main.cpp Tue Mar 28 10:21:09 2017 +0000 +++ b/main.cpp Fri Mar 31 11:20:13 2017 +0000 @@ -1,12 +1,28 @@ #include "mbed.h" +#include "nfc_tag.h" -DigitalOut myled(LED1); +#define NFC_ADRESS 0x53 +//rx2 tx2 +NfcTag nfcTag_cons(p28,p27,NFC_ADRESS<<1,USER_MODE); +bool flag = false; +bool preFlag = false; -int main() { - while(1) { - myled = 1; - wait(0.2); - myled = 0; - wait(0.2); +int main() +{ + //nfcTag = NfcTag(p15,p14); + while(true) { + printf("*****"); + flag = nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1) == 0xff?true:false;// read 0x07ff block address + printf(" %x ",nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1)); + if(flag != preFlag) { + printf("get remote NFC control signal!"); + if(flag == true) { + printf("led will light up!"); + } else { + printf("led will turn dark!"); + } + preFlag = flag; + } + wait(1); } -} +} \ No newline at end of file
diff -r b939441bcdc7 -r c492babe8dc3 nfc_tag.cpp --- a/nfc_tag.cpp Tue Mar 28 10:21:09 2017 +0000 +++ b/nfc_tag.cpp Fri Mar 31 11:20:13 2017 +0000 @@ -41,9 +41,9 @@ NfcTag::NfcTag(PinName sda,PinName scl,uint8_t address,AccessMode mode = USER_MODE): m_I2C(sda, scl) { if(mode == USER_MODE){ - eeAddr = EEPROM_ADDR_E2_DISABLE; + eeAddr = EEPROM_ADDR_E2_DISABLE<<1; }else{ - eeAddr = EEPROM_ADDR_E2_ENABLE; + eeAddr = EEPROM_ADDR_E2_ENABLE<<1; } _address = address; // m_I2C Module Address