Generic library for working with PN532-like chips
Fork of PN532 by
Diff: PN532Interface.h
- Revision:
- 3:4189a10038e6
- Parent:
- 1:b8cab5222fd0
- Child:
- 6:418ee8924317
--- a/PN532Interface.h Thu Oct 17 06:51:32 2013 +0000 +++ b/PN532Interface.h Thu Nov 21 04:30:49 2013 +0000 @@ -5,15 +5,15 @@ #include <stdint.h> -#define PN532_PREAMBLE (0x00) -#define PN532_STARTCODE1 (0x00) -#define PN532_STARTCODE2 (0xFF) -#define PN532_POSTAMBLE (0x00) +#define PN532_PREAMBLE (0x00) +#define PN532_STARTCODE1 (0x00) +#define PN532_STARTCODE2 (0xFF) +#define PN532_POSTAMBLE (0x00) -#define PN532_HOSTTOPN532 (0xD4) -#define PN532_PN532TOHOST (0xD5) +#define PN532_HOSTTOPN532 (0xD4) +#define PN532_PN532TOHOST (0xD5) -#define PN532_ACK_WAIT_TIME (10) // ms, timeout of waiting for ACK +#define PN532_ACK_WAIT_TIME (10) // ms, timeout of waiting for ACK #define PN532_INVALID_ACK (-1) #define PN532_TIMEOUT (-2) @@ -21,8 +21,8 @@ #define PN532_NO_SPACE (-4) #define REVERSE_BITS_ORDER(b) b = (b & 0xF0) >> 4 | (b & 0x0F) << 4; \ - b = (b & 0xCC) >> 2 | (b & 0x33) << 2; \ - b = (b & 0xAA) >> 1 | (b & 0x55) << 1 + b = (b & 0xCC) >> 2 | (b & 0x33) << 2; \ + b = (b & 0xAA) >> 1 | (b & 0x55) << 1 class PN532Interface { @@ -32,12 +32,14 @@ /** * @brief write a command and check ack - * @param buf command to write, not contain prefix and suffix - * @param len lenght of command + * @param header packet header + * @param hlen length of header + * @param body packet body + * @param blen length of body * @return 0 success * not 0 failed */ - virtual int8_t writeCommand(const uint8_t buf[], uint8_t len) = 0; + virtual int8_t writeCommand(const uint8_t *header, uint8_t hlen, const uint8_t *body = 0, uint8_t blen = 0) = 0; /** * @brief read the response of a command, strip prefix and suffix