initial checkin of harald welte's original librfid project
[rfid/librfid.git] / 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_transcieve_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[0];
40 };
41
42 enum tcl_handle_flags {
43         TCL_HANDLE_F_NAD_SUPPORTED      = 0x0001,
44         TCL_HANDLE_F_CID_SUPPORTED      = 0x0002,
45         TCL_HANDLE_F_NAD_USED           = 0x0010,
46         TCL_HANDLE_F_CID_USED           = 0x0020,
47 };
48
49
50 enum tcl_pcb_bits {
51         TCL_PCB_CID_FOLLOWING           = 0x08,
52         TCL_PCB_NAD_FOLLOWING           = 0x04,
53 };
54
55 enum tcl_pcd_state {
56         TCL_STATE_NONE = 0x00,
57         TCL_STATE_INITIAL,
58         TCL_STATE_RATS_SENT,            /* waiting for ATS */
59         TCL_STATE_ATS_RCVD,             /* ATS received */
60         TCL_STATE_PPS_SENT,             /* waiting for PPS response */
61         TCL_STATE_ESTABLISHED,          /* xchg transparent data */
62         TCL_STATE_DESELECT_SENT,        /* waiting for DESELECT response */
63         TCL_STATE_DESELECTED,           /* card deselected or HLTA'd */
64 };
65
66 struct rfid_protocol rfid_protocol_tcl;
67
68 #endif /* __LIBRFID__ */
69
70 #endif