diff options
Diffstat (limited to 'openpicc/application')
-rw-r--r-- | openpicc/application/cmd.c | 24 | ||||
-rw-r--r-- | openpicc/application/iso14443_layer3a.c | 2 | ||||
-rw-r--r-- | openpicc/application/ssc_picc.c | 30 | ||||
-rw-r--r-- | openpicc/application/ssc_picc.h | 12 |
4 files changed, 47 insertions, 21 deletions
diff --git a/openpicc/application/cmd.c b/openpicc/application/cmd.c index 463f514..b66c6c8 100644 --- a/openpicc/application/cmd.c +++ b/openpicc/application/cmd.c @@ -106,6 +106,12 @@ int atoiEx(const char * nptr, char * * eptr) return sign * curval; } +static const struct {ssc_metric metric; char *description;} SSC_METRICS[] = { + {OVERFLOWS, "overflows"}, + {BUFFER_ERRORS, "internal buffer management errors"}, + {FREE_BUFFERS, "free rx buffers"}, + {LATE_FRAMES, "late frames"}, +}; static const struct { int pin; char * description; } PIO_PINS[] = { {OPENPICC_PIO_PLL_LOCK, "pll lock "}, {OPENPICC_PIO_FRAME, "frame start"}, @@ -129,6 +135,7 @@ void print_pio(void) DumpStringToUSB(" *****************************************************\n\r"); } + static const AT91PS_SPI spi = AT91C_BASE_SPI; #define SPI_MAX_XFER_LEN 33 @@ -264,15 +271,14 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { 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 performance metrics:\n\r"); + for(i=0; i<(int)(sizeof(SSC_METRICS)/sizeof(SSC_METRICS[0])); i++) { + DumpStringToUSB(" * \t"); + DumpStringToUSB(SSC_METRICS[i].description); + DumpStringToUSB(": "); + DumpUIntToUSB(ssc_get_metric(SSC_METRICS[i].metric)); + DumpStringToUSB("\n\r"); + } DumpStringToUSB(" * SSC status: "); DumpUIntToUSB(AT91C_BASE_SSC->SSC_SR); DumpStringToUSB("\n\r"); diff --git a/openpicc/application/iso14443_layer3a.c b/openpicc/application/iso14443_layer3a.c index a5db2cd..c4e02cd 100644 --- a/openpicc/application/iso14443_layer3a.c +++ b/openpicc/application/iso14443_layer3a.c @@ -162,7 +162,7 @@ void iso14443_layer3a_state_machine (void *pvParameters) ssc_dma_rx_buffer_t* buffer = NULL; portBASE_TYPE need_receive = 0, switch_on = 0; - if(ssc_get_overflows() > 0 && state != ERROR) { + if(ssc_get_metric(SSC_ERRORS) > 0 && state != ERROR) { LAYER3_DEBUG("SSC overflow error, please debug\n\r"); state = ERROR; } diff --git a/openpicc/application/ssc_picc.c b/openpicc/application/ssc_picc.c index ce507fd..10beaab 100644 --- a/openpicc/application/ssc_picc.c +++ b/openpicc/application/ssc_picc.c @@ -89,15 +89,8 @@ 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) { +static int ssc_count_free(void) { int i,free = 0; for(i=0; i<SSC_DMA_BUFFER_COUNT; i++) { if(dma_buffers[i].state == FREE) free++; @@ -105,6 +98,27 @@ int ssc_count_free(void) { return free; } +int ssc_get_metric(ssc_metric metric) { + switch(metric) { + case OVERFLOWS: + return overflows; + break; + case BUFFER_ERRORS: + return ssc_buffer_errors; + break; + case FREE_BUFFERS: + return ssc_count_free(); + break; + case LATE_FRAMES: + return late_frames; + break; + case SSC_ERRORS: + return ssc_get_metric(OVERFLOWS) + ssc_get_metric(BUFFER_ERRORS); + break; + } + return 0; +} + static ssc_dma_rx_buffer_t* __ramfunc ssc_find_dma_buffer(ssc_dma_buffer_state_t oldstate, ssc_dma_buffer_state_t newstate) { diff --git a/openpicc/application/ssc_picc.h b/openpicc/application/ssc_picc.h index a90f13e..df6da36 100644 --- a/openpicc/application/ssc_picc.h +++ b/openpicc/application/ssc_picc.h @@ -38,9 +38,15 @@ typedef void (*ssc_irq_ext_t)(u_int32_t ssc_sr, enum ssc_mode ssc_mode, u_int8_t * than acceptable for the synchronous responses (around 87us).*/ 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); +/* These are various SSC performance metrics that can be queried */ +typedef enum { + OVERFLOWS, /* Overflows (e.g. no free buffer when reloading DMA controller) */ + BUFFER_ERRORS, /* Internal buffer management errors */ + FREE_BUFFERS, /* Free RX buffers */ + LATE_FRAMES, /* Frames that were not ready to be sent when the FDT passed; e.g. sent too late */ + SSC_ERRORS, /* General error count, e.g. OVERFLOWS + BUFFER_ERRORS */ +} ssc_metric; +extern int ssc_get_metric(ssc_metric metric); #define SSC_DMA_BUFFER_SIZE 2048 #define SSC_DMA_BUFFER_COUNT 4 |