summaryrefslogtreecommitdiff
path: root/openpicc/application/ssc_picc.c
diff options
context:
space:
mode:
authorhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-12-09 06:10:56 +0000
committerhenryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2007-12-09 06:10:56 +0000
commitceb643380b02d0d8289e3ad75a495123414ace8c (patch)
treecf37628d2b07d7cebc2a4f04d5f8ea2488eb9d57 /openpicc/application/ssc_picc.c
parentbdc39aadd1a26d7709ff15722be90c016be2057a (diff)
Prevent late frames by spinning in SSC CP0 IRQ till end of short frame reception
Fix tc_cdiv_set_divider. again. Reverse the polarity! (of the ssc transmit clock) git-svn-id: https://svn.openpcd.org:2342/trunk@381 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application/ssc_picc.c')
-rw-r--r--openpicc/application/ssc_picc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/openpicc/application/ssc_picc.c b/openpicc/application/ssc_picc.c
index 98f9e46..ce507fd 100644
--- a/openpicc/application/ssc_picc.c
+++ b/openpicc/application/ssc_picc.c
@@ -313,7 +313,7 @@ void ssc_tx_start(ssc_dma_tx_buffer_t *buf)
ssc->SSC_TFMR = ((data_len-1) & 0x1f) |
(((num_data-1) & 0x0f) << 8) |
(((sync_len-1) & 0x0f) << 16);
- ssc->SSC_TCMR = 0x01 | AT91C_SSC_CKO_NONE | start_cond;
+ ssc->SSC_TCMR = 0x01 | AT91C_SSC_CKO_NONE | AT91C_SSC_CKI | start_cond;
AT91F_PDC_SetTx(tx_pdc, buf->data, num_data);
AT91F_PDC_SetNextTx(tx_pdc, 0, 0);
@@ -381,11 +381,27 @@ static void __ramfunc ssc_irq(void)
portBASE_TYPE task_woken = pdFALSE;
u_int32_t ssc_sr = ssc->SSC_SR;
+ u_int32_t orig_ssc_sr = ssc_sr;
int i, emptyframe = 0;
u_int32_t *tmp;
ssc_dma_rx_buffer_t *inbuf=NULL;
DEBUGP("ssc_sr=0x%08x, mode=%u: ", ssc_sr, ssc_state.mode);
+ if (ssc_sr & AT91C_SSC_CP0 && ssc_state.mode == SSC_MODE_14443A_SHORT) {
+ /* Short frame, busy loop till the frame is received completely to
+ * prevent a second irq entrance delay when the actual frame end
+ * irq is raised. (The scheduler masks interrupts for about 56us,
+ * which is too much for anticollision.) */
+ int i = 0;
+ vLedBlinkRed();
+ while( ! ((ssc_sr=ssc->SSC_SR) & AT91C_SSC_ENDRX) ) {
+ i++;
+ if(i > 9600) break;
+ }
+ ssc_sr |= orig_ssc_sr;
+ vLedSetRed(1);
+ }
+
if (ssc_sr & AT91C_SSC_ENDRX) {
/* Ignore empty frames */
if (ssc_state.mode == SSC_MODE_CONTINUOUS) {
personal git repositories of Harald Welte. Your mileage may vary