make style

This commit is contained in:
Philippe Teuwen
2020-08-13 12:25:04 +02:00
parent 8a602ed99d
commit 4ed57c7c4d
57 changed files with 878 additions and 878 deletions
+4 -4
View File
@@ -159,8 +159,8 @@ void BigBuf_print_status(void) {
Dbprintf(" traceLen ...............%d", trace_len);
Dbprintf(" dma8 memory.............%d", dma_8.buf - BigBuf_get_addr());
Dbprintf(" dma16 memory............%d", (uint8_t*)dma_16.buf - BigBuf_get_addr());
Dbprintf(" toSend memory...........%d", toSend.buf - BigBuf_get_addr() );
Dbprintf(" dma16 memory............%d", (uint8_t *)dma_16.buf - BigBuf_get_addr());
Dbprintf(" toSend memory...........%d", toSend.buf - BigBuf_get_addr());
}
// return the maximum trace length (i.e. the unallocated size of BigBuf)
@@ -229,7 +229,7 @@ bool RAMFUNC LogTrace(const uint8_t *btBytes, uint16_t iLen, uint32_t timestamp_
*/
duration = 0;
}
hdr->timestamp = timestamp_start;
hdr->duration = duration & 0xFFFF;
hdr->data_len = iLen;
@@ -309,7 +309,7 @@ void tosend_stuffbit(int b) {
dmabuf16_t *get_dma16(void) {
if (dma_16.buf == NULL)
dma_16.buf = (uint16_t*)BigBuf_malloc(DMA_BUFFER_SIZE * sizeof(uint16_t));
dma_16.buf = (uint16_t *)BigBuf_malloc(DMA_BUFFER_SIZE * sizeof(uint16_t));
return &dma_16;
}
+1 -1
View File
@@ -22,7 +22,7 @@
#define DMA_BUFFER_SIZE 256
// 8 data bits and 1 parity bit per payload byte, 1 correction bit, 1 SOC bit, 2 EOC bits
#define TOSEND_BUFFER_SIZE (9 * MAX_FRAME_SIZE + 1 + 1 + 2)
#define TOSEND_BUFFER_SIZE (9 * MAX_FRAME_SIZE + 1 + 1 + 2)
uint8_t *BigBuf_get_addr(void);
uint32_t BigBuf_get_size(void);
+1 -1
View File
@@ -30,7 +30,7 @@ SRC_ISO14443b = iso14443b.c
SRC_FELICA = felica.c
SRC_CRAPTO1 = crypto1.c des.c desfire_crypto.c mifaredesfire.c aes.c platform_util.c
SRC_CRC = crc.c crc16.c crc32.c
SRC_ICLASS = iclass.c optimized_cipherutils.c optimized_ikeys.c optimized_elite.c optimized_cipher.c
SRC_ICLASS = iclass.c optimized_cipherutils.c optimized_ikeys.c optimized_elite.c optimized_cipher.c
SRC_LEGIC = legicrf.c legicrfsim.c legic_prng.c
SRC_NFCBARCODE = thinfilm.c
+14 -14
View File
@@ -51,7 +51,7 @@
#define HF_ICLASS_CC_A "iceclass_cc_a.bin"
#define HF_ICLASS_CC_B "iceclass_cc_b.bin"
char* cc_files[] = { HF_ICLASS_CC_A, HF_ICLASS_CC_B };
char *cc_files[] = { HF_ICLASS_CC_A, HF_ICLASS_CC_B };
@@ -65,7 +65,7 @@ char* cc_files[] = { HF_ICLASS_CC_A, HF_ICLASS_CC_B };
#endif
// iclass card descriptors
char * card_types[] = {
char *card_types[] = {
"PicoPass 16K / 16", // 000
"PicoPass 32K with current book 16K / 16", // 001
"Unknown Card Type!", // 010
@@ -112,13 +112,13 @@ static uint8_t csns[8 * NUM_CSNS] = {
static void download_instructions(uint8_t t) {
DbpString("");
switch (t) {
switch (t) {
case ICE_STATE_FULLSIM: {
DbpString("The emulator memory was saved to SPIFFS");
DbpString("1. " _YELLOW_("mem spiffs dump o " HF_ICLASS_FULLSIM_MOD_BIN " f " HF_ICLASS_FULLSIM_MOD" e"));
DbpString("2. " _YELLOW_("hf iclass view f " HF_ICLASS_FULLSIM_MOD_BIN));
break;
}
}
case ICE_STATE_ATTACK: {
DbpString("The collected data was saved to SPIFFS. The file names below may differ");
DbpString("1. " _YELLOW_("mem spiffs tree"));
@@ -143,9 +143,9 @@ static void save_to_flash(uint8_t *data, uint16_t datalen) {
char fn[SPIFFS_OBJ_NAME_LEN];
sprintf(fn, "iclass-%02X%02X%02X%02X%02X%02X%02X%02X.bin",
data[0], data[1], data[2], data[3],
data[4], data[5], data[6], data[7]
);
data[0], data[1], data[2], data[3],
data[4], data[5], data[6], data[7]
);
int res;
if (exists_in_spiffs(fn) == false) {
@@ -185,7 +185,7 @@ static int fullsim_mode(void) {
Dbprintf("loaded " _GREEN_(HF_ICLASS_FULLSIM_ORIG_BIN) " (%u bytes)", fsize);
}
iclass_simulate(ICLASS_SIM_MODE_FULL, 0 , false, NULL, NULL, NULL);
iclass_simulate(ICLASS_SIM_MODE_FULL, 0, false, NULL, NULL, NULL);
LED_B_ON();
rdv40_spiffs_lazy_mount();
@@ -252,7 +252,7 @@ static int reader_attack_mode(void) {
rdv40_spiffs_lazy_unmount();
LED_B_OFF();
if (res == SPIFFS_OK) {
Dbprintf("saved to " _GREEN_("%s"), fn);
Dbprintf("saved to " _GREEN_("%s"), fn);
} else {
Dbprintf(_RED_("error") " writing %s to flash ( %d )", fn, res);
}
@@ -280,7 +280,7 @@ static int reader_dump_mode(void) {
break;
}
// setup authenticate AA1
// setup authenticate AA1
iclass_auth_req_t auth = {
.use_raw = false,
.use_elite = false,
@@ -334,7 +334,7 @@ static int reader_dump_mode(void) {
res = authenticate_iclass_tag(&auth, hdr, &start_time, &eof_time, NULL);
if (res == false) {
switch_off();
Dbprintf( _RED_("failed AA1 auth") ", skipping ");
Dbprintf(_RED_("failed AA1 auth") ", skipping ");
continue;
}
@@ -389,7 +389,7 @@ static int reader_dump_mode(void) {
}
}
switch_off();
save_to_flash(card_data, (start_block + dumped) * 8 );
save_to_flash(card_data, (start_block + dumped) * 8);
Dbprintf("%u bytes saved", (start_block + dumped) * 8);
}
DbpString("-=[ exiting " _CYAN_("`read & dump`") " mode ]=-");
@@ -409,7 +409,7 @@ static int config_sim_mode(void) {
if (res == SPIFFS_OK) {
Dbprintf("loaded " _GREEN_("%s") " (%u bytes) to emulator memory", cc_files[i], fsize);
iclass_simulate(ICLASS_SIM_MODE_FULL, 0 , false, NULL, NULL, NULL);
iclass_simulate(ICLASS_SIM_MODE_FULL, 0, false, NULL, NULL, NULL);
}
}
@@ -490,7 +490,7 @@ void RunMod(void) {
// Look for config cards
rdv40_spiffs_lazy_mount();
for (uint8_t i =0; i < 2; i++) {
for (uint8_t i = 0; i < 2; i++) {
if (exists_in_spiffs(cc_files[i]) == false) {
Dbprintf(_RED_("error") ", " _YELLOW_("%s") " file missing", cc_files[i]);
mode = ICE_STATE_NONE;
+2 -2
View File
@@ -64,12 +64,12 @@ static void fillbuff(uint8_t bit) {
}
static void construct_EM410x_emul(uint64_t id) {
int i, j;
int binary[4] = {0};
int parity[4] = {0};
buflen = 0;
for (i = 0; i < 9; i++)
fillbuff(1);
+4 -4
View File
@@ -295,7 +295,7 @@ static void TimingIntervalAcquisition(void) {
static void print_debug_level(void) {
char dbglvlstr[20] = {0};
switch(DBGLEVEL) {
switch (DBGLEVEL) {
case DBG_NONE:
sprintf(dbglvlstr, "NONE");
break;
@@ -308,7 +308,7 @@ static void print_debug_level(void) {
case DBG_DEBUG:
sprintf(dbglvlstr, "DEBUG");
break;
case DBG_EXTENDED:
case DBG_EXTENDED:
sprintf(dbglvlstr, "EXTENDED");
break;
}
@@ -362,9 +362,9 @@ static void SendStatus(void) {
print_stack_usage();
print_debug_level();
tosend_t *ts = get_tosend();
Dbprintf(" ToSendMax...............%d", ts->max );
Dbprintf(" ToSendMax...............%d", ts->max);
Dbprintf(" ToSend BUFFERSIZE.......%d", TOSEND_BUFFER_SIZE);
while ((AT91C_BASE_PMC->PMC_MCFR & AT91C_CKGR_MAINRDY) == 0); // Wait for MAINF value to become available...
uint16_t mainf = AT91C_BASE_PMC->PMC_MCFR & AT91C_CKGR_MAINF; // Get # main clocks within 16 slow clocks
+139 -139
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -152,16 +152,16 @@ void FpgaSetupSsc(uint16_t fpga_mode) {
// data and frame signal is sampled on falling edge of RK
AT91C_BASE_SSC->SSC_RCMR = SSC_CLOCK_MODE_SELECT(1) | SSC_CLOCK_MODE_START(1);
// 8, 16 or 32 bits per transfer, no loopback, MSB first, 1 transfer per sync
// 8, 16 or 32 bits per transfer, no loopback, MSB first, 1 transfer per sync
// pulse, no output sync
if ((fpga_mode & FPGA_MAJOR_MODE_MASK) == FPGA_MAJOR_MODE_HF_READER && FpgaGetCurrent() == FPGA_BITSTREAM_HF) {
AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(16) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);
} else {
if ((fpga_mode & FPGA_MAJOR_MODE_MASK) == FPGA_MAJOR_MODE_HF_READER && FpgaGetCurrent() == FPGA_BITSTREAM_HF) {
AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(16) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);
} else {
AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(8) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);
}
}
// TX clock comes from TK pin, no clock output, outputs change on rising edge of TK,
// TF (frame sync) is sampled on falling edge of TK, start TX on rising edge of TF
// TX clock comes from TK pin, no clock output, outputs change on rising edge of TK,
// TF (frame sync) is sampled on falling edge of TK, start TX on rising edge of TF
AT91C_BASE_SSC->SSC_TCMR = SSC_CLOCK_MODE_SELECT(2) | SSC_CLOCK_MODE_START(5);
// tx framing is the same as the rx framing
+3 -3
View File
@@ -52,7 +52,7 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
*len = (BigBuf_max_traceLen() & 0xFFFE);
uint8_t *mem = BigBuf_malloc(*len);
uint32_t trigger_cnt = 0;
uint32_t trigger_cnt = 0;
uint16_t r = 0, interval = 0;
bool pressed = false;
@@ -77,7 +77,7 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
// 180 (0xB4) arbitary value to see if a strong RF field is near.
if (r > 180) {
if (++trigger_cnt > triggersToSkip) {
break;
}
@@ -97,7 +97,7 @@ int HfSniff(uint32_t samplesToSkip, uint32_t triggersToSkip, uint16_t *len) {
}
}
optimizedSniff((uint16_t*)mem, *len);
optimizedSniff((uint16_t *)mem, *len);
if (DBGLEVEL >= DBG_INFO) {
Dbprintf("Trigger kicked in (%d >= 180)", r);
+13 -13
View File
@@ -1002,7 +1002,7 @@ void SniffHitag2(void) {
size_t periods = 0;
uint8_t periods_bytes[4];
// int16_t checked = 0;
// int16_t checked = 0;
/*bool waiting_for_first_edge = true;*/
LED_C_ON();
@@ -1015,18 +1015,18 @@ void SniffHitag2(void) {
WDT_HIT();
/*
// only every 1000th times, in order to save time when collecting samples.
if (checked == 1000) {
if (data_available()) {
checked = -1;
break;
} else {
checked = 0;
}
}
++checked;
*/
/*
// only every 1000th times, in order to save time when collecting samples.
if (checked == 1000) {
if (data_available()) {
checked = -1;
break;
} else {
checked = 0;
}
}
++checked;
*/
// Receive frame, watch for at most T0*EOF periods
+1 -1
View File
@@ -736,7 +736,7 @@ void SmartCardRaw(uint64_t arg0, uint64_t arg1, uint8_t *data) {
if ((flags & SC_LOG) == SC_LOG)
set_tracing(true);
else
else
set_tracing(false);
if ((flags & SC_CONNECT)) {
+139 -139
View File
File diff suppressed because it is too large Load Diff
+7 -7
View File
@@ -729,7 +729,7 @@ void RAMFUNC SniffIso14443a(uint8_t param) {
static void CodeIso14443aAsTagPar(const uint8_t *cmd, uint16_t len, uint8_t *par, bool collision) {
tosend_reset();
tosend_t *ts = get_tosend();
// Correction bit, might be removed when not needed
@@ -798,7 +798,7 @@ static void Code4bitAnswerAsTag(uint8_t cmd) {
uint8_t b = cmd;
tosend_reset();
tosend_t *ts = get_tosend();
// Correction bit, might be removed when not needed
@@ -888,7 +888,7 @@ bool prepare_tag_modulation(tag_response_info_t *response_info, size_t max_buffe
CodeIso14443aAsTag(response_info->response, response_info->response_n);
tosend_t *ts = get_tosend();
// Make sure we do not exceed the free buffer space
if (ts->max > max_buffer_size) {
Dbprintf("ToSend buffer, Out-of-bound, when modulating bits for tag answer:");
@@ -908,7 +908,7 @@ bool prepare_tag_modulation(tag_response_info_t *response_info, size_t max_buffe
bool prepare_allocated_tag_modulation(tag_response_info_t *response_info, uint8_t **buffer, size_t *max_buffer_size) {
tosend_t *ts = get_tosend();
// Retrieve and store the current buffer index
response_info->modulation = *buffer;
@@ -1977,7 +1977,7 @@ int EmSendCmd14443aRaw(uint8_t *resp, uint16_t respLen) {
int EmSend4bit(uint8_t resp) {
Code4bitAnswerAsTag(resp);
tosend_t *ts = get_tosend();
tosend_t *ts = get_tosend();
int res = EmSendCmd14443aRaw(ts->buf, ts->max);
// do the tracing for the previous reader request and this tag answer:
uint8_t par[1] = {0x00};
@@ -1999,7 +1999,7 @@ int EmSendCmdPar(uint8_t *resp, uint16_t respLen, uint8_t *par) {
}
int EmSendCmdParEx(uint8_t *resp, uint16_t respLen, uint8_t *par, bool collision) {
CodeIso14443aAsTagPar(resp, respLen, par, collision);
tosend_t *ts = get_tosend();
tosend_t *ts = get_tosend();
int res = EmSendCmd14443aRaw(ts->buf, ts->max);
// do the tracing for the previous reader request and this tag answer:
@@ -2162,7 +2162,7 @@ void ReaderTransmitBitsPar(uint8_t *frame, uint16_t bits, uint8_t *par, uint32_t
CodeIso14443aBitsAsReaderPar(frame, bits, par);
// Send command to tag
tosend_t *ts = get_tosend();
tosend_t *ts = get_tosend();
TransmitFor14443a(ts->buf, ts->max, timing);
if (g_trigger) LED_A_ON();
+37 -37
View File
@@ -187,12 +187,12 @@ static void CodeIso14443bAsTag(const uint8_t *cmd, int len) {
// Send EOF.
// 10-11 ETU * 4 sample rate = ZEROS
for(i = 0; i < 10; i++) {
for (i = 0; i < 10; i++) {
SEND4STUFFBIT(0);
}
// why this?
for(i = 0; i < 2; i++) {
for (i = 0; i < 2; i++) {
SEND4STUFFBIT(1);
}
@@ -448,7 +448,7 @@ static int GetIso14443bCommandFromReader(uint8_t *received, uint16_t *len) {
while (BUTTON_PRESS() == false) {
WDT_HIT();
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
uint8_t b = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
for (uint8_t mask = 0x80; mask != 0x00; mask >>= 1) {
if (Handle14443bReaderUartBit(b & mask)) {
@@ -501,11 +501,11 @@ void SimulateIso14443bTag(uint32_t pupi) {
// supports only 106kBit/s in both directions, max frame size = 32Bytes,
// supports ISO14443-4, FWI=8 (77ms), NAD supported, CID not supported:
uint8_t respATQB[] = {
0x50,
0x82, 0x0d, 0xe1, 0x74,
0x20, 0x38, 0x19,
0x22, 0x00, 0x21, 0x85,
0x5e, 0xd7
0x50,
0x82, 0x0d, 0xe1, 0x74,
0x20, 0x38, 0x19,
0x22, 0x00, 0x21, 0x85,
0x5e, 0xd7
};
// response to HLTB and ATTRIB
@@ -516,7 +516,7 @@ void SimulateIso14443bTag(uint32_t pupi) {
num_to_bytes(pupi, 4, respATQB + 1);
AddCrc14B(respATQB, 12);
}
// setup device.
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
@@ -537,7 +537,7 @@ void SimulateIso14443bTag(uint32_t pupi) {
int vHf = 0; // in mV
tosend_t *ts = get_tosend();
uint8_t *receivedCmd = BigBuf_malloc(MAX_FRAME_SIZE);
// prepare "ATQB" tag answer (encoded):
@@ -556,7 +556,7 @@ void SimulateIso14443bTag(uint32_t pupi) {
// Simulation loop
while (BUTTON_PRESS() == false) {
WDT_HIT();
//iceman: limit with 2000 times..
if (data_available()) {
break;
@@ -588,7 +588,7 @@ void SimulateIso14443bTag(uint32_t pupi) {
// WUP in HALTED state
if (len == 5) {
if ((receivedCmd[0] == ISO14443B_REQB && (receivedCmd[2] & 0x8) == 0x8 && cardSTATE == SIM_HALTED) ||
receivedCmd[0] == ISO14443B_REQB) {
receivedCmd[0] == ISO14443B_REQB) {
LogTrace(receivedCmd, len, 0, 0, NULL, true);
cardSTATE = SIM_SELECTING;
}
@@ -668,7 +668,7 @@ void SimulateIso14443bTag(uint32_t pupi) {
if (DBGLEVEL >= DBG_DEBUG)
Dbprintf("Emulator stopped. Trace length: %d ", BigBuf_get_traceLen());
switch_off(); //simulate
}
@@ -733,7 +733,7 @@ static RAMFUNC int Handle14443bTagSamplesDemod(uint16_t amplitude) {
Demod.posCount = 0; // start of SOF sequence
} else {
// maximum length of TR1 = 200 1/fs
if (Demod.posCount > 200 / 4){
if (Demod.posCount > 200 / 4) {
Demod.state = DEMOD_UNSYNCD;
}
}
@@ -851,9 +851,9 @@ static int GetTagSamplesFor14443bDemod(int timeout) {
// wait for last transfer to complete
while (!(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXEMPTY))
// Setup and start DMA.
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
// Setup and start DMA.
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
// The DMA buffer, used to stream samples from the FPGA
dmabuf16_t *dma = get_dma16();
if (FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE) == false) {
@@ -870,8 +870,8 @@ static int GetTagSamplesFor14443bDemod(int timeout) {
// uint32_t dma_start_time;
uint16_t *upTo = dma->buf;
for(;;) {
uint16_t behindBy = ((uint16_t*)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
for (;;) {
uint16_t behindBy = ((uint16_t *)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
if (behindBy == 0) continue;
@@ -884,7 +884,7 @@ static int GetTagSamplesFor14443bDemod(int timeout) {
*/
volatile uint16_t tagdata = *upTo++;
if (upTo >= dma->buf + DMA_BUFFER_SIZE) { // we have read all of the DMA buffer content.
upTo = dma->buf; // start reading the circular buffer from the beginning
if (behindBy > (9 * DMA_BUFFER_SIZE / 10)) {
@@ -893,7 +893,7 @@ static int GetTagSamplesFor14443bDemod(int timeout) {
break;
}
}
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_ENDRX)) { // DMA Counter Register had reached 0, already rotated.
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dma->buf; // refresh the DMA Next Buffer and
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE; // DMA Next Counter registers
@@ -904,7 +904,7 @@ static int GetTagSamplesFor14443bDemod(int timeout) {
break;
}
if(samples > timeout && Demod.state < DEMOD_PHASE_REF_TRAINING) {
if (samples > timeout && Demod.state < DEMOD_PHASE_REF_TRAINING) {
ret = -1;
LED_C_OFF();
break;
@@ -918,7 +918,7 @@ static int GetTagSamplesFor14443bDemod(int timeout) {
}
if (Demod.len > 0) {
LogTrace(Demod.output, Demod.len, 0, 0, NULL, false);
LogTrace(Demod.output, Demod.len, 0, 0, NULL, false);
}
return ret;
@@ -933,23 +933,23 @@ static void TransmitFor14443b_AsReader(void) {
LED_B_ON();
tosend_t *ts = get_tosend();
for (int c = 0; c < ts->max; c++) {
uint8_t data = ts->buf[c];
for (int i = 0; i < 8; i++) {
uint16_t send_word = (data & 0x80) ? 0x0000 : 0xffff;
while (!(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))) ;
AT91C_BASE_SSC->SSC_THR = send_word;
AT91C_BASE_SSC->SSC_THR = send_word;
while (!(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))) ;
AT91C_BASE_SSC->SSC_THR = send_word;
data <<= 1;
}
WDT_HIT();
WDT_HIT();
}
LED_B_OFF();
}
@@ -978,7 +978,7 @@ static void CodeIso14443bAsReader(const uint8_t *cmd, int len) {
// Send SOF
// 10-11 ETUs of ZERO
for (int i = 0; i < 10; i++)
for (int i = 0; i < 10; i++)
tosend_stuffbit(0);
@@ -1021,7 +1021,7 @@ static void CodeIso14443bAsReader(const uint8_t *cmd, int len) {
// 8ETUS minum?
// Per specification, Subcarrier must be stopped no later than 2 ETUs after EOF.
// I'm guessing this is for the FPGA to be able to send all bits before we switch to listening mode
// ensure that last byte is filled up
for (int i = 0; i < 8 ; ++i)
tosend_stuffbit(1);
@@ -1068,7 +1068,7 @@ uint8_t iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *r
if (ret < 3) {
LED_A_OFF();
return 0;
return 0;
}
// VALIDATE CRC
@@ -1081,7 +1081,7 @@ uint8_t iso14443b_apdu(uint8_t const *message, size_t message_length, uint8_t *r
memcpy(response, Demod.output, Demod.len);
return Demod.len;
LED_A_OFF();
LED_A_OFF();
}
/**
@@ -1322,7 +1322,7 @@ void ReadSTMemoryIso14443b(uint8_t numofblocks) {
if (i == 0xff) break;
++i;
}
// Todo: iceman: send back read data to client.
// reply_ng(..., );
@@ -1419,7 +1419,7 @@ void RAMFUNC SniffIso14443b(void) {
time_0 = GetCountSspClk();
// loop and listen
for(;;) {
for (;;) {
int behindBy = (lastRxCounter - AT91C_BASE_PDC_SSC->PDC_RCR) & (DMA_BUFFER_SIZE - 1);
if (behindBy > maxBehindBy) {
@@ -1437,7 +1437,7 @@ void RAMFUNC SniffIso14443b(void) {
if (upTo >= dma->buf + DMA_BUFFER_SIZE) { // we have read all of the DMA buffer content.
upTo = dma->buf; // start reading the circular buffer from the beginning again
lastRxCounter += DMA_BUFFER_SIZE;
if (behindBy > (9 * DMA_BUFFER_SIZE / 10)) {
if (behindBy > (9 * DMA_BUFFER_SIZE / 10)) {
Dbprintf("About to blow circular buffer - aborted! behindBy=%d", behindBy);
break;
}
@@ -1462,7 +1462,7 @@ void RAMFUNC SniffIso14443b(void) {
LED_A_INV();
if (Handle14443bReaderUartBit(ci & 0x01)) {
time_stop = GetCountSspClk() - time_0;
LogTrace(Uart.output, Uart.byteCnt, time_start, time_stop, NULL, true);
Uart14bReset();
+81 -81
View File
@@ -66,7 +66,7 @@
#include "ticks.h"
#include "BigBuf.h"
#include "crc16.h"
// Delays in SSP_CLK ticks.
// SSP_CLK runs at 13,56MHz / 32 = 423.75kHz when simulating a tag
#define DELAY_READER_TO_ARM 8
@@ -106,7 +106,7 @@
static void BuildIdentifyRequest(uint8_t *cmd);
// ---------------------------
// ---------------------------
// Signal Processing
// ---------------------------
@@ -114,12 +114,12 @@ static void BuildIdentifyRequest(uint8_t *cmd);
// prepare data using "1 out of 4" code for later transmission
// resulting data rate is 26.48 kbit/s (fc/512)
// cmd ... data
// n ... length of data
static uint8_t encode15_lut[] = {
0x40, // 01000000
0x10, // 00010000
0x04, // 00000100
0x01 // 00000001
// n ... length of data
static uint8_t encode15_lut[] = {
0x40, // 01000000
0x10, // 00010000
0x04, // 00000100
0x01 // 00000001
};
void CodeIso15693AsReader(uint8_t *cmd, int n) {
@@ -132,16 +132,16 @@ void CodeIso15693AsReader(uint8_t *cmd, int n) {
// data
for (int i = 0; i < n; i++) {
volatile uint8_t b = (cmd[i] >> 0) & 0x03;
ts->buf[++ts->max] = encode15_lut[b];
b = (cmd[i] >> 2) & 0x03;
ts->buf[++ts->max] = encode15_lut[b];
b = (cmd[i] >> 4) & 0x03;
ts->buf[++ts->max] = encode15_lut[b];
b = (cmd[i] >> 6) & 0x03;
ts->buf[++ts->max] = encode15_lut[b];
}
@@ -167,12 +167,12 @@ static void CodeIso15693AsReader256(uint8_t *cmd, int n) {
tosend_reset();
tosend_t *ts = get_tosend();
// SOF for 1of256
ts->buf[++ts->max] = 0x81; //10000001
// data
for(int i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
for (int j = 0; j <= 255; j++) {
if (cmd[i] == j) {
tosend_stuffbit(0);
@@ -189,7 +189,7 @@ static void CodeIso15693AsReader256(uint8_t *cmd, int n) {
ts->max++;
}
static const uint8_t encode_4bits[16] = {
static const uint8_t encode_4bits[16] = {
// 0 1 2 3
0xaa, 0x6a, 0x9a, 0x5a,
// 4 5 6 7
@@ -292,7 +292,7 @@ void TransmitTo15693Reader(const uint8_t *cmd, size_t len, uint32_t *start_time,
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR | FPGA_HF_SIMULATOR_MODULATE_424K);
uint32_t modulation_start_time = *start_time - DELAY_ARM_TO_READER + 3 * 8; // no need to transfer the unmodulated start of SOF
while (GetCountSspClk() > (modulation_start_time & 0xfffffff8) + 3) { // we will miss the intended time
if (slot_time) {
modulation_start_time += slot_time; // use next available slot
@@ -310,14 +310,14 @@ void TransmitTo15693Reader(const uint8_t *cmd, size_t len, uint32_t *start_time,
LED_C_ON();
uint8_t bits_to_shift = 0x00;
uint8_t bits_to_send = 0x00;
uint8_t bits_to_send = 0x00;
for (size_t c = 0; c < len; c++) {
for (int i = (c == 0 ? 4 : 7); i >= 0; i--) {
uint8_t cmd_bits = ((cmd[c] >> i) & 0x01) ? 0xff : 0x00;
for (int j = 0; j < (slow ? 4 : 1); ) {
for (int j = 0; j < (slow ? 4 : 1);) {
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
bits_to_send = bits_to_shift << (8 - shift_delay) | cmd_bits >> shift_delay;
AT91C_BASE_SSC->SSC_THR = bits_to_send;
@@ -332,7 +332,7 @@ void TransmitTo15693Reader(const uint8_t *cmd, size_t len, uint32_t *start_time,
// send the remaining bits, padded with 0:
bits_to_send = bits_to_shift << (8 - shift_delay);
if (bits_to_send) {
for ( ; ; ) {
for (; ;) {
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
AT91C_BASE_SSC->SSC_THR = bits_to_send;
break;
@@ -631,7 +631,7 @@ static void DecodeTagInit(DecodeTag_t *tag, uint8_t *data, uint16_t max_len) {
/*
* Receive and decode the tag response, also log to tracebuffer
*/
int GetIso15693AnswerFromTag(uint8_t* response, uint16_t max_len, uint16_t timeout, uint32_t *eof_time) {
int GetIso15693AnswerFromTag(uint8_t *response, uint16_t max_len, uint16_t timeout, uint32_t *eof_time) {
int samples = 0, ret = 0;
@@ -661,10 +661,10 @@ int GetIso15693AnswerFromTag(uint8_t* response, uint16_t max_len, uint16_t timeo
uint32_t dma_start_time = 0;
uint16_t *upTo = dma->buf;
for(;;) {
for (;;) {
volatile uint16_t behindBy = ((uint16_t*)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
if (behindBy == 0)
volatile uint16_t behindBy = ((uint16_t *)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
if (behindBy == 0)
continue;
samples++;
@@ -715,14 +715,14 @@ int GetIso15693AnswerFromTag(uint8_t* response, uint16_t max_len, uint16_t timeo
if (DBGLEVEL >= DBG_EXTENDED) {
Dbprintf("samples = %d, ret = %d, Decoder: state = %d, lastBit = %d, len = %d, bitCount = %d, posCount = %d, maxlen = %u",
samples,
ret,
dt->state,
dt->lastBit,
dt->len,
dt->bitCount,
dt->posCount,
dt->max_len
samples,
ret,
dt->state,
dt->lastBit,
dt->len,
dt->bitCount,
dt->posCount,
dt->max_len
);
Dbprintf("timing: sof_time = %d, eof_time = %d", (sof_time * 4), (*eof_time * 4));
}
@@ -776,7 +776,7 @@ typedef struct {
uint8_t *jam_search_string;
} DecodeReader_t;
static void DecodeReaderInit(DecodeReader_t* reader, uint8_t *data, uint16_t max_len, uint8_t jam_search_len, uint8_t *jam_search_string) {
static void DecodeReaderInit(DecodeReader_t *reader, uint8_t *data, uint16_t max_len, uint8_t jam_search_len, uint8_t *jam_search_string) {
reader->output = data;
reader->byteCountMax = max_len;
reader->state = STATE_READER_UNSYNCD;
@@ -788,12 +788,12 @@ static void DecodeReaderInit(DecodeReader_t* reader, uint8_t *data, uint16_t max
reader->jam_search_string = jam_search_string;
}
static void DecodeReaderReset(DecodeReader_t* reader) {
static void DecodeReaderReset(DecodeReader_t *reader) {
reader->state = STATE_READER_UNSYNCD;
}
//static inline __attribute__((always_inline))
static int RAMFUNC Handle15693SampleFromReader(bool bit, DecodeReader_t *reader) {
static int RAMFUNC Handle15693SampleFromReader(bool bit, DecodeReader_t *reader) {
switch (reader->state) {
case STATE_READER_UNSYNCD:
// wait for unmodulated carrier
@@ -832,7 +832,7 @@ static void DecodeReaderReset(DecodeReader_t* reader) {
reader->posCount++;
if (bit == false) { // detected a falling edge
if (reader->posCount < 20) { // falling edge too early (nominally expected at 21 earliest)
DecodeReaderReset(reader);
} else if (reader->posCount < 23) { // SOF for 1 out of 4 coding
@@ -911,7 +911,7 @@ static void DecodeReaderReset(DecodeReader_t* reader) {
// do nothing, keep waiting
}
} else { // unexpected falling edge
DecodeReaderReset(reader);
DecodeReaderReset(reader);
}
break;
@@ -924,14 +924,14 @@ static void DecodeReaderReset(DecodeReader_t* reader) {
reader->sum1 = bit ? 1 : 0;
} else if (reader->posCount <= 4) {
if (bit)
reader->sum1++;
} else if (reader->posCount == 5) {
reader->sum2 = bit ? 1 : 0;
} else {
if (bit)
reader->sum2++;
@@ -1098,9 +1098,9 @@ int GetIso15693CommandFromReader(uint8_t *received, size_t max_len, uint32_t *eo
uint32_t dma_start_time = GetCountSspClk() & 0xfffffff8;
for (;;) {
volatile uint16_t behindBy = ((uint8_t*)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
volatile uint16_t behindBy = ((uint8_t *)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
if (behindBy == 0) continue;
if (samples == 0) {
// DMA has transferred the very first data
dma_start_time = GetCountSspClk() & 0xfffffff0;
@@ -1144,15 +1144,15 @@ int GetIso15693CommandFromReader(uint8_t *received, size_t max_len, uint32_t *eo
if (DBGLEVEL >= DBG_EXTENDED) {
Dbprintf("samples = %d, gotFrame = %d, Decoder: state = %d, len = %d, bitCount = %d, posCount = %d",
samples, gotFrame, dr->state, dr->byteCount,
dr->bitCount, dr->posCount);
samples, gotFrame, dr->state, dr->byteCount,
dr->bitCount, dr->posCount);
}
if (dr->byteCount >= 0) {
uint32_t sof_time = *eof_time
- dr->byteCount * (dr->Coding == CODING_1_OUT_OF_4 ? 128 : 2048) // time for byte transfers
- 32 // time for SOF transfer
- 16; // time for EOF transfer
- dr->byteCount * (dr->Coding == CODING_1_OUT_OF_4 ? 128 : 2048) // time for byte transfers
- 32 // time for SOF transfer
- 16; // time for EOF transfer
LogTrace_ISO15693(dr->output, dr->byteCount, (sof_time * 32), (*eof_time * 32), NULL, true);
}
@@ -1192,8 +1192,8 @@ void AcquireRawAdcSamplesIso15693(void) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_SUBCARRIER_424_KHZ | FPGA_HF_READER_MODE_RECEIVE_AMPLITUDE);
for(int c = 0; c < 4000; ) {
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
for (int c = 0; c < 4000;) {
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
uint16_t r = AT91C_BASE_SSC->SSC_RHR;
dest[c++] = r >> 5;
}
@@ -1212,7 +1212,7 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
BigBuf_free();
clear_trace();
set_tracing(true);
DecodeTag_t dtag = {0};
uint8_t response[ISO15693_MAX_RESPONSE_LENGTH] = {0};
DecodeTagInit(&dtag, response, sizeof(response));
@@ -1228,7 +1228,7 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_SNIFF_AMPLITUDE);
LED_D_OFF();
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
StartCountSspClk();
@@ -1247,12 +1247,12 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
// Count of samples received so far, so that we can include timing
int samples = 0;
uint16_t *upTo = dma->buf;
for (;;) {
volatile int behind_by = ((uint16_t*)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
volatile int behind_by = ((uint16_t *)AT91C_BASE_PDC_SSC->PDC_RPR - upTo) & (DMA_BUFFER_SIZE - 1);
if (behind_by < 1) continue;
samples++;
@@ -1264,10 +1264,10 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
volatile uint16_t sniffdata = *upTo++;
// we have read all of the DMA buffer content
if (upTo >= dma->buf + DMA_BUFFER_SIZE) {
if (upTo >= dma->buf + DMA_BUFFER_SIZE) {
// start reading the circular buffer from the beginning
upTo = dma->buf;
upTo = dma->buf;
// DMA Counter Register had reached 0, already rotated.
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_ENDRX)) {
@@ -1282,7 +1282,7 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dma->buf;
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
}
WDT_HIT();
if (BUTTON_PRESS()) {
DbpString("Sniff stopped");
@@ -1299,9 +1299,9 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
uint32_t eof_time = dma_start_time + (samples * 16) + 8 - DELAY_READER_TO_ARM_SNIFF; // end of EOF
if (dreader.byteCount > 0) {
uint32_t sof_time = eof_time
- dreader.byteCount * (dreader.Coding == CODING_1_OUT_OF_4 ? 128 * 16 : 2048 * 16) // time for byte transfers
- 32 * 16 // time for SOF transfer
- 16 * 16; // time for EOF transfer
- dreader.byteCount * (dreader.Coding == CODING_1_OUT_OF_4 ? 128 * 16 : 2048 * 16) // time for byte transfers
- 32 * 16 // time for SOF transfer
- 16 * 16; // time for EOF transfer
LogTrace_ISO15693(dreader.output, dreader.byteCount, (sof_time * 4), (eof_time * 4), NULL, true);
}
// And ready to receive another command.
@@ -1315,9 +1315,9 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
uint32_t eof_time = dma_start_time + (samples * 16) + 16 - DELAY_READER_TO_ARM_SNIFF; // end of EOF
if (dreader.byteCount > 0) {
uint32_t sof_time = eof_time
- dreader.byteCount * (dreader.Coding == CODING_1_OUT_OF_4 ? 128 * 16 : 2048 * 16) // time for byte transfers
- 32 * 16 // time for SOF transfer
- 16 * 16; // time for EOF transfer
- dreader.byteCount * (dreader.Coding == CODING_1_OUT_OF_4 ? 128 * 16 : 2048 * 16) // time for byte transfers
- 32 * 16 // time for SOF transfer
- 16 * 16; // time for EOF transfer
LogTrace_ISO15693(dreader.output, dreader.byteCount, (sof_time * 4), (eof_time * 4), NULL, true);
}
// And ready to receive another command
@@ -1370,14 +1370,14 @@ void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string) {
Dbprintf(" DecodeReader byteCnt...%d", dreader.byteCount);
Dbprintf(" DecodeReader posCount..%d", dreader.posCount);
Dbprintf(" Trace length..........." _YELLOW_("%d"), BigBuf_get_traceLen());
DbpString("");
DbpString("");
}
// Initialize Proxmark3 as ISO15693 reader
void Iso15693InitReader(void) {
LEDsoff();
LEDsoff();
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
// Start from off (no field generated)
@@ -1387,7 +1387,7 @@ void Iso15693InitReader(void) {
// switch field on
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER);
LED_D_ON();
// initialize SSC and select proper AD input
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
@@ -1427,7 +1427,7 @@ static void BuildIdentifyRequest(uint8_t *cmd) {
// If you do not need the answer use NULL for *recv[]
// return: length of received data
// logging enabled
int SendDataTag(uint8_t *send, int sendlen, bool init, bool speed_fast, uint8_t *recv,
int SendDataTag(uint8_t *send, int sendlen, bool init, bool speed_fast, uint8_t *recv,
uint16_t max_recv_len, uint32_t start_time, uint16_t timeout, uint32_t *eof_time) {
if (init) {
@@ -1599,7 +1599,7 @@ void ReaderIso15693(uint32_t parameter) {
// When SIM: initialize the Proxmark3 as ISO15693 tag
void Iso15693InitTag(void) {
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
// Start from off (no field generated)
@@ -1658,10 +1658,10 @@ void SimTagIso15693(uint8_t *uid) {
tosend_t *ts = get_tosend();
enum { NO_FIELD, IDLE, ACTIVATED, SELECTED, HALTED } chip_state = NO_FIELD;
bool button_pressed = false;
int vHf = 0; // in mV
int vHf = 0; // in mV
bool exit_loop = false;
while (exit_loop == false) {
WDT_HIT();
@@ -1678,7 +1678,7 @@ void SimTagIso15693(uint8_t *uid) {
chip_state = IDLE;
LED_A_ON();
} else {
continue;
continue;
}
}
@@ -1699,7 +1699,7 @@ void SimTagIso15693(uint8_t *uid) {
uint32_t response_time = reader_eof_time + DELAY_ISO15693_VCD_TO_VICC_SIM;
TransmitTo15693Reader(ts->buf, ts->max, &response_time, 0, slow);
LogTrace_ISO15693(resp_inv, CMD_INV_RESP, response_time * 32, (response_time * 32) + (ts->max * 32 * 64), NULL, false);
chip_state = SELECTED;
}
}
@@ -1715,7 +1715,7 @@ void SimTagIso15693(uint8_t *uid) {
void BruteforceIso15693Afi(uint32_t speed) {
uint8_t data[7] = {0};
uint8_t recv[ISO15693_MAX_RESPONSE_LENGTH];
uint8_t recv[ISO15693_MAX_RESPONSE_LENGTH];
Iso15693InitReader();
// first without AFI
@@ -1726,7 +1726,7 @@ void BruteforceIso15693Afi(uint32_t speed) {
data[2] = 0; // AFI
AddCrc15(data, 3);
int datalen = 5;
int datalen = 5;
uint32_t eof_time = 0;
uint32_t start_time = GetCountSspClk();
int recvlen = SendDataTag(data, datalen, true, speed, recv, sizeof(recv), 0, ISO15693_READER_TIMEOUT, &eof_time);
@@ -1754,7 +1754,7 @@ void BruteforceIso15693Afi(uint32_t speed) {
recvlen = SendDataTag(data, datalen, false, speed, recv, sizeof(recv), start_time, ISO15693_READER_TIMEOUT, &eof_time);
start_time = eof_time + DELAY_ISO15693_VICC_TO_VCD_READER;
WDT_HIT();
if (recvlen >= 12) {
@@ -1790,7 +1790,7 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
uint32_t eof_time;
uint16_t timeout;
bool request_answer = false;
switch (data[1]) {
case ISO15_CMD_WRITE:
case ISO15_CMD_LOCK:
@@ -1804,7 +1804,7 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
break;
default:
timeout = ISO15693_READER_TIMEOUT;
}
}
if (DBGLEVEL >= DBG_EXTENDED) {
Dbprintf("SEND:");
@@ -1814,10 +1814,10 @@ void DirectTag15693Command(uint32_t datalen, uint32_t speed, uint32_t recv, uint
recvlen = SendDataTag(data, datalen, true, speed, (recv ? recvbuf : NULL), sizeof(recvbuf), 0, timeout, &eof_time);
// send a single EOF to get the tag response
if (request_answer) {
if (request_answer) {
recvlen = SendDataTagEOF((recv ? recvbuf : NULL), sizeof(recvbuf), 0, ISO15693_READER_TIMEOUT, &eof_time);
}
// for the time being, switch field off to protect rdv4.0
// note: this prevents using hf 15 cmd with s option - which isn't implemented yet anyway
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
@@ -1882,9 +1882,9 @@ void SetTag15693Uid(uint8_t *uid) {
AddCrc15(cmd[3], 7);
uint32_t start_time = 0;
for (int i = 0; i < 4; i++) {
recvlen = SendDataTag(cmd[i], sizeof(cmd[i]), i == 0 ? true : false, true, recvbuf, sizeof(recvbuf), start_time, ISO15693_READER_TIMEOUT_WRITE, &eof_time);
start_time = eof_time + DELAY_ISO15693_VICC_TO_VCD_READER;
+5 -5
View File
@@ -13,7 +13,7 @@
#include "common.h"
#include "pm3_cmd.h" // struct
// Delays in SSP_CLK ticks.
// SSP_CLK runs at 13,56MHz / 32 = 423.75kHz when simulating a tag
@@ -27,11 +27,11 @@ void Iso15693InitReader(void);
void Iso15693InitTag(void);
void CodeIso15693AsReader(uint8_t *cmd, int n);
void CodeIso15693AsTag(uint8_t *cmd, size_t len);
void TransmitTo15693Reader(const uint8_t *cmd, size_t len, uint32_t *start_time, uint32_t slot_time, bool slow);
int GetIso15693CommandFromReader(uint8_t *received, size_t max_len, uint32_t *eof_time);
void TransmitTo15693Tag(const uint8_t *cmd, int len, uint32_t *start_time);
int GetIso15693AnswerFromTag(uint8_t* response, uint16_t max_len, uint16_t timeout, uint32_t *eof_time);
int GetIso15693AnswerFromTag(uint8_t *response, uint16_t max_len, uint16_t timeout, uint32_t *eof_time);
//void RecordRawAdcSamplesIso15693(void);
void AcquireRawAdcSamplesIso15693(void);
@@ -43,9 +43,9 @@ void Iso15693InitReader(void);
void SniffIso15693(uint8_t jam_search_len, uint8_t *jam_search_string);
int SendDataTag(uint8_t *send, int sendlen, bool init, bool speed_fast, uint8_t *recv,
int SendDataTag(uint8_t *send, int sendlen, bool init, bool speed_fast, uint8_t *recv,
uint16_t max_recv_len, uint32_t start_time, uint16_t timeout, uint32_t *eof_time);
int SendDataTagEOF(uint8_t *recv, uint16_t max_recv_len, uint32_t start_time, uint16_t timeout, uint32_t *eof_time);
void SetTag15693Uid(uint8_t *uid);
+26 -26
View File
@@ -148,7 +148,7 @@ bool lf_get_reader_modulation(void) {
}
void lf_wait_periods(size_t periods) {
// wait detect gap
// wait detect gap
lf_count_edge_periods_ex(periods, true, false);
}
@@ -238,40 +238,40 @@ void lf_finalize(void) {
}
size_t lf_detect_field_drop(size_t max) {
/*
size_t periods = 0;
// int16_t checked = 0;
/*
size_t periods = 0;
// int16_t checked = 0;
while (BUTTON_PRESS() == false) {
while (BUTTON_PRESS() == false) {
// // only every 1000th times, in order to save time when collecting samples.
// if (checked == 4000) {
// if (data_available()) {
// checked = -1;
// break;
// } else {
// checked = 0;
// // only every 1000th times, in order to save time when collecting samples.
// if (checked == 4000) {
// if (data_available()) {
// checked = -1;
// break;
// } else {
// checked = 0;
// }
// }
// }
// ++checked;
// ++checked;
WDT_HIT();
WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
periods++;
volatile uint8_t adc_val = AT91C_BASE_SSC->SSC_RHR;
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
periods++;
volatile uint8_t adc_val = AT91C_BASE_SSC->SSC_RHR;
if (g_logging) logSampleSimple(adc_val);
if (g_logging) logSampleSimple(adc_val);
if (adc_val == 0) {
rising_edge = false;
return periods;
if (adc_val == 0) {
rising_edge = false;
return periods;
}
if (periods == max) return 0;
}
if (periods == max) return 0;
}
}
*/
*/
return 0;
}
+10 -10
View File
@@ -1245,7 +1245,7 @@ int lf_hid_watch(int findone, uint32_t *high, uint32_t *low) {
while (BUTTON_PRESS() == false) {
WDT_HIT();
// cancel w usb command.
if (interval == 4000) {
if (data_available()) {
@@ -1262,7 +1262,7 @@ int lf_hid_watch(int findone, uint32_t *high, uint32_t *low) {
// FSK demodulator
// 50 * 128 * 2 - big enough to catch 2 sequences of largest format
size = MIN(12800, BigBuf_max_traceLen());
int idx = HIDdemodFSK(dest, &size, &hi2, &hi, &lo, &dummyIdx);
if (idx < 0) continue;
@@ -1354,7 +1354,7 @@ int lf_awid_watch(int findone, uint32_t *high, uint32_t *low) {
while (BUTTON_PRESS() == false) {
WDT_HIT();
// cancel w usb command.
if (interval == 4000) {
if (data_available()) {
@@ -1535,7 +1535,7 @@ int lf_io_watch(int findone, uint32_t *high, uint32_t *low) {
while (BUTTON_PRESS() == false) {
WDT_HIT();
// cancel w usb command.
if (interval == 4000) {
if (data_available()) {
@@ -2601,12 +2601,12 @@ void Cotag(uint32_t arg0) {
BigBuf_Clear_ext(false);
//send COTAG start pulse
/*
ON(740) OFF(2035)
ON(3330) OFF(2035)
ON(740) OFF(2035)
ON(1000)
*/
/*
ON(740) OFF(2035)
ON(3330) OFF(2035)
ON(740) OFF(2035)
ON(1000)
*/
ON(800) OFF(2200)
ON(3600) OFF(2200)
+11 -11
View File
@@ -171,7 +171,7 @@ void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool
// keep track of total gather samples regardless how many was discarded.
if (samples.counter-- == 0) return;
if (bits_per_sample == 0) bits_per_sample = 1;
if (bits_per_sample == 0) bits_per_sample = 1;
if (bits_per_sample > 8) bits_per_sample = 8;
if (decimation == 0) decimation = 1;
@@ -323,7 +323,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, in
if (samples.total_saved >= sample_size) break;
}
}
if (checked == -1 && verbose) {
Dbprintf("lf sampling aborted");
}
@@ -414,14 +414,14 @@ void doT55x7Acquisition(size_t sample_size) {
bool lowFound = false;
uint16_t checker = 0;
if (DBGLEVEL >= DBG_DEBUG) {
Dbprintf("doT55x7Acquisition - after init");
print_stack_usage();
}
while (skipCnt < 1000 && (i < bufsize)) {
if (BUTTON_PRESS())
break;
@@ -493,17 +493,17 @@ void doCotagAcquisition() {
dest[0] = 0;
uint8_t firsthigh = 0, firstlow = 0;
uint16_t i = 0, noise_counter = 0;
if (DBGLEVEL >= DBG_DEBUG) {
Dbprintf("doCotagAcquisition - after init");
print_stack_usage();
}
while ((i < bufsize) && (noise_counter < (COTAG_T1 << 1))) {
if (BUTTON_PRESS())
break;
WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
@@ -557,15 +557,15 @@ uint32_t doCotagAcquisitionManchester(void) {
uint8_t curr = 0, prev = 0;
uint16_t sample_counter = 0, period = 0;
uint16_t noise_counter = 0;
if (DBGLEVEL >= DBG_DEBUG) {
Dbprintf("doCotagAcquisitionManchester - after init");
print_stack_usage();
}
while ((sample_counter < bufsize) && (noise_counter < (COTAG_T1 << 1))) {
if (BUTTON_PRESS())
if (BUTTON_PRESS())
break;
WDT_HIT();
+15 -15
View File
@@ -483,9 +483,9 @@ int rdv40_spiffs_read_as_symlink(char *filename, uint8_t *dst, uint32_t size, RD
if (DBGLEVEL > 1) Dbprintf("Symlink destination is : " _YELLOW_("%s"), linkdest);
read_from_spiffs((char *)linkdest, (uint8_t *)dst, size);
)
}
read_from_spiffs((char *)linkdest, (uint8_t *)dst, size);
)
}
// BEWARE ! This function is DESTRUCTIVE as it will UPDATE an existing symlink
// Since it creates a .lnk extension file it may be minor to mistake the order of arguments
@@ -516,18 +516,18 @@ int rdv40_spiffs_make_symlink(char *linkdest, char *filename, RDV40SpiFFSSafetyL
int rdv40_spiffs_read_as_filetype(char *filename, uint8_t *dst, uint32_t size, RDV40SpiFFSSafetyLevel level) {
RDV40_SPIFFS_SAFE_FUNCTION(
RDV40SpiFFSFileType filetype = filetype_in_spiffs((char *)filename);
switch (filetype) {
case RDV40_SPIFFS_FILETYPE_REAL:
rdv40_spiffs_read((char *)filename, (uint8_t *)dst, size, level);
break;
case RDV40_SPIFFS_FILETYPE_SYMLINK:
rdv40_spiffs_read_as_symlink((char *)filename, (uint8_t *)dst, size, level);
break;
case RDV40_SPIFFS_FILETYPE_BOTH:
case RDV40_SPIFFS_FILETYPE_UNKNOWN:
default:
switch (filetype) {
case RDV40_SPIFFS_FILETYPE_REAL:
rdv40_spiffs_read((char *)filename, (uint8_t *)dst, size, level);
break;
case RDV40_SPIFFS_FILETYPE_SYMLINK:
rdv40_spiffs_read_as_symlink((char *)filename, (uint8_t *)dst, size, level);
break;
case RDV40_SPIFFS_FILETYPE_BOTH:
case RDV40_SPIFFS_FILETYPE_UNKNOWN:
default:
;
}
}
)
}
@@ -617,7 +617,7 @@ void rdv40_spiffs_safe_wipe(void) {
while ((pe = SPIFFS_readdir(&d, pe))) {
if (rdv40_spiffs_is_symlink((const char *)pe->name)) {
char linkdest[SPIFFS_OBJ_NAME_LEN];
read_from_spiffs((char *)pe->name, (uint8_t *)linkdest, SPIFFS_OBJ_NAME_LEN);

Some files were not shown because too many files have changed in this diff Show More