Merge pull request #1327 from Pondorasti/patch-1
[RRG-proxmark3.git] / include / iso14b.h
blob766ca851c598238de13c9a968e7b542152799ca4
1 //-----------------------------------------------------------------------------
2 // (c) 2020 Iceman
3 //
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
6 // the license.
7 //-----------------------------------------------------------------------------
8 // ISO 14443B type prototyping
9 //-----------------------------------------------------------------------------
11 #ifndef _ISO14B_H_
12 #define _ISO14B_H_
14 #include "common.h"
15 typedef struct {
16 uint8_t uid[10];
17 uint8_t uidlen;
18 uint8_t atqb[7];
19 uint8_t chipid;
20 uint8_t cid;
21 } PACKED iso14b_card_select_t;
23 typedef struct {
24 uint8_t uid[4];
25 uint8_t pc;
26 uint8_t fc;
27 } PACKED iso14b_cts_card_select_t;
29 typedef enum ISO14B_COMMAND {
30 ISO14B_CONNECT = (1 << 0),
31 ISO14B_DISCONNECT = (1 << 1),
32 ISO14B_APDU = (1 << 2),
33 ISO14B_RAW = (1 << 3),
34 ISO14B_REQUEST_TRIGGER = (1 << 4),
35 ISO14B_APPEND_CRC = (1 << 5),
36 ISO14B_SELECT_STD = (1 << 6),
37 ISO14B_SELECT_SR = (1 << 7),
38 ISO14B_SET_TIMEOUT = (1 << 8),
39 ISO14B_SEND_CHAINING = (1 << 9),
40 ISO14B_SELECT_CTS = (1 << 10),
41 ISO14B_CLEARTRACE = (1 << 11),
42 } iso14b_command_t;
44 typedef struct {
45 uint16_t flags; // the ISO14B_COMMAND enum
46 uint32_t timeout;
47 uint16_t rawlen;
48 uint8_t raw[];
49 } PACKED iso14b_raw_cmd_t;
52 #define US_TO_SSP(x) ( (uint32_t)((x) * 3.39) )
53 #define SSP_TO_US(x) ( (uint32_t)((x) / 3.39) )
55 #define ETU_TO_SSP(x) ((x) * 32)
56 #define SSP_TO_ETU(x) ((x) / 32)
58 #define ETU_TO_US(x) ((((x) * 9440000) / 1000000) + 0.5)
59 #define US_TO_ETU(x) ((((x) * 1000000 / 9440000) + 0.5))
61 #endif // _ISO14B_H_