PN532 customized

Fork of PN532 by Components

Committer:
stanvn
Date:
Tue Feb 09 16:16:11 2016 +0000
Revision:
7:a26fa6ef10eb
Parent:
3:4189a10038e6
Library can now read types by reading the SAK bit instead of guessing it.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 3:4189a10038e6 1 #ifndef NfcAdapter_h
yihui 3:4189a10038e6 2 #define NfcAdapter_h
yihui 3:4189a10038e6 3
yihui 3:4189a10038e6 4 #include <PN532Interface.h>
yihui 3:4189a10038e6 5 #include <PN532.h>
yihui 3:4189a10038e6 6 #include <NfcTag.h>
yihui 3:4189a10038e6 7 #include <Ndef.h>
yihui 3:4189a10038e6 8
yihui 3:4189a10038e6 9 // Drivers
yihui 3:4189a10038e6 10 #include <MifareClassic.h>
yihui 3:4189a10038e6 11 #include <MifareUltralight.h>
yihui 3:4189a10038e6 12
stanvn 7:a26fa6ef10eb 13 #define TAG_TYPE_MIFARE_MINI (0)
stanvn 7:a26fa6ef10eb 14 #define TAG_TYPE_MIFARE_1K (1)
stanvn 7:a26fa6ef10eb 15 #define TAG_TYPE_MIFARE_4K (2)
stanvn 7:a26fa6ef10eb 16 #define TAG_TYPE_MIFARE_UL (3)
stanvn 7:a26fa6ef10eb 17 #define TAG_TYPE_MIFARE_PLUS_2K (4)
stanvn 7:a26fa6ef10eb 18 #define TAG_TYPE_MIFARE_PLUS_4K (5)
stanvn 7:a26fa6ef10eb 19 #define TAG_TYPE_14443 (6)
stanvn 7:a26fa6ef10eb 20
yihui 3:4189a10038e6 21 #define TAG_TYPE_1 (1)
yihui 3:4189a10038e6 22 #define TAG_TYPE_2 (2)
yihui 3:4189a10038e6 23 #define TAG_TYPE_3 (3)
yihui 3:4189a10038e6 24 #define TAG_TYPE_4 (4)
yihui 3:4189a10038e6 25 #define TAG_TYPE_UNKNOWN (99)
yihui 3:4189a10038e6 26
yihui 3:4189a10038e6 27 #define IRQ (2)
yihui 3:4189a10038e6 28 #define RESET (3) // Not connected by default on the NFC Shield
yihui 3:4189a10038e6 29
yihui 3:4189a10038e6 30 class NfcAdapter {
yihui 3:4189a10038e6 31 public:
yihui 3:4189a10038e6 32 NfcAdapter(PN532Interface &interface);
yihui 3:4189a10038e6 33
yihui 3:4189a10038e6 34 ~NfcAdapter(void);
yihui 3:4189a10038e6 35 void begin(void);
yihui 3:4189a10038e6 36 bool tagPresent(); // tagAvailable
yihui 3:4189a10038e6 37 NfcTag read();
yihui 3:4189a10038e6 38 bool write(NdefMessage& ndefMessage);
yihui 3:4189a10038e6 39 // FUTURE bool share(NdefMessage& ndefMessage);
yihui 3:4189a10038e6 40 // FUTURE bool unshare();
yihui 3:4189a10038e6 41 // FUTURE bool erase();
yihui 3:4189a10038e6 42 // FUTURE bool format();
yihui 3:4189a10038e6 43 private:
yihui 3:4189a10038e6 44 PN532* shield;
yihui 3:4189a10038e6 45 uint8_t uid[7]; // Buffer to store the returned UID
yihui 3:4189a10038e6 46 unsigned int uidLength; // Length of the UID (4 or 7 uint8_ts depending on ISO14443A card type)
stanvn 7:a26fa6ef10eb 47 uint8_t sak;
yihui 3:4189a10038e6 48 unsigned int guessTagType();
stanvn 7:a26fa6ef10eb 49 unsigned int getTagType();
yihui 3:4189a10038e6 50 };
yihui 3:4189a10038e6 51
yihui 3:4189a10038e6 52 #endif