1 //-----------------------------------------------------------------------------
2 // Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
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.
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 //-----------------------------------------------------------------------------
22 #define I2C_DEVICE_ADDRESS_BOOT 0xB0
23 #define I2C_DEVICE_ADDRESS_MAIN 0xC0
25 #define I2C_DEVICE_CMD_GENERATE_ATR 0x01
26 #define I2C_DEVICE_CMD_SEND 0x02
27 #define I2C_DEVICE_CMD_READ 0x03
28 #define I2C_DEVICE_CMD_SETBAUD 0x04
29 #define I2C_DEVICE_CMD_SIM_CLC 0x05
30 #define I2C_DEVICE_CMD_GETVERSION 0x06
31 #define I2C_DEVICE_CMD_SEND_T0 0x07
33 void I2C_recovery(void);
36 void I2C_SetResetStatus(uint8_t LineRST
, uint8_t LineSCK
, uint8_t LineSDA
);
38 void I2C_Reset_EnterMainProgram(void);
39 void I2C_Reset_EnterBootloader(void);
41 bool I2C_WriteCmd(uint8_t device_cmd
, uint8_t device_address
);
43 bool I2C_WriteByte(uint8_t data
, uint8_t device_cmd
, uint8_t device_address
);
44 bool I2C_BufferWrite(uint8_t *data
, uint8_t len
, uint8_t device_cmd
, uint8_t device_address
);
45 int16_t I2C_BufferRead(uint8_t *data
, uint8_t len
, uint8_t device_cmd
, uint8_t device_address
);
48 int16_t I2C_ReadFW(uint8_t *data
, uint8_t len
, uint8_t msb
, uint8_t lsb
, uint8_t device_address
);
49 bool I2C_WriteFW(uint8_t *data
, uint8_t len
, uint8_t msb
, uint8_t lsb
, uint8_t device_address
);
51 bool sc_rx_bytes(uint8_t *dest
, uint8_t *destlen
);
53 bool GetATR(smart_card_atr_t
*card_ptr
, bool verbose
);
56 void SmartCardAtr(void);
57 void SmartCardRaw(smart_card_raw_t
*p
);
58 void SmartCardUpgrade(uint64_t arg0
);
59 void SmartCardSetBaud(uint64_t arg0
);
60 void SmartCardSetClock(uint64_t arg0
);
61 void I2C_print_status(void);
62 int I2C_get_version(uint8_t *maj
, uint8_t *min
);