From ba894ea0e3cf9919ab521bd7de1e66b384cca65a Mon Sep 17 00:00:00 2001 From: henryk Date: Thu, 22 Nov 2007 21:34:42 +0000 Subject: Refactor frame print code out and use in iso14443_layer3a git-svn-id: https://svn.openpcd.org:2342/trunk@345 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpicc/application/iso14443_layer3a.c | 14 +++++++-- openpicc/application/main.c | 53 +++++++++++++++++---------------- 2 files changed, 39 insertions(+), 28 deletions(-) (limited to 'openpicc') diff --git a/openpicc/application/iso14443_layer3a.c b/openpicc/application/iso14443_layer3a.c index 26a6115..8a6abac 100644 --- a/openpicc/application/iso14443_layer3a.c +++ b/openpicc/application/iso14443_layer3a.c @@ -40,9 +40,11 @@ static enum ISO14443_STATES state = STARTING_UP; #define LAYER3_DEBUG usb_print_string +extern void main_help_print_buffer(ssc_dma_buffer_t *buffer, int *pktcount); void iso14443_layer3a_state_machine (void *pvParameters) { unsigned long int last_pll_lock = ~0; + int pktcount=0; (void)pvParameters; while(1) { ssc_dma_buffer_t* buffer = NULL; @@ -106,14 +108,14 @@ void iso14443_layer3a_state_machine (void *pvParameters) case POWERED_OFF: if(switch_on == 1) { state=IDLE; + ssc_rx_mode_set(SSC_MODE_14443A_SHORT); + ssc_rx_start(); continue; } break; case IDLE: case HALT: /* Wait for REQA or WUPA (HALT: only WUPA) */ - ssc_rx_mode_set(SSC_MODE_14443A_SHORT); - ssc_rx_start(); need_receive = 1; default: break; @@ -125,10 +127,16 @@ void iso14443_layer3a_state_machine (void *pvParameters) buffer->state = PROCESSING; portEXIT_CRITICAL(); + DumpStringToUSB("Frame: "); + DumpUIntToUSB(*(u_int32_t*)buffer->data); + DumpStringToUSB(" "); + main_help_print_buffer(buffer, &pktcount); + switch(state) { case IDLE: case HALT: - + ssc_rx_mode_set(SSC_MODE_14443A_SHORT); + ssc_rx_start(); break; default: break; diff --git a/openpicc/application/main.c b/openpicc/application/main.c index 0756d10..b739f34 100644 --- a/openpicc/application/main.c +++ b/openpicc/application/main.c @@ -86,12 +86,36 @@ void vApplicationIdleHook(void) usb_print_flush(); } +void main_help_print_buffer(ssc_dma_buffer_t *buffer, int *pktcount) +{ + u_int32_t *tmp = (u_int32_t*)buffer->data; + int i, dumped = 0; + unsigned int j; + for(i = buffer->len / sizeof(*tmp); i >= 0 ; i--) { + if( *tmp != 0x00000000 ) { + if(dumped == 0) { + DumpUIntToUSB(buffer->len); + DumpStringToUSB(", "); + DumpUIntToUSB((*pktcount)++); + DumpStringToUSB(": "); + } else { + DumpStringToUSB(" "); + } + dumped = 1; + for(j=0; j> j) & 0x1) ? '1' : '_' , 0); + } + usb_print_flush(); + //DumpBufferToUSB((char*)(tmp), sizeof(*tmp)); + } + tmp++; + } + if(dumped) DumpStringToUSB("\n\r"); +} + void vMainTestSSCRXConsumer (void *pvParameters) { - int i, dumped; static int pktcount=0; - unsigned int j; - u_int32_t *tmp; (void)pvParameters; while(1) { ssc_dma_buffer_t* buffer; @@ -106,28 +130,7 @@ void vMainTestSSCRXConsumer (void *pvParameters) vLedBlinkGreen();*/ //i = usb_print_set_default_flush(0); - tmp = (u_int32_t*)buffer->data; - dumped = 0; - for(i = buffer->len / sizeof(*tmp); i >= 0 ; i--) { - if( *tmp != 0x00000000 ) { - if(dumped == 0) { - DumpUIntToUSB(buffer->len); - DumpStringToUSB(", "); - DumpUIntToUSB(pktcount++); - DumpStringToUSB(": "); - } else { - DumpStringToUSB(" "); - } - dumped = 1; - for(j=0; j> j) & 0x1) ? '1' : '_' , 0); - } - usb_print_flush(); - //DumpBufferToUSB((char*)(tmp), sizeof(*tmp)); - } - tmp++; - } - if(dumped) DumpStringToUSB("\n\r"); + main_help_print_buffer(buffer, &pktcount); //usb_print_set_default_flush(i); portENTER_CRITICAL(); -- cgit v1.2.3