more constants fro the cmds
[rfid/librfid.git] / gemtag / gemtag.h
1 /*
2  * (C) 2006 by Frank Zirkelbach <hackbard@hackdaworld.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License version 2 
6  *  as published by the Free Software Foundation
7  *
8  *  This program is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *  GNU General Public License for more details.
12  *
13  *  You should have received a copy of the GNU General Public License
14  *  along with this program; if not, write to the Free Software
15  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17
18 #ifndef _GEMTAG_H
19 #define _GEMTAG_H
20
21 #define USB_VENDOR_GEMTAG       0x1394
22 #define USB_DEVICE_X501         0x0501
23
24 struct gemtag_handle {
25         struct usb_dev_handle *handle;
26         unsigned char seq;
27         unsigned char caps;
28         unsigned char serial[4];
29 };
30
31 #define GEMTAG_CAP_CRC                  0x01
32 #define GEMTAG_CAP_VERB_TRANSMIT        0x02
33
34 struct gemtag_cmd_hdr {
35         unsigned char start;
36         unsigned char seq;
37         unsigned char cmd;
38         u_int16_t len;
39 } __attribute__ ((packed));
40
41 #define BAD_CRC                         0x01
42 #define SEQ_MISMATCH                    0x02
43 #define SHORT_ANSWER                    0x03
44 #define CMD_FAILED                      0x04
45 #define AUTH_FAILED                     0x05
46 #define READ_FAILED                     0x06
47 #define NO_PICC                         0x07
48 #define PICC_SELECT_ERROR               0x08
49
50 /* gemtag commands */
51
52 #define GEMTAG_CMD_PCD_CONFIG           0x10
53 #define GEMTAG_CMD_PICC_ANTICOLL        0x12
54 #define GEMTAG_CMD_PICC_SELECT          0x13
55
56 #define GEMTAG_CMD_PICC_AUTH            0x14
57 #define GEMTAG_CMD_PICC_AUTH_E2         0x15
58 #define GEMTAG_CMD_HOST_CODE_KEY        0x16
59 #define GEMTAG_CMD_PCD_LOAD_KEY_E2      0x17
60 #define GEMTAG_CMD_PICC_AUTH_KEY        0x18
61 #define GEMTAG_PICC_AUTHENT1A           0x60
62 #define GEMTAG_PICC_AUTHENT1B           0x61
63
64 #define GEMTAG_CMD_PICC_READ            0x19
65 #define GEMTAG_CMD_PICC_WRITE           0x1a
66 #define GEMTAG_CMD_PICC_VALUE           0x1b
67 #define GEMTAG_CMD_PICC_VALUE_DEBIT     0x1c
68 #define GEMTAG_CMD_PICC_HALT            0x1d
69 #define GEMTAG_CMD_PICC_WRITE4          0x1e
70 #define GEMTAG_CMD_COMMON_WRITE         0x1f
71 #define GEMTAG_CMD_PCD_RF_RESET         0x20
72 #define GEMTAG_CMD_GET_SERIAL_NUMBER    0x22
73 #define GEMTAG_CMD_PCD_READ_E2          0x23
74 #define GEMTAG_CMD_PCD_WRITE_E2         0x24
75 #define GEMTAG_CMD_PICC_COMMON_READ     0x28
76 #define GEMTAG_PICC_DECREMENT           0xc0
77 #define GEMTAG_PICC_INCREMENT           0xc1
78 #define GEMTAG_PICC_RESTORE             0xc2
79 #define GEMTAG_PICC_READ16              0x30
80 #define GEMTAG_PICC_WRITE16             0xa0
81 #define GEMTAG_PICC_WRITE4              0xa2
82
83 #define GEMTAG_CMD_PCD_SET_TMO          0x27
84
85 #define GEMTAG_CMD_PICC_REQUEST         0x40
86 #define GEMTAG_CMD_PICC_CASC_ANTICOLL   0x41
87 #define GEMTAG_CMD_PICC_CASC_SELECT     0x42
88 #define GEMTAG_PICC_STD_SELECT_CODE     0x93
89 #define GEMTAG_PICC_CASC_LEVEL1         0x95
90 #define GEMTAG_PICC_CASC_LEVEL2         0x97
91 /* from another source (mac gemtag tool) ... */
92 #define GEMTAG_PICC_CASC_L1             0x93
93 #define GEMTAG_PICC_CASC_L2             0x92
94 #define GEMTAG_PICC_CASC_L3             0x94
95 #define GEMTAG_PICC_CASC_L4             0x98
96 #define GEMTAG_PICC_CASC_L5             0x95
97 #define GEMTAG_PICC_CASC_L6             0x97
98
99 #define GEMTAG_CMD_PICC_ACTIVATE_IDLE   0x43
100 #define GEMTAG_CMD_PICC_ACTIVATE_WAKEUP 0x44
101 #define GEMTAG_CMD_SET_DFLT_ATTRIBUTES  0x45
102 #define GEMTAG_CMD_SET_ATTRIBUTES       0x46
103 #define GEMTAG_CMD_PICC_EXCHANGE_BLOCK  0x48
104 #define GEMTAG_PICC_REQIDL              0x26
105 #define GEMTAG_PICC_REQALL              0x52
106
107 #define GEMTAG_CMD_SWITCH_LED           0x60
108 #define GEMTAG_LED_OFF                  0x00
109 #define GEMTAG_LED_ON                   0x01
110
111 #define GEMTAG_CMD_GET_FW_VERSION       0x63
112 #define GEMTAG_CMD_GET_RIC_VERSION      0x64
113 #define GEMTAG_CMD_SET_DEFAULT_BAUDRATE 0x81
114 #define GEMTAG_CMD_SET_ONLINE_BAUDRATE  0x82
115 #define GEMTAG_CMD_SET_CPU_TIMEOUT      0x88
116
117 #define GEMTAG_CMD_DETECT_CARD          0x92
118 #define GEMTAG_CMD_DETECT_ISO15693_CARD 0x93
119 #define GEMTAG_CMD_PPS_REQUEST          0xa0
120 #define GEMTAG_CMD_DESELECT             0xa1
121
122 #endif