a88f06bae6c80acb01d302b8295170321663fac7
[hackover2013-badge-firmware.git] / drivers / sensors / 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 #define PN532_DEBUG(fmt, args...) printf(fmt, ##args)
13
14 typedef enum pn532_state_e
15 {
16 PN532_STATE_SLEEP,
17 PN532_STATE_READY,
18 PN532_STATE_BUSY
19 }
20 pn532_state_t;
21
22 /* Error messages generate by the stack (not to be confused with app level errors from the PN532) */
23 typedef enum pn532_error_e
24 {
25 PN532_ERROR_NONE = 0x00,
26 PN532_ERROR_UNABLETOINIT = 0x01, // Unable to initialise or wakeup the device
27 PN532_ERROR_APPLEVELERROR = 0x02, // Application level error detected
28 PN532_ERROR_BUSY = 0x03, // Busy executing a previous command
29 PN532_ERROR_NOACK = 0x04, // No ack message received
30 PN532_ERROR_INVALIDACK = 0x05, // Ack != 00 00 FF 00 FF 00
31 PN532_ERROR_PREAMBLEMISMATCH = 0x06, // Frame preamble + start code mismatch
32 PN532_ERROR_EXTENDEDFRAME = 0x07, // Extended frames currently unsupported
33 PN532_ERROR_LENCHECKSUMMISMATCH = 0x08,
34 PN532_ERROR_RESPONSEBUFFEREMPTY = 0x09, // No response data received
35 PN532_ERROR_SPIREADYSTATUSTIMEOUT = 0x0A // Timeout waiting for 'ready' status (SPI only)
36
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 /* PN532 Protocol control block */
49 typedef struct
50 {
51 BOOL initialised;
52 pn532_state_t state;
53 pn532_modulation_t modulation;
54 uint32_t lastCommand;
55 uint32_t appError;
56 } pn532_pcb_t;
57
58 void pn532Init();
59 pn532_pcb_t * pn532GetPCB();
60 pn532_error_t pn532SetModulation(pn532_modulation_t mod);
61 pn532_error_t pn532Write(byte_t *abtCommand, size_t szLen);
62 pn532_error_t pn532Read(byte_t *abtResponse, size_t * pszLen);
63 void pn532PrintHex(const byte_t * pbtData, const size_t szBytes);
64
65 #endif
This page took 0.040432 seconds and 3 git commands to generate.