From 16e8b89e01418f5f78f8b04ab94238df2c06162c Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> Date: Wed, 23 Aug 2006 20:23:51 +0000 Subject: add usb benchmarking firmware code git-svn-id: https://svn.openpcd.org:2342/trunk@123 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpcd/firmware/Makefile | 2 +- openpcd/firmware/src/main_usb.c | 36 ++++++----------------- openpcd/firmware/src/usb_benchmark.c | 56 ++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 29 deletions(-) create mode 100644 openpcd/firmware/src/usb_benchmark.c diff --git a/openpcd/firmware/Makefile b/openpcd/firmware/Makefile index d9f902c..4312257 100644 --- a/openpcd/firmware/Makefile +++ b/openpcd/firmware/Makefile @@ -76,7 +76,7 @@ SRCARM = lib/lib_AT91SAM7.c SRCARM += src/pcd_enumerate.c src/fifo.c src/dbgu.c \ src/led.c src/rc632.c src/rc632_highlevel.c src/req_ctx.c \ src/trigger.c src/main.c src/syscalls.c src/pwm.c src/tc.c \ - src/usb_handler.c src/ssc.c \ + src/usb_handler.c src/ssc.c src/usb_benchmark.c \ src/$(TARGET).c src/start/Cstartup_SAM7.c ifdef DEBUG SRCARM += lib/vsprintf.c lib/ctype.c lib/string.c diff --git a/openpcd/firmware/src/main_usb.c b/openpcd/firmware/src/main_usb.c index 1002db5..ee9556c 100644 --- a/openpcd/firmware/src/main_usb.c +++ b/openpcd/firmware/src/main_usb.c @@ -15,30 +15,10 @@ #include "pcd_enumerate.h" #include "usb_handler.h" -static char usb_buf1[64]; -static char usb_buf2[64]; -static struct req_ctx dummy_rctx1; - - static void help(void) { } -void _init_func(void) -{ - DEBUGPCR("\r\n===> main_usb <===\r\n"); - help(); - - udp_init(); - - memset(usb_buf1, '1', sizeof(usb_buf1)); - memset(usb_buf2, '2', sizeof(usb_buf2)); - - dummy_rctx1.tx.tot_len = sizeof(usb_buf1); - memcpy(dummy_rctx1.tx.data, usb_buf1, sizeof(usb_buf1)); - -} - int _main_dbgu(char key) { switch (key) { @@ -49,21 +29,21 @@ int _main_dbgu(char key) return 0; } +void _init_func(void) +{ + udp_init(); + usbtest_init(); +} + void _main_func(void) { /* first we try to get rid of pending to-be-sent stuff */ //usb_out_process(); /* next we deal with incoming reqyests from USB EP1 (OUT) */ - //usb_in_process(); + usb_in_process(); /* try unthrottling sources since we now are [more] likely to * have empty request contexts */ - //udp_unthrottle(); - - while (udp_refill_ep(2, &dummy_rctx1) < 0) ; - - DEBUGP("S"); - - //led_toggle(2); + udp_unthrottle(); } diff --git a/openpcd/firmware/src/usb_benchmark.c b/openpcd/firmware/src/usb_benchmark.c new file mode 100644 index 0000000..9f593f8 --- /dev/null +++ b/openpcd/firmware/src/usb_benchmark.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include "openpcd.h" +#include "led.h" +#include "pcd_enumerate.h" +#include "usb_handler.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