adjusting check button timings

This commit is contained in:
iceman1001 2019-10-04 10:24:04 +02:00
commit ebb2ac6f66
3 changed files with 24 additions and 25 deletions

View file

@ -906,11 +906,11 @@ void RAMFUNC SniffIClass(void) {
for (;;) {
WDT_HIT();
if (checked == 2000) {
if (checked == 1000) {
if (BUTTON_PRESS() || data_available()) break;
checked = 0;
}
checked++;
++checked;
previous_data <<= 8;
previous_data |= *data;
@ -1014,11 +1014,11 @@ static bool GetIClassCommandFromReader(uint8_t *received, int *len, int maxLen)
WDT_HIT();
if (checked == 2000) {
if (checked == 1000) {
if (BUTTON_PRESS() || data_available()) return false;
checked = 0;
}
checked++;
++checked;
// keep tx buffer in a defined state anyway.
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))
@ -1666,11 +1666,11 @@ static int SendIClassAnswer(uint8_t *resp, int respLen, uint16_t delay) {
uint16_t checked = 0;
for (;;) {
if (checked == 2000) {
if (checked == 1000) {
if (BUTTON_PRESS() || data_available()) return 0;
checked = 0;
}
checked++;
++checked;
// Prevent rx holding register from overflowing
if ((AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY)) {
@ -1828,11 +1828,11 @@ static int GetIClassAnswer(uint8_t *receivedResponse, int maxLen, int *wait) {
for (;;) {
WDT_HIT();
if (checked == 2000) {
if (checked == 1000) {
if (BUTTON_PRESS() || data_available()) return false;
checked = 0;
}
checked++;
++checked;
// Wait for byte be become available in rx holding register
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
@ -2123,11 +2123,11 @@ void ReaderIClass(uint8_t arg0) {
}
LED_B_OFF();
if (checked == 2000) {
if (checked == 1000) {
userCancelled = BUTTON_PRESS() || data_available();
checked = 0;
}
checked++;
++checked;
}
if (userCancelled) {
@ -2326,11 +2326,11 @@ void iClass_Authentication_fast(uint64_t arg0, uint64_t arg1, uint8_t *datain) {
uint8_t startup_limit = 10;
while (read_status != 2) {
if (checked == 2000) {
if (checked == 1000) {
if (BUTTON_PRESS() || !data_available()) goto out;
checked = 0;
}
checked++;
++checked;
read_status = handshakeIclassTag_ext(card_data, use_credit_key);
if (startup_limit-- == 0) {
@ -2347,11 +2347,11 @@ void iClass_Authentication_fast(uint64_t arg0, uint64_t arg1, uint8_t *datain) {
for (i = 0; i < keyCount; i++) {
// Allow button press / usb cmd to interrupt device
if (checked == 2000) {
if (checked == 1000) {
if (BUTTON_PRESS() || !data_available()) goto out;
checked = 0;
}
checked++;
++checked;
WDT_HIT();
LED_B_ON();

View file

@ -2818,7 +2818,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
WDT_HIT();
// Test if the action was cancelled
if (checkbtn_cnt == 2000) {
if (checkbtn_cnt == 1000) {
if (BUTTON_PRESS() || data_available()) {
isOK = -1;
return_status = PM3_EOPABORTED;
@ -2832,7 +2832,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
if (!have_uid) { // need a full select cycle to get the uid first
iso14a_card_select_t card_info;
if (!iso14443a_select_card(uid, &card_info, &cuid, true, 0, true)) {
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Mifare: Can't select card (ALL)");
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (ALL)");
continue;
}
switch (card_info.uidlen) {
@ -2851,7 +2851,7 @@ void ReaderMifare(bool first_try, uint8_t block, uint8_t keytype) {
have_uid = true;
} else { // no need for anticollision. We can directly select the card
if (!iso14443a_fast_select_card(uid, cascade_levels)) {
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Mifare: Can't select card (UID)");
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (UID)");
continue;
}
}
@ -3092,7 +3092,7 @@ void DetectNACKbug(void) {
WDT_HIT();
// Test if the action was cancelled
if (checkbtn_cnt == 2000) {
if (checkbtn_cnt == 1000) {
if (BUTTON_PRESS() || data_available()) {
status = PM3_EOPABORTED;
break;
@ -3105,7 +3105,7 @@ void DetectNACKbug(void) {
if (!have_uid) { // need a full select cycle to get the uid first
iso14a_card_select_t card_info;
if (!iso14443a_select_card(uid, &card_info, &cuid, true, 0, true)) {
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Mifare: Can't select card (ALL)");
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (ALL)");
i = 0;
continue;
}
@ -3127,7 +3127,7 @@ void DetectNACKbug(void) {
have_uid = true;
} else { // no need for anticollision. We can directly select the card
if (!iso14443a_fast_select_card(uid, cascade_levels)) {
if (DBGLEVEL >= DBG_ERROR) Dbprintf("Mifare: Can't select card (UID)");
if (DBGLEVEL >= DBG_INFO) Dbprintf("Mifare: Can't select card (UID)");
i = 0;
have_uid = false;
continue;

View file

@ -149,17 +149,16 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
uint32_t sample_total_saved = 0;
uint32_t cancel_counter = 0;
uint16_t checker = 0;
uint16_t checked = 0;
while (true) {
if (checker == 2000) {
if (checked == 1000) {
if (BUTTON_PRESS() || data_available())
break;
else
checker = 0;
} else {
++checker;
checked = 0;
}
++checked;
WDT_HIT();