From 84763f9c33b54ecd74565fce8ea633f83a7aaa45 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 2 Dec 2011 22:51:44 +0100 Subject: fix fast audio source test, generates 640 kS/s to 1 Ms/s now --- usb-fast-audio-source/AUDDFastSourceDescriptors.h | 2 +- usb-fast-audio-source/Makefile | 2 +- usb-fast-audio-source/fast_source.c | 22 +++++++++++++++------- usb-fast-audio-source/fast_source.h | 6 +++--- usb-fast-audio-source/main.c | 8 +++++++- 5 files changed, 27 insertions(+), 13 deletions(-) (limited to 'usb-fast-audio-source') diff --git a/usb-fast-audio-source/AUDDFastSourceDescriptors.h b/usb-fast-audio-source/AUDDFastSourceDescriptors.h index ab25f49..594adb5 100644 --- a/usb-fast-audio-source/AUDDFastSourceDescriptors.h +++ b/usb-fast-audio-source/AUDDFastSourceDescriptors.h @@ -89,7 +89,7 @@ #endif /// Endpoint polling interval 2^(x-1) * 125us -#define AUDDLoopRecDriverDescriptors_HS_INTERVAL 0x04 +#define AUDDLoopRecDriverDescriptors_HS_INTERVAL 0x01 /// Endpoint polling interval 2^(x-1) * ms #define AUDDLoopRecDriverDescriptors_FS_INTERVAL 0x01 //------------------------------------------------------------------------------ diff --git a/usb-fast-audio-source/Makefile b/usb-fast-audio-source/Makefile index 38ea27d..8444be8 100644 --- a/usb-fast-audio-source/Makefile +++ b/usb-fast-audio-source/Makefile @@ -45,7 +45,7 @@ BOARD = at91sam3u-ek # TRACE_LEVEL_ERROR 2 # TRACE_LEVEL_FATAL 1 # TRACE_LEVEL_NO_TRACE 0 -TRACE_LEVEL = 5 +TRACE_LEVEL = 4 # Optimization level, put in comment for debugging OPTIMIZATION = -Os diff --git a/usb-fast-audio-source/fast_source.c b/usb-fast-audio-source/fast_source.c index 7d20c7e..d9633fe 100644 --- a/usb-fast-audio-source/fast_source.c +++ b/usb-fast-audio-source/fast_source.c @@ -19,6 +19,8 @@ extern const USBDDriverDescriptors auddFastSourceDriverDescriptors; static unsigned char driver_interfaces[3]; static USBDDriver fast_source_driver; +#define EP_NR 6 + /* callback */ void USBDCallbacks_RequestReceived(const USBGenericRequest *request) { @@ -117,24 +119,30 @@ void fastsource_init(void) USBD_Init(); } -const uint8_t test_data[2048]; +const uint8_t test_data[AUDDLoopRecDriver_BYTESPERFRAME] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; static void wr_compl_cb(void *arg, unsigned char status, unsigned int transferred, unsigned int remain) { - uint8_t epnr = (uint8_t) arg; + //TRACE_INFO("COMPL: status %u transferred %u remain %u\r\n", status, transferred, remain); + //TRACE_INFO("."); if (status == 0 && remain == 0) { - fastsource_start(epnr); + fastsource_start(); } else { - printf("Err: EP%u wr_compl, status 0x%02u, xfr %u, remain %u\r\n", - epnr, status, transferred, remain); + TRACE_WARNING("Err: EP%u wr_compl, status 0x%02u, xfr %u, remain %u\r\n", + EP_NR, status, transferred, remain); } } -void fastsource_start(uint8_t epnr) +void fastsource_start(void) { - USBD_Write(epnr, &test_data, sizeof(test_data), wr_compl_cb, (void *) epnr); + //TRACE_WARNING("DATA: %02x %02x %02x %02x\r\n", test_data[0], test_data[1], test_data[2], test_data[3]); + USBD_Write(EP_NR, test_data, sizeof(test_data), wr_compl_cb, NULL); } diff --git a/usb-fast-audio-source/fast_source.h b/usb-fast-audio-source/fast_source.h index 1fc0b2b..d448b15 100644 --- a/usb-fast-audio-source/fast_source.h +++ b/usb-fast-audio-source/fast_source.h @@ -1,11 +1,11 @@ #include -#define AUDDLoopRecDriver_SAMPLERATE 512000 +#define AUDDLoopRecDriver_SAMPLERATE 640000 #define AUDDLoopRecDriver_NUMCHANNELS 2 #define AUDDLoopRecDriver_BYTESPERSAMPLE 2 -#define AUDDLoopRecDriver_SAMPLESPERFRAME (AUDDLoopRecDriver_SAMPLERATE / 16384 \ +#define AUDDLoopRecDriver_SAMPLESPERFRAME (AUDDLoopRecDriver_SAMPLERATE / 5000 \ * AUDDLoopRecDriver_NUMCHANNELS) #define AUDDLoopRecDriver_BYTESPERFRAME (AUDDLoopRecDriver_SAMPLESPERFRAME * \ @@ -14,5 +14,5 @@ #include void fastsource_init(void); -void fastsource_start(uint8_t epnr); +void fastsource_start(void); void fastsource_req_hdlr(const USBGenericRequest *request); diff --git a/usb-fast-audio-source/main.c b/usb-fast-audio-source/main.c index 57808a1..cc57325 100644 --- a/usb-fast-audio-source/main.c +++ b/usb-fast-audio-source/main.c @@ -272,6 +272,8 @@ int main(void) volatile uint8_t usbConn = 0; volatile uint8_t plyOn = 0, recOn = 0; + TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK); + printf("-- USB Device Fast Audio Source %s --\n\r", SOFTPACK_VERSION); printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); @@ -291,7 +293,7 @@ int main(void) /* connect if needed */ VBus_Configure(); - fastsource_start(0x86); + static int state = 0; /* Infinite loop */ while (1) @@ -301,6 +303,10 @@ int main(void) usbConn = 0; continue; } + if (state == 0) { + fastsource_start(); + state = 1; + } if (plyOn) { if (isPlyActive == 0) -- cgit v1.2.3