Merge pull request #2654 from Antiklesys/master
[RRG-proxmark3.git] / common / iso15693tools.h
bloba18498a8dc554afe27eac27a7063e65f138cdffb
1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
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 as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // See LICENSE.txt for the text of the license.
15 //-----------------------------------------------------------------------------
16 // ISO15693 other commons
17 //-----------------------------------------------------------------------------
19 #ifndef ISO15693_H__
20 #define ISO15693_H__
22 #include "common.h"
24 // REQUEST FLAGS
25 #define ISO15_REQ_SUBCARRIER_SINGLE 0x00 // Tag should respond using one subcarrier (ASK)
26 #define ISO15_REQ_SUBCARRIER_TWO 0x01 // Tag should respond using two subcarriers (FSK)
27 #define ISO15_REQ_DATARATE_LOW 0x00 // Tag should respond using low data rate
28 #define ISO15_REQ_DATARATE_HIGH 0x02 // Tag should respond using high data rate
29 #define ISO15_REQ_NONINVENTORY 0x00
30 #define ISO15_REQ_INVENTORY 0x04 // This is an inventory request - see inventory flags
31 #define ISO15_REQ_PROTOCOL_NONEXT 0x00
32 #define ISO15_REQ_PROTOCOL_EXT 0x08 // RFU
34 // REQUEST FLAGS when INVENTORY is not set
35 #define ISO15_REQ_SELECT 0x10 // only selected cards response
36 #define ISO15_REQ_ADDRESS 0x20 // this req contains an address
37 #define ISO15_REQ_OPTION 0x40 // Command specific option selector
39 //REQUEST FLAGS when INVENTORY is set
40 #define ISO15_REQINV_AFI 0x10 // AFI Field is present
41 #define ISO15_REQINV_SLOT1 0x20 // 1 Slot
42 #define ISO15_REQINV_SLOT16 0x00 // 16 Slots
43 #define ISO15_REQINV_OPTION 0x40 // Command specific option selector
45 //RESPONSE FLAGS
46 #define ISO15_RES_ERROR 0x01
47 #define ISO15_RES_EXT 0x08 // Protocol Extension
49 // RESPONSE ERROR CODES
50 #define ISO15_NOERROR 0x00
51 #define ISO15_ERROR_CMD_NOT_SUP 0x01 // Command not supported
52 #define ISO15_ERROR_CMD_NOT_REC 0x02 // Command not recognized (eg. parameter error)
53 #define ISO15_ERROR_CMD_OPTION 0x03 // Command option not supported
54 #define ISO15_ERROR_GENERIC 0x0F // No additional Info about this error
55 #define ISO15_ERROR_BLOCK_UNAVAILABLE 0x10
56 #define ISO15_ERROR_BLOCK_LOCKED_ALREADY 0x11 // cannot lock again
57 #define ISO15_ERROR_BLOCK_LOCKED 0x12 // cannot be changed
58 #define ISO15_ERROR_BLOCK_WRITE 0x13 // Writing was unsuccessful
59 #define ISO15_ERROR_BLOCL_WRITELOCK 0x14 // Locking was unsuccessful
61 //-----------------------------------------------------------------------------
62 // Map a sequence of octets (~layer 2 command) into the set of bits to feed
63 // to the FPGA, to transmit that command to the tag.
64 // Mode: highspeed && one subcarrier (ASK)
65 //-----------------------------------------------------------------------------
67 // The sampling rate is 106.353 ksps/s, for T = 18.8 us
69 // SOF defined as
70 // 1) Unmodulated time of 56.64us
71 // 2) 24 pulses of 423.75kHz
72 // 3) logic '1' (unmodulated for 18.88us followed by 8 pulses of 423.75kHz)
74 static const int Iso15693FrameSOF[] = {
75 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
76 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
77 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
78 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
79 -1, -1, -1, -1,
80 -1, -1, -1, -1,
81 1, 1, 1, 1,
82 1, 1, 1, 1
84 static const int Iso15693Logic0[] = {
85 1, 1, 1, 1,
86 1, 1, 1, 1,
87 -1, -1, -1, -1,
88 -1, -1, -1, -1
90 static const int Iso15693Logic1[] = {
91 -1, -1, -1, -1,
92 -1, -1, -1, -1,
93 1, 1, 1, 1,
94 1, 1, 1, 1
97 // EOF defined as
98 // 1) logic '0' (8 pulses of 423.75kHz followed by unmodulated for 18.88us)
99 // 2) 24 pulses of 423.75kHz
100 // 3) Unmodulated time of 56.64us
101 static const int Iso15693FrameEOF[] = {
102 1, 1, 1, 1,
103 1, 1, 1, 1,
104 -1, -1, -1, -1,
105 -1, -1, -1, -1,
106 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
107 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
108 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
109 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
112 char *iso15693_sprintUID(char *dest, uint8_t *uid);
114 #endif