From 7c198cbff3872795661b6ded45662dc0a9ba6db9 Mon Sep 17 00:00:00 2001 From: henryk Date: Sat, 15 Dec 2007 20:56:57 +0000 Subject: Record size of SSC RX DMA buffers in transfers, much clearer Change miller decoder to take an RX DMA buffer in order to have access to the reception_mode member, much more versatile git-svn-id: https://svn.openpcd.org:2342/trunk@393 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpicc/application/iso14443a_miller.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'openpicc/application/iso14443a_miller.c') diff --git a/openpicc/application/iso14443a_miller.c b/openpicc/application/iso14443a_miller.c index d7c24cd..a17a6e8 100644 --- a/openpicc/application/iso14443a_miller.c +++ b/openpicc/application/iso14443a_miller.c @@ -24,6 +24,7 @@ #include "iso14443_layer3a.h" #include "usb_print.h" +#include "ssc_picc.h" #include "cmd.h" #ifdef FOUR_TIMES_OVERSAMPLING @@ -49,9 +50,10 @@ enum miller_sequence { #define BIT_ENDMARKER -1 int iso14443a_decode_miller(iso14443_frame *frame, - const u_int8_t *sample_buf, const u_int16_t sample_buf_len) + const ssc_dma_rx_buffer_t *buffer) { - signed int i, j, bit = 0, last_bit = -1, next_to_last_bit = 0; + u_int32_t i,j; + signed int bit = 0, last_bit = ISO14443A_LAST_BIT_NONE, next_to_last_bit = ISO14443A_LAST_BIT_NONE; enum miller_sequence current_seq; unsigned int bitpos = 0; @@ -59,17 +61,23 @@ int iso14443a_decode_miller(iso14443_frame *frame, frame->type = TYPE_A; frame->parameters.a.parity = GIVEN_PARITY; - for(i=0; ilen_transfers && bit != BIT_ENDMARKER; i++) { + u_int32_t sample = 0; DumpStringToUSB(" "); - DumpUIntToUSB(sample_buf[i]); - for(j=0; j<(signed)(sizeof(sample_buf[0])*8)/OVERSAMPLING_RATE && bit != BIT_ENDMARKER; j++) { + switch(buffer->reception_mode->transfersize_pdc) { + case 8: sample = ((u_int8_t*)buffer->data)[i]; break; + case 16: sample = ((u_int16_t*)buffer->data)[i]; break; + case 32: sample = ((u_int32_t*)buffer->data)[i]; break; + } + DumpUIntToUSB(sample); + for(j=0; jreception_mode->transfersize_ssc/OVERSAMPLING_RATE && bit != BIT_ENDMARKER; j++) { DumpStringToUSB("."); - int sample = (sample_buf[i]>>(j*OVERSAMPLING_RATE)) & ~(~0 << OVERSAMPLING_RATE); - switch(sample) { + int bitsample = (sample>>(j*OVERSAMPLING_RATE)) & ~(~0 << OVERSAMPLING_RATE); + switch(bitsample) { case SEQ_X: current_seq = SEQUENCE_X; DumpStringToUSB("X"); break; case SEQ_Y: current_seq = SEQUENCE_Y; DumpStringToUSB("Y"); break; case SEQ_Z: current_seq = SEQUENCE_Z; DumpStringToUSB("Z"); break; - default: DumpUIntToUSB(sample); current_seq = SEQUENCE_Y; + default: DumpUIntToUSB(bitsample); current_seq = SEQUENCE_Y; } switch(current_seq) { -- cgit v1.2.3