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