1 /**************************************************************************/
5 /**************************************************************************/
7 #ifndef __PN532_DRV_H__
8 #define __PN532_DRV_H__
10 #include "projectconfig.h"
16 #define PN532_DEBUG(fmt, args...) printf(fmt, ##args)
18 #define PN532_RSTPD_PORT (2)
19 #define PN532_RSTPD_PIN (2)
20 #define PN532_SPI_CSPORT (0)
21 #define PN532_SPI_CSPIN (2)
23 #define PN532_NORMAL_FRAME__DATA_MAX_LEN (254)
24 #define PN532_NORMAL_FRAME__OVERHEAD (8)
25 #define PN532_EXTENDED_FRAME__DATA_MAX_LEN (264)
26 #define PN532_EXTENDED_FRAME__OVERHEAD (11)
27 #define PN532_BUFFER_LEN (PN532_EXTENDED_FRAME__DATA_MAX_LEN + PN532_EXTENDED_FRAME__OVERHEAD)
28 #define PN532_UART_BAUDRATE (115200)
32 PN532_COMMAND_DIAGNOSE
= 0x00,
33 PN532_COMMAND_GETFIRMWAREVERSION
= 0x02,
34 PN532_COMMAND_GETGENERALSTATUS
= 0x04,
35 PN532_COMMAND_READREGISTER
= 0x06,
36 PN532_COMMAND_WRITEREGISTER
= 0x08,
37 PN532_COMMAND_READGPIO
= 0x0C,
38 PN532_COMMAND_WRITEGPIO
= 0x0E,
39 PN532_COMMAND_SETSERIALBAUDRATE
= 0x10,
40 PN532_COMMAND_SETPARAMETERS
= 0x12,
41 PN532_COMMAND_SAMCONFIGURATION
= 0x14,
42 PN532_COMMAND_POWERDOWN
= 0x16,
43 PN532_COMMAND_RFCONFIGURATION
= 0x32,
44 PN532_COMMAND_RFREGULATIONTEST
= 0x58,
45 PN532_COMMAND_INJUMPFORDEP
= 0x56,
46 PN532_COMMAND_INJUMPFORPSL
= 0x46,
47 PN532_COMMAND_INLISTPASSIVETARGET
= 0x4A,
48 PN532_COMMAND_INATR
= 0x50,
49 PN532_COMMAND_INPSL
= 0x4E,
50 PN532_COMMAND_INDATAEXCHANGE
= 0x40,
51 PN532_COMMAND_INCOMMUNICATETHRU
= 0x42,
52 PN532_COMMAND_INDESELECT
= 0x44,
53 PN532_COMMAND_INRELEASE
= 0x52,
54 PN532_COMMAND_INSELECT
= 0x54,
55 PN532_COMMAND_INAUTOPOLL
= 0x60,
56 PN532_COMMAND_TGINITASTARGET
= 0x8C,
57 PN532_COMMAND_TGSETGENERALBYTES
= 0x92,
58 PN532_COMMAND_TGGETDATA
= 0x86,
59 PN532_COMMAND_TGSETDATA
= 0x8E,
60 PN532_COMMAND_TGSETMETADATA
= 0x94,
61 PN532_COMMAND_TGGETINITIATORCOMMAND
= 0x88,
62 PN532_COMMAND_TGRESPONSETOINITIATOR
= 0x90,
63 PN532_COMMAND_TGGETTARGETSTATUS
= 0x8A
66 /* Application level errors generated by the PN532 chip */
69 PN532_APPERROR_NONE
= 0x00,
70 PN532_APPERROR_TIMEOUT
= 0x01,
71 PN532_APPERROR_CRCERROR
= 0x02,
72 PN532_APPERROR_PARITYERROR
= 0x04,
73 PN532_APPERROR_FRAMINGERROR
= 0x05,
74 PN532_APPERROR_BITCOLLISION
= 0x06,
75 PN532_APPERROR_INSUFFICIENTBUFFER
= 0x07,
76 PN532_APPERROR_RFBUFFEROVERFLOW
= 0x09,
77 PN532_APPERROR_RFFIELDTIMEOUT
= 0x0A,
78 PN532_APPERROR_RFPROTOCOLERROR
= 0x0B,
79 PN532_APPERROR_TEMPERROR
= 0x0D,
80 PN532_APPERROR_INTERNBUFFEROVERFLOW
= 0x0E,
81 PN532_APPERROR_INVALIDPARAMETER
= 0x10,
82 PN532_APPERROR_DEP_UNSUPPORTEDCMD
= 0x12,
83 PN532_APPERROR_DEP_INVALIDOFORMAT
= 0x13,
84 PN532_APPERROR_AUTHENTERR
= 0x14,
85 PN532_APPERROR_UIDCCHECKERROR
= 0x23,
86 PN532_APPERROR_DEP_INVALIDDEVSTATE
= 0x25,
87 PN532_APPERROR_OPERATIONNOTALLOWED
= 0x26,
88 PN532_APPERROR_CMDNOTACCEPTABLE
= 0x27,
89 PN532_APPERROR_TARGETRELEASED
= 0x29,
90 PN532_APPERROR_IDMISMATCH
= 0x2A,
91 PN532_APPERROR_CARDDISAPPEARED
= 0x2B,
92 PN532_APPERROR_NFCID3MISMATCH
= 0x2C,
93 PN532_APPERROR_OVERCURRENTEVENT
= 0x2D,
94 PN532_APPERROR_NADMISSINGINDEP
= 0x2E
97 void pn532HWInit(void);
98 pn532_error_t
pn532BuildFrame(byte_t
* pbtFrame
, size_t * pszFrame
, const byte_t
* pbtData
, const size_t szData
);
99 pn532_error_t
pn532SendCommand(const byte_t
* pbtData
, const size_t szData
);
100 pn532_error_t
pn532ReadResponse(byte_t
* pbtResponse
, size_t * pszRxLen
);
101 pn532_error_t
pn532Wakeup(void);