CHG: code clean up. Have some questions regarding the CopyVikingTo method. The configblock looks wrong..

This commit is contained in:
iceman1001 2015-10-15 11:30:37 +02:00
commit 6a09bea427
2 changed files with 11 additions and 33 deletions

View file

@ -1132,6 +1132,7 @@ void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
* Relevant times in microsecond * Relevant times in microsecond
* To compensate antenna falling times shorten the write times * To compensate antenna falling times shorten the write times
* and enlarge the gap ones. * and enlarge the gap ones.
* Q5 tags seems to have issues when these values changes.
*/ */
#define START_GAP 50*8 // was 250 // SPEC: 1*8 to 50*8 - typ 15*8 (or 15fc) #define START_GAP 50*8 // was 250 // SPEC: 1*8 to 50*8 - typ 15*8 (or 15fc)
@ -1257,7 +1258,6 @@ void T55xxReadBlock(uint32_t Block, uint32_t Pwd, uint8_t PwdMode) {
LED_A_OFF(); LED_A_OFF();
} }
// Read card traceability data (page 1) // Read card traceability data (page 1)
void T55xxReadTrace(void){ void T55xxReadTrace(void){
LED_A_ON(); LED_A_ON();
@ -1285,7 +1285,6 @@ void T55xxReadTrace(void){
LED_A_OFF(); LED_A_OFF();
} }
/*-------------- Cloning routines -----------*/ /*-------------- Cloning routines -----------*/
// Copy HID id to card and setup block 0 config // Copy HID id to card and setup block 0 config
void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT)
@ -1542,7 +1541,6 @@ void WriteEM410x(uint32_t card, uint32_t id_hi, uint32_t id_lo)
// Clone Indala 64-bit tag by UID to T55x7 // Clone Indala 64-bit tag by UID to T55x7
void CopyIndala64toT55x7(int hi, int lo) void CopyIndala64toT55x7(int hi, int lo)
{ {
//Program the 2 data blocks for supplied 64bit UID //Program the 2 data blocks for supplied 64bit UID
// and the block 0 for Indala64 format // and the block 0 for Indala64 format
T55xxWriteBlock(hi,1,0,0); T55xxWriteBlock(hi,1,0,0);
@ -1556,12 +1554,10 @@ void CopyIndala64toT55x7(int hi, int lo)
// T5567WriteBlock(0x603E1042,0); // T5567WriteBlock(0x603E1042,0);
DbpString("DONE!"); DbpString("DONE!");
} }
void CopyIndala224toT55x7(int uid1, int uid2, int uid3, int uid4, int uid5, int uid6, int uid7) void CopyIndala224toT55x7(int uid1, int uid2, int uid3, int uid4, int uid5, int uid6, int uid7)
{ {
//Program the 7 data blocks for supplied 224bit UID //Program the 7 data blocks for supplied 224bit UID
// and the block 0 for Indala224 format // and the block 0 for Indala224 format
T55xxWriteBlock(uid1,1,0,0); T55xxWriteBlock(uid1,1,0,0);
@ -1580,7 +1576,6 @@ void CopyIndala224toT55x7(int uid1, int uid2, int uid3, int uid4, int uid5, int
// T5567WriteBlock(0x603E10E2,0); // T5567WriteBlock(0x603E10E2,0);
DbpString("DONE!"); DbpString("DONE!");
} }
//----------------------------------- //-----------------------------------
@ -1591,7 +1586,6 @@ void CopyIndala224toT55x7(int uid1, int uid2, int uid3, int uid4, int uid5, int
#define FWD_CMD_READ 0x9 #define FWD_CMD_READ 0x9
#define FWD_CMD_DISABLE 0x5 #define FWD_CMD_DISABLE 0x5
uint8_t forwardLink_data[64]; //array of forwarded bits uint8_t forwardLink_data[64]; //array of forwarded bits
uint8_t * forward_ptr; //ptr for forward message preparation uint8_t * forward_ptr; //ptr for forward message preparation
uint8_t fwd_bit_sz; //forwardlink bit counter uint8_t fwd_bit_sz; //forwardlink bit counter
@ -1601,9 +1595,7 @@ uint8_t * fwd_write_ptr; //forwardlink bit pointer
// prepares command bits // prepares command bits
// see EM4469 spec // see EM4469 spec
//==================================================================== //====================================================================
//--------------------------------------------------------------------
uint8_t Prepare_Cmd( uint8_t cmd ) { uint8_t Prepare_Cmd( uint8_t cmd ) {
//--------------------------------------------------------------------
*forward_ptr++ = 0; //start bit *forward_ptr++ = 0; //start bit
*forward_ptr++ = 0; //second pause for 4050 code *forward_ptr++ = 0; //second pause for 4050 code
@ -1623,10 +1615,7 @@ uint8_t Prepare_Cmd( uint8_t cmd ) {
// prepares address bits // prepares address bits
// see EM4469 spec // see EM4469 spec
//==================================================================== //====================================================================
//--------------------------------------------------------------------
uint8_t Prepare_Addr( uint8_t addr ) { uint8_t Prepare_Addr( uint8_t addr ) {
//--------------------------------------------------------------------
register uint8_t line_parity; register uint8_t line_parity;
@ -1647,10 +1636,7 @@ uint8_t Prepare_Addr( uint8_t addr ) {
// prepares data bits intreleaved with parity bits // prepares data bits intreleaved with parity bits
// see EM4469 spec // see EM4469 spec
//==================================================================== //====================================================================
//--------------------------------------------------------------------
uint8_t Prepare_Data( uint16_t data_low, uint16_t data_hi) { uint8_t Prepare_Data( uint16_t data_low, uint16_t data_hi) {
//--------------------------------------------------------------------
register uint8_t line_parity; register uint8_t line_parity;
register uint8_t column_parity; register uint8_t column_parity;
@ -1694,21 +1680,14 @@ void SendForward(uint8_t fwd_bit_count) {
LED_D_ON(); LED_D_ON();
//Field on // Set up FPGA, 125kHz
FpgaDownloadAndGo(FPGA_BITSTREAM_LF); LFSetupFPGAForADC(95, true);
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
// Give it a bit of time for the resonant antenna to settle.
// And for the tag to fully power up
SpinDelay(150);
// force 1st mod pulse (start gap must be longer for 4305) // force 1st mod pulse (start gap must be longer for 4305)
fwd_bit_sz--; //prepare next bit modulation fwd_bit_sz--; //prepare next bit modulation
fwd_write_ptr++; fwd_write_ptr++;
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
SpinDelayUs(55*8); //55 cycles off (8us each)for 4305 SpinDelayUs(55*8); //55 cycles off (8us each)for 4305
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);//field on FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);//field on
SpinDelayUs(16*8); //16 cycles on (8us each) SpinDelayUs(16*8); //16 cycles on (8us each)
@ -1720,7 +1699,6 @@ void SendForward(uint8_t fwd_bit_count) {
//These timings work for 4469/4269/4305 (with the 55*8 above) //These timings work for 4469/4269/4305 (with the 55*8 above)
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
SpinDelayUs(23*8); //16-4 cycles off (8us each) SpinDelayUs(23*8); //16-4 cycles off (8us each)
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);//field on FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);//field on
SpinDelayUs(9*8); //16 cycles on (8us each) SpinDelayUs(9*8); //16 cycles on (8us each)
} }
@ -1739,7 +1717,6 @@ void EM4xLogin(uint32_t Password) {
//Wait for command to complete //Wait for command to complete
SpinDelay(20); SpinDelay(20);
} }
void EM4xReadWord(uint8_t Address, uint32_t Pwd, uint8_t PwdMode) { void EM4xReadWord(uint8_t Address, uint32_t Pwd, uint8_t PwdMode) {
@ -1780,8 +1757,8 @@ void EM4xReadWord(uint8_t Address, uint32_t Pwd, uint8_t PwdMode) {
} }
} }
cmd_send(CMD_ACK,0,0,0,0,0);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
cmd_send(CMD_ACK,0,0,0,0,0);
LED_D_OFF(); LED_D_OFF();
} }
@ -1809,9 +1786,11 @@ void CopyViKingtoT55x7(uint32_t block1,uint32_t block2) {
LED_D_ON(); LED_D_ON();
T55xxWriteBlock(block1,1,0,0); T55xxWriteBlock(block1,1,0,0);
T55xxWriteBlock(block2,2,0,0); T55xxWriteBlock(block2,2,0,0);
T55xxWriteBlock(T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | 2 << T5555_MAXBLOCK_SHIFT,0,0,1); T55xxWriteBlock(T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | 2 << T5555_MAXBLOCK_SHIFT,0,0,1);
// ICEMAN NOTES:
// Shouldn't this one be: T55x7_MAXBLOCK_SHIFT and 0 in password mode
// like this:
// T55xxWriteBlock(T55x7_MODULATION_MANCHESTER | T55x7_BITRATE_RF_32 | 2 << T55x7_MAXBLOCK_SHIFT,0,0,0);
LED_D_OFF(); LED_D_OFF();
DbpString("DONE!");
} }

View file

@ -232,7 +232,6 @@ int CmdEM410xWrite(const char *Cmd)
UsbCommand c = {CMD_EM410X_WRITE_TAG, {card, (uint32_t)(id >> 32), (uint32_t)id}}; UsbCommand c = {CMD_EM410X_WRITE_TAG, {card, (uint32_t)(id >> 32), (uint32_t)id}};
SendCommand(&c); SendCommand(&c);
return 0; return 0;
} }