summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-08-23 20:23:51 +0000
committer(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-08-23 20:23:51 +0000
commit16e8b89e01418f5f78f8b04ab94238df2c06162c (patch)
treeab56ab3bc7d2e7a50f0094dde4db9a74fae80e0f
parent8be42687141fc32db48bf57ce0fcc13400b3daaf (diff)
add usb benchmarking firmware code
git-svn-id: https://svn.openpcd.org:2342/trunk@123 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
-rw-r--r--openpcd/firmware/Makefile2
-rw-r--r--openpcd/firmware/src/main_usb.c36
-rw-r--r--openpcd/firmware/src/usb_benchmark.c56
3 files changed, 65 insertions, 29 deletions
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 <errno.h>
+#include <string.h>
+#include <lib_AT91SAM7.h>
+#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);
+}
personal git repositories of Harald Welte. Your mileage may vary