diff options
author | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-23 10:30:50 +0000 |
---|---|---|
committer | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-23 10:30:50 +0000 |
commit | 062f55ca3ea77ebcace83aab4772c9cd3f28ec34 (patch) | |
tree | 22581f5054c35007e1a34113dd77f4818a3a67e3 /openpicc/application | |
parent | ae5309d51c484ddf052ee19fd2a76c058e927bcb (diff) |
Commit status quo (pending cleanup of the debug and experimental code that I added during the last week)
Change freertos code to not mask FIQ, this finally makes the FIQ working (with approx 700ns +/- 100ns latency; yeah!) and therefore reception starts working
Change to two times oversampling (keep four times oversampling code ifdef'd, extract all the magical values to a header file) because at four times oversampling every other sample is very close to
a possible data edge and therefore not reliable
git-svn-id: https://svn.openpcd.org:2342/trunk@347 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application')
-rw-r--r-- | openpicc/application/cmd.c | 11 | ||||
-rw-r--r-- | openpicc/application/iso14443_layer3a.c | 4 | ||||
-rw-r--r-- | openpicc/application/iso14443_layer3a.h | 27 | ||||
-rw-r--r-- | openpicc/application/main.c | 7 | ||||
-rw-r--r-- | openpicc/application/openpicc.h | 1 | ||||
-rw-r--r-- | openpicc/application/pio_irq.c | 4 | ||||
-rw-r--r-- | openpicc/application/ssc_picc.c | 23 |
7 files changed, 61 insertions, 16 deletions
diff --git a/openpicc/application/cmd.c b/openpicc/application/cmd.c index dba4e3e..d8a88df 100644 --- a/openpicc/application/cmd.c +++ b/openpicc/application/cmd.c @@ -256,6 +256,17 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { DumpStringToUSB(" * SSC status: "); DumpUIntToUSB(AT91C_BASE_SSC->SSC_SR); DumpStringToUSB("\n\r"); + DumpStringToUSB(" * TC0_CV value: "); + DumpUIntToUSB(*AT91C_TC0_CV); + DumpStringToUSB("\n\r"); + DumpStringToUSB(" * SSC_RCMR value: "); + DumpUIntToUSB(*AT91C_SSC_RCMR); + DumpStringToUSB("\n\r"); + DumpStringToUSB(" * is remapped?: "); + DumpStringToUSB( (*(int*)0x00100100 == *(int*)0x00000100) ? "no" : + ((*(int*)0x00200100 == *(int*)0x00000100) ? "yes" : "foo") + ); + DumpStringToUSB("\n\r"); DumpStringToUSB( " *\n\r" " *****************************************************\n\r" diff --git a/openpicc/application/iso14443_layer3a.c b/openpicc/application/iso14443_layer3a.c index 8a6abac..8dd9cd2 100644 --- a/openpicc/application/iso14443_layer3a.c +++ b/openpicc/application/iso14443_layer3a.c @@ -91,7 +91,11 @@ void iso14443_layer3a_state_machine (void *pvParameters) pll_init(); tc_cdiv_init(); +#ifdef FOUR_TIMES_OVERSAMPLING tc_cdiv_set_divider(32); +#else + tc_cdiv_set_divider(64); +#endif tc_fdt_init(); #if 0 ssc_tx_init(); diff --git a/openpicc/application/iso14443_layer3a.h b/openpicc/application/iso14443_layer3a.h index 396ebe9..f76a514 100644 --- a/openpicc/application/iso14443_layer3a.h +++ b/openpicc/application/iso14443_layer3a.h @@ -15,4 +15,31 @@ enum ISO14443_STATES { ERROR, /* Some unrecoverable error has occured */ }; +/* standard derived magic values */ +#define ISO14443A_FDT_SHORT_1 1236 +#define ISO14443A_FDT_SHORT_0 1172 + +#ifdef FOUR_TIMES_OVERSAMPLING +/* definitions for four-times oversampling */ +/* Sample values for the REQA and WUPA short frames */ +#define REQA 0x10410441 +#define WUPA 0x04041041 + +/* Start of frame sample for SSC compare 0 */ +#define ISO14443A_SOF_SAMPLE 0x01 +#define ISO14443A_SOF_LEN 4 +/* Length in samples of a short frame */ +#define ISO14443A_SHORT_LEN 32 + +#else +/* definitions for two-times oversampling */ +#define REQA 0x18729 +#define WUPA 0x2249 + +#define ISO14443A_SOF_SAMPLE 0x01 +#define ISO14443A_SOF_LEN 2 +#define ISO14443A_SHORT_LEN 16 + +#endif + #endif /*ISO14443_LAYER3A_H_*/ diff --git a/openpicc/application/main.c b/openpicc/application/main.c index b739f34..37cc24a 100644 --- a/openpicc/application/main.c +++ b/openpicc/application/main.c @@ -88,7 +88,7 @@ void vApplicationIdleHook(void) void main_help_print_buffer(ssc_dma_buffer_t *buffer, int *pktcount) { - u_int32_t *tmp = (u_int32_t*)buffer->data; + u_int16_t *tmp = (u_int16_t*)buffer->data; int i, dumped = 0; unsigned int j; for(i = buffer->len / sizeof(*tmp); i >= 0 ; i--) { @@ -163,7 +163,10 @@ int main (void) vCmdInit(); - //vLedSetGreen(1); + //vLedSetGreen(1); + + /* Remap RAM to addr 0 */ + AT91C_BASE_MC->MC_RCR = AT91C_MC_RCB; vTaskStartScheduler (); diff --git a/openpicc/application/openpicc.h b/openpicc/application/openpicc.h index 15f9143..fc2c4d8 100644 --- a/openpicc/application/openpicc.h +++ b/openpicc/application/openpicc.h @@ -38,4 +38,5 @@ typedef int s_int32_t; #define DA_BASELINE 200 + #endif/*__OPENPICC_H__*/ diff --git a/openpicc/application/pio_irq.c b/openpicc/application/pio_irq.c index 73dbae5..a92ceaa 100644 --- a/openpicc/application/pio_irq.c +++ b/openpicc/application/pio_irq.c @@ -148,7 +148,9 @@ void pio_irq_init_once(void) } #define USE_FIQ +extern void my_fiq_handler(void); extern void fiq_handler(void); + void pio_irq_init(void) { initialized = 1; @@ -156,7 +158,7 @@ void pio_irq_init(void) #ifdef USE_FIQ AT91F_AIC_ConfigureIt(AT91C_ID_FIQ, //0, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, &cdsync_cb); - 0, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, &fiq_handler); + 0, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, &my_fiq_handler); /* enable fast forcing for PIOA interrupt */ *AT91C_AIC_FFER = (1 << AT91C_ID_PIOA); #else diff --git a/openpicc/application/ssc_picc.c b/openpicc/application/ssc_picc.c index 3dbc246..acdf9ae 100644 --- a/openpicc/application/ssc_picc.c +++ b/openpicc/application/ssc_picc.c @@ -45,13 +45,10 @@ #include "tc_fdt.h" #include "usb_print.h" +#include "iso14443_layer3a.h" //#define DEBUG_SSC_REFILL -/* definitions for four-times oversampling */ -#define REQA 0x10410441 -#define WUPA 0x04041041 - static const AT91PS_SSC ssc = AT91C_BASE_SSC; static AT91PS_PDC rx_pdc; @@ -91,10 +88,6 @@ static const u_int16_t ssc_dmasize[] = { [SSC_MODE_CONTINUOUS] = 511, /* 2044 bytes */ }; -/* This is for four-times oversampling */ -#define ISO14443A_SOF_SAMPLE 0x01 -#define ISO14443A_SOF_LEN 4 - #define SSC_RX_IRQ_MASK (AT91C_SSC_RXRDY | \ AT91C_SSC_OVRUN | \ AT91C_SSC_ENDRX | \ @@ -109,6 +102,9 @@ static const u_int16_t ssc_dmasize[] = { AT91C_SSC_TXBUFE | \ AT91C_SSC_TXSYN) +/* This stores the value that SSC_RCMR should be set to when a frame start is detected. + * Will be used in my_fiq_handler in os/boot/boot.s */ +u_int32_t ssc_rcmr_on_start = 0; void ssc_rx_mode_set(enum ssc_mode ssc_mode) { u_int8_t data_len=0, num_data=0, sync_len=0; @@ -123,7 +119,7 @@ void ssc_rx_mode_set(enum ssc_mode ssc_mode) start_cond = AT91C_SSC_START_0; sync_len = ISO14443A_SOF_LEN; ssc->SSC_RC0R = ISO14443A_SOF_SAMPLE; - data_len = 32; + data_len = ISO14443A_SHORT_LEN; num_data = 16; break; case SSC_MODE_14443A_STANDARD: @@ -283,9 +279,6 @@ static int __ramfunc __ssc_rx_refill(int secondary) return 0; } -#define ISO14443A_FDT_SHORT_1 1236 -#define ISO14443A_FDT_SHORT_0 1172 - static void __ramfunc ssc_irq_short_inner(void) __attribute__ ((naked)); static void __ramfunc ssc_irq_short_inner(void) { @@ -458,7 +451,11 @@ static void __ramfunc ssc_irq(void) if (ssc_sr & AT91C_SSC_RXSYN) DEBUGP("RXSYN "); if (ssc_sr & AT91C_SSC_RXRDY) { - u_int32_t sample = ssc->SSC_RHR; + u_int32_t sample = ssc->SSC_RHR; + int i = usb_print_set_default_flush(0); + DumpUIntToUSB(sample); + DumpStringToUSB("\n\r"); + usb_print_set_default_flush(i); DEBUGP("RXRDY=0x%08x ", sample); /* Try to set FDT compare register ASAP */ if (sample == REQA) { |