PN532 Driver library This library provides an abstract API to drive the pn532 nfc chip, with I2C/HSU/SPI interface. Its based on the Seeed Studio's Arduino version.
Dependents: PN532_ReadUid Nfctest2
PN532_IF/PN532_HSU.h@0:db8030e71f55, 2016-09-13 (annotated)
- Committer:
- dotnfc
- Date:
- Tue Sep 13 06:01:19 2016 +0000
- Revision:
- 0:db8030e71f55
first commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dotnfc | 0:db8030e71f55 | 1 | |
dotnfc | 0:db8030e71f55 | 2 | #ifndef __PN532_HSU_H__ |
dotnfc | 0:db8030e71f55 | 3 | #define __PN532_HSU_H__ |
dotnfc | 0:db8030e71f55 | 4 | |
dotnfc | 0:db8030e71f55 | 5 | #include "PN532Interface.h" |
dotnfc | 0:db8030e71f55 | 6 | #include "Arduino.h" |
dotnfc | 0:db8030e71f55 | 7 | |
dotnfc | 0:db8030e71f55 | 8 | #define PN532_HSU_DEBUG |
dotnfc | 0:db8030e71f55 | 9 | |
dotnfc | 0:db8030e71f55 | 10 | #define PN532_HSU_READ_TIMEOUT (1000) |
dotnfc | 0:db8030e71f55 | 11 | |
dotnfc | 0:db8030e71f55 | 12 | class PN532_HSU : public PN532Interface { |
dotnfc | 0:db8030e71f55 | 13 | public: |
dotnfc | 0:db8030e71f55 | 14 | PN532_HSU(HardwareSerial &serial); |
dotnfc | 0:db8030e71f55 | 15 | |
dotnfc | 0:db8030e71f55 | 16 | virtual void begin(); |
dotnfc | 0:db8030e71f55 | 17 | virtual void wakeup(); |
dotnfc | 0:db8030e71f55 | 18 | virtual int8_t writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *body = 0, uint8_t blen = 0); |
dotnfc | 0:db8030e71f55 | 19 | virtual int16_t readResponse(uint8_t buf[], uint8_t len, uint16_t timeout); |
dotnfc | 0:db8030e71f55 | 20 | |
dotnfc | 0:db8030e71f55 | 21 | private: |
dotnfc | 0:db8030e71f55 | 22 | HardwareSerial* _serial; |
dotnfc | 0:db8030e71f55 | 23 | uint8_t command; |
dotnfc | 0:db8030e71f55 | 24 | |
dotnfc | 0:db8030e71f55 | 25 | int8_t readAckFrame(); |
dotnfc | 0:db8030e71f55 | 26 | |
dotnfc | 0:db8030e71f55 | 27 | int8_t receive(uint8_t *buf, int len, uint16_t timeout=PN532_HSU_READ_TIMEOUT); |
dotnfc | 0:db8030e71f55 | 28 | }; |
dotnfc | 0:db8030e71f55 | 29 | |
dotnfc | 0:db8030e71f55 | 30 | #endif |