summaryrefslogtreecommitdiff
path: root/openpicc/application
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-12-09 06:00:31 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-12-09 06:00:31 +0000
commit61ae0602b252c367c6c5514b113fdf9bacdddc0b (patch)
treed09c4713e89314a9f97141cf60a82c73585fb71c /openpicc/application
parent4077ce43189067b2498b9fd0e306052ea18ed3fb (diff)
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
Diffstat (limited to 'openpicc/application')
-rw-r--r--openpicc/application/cmd.c41
-rw-r--r--openpicc/application/iso14443_layer3a.h10
-rw-r--r--openpicc/application/ssc_picc.c8
-rw-r--r--openpicc/application/ssc_picc.h1
4 files changed, 57 insertions, 3 deletions
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<SSC_DMA_BUFFER_COUNT; i++) {
@@ -327,6 +332,9 @@ void ssc_tx_start(ssc_dma_tx_buffer_t *buf)
if(AT91F_PIO_IsInputSet(AT91C_BASE_PIOA, OPENPICC_SSC_TF)) {
/* TF was probably already high when we enabled the PIO change interrupt for it. */
ssc_tf_irq(OPENPICC_SSC_TF);
+ vLedBlinkRed();
+ late_frames++;
+ usb_print_string_f("Late response\n\r", 0);
}
#endif
}
diff --git a/openpicc/application/ssc_picc.h b/openpicc/application/ssc_picc.h
index d141e44..a90f13e 100644
--- a/openpicc/application/ssc_picc.h
+++ b/openpicc/application/ssc_picc.h
@@ -40,6 +40,7 @@ extern ssc_irq_ext_t ssc_set_irq_extension(ssc_irq_ext_t ext_handler);
extern int ssc_get_overflows(void);
extern int ssc_count_free(void);
+extern int ssc_get_late_frames(void);
#define SSC_DMA_BUFFER_SIZE 2048
#define SSC_DMA_BUFFER_COUNT 4
personal git repositories of Harald Welte. Your mileage may vary