mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 05:43:48 -07:00
chg: minor clean up in iso15693 commands.
This commit is contained in:
parent
4d354f75fe
commit
eec5780b62
2 changed files with 90 additions and 131 deletions
|
@ -197,6 +197,7 @@ void SimTagIso15693(uint32_t parameter, uint8_t *uid); // simulate an ISO15693 t
|
||||||
void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
|
void BruteforceIso15693Afi(uint32_t speed); // find an AFI of a tag - atrox
|
||||||
void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t data[]); // send arbitrary commands from CLI - atrox
|
void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8_t data[]); // send arbitrary commands from CLI - atrox
|
||||||
void SetDebugIso15693(uint32_t flag);
|
void SetDebugIso15693(uint32_t flag);
|
||||||
|
void Iso15693InitReader(void);
|
||||||
|
|
||||||
// iclass.h
|
// iclass.h
|
||||||
void RAMFUNC SniffIClass(void);
|
void RAMFUNC SniffIClass(void);
|
||||||
|
|
|
@ -90,8 +90,7 @@ int DEBUG = 0;
|
||||||
// resulting data rate is 26,48 kbit/s (fc/512)
|
// resulting data rate is 26,48 kbit/s (fc/512)
|
||||||
// cmd ... data
|
// cmd ... data
|
||||||
// n ... length of data
|
// n ... length of data
|
||||||
static void CodeIso15693AsReader(uint8_t *cmd, int n)
|
static void CodeIso15693AsReader(uint8_t *cmd, int n) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
ToSendReset();
|
ToSendReset();
|
||||||
|
@ -170,8 +169,7 @@ static void CodeIso15693AsReader(uint8_t *cmd, int n)
|
||||||
// encode data using "1 out of 256" sheme
|
// encode data using "1 out of 256" sheme
|
||||||
// data rate is 1,66 kbit/s (fc/8192)
|
// data rate is 1,66 kbit/s (fc/8192)
|
||||||
// is designed for more robust communication over longer distances
|
// is designed for more robust communication over longer distances
|
||||||
static void CodeIso15693AsReader256(uint8_t *cmd, int n)
|
static void CodeIso15693AsReader256(uint8_t *cmd, int n) {
|
||||||
{
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
ToSendReset();
|
ToSendReset();
|
||||||
|
@ -212,10 +210,8 @@ static void CodeIso15693AsReader256(uint8_t *cmd, int n)
|
||||||
ToSendStuffBit(1);
|
ToSendStuffBit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Transmit the command (to the tag) that was placed in ToSend[].
|
// Transmit the command (to the tag) that was placed in ToSend[].
|
||||||
static void TransmitTo15693Tag(const uint8_t *cmd, int len, int *samples, int *wait)
|
static void TransmitTo15693Tag(const uint8_t *cmd, int len, int *samples, int *wait) {
|
||||||
{
|
|
||||||
int c;
|
int c;
|
||||||
volatile uint32_t r;
|
volatile uint32_t r;
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_TX);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_TX);
|
||||||
|
@ -236,15 +232,17 @@ static void TransmitTo15693Tag(const uint8_t *cmd, int len, int *samples, int *w
|
||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
WDT_HIT();
|
||||||
|
|
||||||
|
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||||
AT91C_BASE_SSC->SSC_THR = cmd[c];
|
AT91C_BASE_SSC->SSC_THR = cmd[c];
|
||||||
if( ++c >= len) break;
|
if( ++c >= len) break;
|
||||||
}
|
}
|
||||||
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
||||||
r = AT91C_BASE_SSC->SSC_RHR; (void)r;
|
r = AT91C_BASE_SSC->SSC_RHR; (void)r;
|
||||||
}
|
}
|
||||||
WDT_HIT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (samples) {
|
if (samples) {
|
||||||
if (wait)
|
if (wait)
|
||||||
*samples = (c + *wait) << 3;
|
*samples = (c + *wait) << 3;
|
||||||
|
@ -256,11 +254,11 @@ static void TransmitTo15693Tag(const uint8_t *cmd, int len, int *samples, int *w
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Transmit the command (to the reader) that was placed in ToSend[].
|
// Transmit the command (to the reader) that was placed in ToSend[].
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static void TransmitTo15693Reader(const uint8_t *cmd, int len, int *samples, int *wait)
|
static void TransmitTo15693Reader(const uint8_t *cmd, int len, int *samples, int *wait) {
|
||||||
{
|
|
||||||
int c = 0;
|
int c = 0;
|
||||||
volatile uint32_t r;
|
volatile uint32_t r;
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR|FPGA_HF_SIMULATOR_MODULATE_424K);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SIMULATOR|FPGA_HF_SIMULATOR_MODULATE_424K);
|
||||||
|
|
||||||
if (wait) {
|
if (wait) {
|
||||||
if (*wait < 10) { *wait = 10; }
|
if (*wait < 10) { *wait = 10; }
|
||||||
for (c = 0; c < *wait;) {
|
for (c = 0; c < *wait;) {
|
||||||
|
@ -275,15 +273,16 @@ static void TransmitTo15693Reader(const uint8_t *cmd, int len, int *samples, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
WDT_HIT();
|
||||||
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||||
AT91C_BASE_SSC->SSC_THR = cmd[c];
|
AT91C_BASE_SSC->SSC_THR = cmd[c];
|
||||||
if( ++c >= len) break;
|
if( ++c >= len) break;
|
||||||
}
|
}
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
||||||
r = AT91C_BASE_SSC->SSC_RHR; (void)r;
|
r = AT91C_BASE_SSC->SSC_RHR; (void)r;
|
||||||
}
|
}
|
||||||
WDT_HIT();
|
|
||||||
}
|
}
|
||||||
if (samples) {
|
if (samples) {
|
||||||
if (wait)
|
if (wait)
|
||||||
|
@ -293,7 +292,6 @@ static void TransmitTo15693Reader(const uint8_t *cmd, int len, int *samples, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read from Tag
|
// Read from Tag
|
||||||
// Parameters:
|
// Parameters:
|
||||||
// receivedResponse
|
// receivedResponse
|
||||||
|
@ -302,16 +300,15 @@ static void TransmitTo15693Reader(const uint8_t *cmd, int len, int *samples, int
|
||||||
// elapsed
|
// elapsed
|
||||||
// returns:
|
// returns:
|
||||||
// number of decoded bytes
|
// number of decoded bytes
|
||||||
static int GetIso15693AnswerFromTag(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed)
|
static int GetIso15693AnswerFromTag(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed) {
|
||||||
{
|
|
||||||
uint8_t *dest = BigBuf_get_addr();
|
|
||||||
|
|
||||||
int c = 0, getNext = false;
|
|
||||||
int8_t prev = 0;
|
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
||||||
//SpinDelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
|
//SpinDelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
|
||||||
|
|
||||||
|
int c = 0, getNext = false;
|
||||||
|
int8_t prev = 0;
|
||||||
|
uint8_t *dest = BigBuf_get_addr();
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
|
@ -431,13 +428,12 @@ static int GetIso15693AnswerFromTag(uint8_t *receivedResponse, int maxLen, int *
|
||||||
|
|
||||||
// Now the GetISO15693 message from sniffing command
|
// Now the GetISO15693 message from sniffing command
|
||||||
static int GetIso15693AnswerFromSniff(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed) {
|
static int GetIso15693AnswerFromSniff(uint8_t *receivedResponse, int maxLen, int *samples, int *elapsed) {
|
||||||
uint8_t *dest = BigBuf_get_addr();
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
||||||
|
//SpinDelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
|
||||||
|
|
||||||
int c = 0, getNext = false;
|
int c = 0, getNext = false;
|
||||||
int8_t prev = 0;
|
int8_t prev = 0;
|
||||||
|
uint8_t *dest = BigBuf_get_addr();
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
|
||||||
//SpinDelay(60); // greg - experiment to get rid of some of the 0 byte/failed reads
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
@ -468,7 +464,7 @@ static int GetIso15693AnswerFromSniff(uint8_t *receivedResponse, int maxLen, int
|
||||||
/////////// DEMODULATE ///////////////////
|
/////////// DEMODULATE ///////////////////
|
||||||
//////////////////////////////////////////
|
//////////////////////////////////////////
|
||||||
|
|
||||||
int i, j, max = 0, maxPos=0, skip = 4;
|
int i, j, max = 0, maxPos = 0, skip = 4;
|
||||||
|
|
||||||
// First, correlate for SOF
|
// First, correlate for SOF
|
||||||
for(i = 0; i < 19000; i++) {
|
for(i = 0; i < 19000; i++) {
|
||||||
|
@ -559,48 +555,52 @@ static void BuildIdentifyRequest(void);
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void AcquireRawAdcSamplesIso15693(void)
|
void AcquireRawAdcSamplesIso15693(void)
|
||||||
{
|
{
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
|
||||||
|
|
||||||
int c = 0, getNext = false;
|
int c = 0, getNext = false;
|
||||||
int8_t prev = 0;
|
int8_t prev = 0;
|
||||||
volatile uint32_t r;
|
volatile uint32_t r;
|
||||||
|
volatile int8_t b;
|
||||||
|
|
||||||
uint8_t *dest = BigBuf_get_addr();
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
BuildIdentifyRequest();
|
|
||||||
|
|
||||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
||||||
|
|
||||||
|
FpgaSetupSsc();
|
||||||
|
|
||||||
// Give the tags time to energize
|
// Give the tags time to energize
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
||||||
SpinDelay(100);
|
SpinDelay(100);
|
||||||
|
|
||||||
// Now send the command
|
// Now send the command
|
||||||
FpgaSetupSsc();
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_TX);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_TX);
|
||||||
|
|
||||||
|
uint8_t *dest = BigBuf_get_addr();
|
||||||
|
BuildIdentifyRequest();
|
||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
WDT_HIT();
|
||||||
|
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||||
AT91C_BASE_SSC->SSC_THR = ToSend[c];
|
AT91C_BASE_SSC->SSC_THR = ToSend[c];
|
||||||
if( ++c == ToSendMax+3) break;
|
if( ++c == ToSendMax+3) break;
|
||||||
}
|
}
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
||||||
r = AT91C_BASE_SSC->SSC_RHR;
|
r = AT91C_BASE_SSC->SSC_RHR; (void)r;
|
||||||
(void)r;
|
|
||||||
}
|
}
|
||||||
WDT_HIT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
||||||
|
|
||||||
c = 0;
|
c = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
WDT_HIT();
|
||||||
|
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY))
|
||||||
AT91C_BASE_SSC->SSC_THR = 0x43;
|
AT91C_BASE_SSC->SSC_THR = 0x43;
|
||||||
|
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
||||||
|
|
||||||
int8_t b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
|
b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||||
|
|
||||||
// The samples are correlations against I and Q versions of the
|
// The samples are correlations against I and Q versions of the
|
||||||
// tone that the tag AM-modulates, so every other sample is I,
|
// tone that the tag AM-modulates, so every other sample is I,
|
||||||
|
@ -620,40 +620,31 @@ void AcquireRawAdcSamplesIso15693(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// switch_off, initreader
|
||||||
void RecordRawAdcSamplesIso15693(void)
|
void RecordRawAdcSamplesIso15693(void) {
|
||||||
{
|
|
||||||
uint8_t *dest = BigBuf_get_addr();
|
|
||||||
|
|
||||||
int c = 0, getNext = false;
|
int c = 0, getNext = false;
|
||||||
int8_t prev = 0;
|
int8_t prev = 0;
|
||||||
|
volatile int8_t b;
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
Iso15693InitReader();
|
||||||
// Setup SSC
|
|
||||||
FpgaSetupSsc();
|
|
||||||
|
|
||||||
// Start from off (no field generated)
|
uint8_t *dest = BigBuf_get_addr();
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
|
||||||
SpinDelay(200);
|
|
||||||
|
|
||||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
|
||||||
SpinDelay(100);
|
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
WDT_HIT();
|
||||||
|
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
|
||||||
AT91C_BASE_SSC->SSC_THR = 0x43;
|
AT91C_BASE_SSC->SSC_THR = 0x43;
|
||||||
}
|
}
|
||||||
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
|
||||||
int8_t b;
|
|
||||||
b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
|
b = (int8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||||
|
|
||||||
// The samples are correlations against I and Q versions of the
|
// The samples are correlations against I and Q versions of the
|
||||||
// tone that the tag AM-modulates, so every other sample is I,
|
// tone that the tag AM-modulates, so every other sample is I,
|
||||||
// every other is Q. We just want power, so abs(I) + abs(Q) is
|
// every other is Q. We just want power, so abs(I) + abs(Q) is
|
||||||
// close to what we want.
|
// close to what we want.
|
||||||
if(getNext) {
|
if (getNext) {
|
||||||
dest[c++] = (uint8_t) ABS(b) + ABS(prev);
|
dest[c++] = (uint8_t) ABS(b) + ABS(prev);
|
||||||
|
|
||||||
if(c >= 7000)
|
if(c >= 7000)
|
||||||
|
@ -663,40 +654,34 @@ void RecordRawAdcSamplesIso15693(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
getNext = !getNext;
|
getNext = !getNext;
|
||||||
WDT_HIT();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Dbprintf("fin record");
|
|
||||||
|
Dbprintf("done");
|
||||||
|
switch_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initialize the proxmark as iso15k reader
|
// Initialize the proxmark as iso15k reader
|
||||||
// (this might produces glitches that confuse some tags
|
// (this might produces glitches that confuse some tags
|
||||||
void Iso15693InitReader() {
|
void Iso15693InitReader(void) {
|
||||||
LED_A_ON();
|
LEDsoff();
|
||||||
LED_B_ON();
|
|
||||||
LED_C_OFF();
|
|
||||||
LED_D_OFF();
|
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
// Setup SSC
|
|
||||||
// FpgaSetupSsc();
|
|
||||||
|
|
||||||
// Start from off (no field generated)
|
// Start from off (no field generated)
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
SpinDelay(10);
|
SpinDelay(10);
|
||||||
|
|
||||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
||||||
|
|
||||||
FpgaSetupSsc();
|
FpgaSetupSsc();
|
||||||
|
|
||||||
// Give the tags time to energize
|
// Give the tags time to energize
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
||||||
SpinDelay(250);
|
SpinDelay(60);
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_OFF();
|
|
||||||
LED_D_OFF();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
|
@ -795,10 +780,9 @@ int SendDataTag(uint8_t *send, int sendlen, int init, int speed, uint8_t **recv)
|
||||||
int wait = 0, elapsed = 0;
|
int wait = 0, elapsed = 0;
|
||||||
int answerLen = 0;
|
int answerLen = 0;
|
||||||
|
|
||||||
|
LEDsoff();
|
||||||
LED_A_ON(); LED_B_ON();
|
LED_A_ON(); LED_B_ON();
|
||||||
|
|
||||||
LED_C_OFF(); LED_D_OFF();
|
|
||||||
|
|
||||||
if (init) Iso15693InitReader();
|
if (init) Iso15693InitReader();
|
||||||
|
|
||||||
// answer is 100bytes long?
|
// answer is 100bytes long?
|
||||||
|
@ -813,14 +797,12 @@ int SendDataTag(uint8_t *send, int sendlen, int init, int speed, uint8_t **recv)
|
||||||
CodeIso15693AsReader(send, sendlen);
|
CodeIso15693AsReader(send, sendlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_INV();
|
||||||
LED_B_OFF();
|
|
||||||
|
|
||||||
TransmitTo15693Tag(ToSend, ToSendMax, &tsamples, &wait);
|
TransmitTo15693Tag(ToSend, ToSendMax, &tsamples, &wait);
|
||||||
// Now wait for a response
|
// Now wait for a response
|
||||||
if (recv!=NULL) {
|
if (recv != NULL) {
|
||||||
LED_A_OFF();
|
LED_B_INV();
|
||||||
LED_B_ON();
|
|
||||||
answerLen = GetIso15693AnswerFromTag(answer, 100, &samples, &elapsed) ;
|
answerLen = GetIso15693AnswerFromTag(answer, 100, &samples, &elapsed) ;
|
||||||
*recv = answer;
|
*recv = answer;
|
||||||
}
|
}
|
||||||
|
@ -906,13 +888,7 @@ void SetDebugIso15693(uint32_t debug) {
|
||||||
// Simulate an ISO15693 reader, perform anti-collision and then attempt to read a sector
|
// Simulate an ISO15693 reader, perform anti-collision and then attempt to read a sector
|
||||||
// all demodulation performed in arm rather than host. - greg
|
// all demodulation performed in arm rather than host. - greg
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void ReaderIso15693(uint32_t parameter)
|
void ReaderIso15693(uint32_t parameter) {
|
||||||
{
|
|
||||||
LED_A_ON();
|
|
||||||
LED_B_ON();
|
|
||||||
LED_C_OFF();
|
|
||||||
LED_D_OFF();
|
|
||||||
|
|
||||||
int answerLen1 = 0;
|
int answerLen1 = 0;
|
||||||
int answerLen2 = 0;
|
int answerLen2 = 0;
|
||||||
int answerLen3 = 0;
|
int answerLen3 = 0;
|
||||||
|
@ -921,9 +897,8 @@ void ReaderIso15693(uint32_t parameter)
|
||||||
int tsamples = 0;
|
int tsamples = 0;
|
||||||
int wait = 0;
|
int wait = 0;
|
||||||
int elapsed = 0;
|
int elapsed = 0;
|
||||||
uint8_t TagUID[8] = {0x00};
|
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
uint8_t TagUID[8] = {0x00};
|
||||||
|
|
||||||
uint8_t *answer1 = BigBuf_malloc(100);
|
uint8_t *answer1 = BigBuf_malloc(100);
|
||||||
uint8_t *answer2 = BigBuf_malloc(100);
|
uint8_t *answer2 = BigBuf_malloc(100);
|
||||||
|
@ -933,36 +908,21 @@ void ReaderIso15693(uint32_t parameter)
|
||||||
memset(answer2, 0x00, 100);
|
memset(answer2, 0x00, 100);
|
||||||
memset(answer3, 0x00, 100);
|
memset(answer3, 0x00, 100);
|
||||||
|
|
||||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
// Now send the IDENTIFY command
|
||||||
// Setup SSC
|
|
||||||
FpgaSetupSsc();
|
|
||||||
|
|
||||||
// Start from off (no field generated)
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
|
||||||
SpinDelay(200);
|
|
||||||
|
|
||||||
// Give the tags time to energize
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER_RX_XCORR);
|
|
||||||
SpinDelay(200);
|
|
||||||
|
|
||||||
LED_A_ON();
|
|
||||||
LED_B_OFF();
|
|
||||||
LED_C_OFF();
|
|
||||||
LED_D_OFF();
|
|
||||||
|
|
||||||
// FIRST WE RUN AN INVENTORY TO GET THE TAG UID
|
// FIRST WE RUN AN INVENTORY TO GET THE TAG UID
|
||||||
// THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
|
// THIS MEANS WE CAN PRE-BUILD REQUESTS TO SAVE CPU TIME
|
||||||
|
|
||||||
// Now send the IDENTIFY command
|
|
||||||
BuildIdentifyRequest();
|
BuildIdentifyRequest();
|
||||||
|
|
||||||
|
// set up device/fpga
|
||||||
|
Iso15693InitReader();
|
||||||
|
|
||||||
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);
|
TransmitTo15693Tag(ToSend,ToSendMax,&tsamples, &wait);
|
||||||
|
|
||||||
// Now wait for a response
|
// Now wait for a response
|
||||||
answerLen1 = GetIso15693AnswerFromTag(answer1, 100, &samples, &elapsed) ;
|
answerLen1 = GetIso15693AnswerFromTag(answer1, 100, &samples, &elapsed) ;
|
||||||
|
|
||||||
if (answerLen1 >= 12) // we should do a better check than this
|
// we should do a better check than this
|
||||||
{
|
if (answerLen1 >= 12) {
|
||||||
TagUID[0] = answer1[2];
|
TagUID[0] = answer1[2];
|
||||||
TagUID[1] = answer1[3];
|
TagUID[1] = answer1[3];
|
||||||
TagUID[2] = answer1[4];
|
TagUID[2] = answer1[4];
|
||||||
|
@ -971,7 +931,6 @@ void ReaderIso15693(uint32_t parameter)
|
||||||
TagUID[5] = answer1[7];
|
TagUID[5] = answer1[7];
|
||||||
TagUID[6] = answer1[8]; // IC Manufacturer code
|
TagUID[6] = answer1[8]; // IC Manufacturer code
|
||||||
TagUID[7] = answer1[9]; // always E0
|
TagUID[7] = answer1[9]; // always E0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dbprintf("%d octets read from IDENTIFY request:", answerLen1);
|
Dbprintf("%d octets read from IDENTIFY request:", answerLen1);
|
||||||
|
@ -979,7 +938,7 @@ void ReaderIso15693(uint32_t parameter)
|
||||||
Dbhexdump(answerLen1, answer1, true);
|
Dbhexdump(answerLen1, answer1, true);
|
||||||
|
|
||||||
// UID is reverse
|
// UID is reverse
|
||||||
if (answerLen1>=12)
|
if (answerLen1 >= 12)
|
||||||
Dbprintf("UID = %02hX%02hX%02hX%02hX%02hX%02hX%02hX%02hX",
|
Dbprintf("UID = %02hX%02hX%02hX%02hX%02hX%02hX%02hX%02hX",
|
||||||
TagUID[7],TagUID[6],TagUID[5],TagUID[4],
|
TagUID[7],TagUID[6],TagUID[5],TagUID[4],
|
||||||
TagUID[3],TagUID[2],TagUID[1],TagUID[0]);
|
TagUID[3],TagUID[2],TagUID[1],TagUID[0]);
|
||||||
|
@ -990,7 +949,7 @@ void ReaderIso15693(uint32_t parameter)
|
||||||
Dbhexdump(answerLen2, answer2, true);
|
Dbhexdump(answerLen2, answer2, true);
|
||||||
|
|
||||||
Dbprintf("%d octets read from XXX request:", answerLen3);
|
Dbprintf("%d octets read from XXX request:", answerLen3);
|
||||||
DbdecodeIso15693Answer(answerLen3,answer3);
|
DbdecodeIso15693Answer(answerLen3, answer3);
|
||||||
Dbhexdump(answerLen3, answer3, true);
|
Dbhexdump(answerLen3, answer3, true);
|
||||||
|
|
||||||
// read all pages
|
// read all pages
|
||||||
|
@ -1010,13 +969,22 @@ void ReaderIso15693(uint32_t parameter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LEDsoff();
|
switch_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simulate an ISO15693 TAG, perform anti-collision and then print any reader commands
|
// Simulate an ISO15693 TAG, perform anti-collision and then print any reader commands
|
||||||
// all demodulation performed in arm rather than host. - greg
|
// all demodulation performed in arm rather than host. - greg
|
||||||
void SimTagIso15693(uint32_t parameter, uint8_t *uid)
|
void SimTagIso15693(uint32_t parameter, uint8_t *uid) {
|
||||||
{
|
|
||||||
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
|
|
||||||
|
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
||||||
|
FpgaSetupSsc();
|
||||||
|
|
||||||
|
// Start from off (no field generated)
|
||||||
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
|
SpinDelay(200);
|
||||||
|
|
||||||
LED_A_ON();
|
LED_A_ON();
|
||||||
|
|
||||||
int ans = 0;
|
int ans = 0;
|
||||||
|
@ -1027,32 +995,23 @@ void SimTagIso15693(uint32_t parameter, uint8_t *uid)
|
||||||
|
|
||||||
Dbprintf("iso15963 Simulating uid: %x %x %x %x %x %x %x %x", uid[0], uid[1], uid[2], uid[3], uid[4], uid[5], uid[6], uid[7]);
|
Dbprintf("iso15963 Simulating uid: %x %x %x %x %x %x %x %x", uid[0], uid[1], uid[2], uid[3], uid[4], uid[5], uid[6], uid[7]);
|
||||||
|
|
||||||
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
|
||||||
|
|
||||||
uint8_t *buf = BigBuf_malloc(100);
|
uint8_t *buf = BigBuf_malloc(100);
|
||||||
memset(buf, 0x00, 100);
|
memset(buf, 0x00, 100);
|
||||||
|
|
||||||
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
|
||||||
FpgaSetupSsc();
|
|
||||||
|
|
||||||
// Start from off (no field generated)
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
|
||||||
SpinDelay(200);
|
|
||||||
|
|
||||||
LED_C_ON();
|
LED_C_ON();
|
||||||
|
|
||||||
// Build a suitable reponse to the reader INVENTORY cocmmand
|
// Build a suitable reponse to the reader INVENTORY cocmmand
|
||||||
// not so obsvious, but in the call to BuildInventoryResponse, the command is copied to the global ToSend buffer used below.
|
// not so obsvious, but in the call to BuildInventoryResponse, the command is copied to the global ToSend buffer used below.
|
||||||
BuildInventoryResponse(uid);
|
BuildInventoryResponse(uid);
|
||||||
|
|
||||||
while(!BUTTON_PRESS() && !usb_poll_validate_length() ) {
|
while (!BUTTON_PRESS() && !usb_poll_validate_length() ) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
|
|
||||||
// Listen to reader
|
// Listen to reader
|
||||||
ans = GetIso15693AnswerFromSniff(buf, 100, &samples, &elapsed) ;
|
ans = GetIso15693AnswerFromSniff(buf, 100, &samples, &elapsed) ;
|
||||||
|
|
||||||
// we should do a better check than this
|
// we should do a better check than this
|
||||||
if (ans >=1 ) {
|
if (ans >= 1 ) {
|
||||||
TransmitTo15693Reader(ToSend, ToSendMax, &tsamples, &wait);
|
TransmitTo15693Reader(ToSend, ToSendMax, &tsamples, &wait);
|
||||||
|
|
||||||
Dbprintf("%d octets read from reader command: %x %x %x %x %x %x %x %x %x", ans,
|
Dbprintf("%d octets read from reader command: %x %x %x %x %x %x %x %x %x", ans,
|
||||||
|
@ -1060,8 +1019,7 @@ void SimTagIso15693(uint32_t parameter, uint8_t *uid)
|
||||||
buf[4], buf[5], buf[6], buf[7], buf[8]);
|
buf[4], buf[5], buf[6], buf[7], buf[8]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LEDsoff();
|
switch_off();
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1125,13 +1083,13 @@ void DirectTag15693Command(uint32_t datalen,uint32_t speed, uint32_t recv, uint8
|
||||||
|
|
||||||
if (recv) {
|
if (recv) {
|
||||||
LED_B_ON();
|
LED_B_ON();
|
||||||
cmd_send(CMD_ACK,recvlen>48?48:recvlen,0,0,recvbuf,48);
|
cmd_send(CMD_ACK, recvlen > 48 ? 48 : recvlen, 0, 0, recvbuf, 48);
|
||||||
LED_B_OFF();
|
LED_B_OFF();
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Dbprintf("RECV");
|
Dbprintf("RECV");
|
||||||
DbdecodeIso15693Answer(recvlen,recvbuf);
|
DbdecodeIso15693Answer(recvlen, recvbuf);
|
||||||
Dbhexdump(recvlen,recvbuf,true);
|
Dbhexdump(recvlen, recvbuf, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue