diff options
author | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-21 00:30:19 +0000 |
---|---|---|
committer | henryk <henryk@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2007-11-21 00:30:19 +0000 |
commit | 5cc0ed498f99d3b23c6f1b87a9a2fdcbb05dd1a9 (patch) | |
tree | e0f681d5a7fc06f192abdac3961ab39e08f98592 /openpicc/application/main.c | |
parent | ac77f6b5c53c4f2afb97564d1d281c5fdc429409 (diff) |
Checking in status quo: Can currently receive and print frames in ssc continuous mode (with new short and incomplete ssc irq handler: FIXME, either switch back to original handler (maybe fixing it
if necessary) or handle the missing cases in the new handler). Lots of debug statements still in there
git-svn-id: https://svn.openpcd.org:2342/trunk@335 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpicc/application/main.c')
-rw-r--r-- | openpicc/application/main.c | 66 |
1 files changed, 65 insertions, 1 deletions
diff --git a/openpicc/application/main.c b/openpicc/application/main.c index fd776ec..e13c793 100644 --- a/openpicc/application/main.c +++ b/openpicc/application/main.c @@ -74,8 +74,10 @@ static inline void prvSetupHardware (void) void vApplicationIdleHook(void) { static char disabled_green = 0; + //static int i=0; /* Restart watchdog, has been enabled in Cstartup_SAM7.c */ AT91F_WDTRestart(AT91C_BASE_WDTC); + //vLedSetGreen(i^=1); if(!disabled_green) { //vLedSetGreen(0); disabled_green = 1; @@ -83,6 +85,57 @@ void vApplicationIdleHook(void) usb_print_flush(); } +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; + if(xQueueReceive(ssc_rx_queue, &buffer, portMAX_DELAY)) { + portENTER_CRITICAL(); + buffer->state = PROCESSING; + portEXIT_CRITICAL(); + /*vLedBlinkGreen(); + for(i=0; i<buffer->len*8; i++) { + vLedSetGreen( buffer->data[i/8] & (1<<(i%8)) ); + } + 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<sizeof(*tmp)*8; j++) { + usb_print_char_f( (((*tmp) >> j) & 0x1) ? '1' : '_' , 0); + } + usb_print_flush(); + //DumpBufferToUSB((char*)(tmp), sizeof(*tmp)); + } + tmp++; + } + if(dumped) DumpStringToUSB("\n\r"); + + //usb_print_set_default_flush(i); + portENTER_CRITICAL(); + buffer->state = FREE; + portEXIT_CRITICAL(); + } + } +} + /**********************************************************************/ int main (void) { @@ -99,9 +152,20 @@ int main (void) pll_init(); tc_cdiv_init(); + tc_cdiv_set_divider(16); tc_fdt_init(); +#if 0 ssc_tx_init(); - //ssc_rx_init(); +#else + AT91F_PIO_CfgInput(AT91C_BASE_PIOA, OPENPICC_MOD_PWM); + AT91F_PIO_CfgPeriph(AT91C_BASE_PIOA, OPENPICC_MOD_SSC | + OPENPICC_SSC_DATA | OPENPICC_SSC_DATA | + AT91C_PIO_PA15, 0); +#endif + ssc_rx_init(); + + xTaskCreate (vMainTestSSCRXConsumer, (signed portCHAR *) "SSC_CONSUMER", TASK_USB_STACK, + NULL, TASK_USB_PRIORITY, NULL); xTaskCreate (vUSBCDCTask, (signed portCHAR *) "USB", TASK_USB_STACK, NULL, TASK_USB_PRIORITY, NULL); |