From 61ae0602b252c367c6c5514b113fdf9bacdddc0b Mon Sep 17 00:00:00 2001 From: henryk Date: Sun, 9 Dec 2007 06:00:31 +0000 Subject: Count and print late frames Make load modulation level changeable on the fly Better fdt calculation and ajustable fdt offset git-svn-id: https://svn.openpcd.org:2342/trunk@378 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpicc/application/cmd.c | 41 ++++++++++++++++++++++++++++++++- openpicc/application/iso14443_layer3a.h | 10 ++++++-- openpicc/application/ssc_picc.c | 8 +++++++ openpicc/application/ssc_picc.h | 1 + 4 files changed, 57 insertions(+), 3 deletions(-) (limited to 'openpicc') diff --git a/openpicc/application/cmd.c b/openpicc/application/cmd.c index 776d5e5..463f514 100644 --- a/openpicc/application/cmd.c +++ b/openpicc/application/cmd.c @@ -19,6 +19,7 @@ #include "pio_irq.h" #include "ssc_picc.h" #include "usb_print.h" +#include "load_modulation.h" xQueueHandle xCmdQueue; xTaskHandle xCmdTask; @@ -26,6 +27,9 @@ xTaskHandle xCmdRecvUsbTask; xTaskHandle xFieldMeterTask; xSemaphoreHandle xFieldMeterMutex; +volatile int fdt_offset=0; +volatile int load_mod_level_set=3; + #if ( configUSE_TRACE_FACILITY == 1 ) static signed portCHAR pcWriteBuffer[512]; #endif @@ -40,7 +44,7 @@ static const portBASE_TYPE USE_COLON_FOR_LONG_COMMANDS = 0; /* When not USE_COLON_FOR_LONG_COMMANDS then short commands will be recognized by including * their character in the string SHORT_COMMANDS * */ -static const char *SHORT_COMMANDS = "!pc+-l?hq9f"; +static const char *SHORT_COMMANDS = "!pc+-l?hq9fjka"; /* Note that the long/short command distinction only applies to the USB serial console * */ @@ -251,12 +255,24 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { DumpStringToUSB(" * current field strength: "); DumpUIntToUSB(adc_get_field_strength()); DumpStringToUSB("\n\r"); + DumpStringToUSB(" * fdt_offset: "); + if(fdt_offset < 0) { + DumpStringToUSB("-"); + DumpUIntToUSB(-fdt_offset); + } else DumpUIntToUSB(fdt_offset); + DumpStringToUSB("\n\r"); + DumpStringToUSB(" * load_mod_level: "); + DumpUIntToUSB(load_mod_level_set); + DumpStringToUSB("\n\r"); DumpStringToUSB(" * SSC RX overflows: "); DumpUIntToUSB(ssc_get_overflows()); DumpStringToUSB("\n\r"); DumpStringToUSB(" * SSC free buffers: "); DumpUIntToUSB(ssc_count_free()); DumpStringToUSB("\n\r"); + DumpStringToUSB(" * SSC late frames: "); + DumpUIntToUSB(ssc_get_late_frames()); + DumpStringToUSB("\n\r"); DumpStringToUSB(" * SSC status: "); DumpUIntToUSB(AT91C_BASE_SSC->SSC_SR); DumpStringToUSB("\n\r"); @@ -315,6 +331,20 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { case '!': tc_cdiv_sync_reset(); break; + case 'J': + fdt_offset++; + DumpStringToUSB("fdt_offset is now "); + if(fdt_offset<0) { DumpStringToUSB("-"); DumpUIntToUSB(-fdt_offset); } + else { DumpStringToUSB("+"); DumpUIntToUSB(fdt_offset); } + DumpStringToUSB("\n\r"); + break; + case 'K': + fdt_offset--; + DumpStringToUSB("fdt_offset is now "); + if(fdt_offset<0) { DumpStringToUSB("-"); DumpUIntToUSB(-fdt_offset); } + else { DumpStringToUSB("+"); DumpUIntToUSB(fdt_offset); } + DumpStringToUSB("\n\r"); + break; case 'F': startstop_field_meter(); break; @@ -332,6 +362,13 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { DumpStringToUSB("\n\r"); } break; + case 'A': + load_mod_level_set = (load_mod_level_set+1) % 4; + load_mod_level(load_mod_level_set); + DumpStringToUSB("load_mod_level is now "); + DumpUIntToUSB(load_mod_level_set); + DumpStringToUSB("\n\r"); + break; case 'H': case '?': DumpStringToUSB( @@ -359,6 +396,8 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { " * q - start rx\n\r" " * f - start/stop field meter\n\r" " * d div- set tc_cdiv divider value 16, 32, 64, ...\n\r" + " * j,k - increase, decrease fdt_offset\n\r" + " * a - change load modulation level\n\r" " * 9 - reset CPU\n\r" " * ?,h - display this help screen\n\r" " *\n\r" diff --git a/openpicc/application/iso14443_layer3a.h b/openpicc/application/iso14443_layer3a.h index d398d1f..2b39d4e 100644 --- a/openpicc/application/iso14443_layer3a.h +++ b/openpicc/application/iso14443_layer3a.h @@ -18,9 +18,15 @@ enum ISO14443_STATES { /******************** RX ************************************/ /* measured TF->FIQ->SSC TX start delay (~3.480us) in carrier cycles */ #define TF_FIQ_SSC_DELAY 47 +//#define TF_FIQ_SSC_DELAY 40 +#define FALLING_EDGE_DETECTION_DELAY 12 +extern volatile int fdt_offset; /* standard derived magic values */ -#define ISO14443A_FDT_SHORT_1 (1236-TF_FIQ_SSC_DELAY) -#define ISO14443A_FDT_SHORT_0 (1172-TF_FIQ_SSC_DELAY) +#define ISO14443A_FDT_SLOTLEN 128 +#define ISO14443A_FDT_OFFSET_1 84 +#define ISO14443A_FDT_OFFSET_0 20 +#define ISO14443A_FDT_SHORT_1 (ISO14443A_FDT_SLOTLEN*9 + ISO14443A_FDT_OFFSET_1 -FALLING_EDGE_DETECTION_DELAY +fdt_offset -TF_FIQ_SSC_DELAY) +#define ISO14443A_FDT_SHORT_0 (ISO14443A_FDT_SLOTLEN*9 + ISO14443A_FDT_OFFSET_0 -FALLING_EDGE_DETECTION_DELAY +fdt_offset -TF_FIQ_SSC_DELAY) #ifdef FOUR_TIMES_OVERSAMPLING /* definitions for four-times oversampling */ diff --git a/openpicc/application/ssc_picc.c b/openpicc/application/ssc_picc.c index 9f0630f..8faa681 100644 --- a/openpicc/application/ssc_picc.c +++ b/openpicc/application/ssc_picc.c @@ -88,10 +88,15 @@ ssc_dma_tx_buffer_t ssc_tx_buffer; static volatile int overflows; static volatile int ssc_buffer_errors; +static volatile int late_frames = 0; int ssc_get_overflows(void) { return 1000*ssc_buffer_errors + overflows; } +int ssc_get_late_frames(void) { + return late_frames; +} + int ssc_count_free(void) { int i,free = 0; for(i=0; i