From 1a23c27e71edc61acb2425f237a14ca0f90e7a5e Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 1 Dec 2011 21:32:04 +0100 Subject: import usb-benchmark-project this can be used to measure the net USB throughput of a given atmel microcontroller. --- usb-benchmark-project/benchm_drv.c | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 usb-benchmark-project/benchm_drv.c (limited to 'usb-benchmark-project/benchm_drv.c') diff --git a/usb-benchmark-project/benchm_drv.c b/usb-benchmark-project/benchm_drv.c new file mode 100644 index 0000000..c6295f0 --- /dev/null +++ b/usb-benchmark-project/benchm_drv.c @@ -0,0 +1,51 @@ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +extern const USBDDriverDescriptors usb_perf_driver_desc; + +static unsigned char driver_interfaces[3]; +static USBDDriver benchm_driver; + + +/* call-back for control EP requests from the host */ +void USBDCallbacks_RequestReceived(const USBGenericRequest *req) +{ + /* forward all (other) requests to core */ + USBDDriver_RequestHandler(&benchm_driver, req); +} + +void benchmark_drv_init(void) +{ + USBDDriver_Initialize(&benchm_driver, &usb_perf_driver_desc, + driver_interfaces); + USBD_Init(); +} + +const uint8_t test_data[2048]; + +static void wr_compl_cb(void *arg, unsigned char status, unsigned int transferred, unsigned int remain) +{ + uint8_t epnr = arg; + + /* re-start */ + if (status == 0 && remain == 0) { + //printf("."); + benchmark_start(epnr); + } else + printf("Err: EP%u wr_compl, status 0x%02u, xfr %u, remain %u\r\n", + epnr, status, transferred, remain); +} + +void benchmark_start(uint8_t epnr) +{ + USBD_Write(epnr, &test_data, sizeof(test_data), wr_compl_cb, epnr); +} -- cgit v1.2.3