Forked from LibPN532

Dependents:   NFC_Secure_Access NFC_Secure_Access

Fork of LibPN532 by dotnfc Tang

Committer:
udareaniket
Date:
Sun Apr 22 23:29:20 2018 +0000
Revision:
2:9a2ab3fa7862
Parent:
0:db8030e71f55
Initial commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dotnfc 0:db8030e71f55 1
dotnfc 0:db8030e71f55 2
dotnfc 0:db8030e71f55 3 #ifndef __PN532_INTERFACE_H__
dotnfc 0:db8030e71f55 4 #define __PN532_INTERFACE_H__
dotnfc 0:db8030e71f55 5
dotnfc 0:db8030e71f55 6 #include <stdint.h>
dotnfc 0:db8030e71f55 7
dotnfc 0:db8030e71f55 8 #define PN532_PREAMBLE (0x00)
dotnfc 0:db8030e71f55 9 #define PN532_STARTCODE1 (0x00)
dotnfc 0:db8030e71f55 10 #define PN532_STARTCODE2 (0xFF)
dotnfc 0:db8030e71f55 11 #define PN532_POSTAMBLE (0x00)
dotnfc 0:db8030e71f55 12
dotnfc 0:db8030e71f55 13 #define PN532_HOSTTOPN532 (0xD4)
dotnfc 0:db8030e71f55 14 #define PN532_PN532TOHOST (0xD5)
dotnfc 0:db8030e71f55 15
dotnfc 0:db8030e71f55 16 #define PN532_ACK_WAIT_TIME (10) // ms, timeout of waiting for ACK
dotnfc 0:db8030e71f55 17
dotnfc 0:db8030e71f55 18 #define PN532_INVALID_ACK (-1)
dotnfc 0:db8030e71f55 19 #define PN532_TIMEOUT (-2)
dotnfc 0:db8030e71f55 20 #define PN532_INVALID_FRAME (-3)
dotnfc 0:db8030e71f55 21 #define PN532_NO_SPACE (-4)
dotnfc 0:db8030e71f55 22
dotnfc 0:db8030e71f55 23 #define REVERSE_BITS_ORDER(b) b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; \
dotnfc 0:db8030e71f55 24 b = (b & 0xCC) >> 2 | (b & 0x33) << 2; \
dotnfc 0:db8030e71f55 25 b = (b & 0xAA) >> 1 | (b & 0x55) << 1
dotnfc 0:db8030e71f55 26
dotnfc 0:db8030e71f55 27 class PN532Interface
dotnfc 0:db8030e71f55 28 {
dotnfc 0:db8030e71f55 29 public:
dotnfc 0:db8030e71f55 30 virtual void begin() = 0;
dotnfc 0:db8030e71f55 31 virtual void wakeup() = 0;
dotnfc 0:db8030e71f55 32
dotnfc 0:db8030e71f55 33 /**
dotnfc 0:db8030e71f55 34 * @brief write a command and check ack
dotnfc 0:db8030e71f55 35 * @param header packet header
dotnfc 0:db8030e71f55 36 * @param hlen length of header
dotnfc 0:db8030e71f55 37 * @param body packet body
dotnfc 0:db8030e71f55 38 * @param blen length of body
dotnfc 0:db8030e71f55 39 * @return 0 success
dotnfc 0:db8030e71f55 40 * not 0 failed
dotnfc 0:db8030e71f55 41 */
dotnfc 0:db8030e71f55 42 virtual int8_t writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *body = 0, uint8_t blen = 0) = 0;
dotnfc 0:db8030e71f55 43
dotnfc 0:db8030e71f55 44 /**
dotnfc 0:db8030e71f55 45 * @brief read the response of a command, strip prefix and suffix
dotnfc 0:db8030e71f55 46 * @param buf to contain the response data
dotnfc 0:db8030e71f55 47 * @param len lenght to read
dotnfc 0:db8030e71f55 48 * @param timeout max time to wait, 0 means no timeout
dotnfc 0:db8030e71f55 49 * @return >=0 length of response without prefix and suffix
dotnfc 0:db8030e71f55 50 * <0 failed to read response
dotnfc 0:db8030e71f55 51 */
dotnfc 0:db8030e71f55 52 virtual int16_t readResponse(uint8_t buf[], uint8_t len, uint16_t timeout = 1000) = 0;
dotnfc 0:db8030e71f55 53 };
dotnfc 0:db8030e71f55 54
dotnfc 0:db8030e71f55 55 #endif
dotnfc 0:db8030e71f55 56