Prepare RFID compilation in firmware mode
[librfid] / include / librfid / rfid_protocol_tcl.h
1 #ifndef _RFID_PROTOCOL_TCL_H
2 #define _RFID_PROTOCOL_TCL_H
3
4 #ifdef __LIBRFID__
5
6 enum tcl_transport_rate {
7         TCL_RATE_106    = 0x01,
8         TCL_RATE_212    = 0x02,
9         TCL_RATE_424    = 0x04,
10         TCL_RATE_848    = 0x08,
11 };
12
13 enum tcl_transport_transceive_flags {
14         TCL_TRANSP_F_TX_CRC     = 0x01, /* transport adds TX CRC */
15         TCL_TRANSP_F_RX_CRC     = 0x02, 
16 };
17
18 struct tcl_handle {
19         /* derived from ats */
20         unsigned char *historical_bytes; /* points into ats */
21         unsigned int historical_len;
22
23         unsigned int fsc;       /* max frame size accepted by card */
24         unsigned int fsd;       /* max frame size accepted by reader */
25         unsigned int fwt;       /* frame waiting time (in usec)*/
26         unsigned char ta;       /* divisor information */
27         unsigned char sfgt;     /* start-up frame guard time (in usec) */
28
29         /* otherwise determined */
30         unsigned int cid;       /* Card ID */
31         unsigned int nad;       /* Node Address */
32
33         unsigned int flags;
34         unsigned int state;     /* protocol state */
35
36         unsigned int toggle;    /* send toggle with next frame */
37
38         unsigned int ats_len;
39         unsigned char ats[256]; /* ATS cannot be bigger than FSD-2 bytes,
40                                    according to ISO 14443-4 5.2.2 */
41 };
42
43 enum tcl_handle_flags {
44         TCL_HANDLE_F_NAD_SUPPORTED      = 0x0001,
45         TCL_HANDLE_F_CID_SUPPORTED      = 0x0002,
46         TCL_HANDLE_F_NAD_USED           = 0x0010,
47         TCL_HANDLE_F_CID_USED           = 0x0020,
48 };
49
50
51 enum tcl_pcb_bits {
52         TCL_PCB_CID_FOLLOWING           = 0x08,
53         TCL_PCB_NAD_FOLLOWING           = 0x04,
54 };
55
56 enum tcl_pcd_state {
57         TCL_STATE_NONE = 0x00,
58         TCL_STATE_INITIAL,
59         TCL_STATE_RATS_SENT,            /* waiting for ATS */
60         TCL_STATE_ATS_RCVD,             /* ATS received */
61         TCL_STATE_PPS_SENT,             /* waiting for PPS response */
62         TCL_STATE_ESTABLISHED,          /* xchg transparent data */
63         TCL_STATE_DESELECT_SENT,        /* waiting for DESELECT response */
64         TCL_STATE_DESELECTED,           /* card deselected or HLTA'd */
65 };
66
67 extern const struct rfid_protocol rfid_protocol_tcl;
68
69 #endif /* __LIBRFID__ */
70
71 #endif