#include "mifareutil.h"
static uint32_t iso14a_timeout;
-uint8_t *trace = (uint8_t *) BigBuf;
+uint8_t *trace = (uint8_t *) BigBuf+TRACE_OFFSET;
int traceLen = 0;
int rsamples = 0;
int tracing = TRUE;
trigger = enable;
}
-void iso14a_clear_tracelen(void) {
+void iso14a_clear_trace(void) {
+ memset(trace, 0x44, TRACE_SIZE);
traceLen = 0;
}
+
void iso14a_set_tracing(int enable) {
tracing = enable;
}
+
void iso14a_set_timeout(uint32_t timeout) {
iso14a_timeout = timeout;
}
LEDsoff();
// init trace buffer
- traceLen = 0;
- memset(trace, 0x44, TRACE_SIZE);
+ iso14a_clear_trace();
// We won't start recording the frames that we acquire until we trigger;
// a good trigger condition to get started is probably when we see a
{
// Enable and clear the trace
tracing = TRUE;
- traceLen = 0;
- memset(trace, 0x44, TRACE_SIZE);
+ iso14a_clear_trace();
// This function contains the tag emulation
uint8_t sak;
iso14a_command_t param = c->arg[0];
uint8_t * cmd = c->d.asBytes;
size_t len = c->arg[1];
+ uint8_t *receiveBuf = (((uint8_t *)BigBuf) + FREE_BUFFER_OFFSET);
if(param & ISO14A_REQUEST_TRIGGER) iso14a_set_trigger(1);
}
if(param & ISO14A_APDU) {
- ack->arg[0] = iso14_apdu(cmd, len, ack->d.asBytes);
+ memcpy(receiveBuf, ack->d.asBytes, len);
+ ack->arg[0] = iso14_apdu(cmd, len, receiveBuf);
+
+ while(ack->arg[0] > sizeof(ack->d))
+ {
+ memcpy(ack->d.asBytes, receiveBuf, sizeof(ack->d));
+ UsbSendPacket((void *)ack, sizeof(UsbCommand));
+
+ receiveBuf+=sizeof(ack->d);
+ ack->arg[0]-=sizeof(ack->d);
+ }
+
+ memcpy(ack->d.asBytes, receiveBuf, ack->arg[0]);
UsbSendPacket((void *)ack, sizeof(UsbCommand));
}
while(TRUE)
{
- LED_C_ON();
+ LED_C_OFF();
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
- SpinDelay(200);
+ SpinDelay(50);
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_ISO14443A | FPGA_HF_ISO14443A_READER_MOD);
- LED_C_OFF();
+ LED_C_ON();
+ SpinDelay(2);
// Test if the action was cancelled
if(BUTTON_PRESS()) {
// C(red) A(yellow) B(green)
LEDsoff();
// init trace buffer
- traceLen = 0;
- memset(trace, 0x44, TRACE_SIZE);
+ iso14a_clear_trace();
// The command (reader -> tag) that we're receiving.
// The length of a received command will in most cases be no more than 18 bytes.
Dbprintf("maxDataLen=%x, Uart.state=%x, Uart.byteCnt=%x Uart.byteCntMax=%x", maxDataLen, Uart.state, Uart.byteCnt, Uart.byteCntMax);
LEDsoff();
-}
\ No newline at end of file
+}