Pinconfig für Endbadge.
[hackover2013-badge-firmware.git] / drivers / rf / pn532 / pn532.h
1 /**************************************************************************/
2 /*!
3 @file pn532.h
4 */
5 /**************************************************************************/
6
7 #ifndef __PN532_H__
8 #define __PN532_H__
9
10 #include "projectconfig.h"
11
12 // Comment out this line to disable debug output
13 // #define PN532_DEBUGMODE
14 #define PN532_DEBUG(fmt, args...) printf(fmt, ##args)
15
16 /* Error messages generated by the stack */
17 /* Not to be confused with app level errors from the PN532 */
18 /* These are the errors that are returned by the PN532 driver */
19 typedef enum pn532_error_e
20 {
21 PN532_ERROR_NONE = 0x00,
22 PN532_ERROR_UNABLETOINIT = 0x01, // Unable to initialise or wakeup the device
23 PN532_ERROR_APPLEVELERROR = 0x02, // Application level error detected
24 PN532_ERROR_BUSY = 0x03, // Busy executing a previous command
25 PN532_ERROR_NOACK = 0x04, // No ack message received
26 PN532_ERROR_INVALIDACK = 0x05, // Ack != 00 00 FF 00 FF 00
27 PN532_ERROR_PREAMBLEMISMATCH = 0x06, // Frame preamble + start code mismatch
28 PN532_ERROR_EXTENDEDFRAME = 0x07, // Extended frames currently unsupported
29 PN532_ERROR_LENCHECKSUMMISMATCH = 0x08,
30 PN532_ERROR_RESPONSEBUFFEREMPTY = 0x09, // No response data received
31 PN532_ERROR_READYSTATUSTIMEOUT = 0x0A, // Timeout waiting for 'ready' status (SPI/I2C only)
32 PN532_ERROR_TIMEOUTWAITINGFORCARD = 0x0B, // No card detected in field with the specified timeout
33 PN532_ERROR_BLOCKREADFAILED = 0x0C, // Unexpected response to block read request
34 PN532_ERROR_WRONGCARDTYPE = 0x0D, // Card is not the expected format (based on SENS_RES/ATQA value)
35 PN532_ERROR_ADDRESSOUTOFRANGE = 0x0E, // Specified block and page is out of range
36 PN532_ERROR_I2C_NACK = 0x0F // I2C Bus - No ACK was received for master to slave data transfer
37 } pn532_error_t;
38
39 typedef enum pn532_modulation_e
40 {
41 PN532_MODULATION_ISO14443A_106KBPS = 0x00,
42 PN532_MODULATION_FELICA_212KBPS = 0x01,
43 PN532_MODULATION_FELICA_424KBPS = 0x02,
44 PN532_MODULATION_ISO14443B_106KBPS = 0x03,
45 PN532_MODULATION_JEWEL_106KBPS = 0x04
46 } pn532_modulation_t;
47
48 /* HW Commands for the PN532. */
49 /* See UM0701-02 - PN532 User Manual */
50 enum
51 {
52 PN532_COMMAND_DIAGNOSE = 0x00,
53 PN532_COMMAND_GETFIRMWAREVERSION = 0x02,
54 PN532_COMMAND_GETGENERALSTATUS = 0x04,
55 PN532_COMMAND_READREGISTER = 0x06,
56 PN532_COMMAND_WRITEREGISTER = 0x08,
57 PN532_COMMAND_READGPIO = 0x0C,
58 PN532_COMMAND_WRITEGPIO = 0x0E,
59 PN532_COMMAND_SETSERIALBAUDRATE = 0x10,
60 PN532_COMMAND_SETPARAMETERS = 0x12,
61 PN532_COMMAND_SAMCONFIGURATION = 0x14,
62 PN532_COMMAND_POWERDOWN = 0x16,
63 PN532_COMMAND_RFCONFIGURATION = 0x32,
64 PN532_COMMAND_RFREGULATIONTEST = 0x58,
65 PN532_COMMAND_INJUMPFORDEP = 0x56,
66 PN532_COMMAND_INJUMPFORPSL = 0x46,
67 PN532_COMMAND_INLISTPASSIVETARGET = 0x4A,
68 PN532_COMMAND_INATR = 0x50,
69 PN532_COMMAND_INPSL = 0x4E,
70 PN532_COMMAND_INDATAEXCHANGE = 0x40,
71 PN532_COMMAND_INCOMMUNICATETHRU = 0x42,
72 PN532_COMMAND_INDESELECT = 0x44,
73 PN532_COMMAND_INRELEASE = 0x52,
74 PN532_COMMAND_INSELECT = 0x54,
75 PN532_COMMAND_INAUTOPOLL = 0x60,
76 PN532_COMMAND_TGINITASTARGET = 0x8C,
77 PN532_COMMAND_TGSETGENERALBYTES = 0x92,
78 PN532_COMMAND_TGGETDATA = 0x86,
79 PN532_COMMAND_TGSETDATA = 0x8E,
80 PN532_COMMAND_TGSETMETADATA = 0x94,
81 PN532_COMMAND_TGGETINITIATORCOMMAND = 0x88,
82 PN532_COMMAND_TGRESPONSETOINITIATOR = 0x90,
83 PN532_COMMAND_TGGETTARGETSTATUS = 0x8A
84 };
85
86 /* Application level errors generated by the PN532 chip */
87 /* See UM0701-02 - PN532 User Manual */
88 enum
89 {
90 PN532_APPERROR_NONE = 0x00,
91 PN532_APPERROR_TIMEOUT = 0x01,
92 PN532_APPERROR_CRCERROR = 0x02,
93 PN532_APPERROR_PARITYERROR = 0x04,
94 PN532_APPERROR_FRAMINGERROR = 0x05,
95 PN532_APPERROR_BITCOLLISION = 0x06,
96 PN532_APPERROR_INSUFFICIENTBUFFER = 0x07,
97 PN532_APPERROR_RFBUFFEROVERFLOW = 0x09,
98 PN532_APPERROR_RFFIELDTIMEOUT = 0x0A,
99 PN532_APPERROR_RFPROTOCOLERROR = 0x0B,
100 PN532_APPERROR_TEMPERROR = 0x0D,
101 PN532_APPERROR_INTERNBUFFEROVERFLOW = 0x0E,
102 PN532_APPERROR_INVALIDPARAMETER = 0x10,
103 PN532_APPERROR_DEP_UNSUPPORTEDCMD = 0x12,
104 PN532_APPERROR_DEP_INVALIDOFORMAT = 0x13,
105 PN532_APPERROR_AUTHENTERR = 0x14,
106 PN532_APPERROR_UIDCCHECKERROR = 0x23,
107 PN532_APPERROR_DEP_INVALIDDEVSTATE = 0x25,
108 PN532_APPERROR_OPERATIONNOTALLOWED = 0x26,
109 PN532_APPERROR_CMDNOTACCEPTABLE = 0x27,
110 PN532_APPERROR_TARGETRELEASED = 0x29,
111 PN532_APPERROR_IDMISMATCH = 0x2A,
112 PN532_APPERROR_CARDDISAPPEARED = 0x2B,
113 PN532_APPERROR_NFCID3MISMATCH = 0x2C,
114 PN532_APPERROR_OVERCURRENTEVENT = 0x2D,
115 PN532_APPERROR_NADMISSINGINDEP = 0x2E
116 };
117
118 /* Possible states for the PN532 SW Stack */
119 typedef enum pn532_state_e
120 {
121 PN532_STATE_SLEEP,
122 PN532_STATE_READY,
123 PN532_STATE_BUSY
124 }
125 pn532_state_t;
126
127 /* PN532 Protocol control block */
128 typedef struct
129 {
130 BOOL initialised;
131 pn532_state_t state;
132 pn532_modulation_t modulation;
133 uint32_t lastCommand;
134 uint32_t appError;
135 } pn532_pcb_t;
136
137 void pn532PrintHex(const byte_t * pbtData, const size_t szBytes);
138 void pn532PrintHexChar(const byte_t * pbtData, const size_t szBytes);
139 pn532_pcb_t * pn532GetPCB();
140 void pn532Init();
141 pn532_error_t pn532Read(byte_t *pbtResponse, size_t * pszLen);
142 pn532_error_t pn532Write(byte_t *abtCommand, size_t szLen);
143
144 #endif
This page took 0.049893 seconds and 5 git commands to generate.