From d256545b2fd62d78910efcc6273c3b70abd3aa13 Mon Sep 17 00:00:00 2001 From: laforge Date: Tue, 12 Sep 2006 17:35:30 +0000 Subject: move to new directory git-svn-id: https://svn.openpcd.org:2342/trunk@191 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- firmware/src/os/usb_benchmark.c | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 firmware/src/os/usb_benchmark.c (limited to 'firmware/src/os/usb_benchmark.c') diff --git a/firmware/src/os/usb_benchmark.c b/firmware/src/os/usb_benchmark.c new file mode 100644 index 0000000..3637bc3 --- /dev/null +++ b/firmware/src/os/usb_benchmark.c @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include +#include +#include +#include "../openpcd.h" + +static struct req_ctx dummy_rctx; +static struct req_ctx empty_rctx; + +static void usbtest_tx_transfer(unsigned int num_pkts) +{ + unsigned int i; + + for (i = 0; i < num_pkts; i++) { + /* send 16 packets of 64byte */ + while (udp_refill_ep(2, &dummy_rctx) < 0) + ; + } + /* send one packet of 0 byte */ + while (udp_refill_ep(2, &empty_rctx) < 0) + ; +} + +static int usbtest_rx(struct req_ctx *rctx) +{ + struct openpcd_hdr *poh = (struct openpcd_hdr *) &rctx->rx.data[0]; + int i; + + switch (poh->cmd) { + case OPENPCD_CMD_USBTEST_IN: + /* test bulk in pipe */ + for (i = 0; i < poh->reg; i++) { + usbtest_tx_transfer(poh->val); + led_toggle(2); + } + break; + case OPENPCD_CMD_USBTEST_OUT: + /* test bulk out pipe */ + break; + } + + req_ctx_put(rctx); + return 1; +} + +void usbtest_init(void) +{ + dummy_rctx.tx.tot_len = 64; + memset(dummy_rctx.tx.data, 0x23, 64); + + empty_rctx.tx.tot_len = 0; + + usb_hdlr_register(&usbtest_rx, OPENPCD_CMD_CLS_USBTEST); +} -- cgit v1.2.3