mirror of
https://github.com/Vale54321/schafkopf-bot.git
synced 2025-12-16 03:39:34 +01:00
added arduino nfcReader files (#42)
This commit is contained in:
committed by
GitHub
parent
76cb0eaf1a
commit
6259d0bef3
56
Arduino/nfcReader/PN532/PN532Interface.h
Normal file
56
Arduino/nfcReader/PN532/PN532Interface.h
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
#ifndef __PN532_INTERFACE_H__
|
||||
#define __PN532_INTERFACE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#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_ACK_WAIT_TIME (10) // ms, timeout of waiting for ACK
|
||||
|
||||
#define PN532_INVALID_ACK (-1)
|
||||
#define PN532_TIMEOUT (-2)
|
||||
#define PN532_INVALID_FRAME (-3)
|
||||
#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
|
||||
|
||||
class PN532Interface
|
||||
{
|
||||
public:
|
||||
virtual void begin() = 0;
|
||||
virtual void wakeup() = 0;
|
||||
|
||||
/**
|
||||
* @brief write a command and check ack
|
||||
* @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 *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
|
||||
* @param buf to contain the response data
|
||||
* @param len lenght to read
|
||||
* @param timeout max time to wait, 0 means no timeout
|
||||
* @return >=0 length of response without prefix and suffix
|
||||
* <0 failed to read response
|
||||
*/
|
||||
virtual int16_t readResponse(uint8_t buf[], uint8_t len, uint16_t timeout = 1000) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user