Merge pull request #1327 from Pondorasti/patch-1
[RRG-proxmark3.git] / include / em4x50.h
blobac8fb0bfdf142428721868d98309eeb2bcc51539
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2020 tharexde
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 // Low frequency EM4x50 structs
9 //-----------------------------------------------------------------------------
11 #ifndef EM4X50_H__
12 #define EM4X50_H__
14 #include "common.h"
16 #define EM4X50_NO_WORDS 34
18 // special words
19 #define EM4X50_DEVICE_PASSWORD 0
20 #define EM4X50_PROTECTION 1
21 #define EM4X50_CONTROL 2
22 #define EM4X50_DEVICE_SERIAL 32
23 #define EM4X50_DEVICE_ID 33
25 // control word (word = 4 bytes)
26 #define FIRST_WORD_READ 0 // first byte
27 #define LAST_WORD_READ 1 // second byte
28 #define CONFIG_BLOCK 2 // third byte
29 #define PASSWORD_CHECK 0x80 // first bit in third byte
30 #define READ_AFTER_WRITE 0x40 // second bit in third byte
32 // protection word
33 #define FIRST_WORD_READ_PROTECTED 0 // first byte
34 #define LAST_WORD_READ_PROTECTED 1 // second byte
35 #define FIRST_WORD_WRITE_INHIBITED 2 // third byte
36 #define LAST_WORD_WRITE_INHIBITED 3 // fourth byte
38 // commands
39 #define EM4X50_COMMAND_LOGIN 0x01
40 #define EM4X50_COMMAND_RESET 0x80
41 #define EM4X50_COMMAND_WRITE 0x12
42 #define EM4X50_COMMAND_WRITE_PASSWORD 0x11
43 #define EM4X50_COMMAND_SELECTIVE_READ 0x0A
44 #define EM4X50_COMMAND_STANDARD_READ 0x02 // virtual command
46 // misc
47 #define TIMEOUT_CMD 3000
48 #define DUMP_FILESIZE 136
50 typedef struct {
51 bool addr_given;
52 bool pwd_given;
53 uint32_t password1;
54 uint32_t password2;
55 uint32_t word;
56 uint32_t addresses;
57 } PACKED em4x50_data_t;
59 typedef struct {
60 uint8_t byte[4];
61 } PACKED em4x50_word_t;
63 extern bool gLogin;
64 extern bool gWritePasswordProcess;
65 extern uint32_t gPassword;
67 #endif /* EM4X50_H__ */