summaryrefslogtreecommitdiff
path: root/usb-benchmark-project/benchm_drv.c
diff options
context:
space:
mode:
Diffstat (limited to 'usb-benchmark-project/benchm_drv.c')
-rw-r--r--usb-benchmark-project/benchm_drv.c51
1 files changed, 51 insertions, 0 deletions
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 <stdlib.h>
+#include <stdint.h>
+#include <board.h>
+#include <utility/trace.h>
+
+#include <usb/common/core/USBGenericRequest.h>
+#include <usb/device/core/USBD.h>
+#include <usb/device/core/USBDDriver.h>
+#include <usb/device/core/USBDDriverDescriptors.h>
+#include <usb/device/core/USBDCallbacks.h>
+
+
+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);
+}
personal git repositories of Harald Welte. Your mileage may vary