diff options
author | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-13 00:47:14 +0000 |
---|---|---|
committer | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-13 00:47:14 +0000 |
commit | 3d0a9bd40be2d014e0877eb623042c899d8cbe66 (patch) | |
tree | 16afede5c836924716cbd916ad1d63e5cc1be7c5 /openpicc/application | |
parent | 1dfa375abb95c59830c38697c53fa9a6794a9fb9 (diff) |
Add PIO IRQ counter (and print it in 'c' command)
Make tc_cdiv_sync interrupt working
Add 'p' command to print some PIO inputs
Add 'z' command to enable/disable tc_cdiv_sync
git-svn-id: https://svn.openpcd.org:2342/trunk@324 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application')
-rw-r--r-- | openpicc/application/cmd.c | 46 | ||||
-rw-r--r-- | openpicc/application/main.c | 3 | ||||
-rw-r--r-- | openpicc/application/pio_irq.c | 8 | ||||
-rw-r--r-- | openpicc/application/pio_irq.h | 1 | ||||
-rw-r--r-- | openpicc/application/tc_cdiv_sync.c | 47 | ||||
-rw-r--r-- | openpicc/application/tc_cdiv_sync.h | 1 |
6 files changed, 66 insertions, 40 deletions
diff --git a/openpicc/application/cmd.c b/openpicc/application/cmd.c index 7ff7f53..d7ce784 100644 --- a/openpicc/application/cmd.c +++ b/openpicc/application/cmd.c @@ -11,6 +11,8 @@ #include "openpicc.h" #include "led.h" #include "da.h" +#include "tc_cdiv_sync.h" +#include "pio_irq.h" xQueueHandle xCmdQueue; xTaskHandle xCmdTask; @@ -26,7 +28,7 @@ static const portBASE_TYPE USE_COLON_FOR_LONG_COMMANDS = 0; /* When not USE_COLON_FOR_LONG_COMMANDS then short commands will be recognized by including * their character in the string SHORT_COMMANDS * */ -static const char *SHORT_COMMANDS = "c+-l?h"; +static const char *SHORT_COMMANDS = "pc+-l?h"; /* Note that the long/short command distinction only applies to the USB serial console * */ @@ -92,6 +94,29 @@ int atoiEx(const char * nptr, char * * eptr) return sign * curval; } +static const struct { int pin; char * description; } PIO_PINS[] = { + {OPENPICC_PIO_PLL_LOCK, "pll lock "}, + {OPENPICC_PIO_FRAME, "frame start"}, +}; +void print_pio(void) +{ + int data = *AT91C_PIOA_PDSR; + unsigned int i; + DumpStringToUSB( + " *****************************************************\n\r" + " * Current PIO readings: *\n\r" + " *****************************************************\n\r" + " *\n\r"); + for(i=0; i<sizeof(PIO_PINS)/sizeof(PIO_PINS[0]); i++) { + DumpStringToUSB(" * "); + DumpStringToUSB(PIO_PINS[i].description); + DumpStringToUSB(": "); + DumpUIntToUSB((data & PIO_PINS[i].pin) ? 1 : 0 ); + DumpStringToUSB("\n\r"); + } + DumpStringToUSB(" *****************************************************\n\r"); +} + static const AT91PS_SPI spi = AT91C_BASE_SPI; #define SPI_MAX_XFER_LEN 33 @@ -157,6 +182,19 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { DumpStringToUSB("\n\r"); } break; + case 'Z': + i=atoiEx(args, &args); + if(i==0) { + tc_cdiv_sync_disable(); + DumpStringToUSB("cdiv_sync disabled \n\r"); + } else { + tc_cdiv_sync_enable(); + DumpStringToUSB("cdiv_sync enabled \n\r"); + } + break; + case 'P': + print_pio(); + break; case 'C': DumpStringToUSB( " *****************************************************\n\r" @@ -188,6 +226,10 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { DumpStringToUSB(" * The comparator threshold is "); DumpUIntToUSB(da_get_value()); DumpStringToUSB("\n\r"); + DumpStringToUSB(" * Number of PIO IRQs handled: "); + i = pio_irq_get_count() & (~(unsigned int)0); + DumpUIntToUSB(i); + DumpStringToUSB("\n\r"); DumpStringToUSB( " *\n\r" " *****************************************************\n\r" @@ -232,6 +274,8 @@ void prvExecCommand(u_int32_t cmd, portCHAR *args) { " * 1..4 - automatic transmit at selected power levels\n\r" " * +,- - decrease/increase comparator threshold\n\r" " * l - cycle LEDs\n\r" + " * p - print PIO pins\n\r" + " * z 0/1- enable or disable tc_cdiv_sync\n\r" " * ?,h - display this help screen\n\r" " *\n\r" " *****************************************************\n\r" diff --git a/openpicc/application/main.c b/openpicc/application/main.c index 1bd23ae..8f950ab 100644 --- a/openpicc/application/main.c +++ b/openpicc/application/main.c @@ -42,6 +42,7 @@ #include "pll.h" #include "pio_irq.h" #include "ssc_picc.h" +#include "tc_cdiv_sync.h" /**********************************************************************/ static inline void prvSetupHardware (void) @@ -84,7 +85,9 @@ int main (void) pio_irq_init(); + tc_cdiv_sync_init(); ssc_tx_init(); + //ssc_rx_init(); vLedInit(); diff --git a/openpicc/application/pio_irq.c b/openpicc/application/pio_irq.c index 572a4e4..c7238d8 100644 --- a/openpicc/application/pio_irq.c +++ b/openpicc/application/pio_irq.c @@ -38,6 +38,7 @@ struct pioirq_state { }; static struct pioirq_state pirqs; +static unsigned long count = 0; /* low-level handler, used by Cstartup_app.S PIOA fast forcing and * by regular interrupt handler below */ @@ -45,6 +46,7 @@ void __ramfunc __pio_irq_demux(u_int32_t pio) { u_int8_t send_usb = 0; int i; + count++; DEBUGPCRF("PIO_ISR_STATUS = 0x%08x", pio); @@ -101,6 +103,12 @@ void pio_irq_disable(u_int32_t pio) AT91F_PIO_InterruptDisable(AT91C_BASE_PIOA, pio); } +/* Return the number of PIO IRQs received */ +long pio_irq_get_count(void) +{ + return count; +} + int pio_irq_register(u_int32_t pio, irq_handler_t *handler) { u_int8_t num = ffs(pio); diff --git a/openpicc/application/pio_irq.h b/openpicc/application/pio_irq.h index 65a0f9d..ecb6fef 100644 --- a/openpicc/application/pio_irq.h +++ b/openpicc/application/pio_irq.h @@ -8,6 +8,7 @@ typedef void irq_handler_t(u_int32_t pio); extern void pio_irq_enable(u_int32_t pio); extern void pio_irq_disable(u_int32_t pio); +extern long pio_irq_get_count(void); extern int pio_irq_register(u_int32_t pio, irq_handler_t *func); extern void pio_irq_unregister(u_int32_t pio); extern void pio_irq_init(void); diff --git a/openpicc/application/tc_cdiv_sync.c b/openpicc/application/tc_cdiv_sync.c index 486e93b..45c65b6 100644 --- a/openpicc/application/tc_cdiv_sync.c +++ b/openpicc/application/tc_cdiv_sync.c @@ -5,12 +5,12 @@ #include "dbgu.h" #include "pio_irq.h" #include "openpicc.h" +#include "led.h" #define USE_IRQ static u_int8_t enabled; -#if 0 static void pio_data_change(u_int32_t pio) { (void)pio; @@ -24,29 +24,9 @@ static void pio_data_change(u_int32_t pio) *AT91C_TC0_CV); } else DEBUGPCR(""); + vLedSetGreen(0); } -#else - -static void __ramfunc cdsync_cb(void) -{ - DEBUGP("PIO_IRQ: "); - if (*AT91C_PIOA_ISR & OPENPICC_PIO_FRAME) { - DEBUGP("PIO_FRAME_IRQ: "); - /* we get one interrupt for each change. If now, after the - * change the level is high, then it must have been a rising - * edge */ - if (*AT91C_PIOA_PDSR & OPENPICC_PIO_FRAME) { - *AT91C_TC0_CCR = AT91C_TC_SWTRG; - DEBUGPCR("CDIV_SYNC_FLIP SWTRG CV=0x%08x", - *AT91C_TC0_CV); - } else - DEBUGPCR(""); - } else - DEBUGPCR(""); -} -#endif - void tc_cdiv_sync_reset(void) { if (enabled) { @@ -54,6 +34,7 @@ void tc_cdiv_sync_reset(void) (void)tmp; volatile int i; DEBUGPCRF("CDIV_SYNC_FLOP"); + vLedSetGreen(1); /* reset the hardware flipflop */ AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, @@ -87,24 +68,12 @@ void tc_cdiv_sync_init(void) enabled = 0; AT91F_PIOA_CfgPMC(); - -#ifdef USE_IRQ - /* Configure IRQ */ - AT91F_AIC_ConfigureIt(AT91C_ID_PIOA, - AT91C_AIC_PRIOR_HIGHEST, - AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, (THandler)&cdsync_cb); -#else - /* Configure FIQ */ - AT91F_AIC_ConfigureIt(AT91C_ID_FIQ, - //0, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, &cdsync_cb); - 0, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, (THandler)&fiq_handler); - /* enable fast forcing for PIOA interrupt */ - *AT91C_AIC_FFER = (1 << AT91C_ID_PIOA); - - /* register pio irq handler */ + + AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPICC_PIO_SSC_DATA_CONTROL); + pio_irq_register(OPENPICC_PIO_FRAME, &pio_data_change); -#endif AT91F_AIC_EnableIt(AT91C_ID_PIOA); - + + vLedSetGreen(0); tc_cdiv_sync_disable(); } diff --git a/openpicc/application/tc_cdiv_sync.h b/openpicc/application/tc_cdiv_sync.h index 0101321..0c7bd37 100644 --- a/openpicc/application/tc_cdiv_sync.h +++ b/openpicc/application/tc_cdiv_sync.h @@ -1,5 +1,6 @@ #ifndef _TC_CDIV_SYNC_H #define _TC_CDIV_SYNC_H +extern void tc_cdiv_sync_disable(void); extern void tc_cdiv_sync_enable(void); extern void tc_cdiv_sync_init(void); extern void tc_cdiv_sync_reset(void); |