mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 21:03:48 -07:00
syntax sugar
This commit is contained in:
parent
82dbfba827
commit
05b62d0b3d
1 changed files with 14 additions and 13 deletions
|
@ -3410,8 +3410,8 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
||||||
|
|
||||||
// Setup and start DMA.
|
// Setup and start DMA.
|
||||||
// set transfer address and number of bytes. Start transfer.
|
// set transfer address and number of bytes. Start transfer.
|
||||||
if ( !FpgaSetupSscDma((uint8_t*) dmaBuf, DMA_BUFFER_SIZE) ){
|
if ( !FpgaSetupSscDma(dmaBuf, DMA_BUFFER_SIZE) ){
|
||||||
if (MF_DBGLEVEL > 1) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
if (MF_DBGLEVEL > 1) Dbprintf("[-] FpgaSetupSscDma failed. Exiting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3427,6 +3427,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
|
||||||
if ((sniffCounter & 0x0000FFFF) == 0) { // from time to time
|
if ((sniffCounter & 0x0000FFFF) == 0) { // from time to time
|
||||||
|
|
||||||
// check if a transaction is completed (timeout after 2000ms).
|
// check if a transaction is completed (timeout after 2000ms).
|
||||||
// if yes, stop the DMA transfer and send what we have so far to the client
|
// if yes, stop the DMA transfer and send what we have so far to the client
|
||||||
if (MfSniffSend(2000)) {
|
if (MfSniffSend(2000)) {
|
||||||
|
@ -3438,7 +3439,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
||||||
TagIsActive = false;
|
TagIsActive = false;
|
||||||
// Setup and start DMA. set transfer address and number of bytes. Start transfer.
|
// Setup and start DMA. set transfer address and number of bytes. Start transfer.
|
||||||
if ( !FpgaSetupSscDma(dmaBuf, DMA_BUFFER_SIZE) ){
|
if ( !FpgaSetupSscDma(dmaBuf, DMA_BUFFER_SIZE) ){
|
||||||
if (MF_DBGLEVEL > 1) Dbprintf("FpgaSetupSscDma failed. Exiting");
|
if (MF_DBGLEVEL > 1) DbpString("[-] FpgaSetupSscDma failed. Exiting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3455,24 +3456,24 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
||||||
dataLen = DMA_BUFFER_SIZE - readBufDataP + dmaBufDataP; // number of bytes still to be processed
|
dataLen = DMA_BUFFER_SIZE - readBufDataP + dmaBufDataP; // number of bytes still to be processed
|
||||||
|
|
||||||
// test for length of buffer
|
// test for length of buffer
|
||||||
if(dataLen > maxDataLen) { // we are more behind than ever...
|
if (dataLen > maxDataLen) { // we are more behind than ever...
|
||||||
maxDataLen = dataLen;
|
maxDataLen = dataLen;
|
||||||
if(dataLen > (9 * DMA_BUFFER_SIZE / 10)) {
|
if (dataLen > (9 * DMA_BUFFER_SIZE / 10)) {
|
||||||
Dbprintf("blew circular buffer! dataLen=0x%x", dataLen);
|
Dbprintf("[-] blew circular buffer! dataLen=0x%x", dataLen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(dataLen < 1) continue;
|
if (dataLen < 1) continue;
|
||||||
|
|
||||||
// primary buffer was stopped ( <-- we lost data!
|
// primary buffer was stopped ( <-- we lost data!
|
||||||
if (!AT91C_BASE_PDC_SSC->PDC_RCR) {
|
if (!AT91C_BASE_PDC_SSC->PDC_RCR) {
|
||||||
AT91C_BASE_PDC_SSC->PDC_RPR = (uint32_t) dmaBuf;
|
AT91C_BASE_PDC_SSC->PDC_RPR = (uint32_t)dmaBuf;
|
||||||
AT91C_BASE_PDC_SSC->PDC_RCR = DMA_BUFFER_SIZE;
|
AT91C_BASE_PDC_SSC->PDC_RCR = DMA_BUFFER_SIZE;
|
||||||
Dbprintf("RxEmpty ERROR, data length:%d", dataLen); // temporary
|
Dbprintf("[-] RxEmpty ERROR, data length:%d", dataLen); // temporary
|
||||||
}
|
}
|
||||||
// secondary buffer sets as primary, secondary buffer was stopped
|
// secondary buffer sets as primary, secondary buffer was stopped
|
||||||
if (!AT91C_BASE_PDC_SSC->PDC_RNCR) {
|
if (!AT91C_BASE_PDC_SSC->PDC_RNCR) {
|
||||||
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t) dmaBuf;
|
AT91C_BASE_PDC_SSC->PDC_RNPR = (uint32_t)dmaBuf;
|
||||||
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
AT91C_BASE_PDC_SSC->PDC_RNCR = DMA_BUFFER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3483,7 +3484,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
||||||
// no need to try decoding tag data if the reader is sending
|
// no need to try decoding tag data if the reader is sending
|
||||||
if (!TagIsActive) {
|
if (!TagIsActive) {
|
||||||
uint8_t readerdata = (previous_data & 0xF0) | (*data >> 4);
|
uint8_t readerdata = (previous_data & 0xF0) | (*data >> 4);
|
||||||
if(MillerDecoding(readerdata, (sniffCounter-1)*4)) {
|
if (MillerDecoding(readerdata, (sniffCounter-1)*4)) {
|
||||||
LED_C_INV();
|
LED_C_INV();
|
||||||
|
|
||||||
if (MfSniffLogic(receivedCmd, Uart.len, Uart.parity, Uart.bitCount, true)) break;
|
if (MfSniffLogic(receivedCmd, Uart.len, Uart.parity, Uart.bitCount, true)) break;
|
||||||
|
@ -3497,7 +3498,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
||||||
// no need to try decoding tag data if the reader is sending
|
// no need to try decoding tag data if the reader is sending
|
||||||
if (!ReaderIsActive) {
|
if (!ReaderIsActive) {
|
||||||
uint8_t tagdata = (previous_data << 4) | (*data & 0x0F);
|
uint8_t tagdata = (previous_data << 4) | (*data & 0x0F);
|
||||||
if(ManchesterDecoding(tagdata, 0, (sniffCounter-1)*4)) {
|
if (ManchesterDecoding(tagdata, 0, (sniffCounter-1)*4)) {
|
||||||
LED_C_INV();
|
LED_C_INV();
|
||||||
|
|
||||||
if (MfSniffLogic(receivedResponse, Demod.len, Demod.parity, Demod.bitCount, false)) break;
|
if (MfSniffLogic(receivedResponse, Demod.len, Demod.parity, Demod.bitCount, false)) break;
|
||||||
|
@ -3513,7 +3514,7 @@ void RAMFUNC SniffMifare(uint8_t param) {
|
||||||
sniffCounter++;
|
sniffCounter++;
|
||||||
data++;
|
data++;
|
||||||
|
|
||||||
if(data == dmaBuf + DMA_BUFFER_SIZE)
|
if (data == dmaBuf + DMA_BUFFER_SIZE)
|
||||||
data = dmaBuf;
|
data = dmaBuf;
|
||||||
|
|
||||||
} // main cycle
|
} // main cycle
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue