]> git.zerfleddert.de Git - proxmark3-svn/blob - common/iso15693tools.h
Update cmddata.c
[proxmark3-svn] / common / iso15693tools.h
1 // ISO15693 commons
2 // Adrian Dabrowski 2010 and others, GPLv2
3
4 #ifndef ISO15693_H__
5 #define ISO15693_H__
6
7 // ISO15693 CRC
8 #define ISO15_CRC_PRESET (uint16_t)0xFFFF
9 #define ISO15_CRC_POLY (uint16_t)0x8408
10 #define ISO15_CRC_CHECK ((uint16_t)(~0xF0B8 & 0xFFFF)) // use this for checking of a correct crc
11
12 // REQUEST FLAGS
13
14 #define ISO15_REQ_SUBCARRIER_SINGLE 0x00 // Tag should respond using one subcarrier (ASK)
15 #define ISO15_REQ_SUBCARRIER_TWO 0x01 // Tag should respond using two subcarriers (FSK)
16 #define ISO15_REQ_DATARATE_LOW 0x00 // Tag should respond using low data rate
17 #define ISO15_REQ_DATARATE_HIGH 0x02 // Tag should respond using high data rate
18 #define ISO15_REQ_NONINVENTORY 0x00
19 #define ISO15_REQ_INVENTORY 0x04 // This is an inventory request - see inventory flags
20 #define ISO15_REQ_PROTOCOL_NONEXT 0x00
21 #define ISO15_REQ_PROTOCOL_EXT 0x08 // RFU
22
23 // REQUEST FLAGS when INVENTORY is not set
24
25 #define ISO15_REQ_SELECT 0x10 // only selected cards response
26 #define ISO15_REQ_ADDRESS 0x20 // this req contains an address
27 #define ISO15_REQ_OPTION 0x40 // Command specific option selector
28
29 //REQUEST FLAGS when INVENTORY is set
30
31 #define ISO15_REQINV_AFI 0x10 // AFI Field is present
32 #define ISO15_REQINV_SLOT1 0x20 // 1 Slot
33 #define ISO15_REQINV_SLOT16 0x00 // 16 Slots
34 #define ISO15_REQINV_OPTION 0x40 // Command specific option selector
35
36 //RESPONSE FLAGS
37 #define ISO15_RES_ERROR 0x01
38 #define ISO15_RES_EXT 0x08 // Protocol Extention
39
40 // RESPONSE ERROR CODES
41 #define ISO15_NOERROR 0x00
42 #define ISO15_ERROR_CMD_NOT_SUP 0x01 // Command not supported
43 #define ISO15_ERROR_CMD_NOT_REC 0x02 // Command not recognized (eg. parameter error)
44 #define ISO15_ERROR_CMD_OPTION 0x03 // Command option not supported
45 #define ISO15_ERROR_GENERIC 0x0F // No additional Info about this error
46 #define ISO15_ERROR_BLOCK_UNAVAILABLE 0x10
47 #define ISO15_ERROR_BLOCK_LOCKED_ALREADY 0x11 // cannot lock again
48 #define ISO15_ERROR_BLOCK_LOCKED 0x12 // cannot be changed
49 #define ISO15_ERROR_BLOCK_WRITE 0x13 // Writing was unsuccessful
50 #define ISO15_ERROR_BLOCL_WRITELOCK 0x14 // Locking was unsuccessful
51
52 // COMMAND CODES
53 #define ISO15_CMD_INVENTORY 0x01
54 #define ISO15_CMD_STAYQUIET 0x02
55 #define ISO15_CMD_READ 0x20
56 #define ISO15_CMD_WRITE 0x21
57 #define ISO15_CMD_LOCK 0x22
58 #define ISO15_CMD_READMULTI 0x23
59 #define ISO15_CMD_WRITEMULTI 0x24
60 #define ISO15_CMD_SELECT 0x25
61 #define ISO15_CMD_RESET 0x26
62 #define ISO15_CMD_WRITEAFI 0x27
63 #define ISO15_CMD_LOCKAFI 0x28
64 #define ISO15_CMD_WRITEDSFID 0x29
65 #define ISO15_CMD_LOCKDSFID 0x2A
66 #define ISO15_CMD_SYSINFO 0x2B
67 #define ISO15_CMD_SECSTATUS 0x2C
68
69
70 uint16_t Iso15693Crc(uint8_t *v, int n);
71 int Iso15693AddCrc(uint8_t *req, int n);
72 char* Iso15693sprintUID(char *target,uint8_t *uid);
73 unsigned short iclass_crc16(char *data_p, unsigned short length);
74
75 //-----------------------------------------------------------------------------
76 // Map a sequence of octets (~layer 2 command) into the set of bits to feed
77 // to the FPGA, to transmit that command to the tag.
78 // Mode: highspeed && one subcarrier (ASK)
79 //-----------------------------------------------------------------------------
80
81 // The sampling rate is 106.353 ksps/s, for T = 18.8 us
82
83 // SOF defined as
84 // 1) Unmodulated time of 56.64us
85 // 2) 24 pulses of 423.75khz
86 // 3) logic '1' (unmodulated for 18.88us followed by 8 pulses of 423.75khz)
87
88 static const int Iso15693FrameSOF[] = {
89 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
90 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
91 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
92 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
93 -1, -1, -1, -1,
94 -1, -1, -1, -1,
95 1, 1, 1, 1,
96 1, 1, 1, 1
97 };
98 static const int Iso15693Logic0[] = {
99 1, 1, 1, 1,
100 1, 1, 1, 1,
101 -1, -1, -1, -1,
102 -1, -1, -1, -1
103 };
104 static const int Iso15693Logic1[] = {
105 -1, -1, -1, -1,
106 -1, -1, -1, -1,
107 1, 1, 1, 1,
108 1, 1, 1, 1
109 };
110
111 // EOF defined as
112 // 1) logic '0' (8 pulses of 423.75khz followed by unmodulated for 18.88us)
113 // 2) 24 pulses of 423.75khz
114 // 3) Unmodulated time of 56.64us
115
116 static const int Iso15693FrameEOF[] = {
117 1, 1, 1, 1,
118 1, 1, 1, 1,
119 -1, -1, -1, -1,
120 -1, -1, -1, -1,
121 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
122 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
123 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
124 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
125 };
126
127
128 #endif
Impressum, Datenschutz