Project

General

Profile

Download (2.07 KB) Statistics
| Branch: | Tag: | Revision:
1 32985a29 laforge
/* AT91SAM7 USB benchmark routines for OpenPCD / OpenPICC
2
 * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
3
 *
4
 *  This program is free software; you can redistribute it and/or modify
5
 *  it under the terms of the GNU General Public License as published by 
6
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  (at your option) any later version.
8
 *
9
 *  This program is distributed in the hope that it will be useful,
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU General Public License
15
 *  along with this program; if not, write to the Free Software
16
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
18
 */
19
20 16e8b89e (no author)
#include <errno.h>
21
#include <string.h>
22
#include <lib_AT91SAM7.h>
23 520784c7 (no author)
#include <os/led.h>
24 706ffa9f laforge
#include <os/dbgu.h>
25 520784c7 (no author)
#include <os/pcd_enumerate.h>
26
#include <os/usb_handler.h>
27
#include <os/req_ctx.h>
28
#include "../openpcd.h"
29 16e8b89e (no author)
30
static struct req_ctx dummy_rctx;
31
static struct req_ctx empty_rctx;
32
33
static int usbtest_rx(struct req_ctx *rctx)
34
{
35 514b0f72 laforge
	struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
36 706ffa9f laforge
	struct req_ctx *rctx_new;
37 16e8b89e (no author)
	int i;
38
39
	switch (poh->cmd) {
40
	case OPENPCD_CMD_USBTEST_IN:
41 706ffa9f laforge
		DEBUGP("USBTEST_IN ");
42 16e8b89e (no author)
		/* test bulk in pipe */
43 706ffa9f laforge
		if (poh->val > RCTX_SIZE_LARGE/AT91C_EP_OUT_SIZE)
44
			poh->val = RCTX_SIZE_LARGE/AT91C_EP_OUT_SIZE;
45
		rctx_new = req_ctx_find_get(1, RCTX_STATE_FREE,
46
					    RCTX_STATE_MAIN_PROCESSING);
47
		if (!rctx_new) {
48
			DEBUGP("NO RCTX ");
49
			return USB_ERR(0);
50 16e8b89e (no author)
		}
51 706ffa9f laforge
52
		rctx_new->tot_len = poh->val * AT91C_EP_OUT_SIZE;
53
		req_ctx_set_state(rctx_new, RCTX_STATE_UDP_EP2_PENDING);
54
		led_toggle(2);
55 16e8b89e (no author)
		break;
56
	case OPENPCD_CMD_USBTEST_OUT:
57 706ffa9f laforge
		DEBUGP("USBTEST_IN ");
58 16e8b89e (no author)
		/* test bulk out pipe */
59 706ffa9f laforge
		return USB_ERR(USB_ERR_CMD_NOT_IMPL);
60 16e8b89e (no author)
		break;
61
	}
62
63
	req_ctx_put(rctx);
64
	return 1;
65
}
66
67
void usbtest_init(void)
68
{
69 514b0f72 laforge
	dummy_rctx.tot_len = 64;
70
	memset(dummy_rctx.data, 0x23, 64);
71 16e8b89e (no author)
72 514b0f72 laforge
	empty_rctx.tot_len = 0;
73 16e8b89e (no author)
74
	usb_hdlr_register(&usbtest_rx, OPENPCD_CMD_CLS_USBTEST);
75
}
Add picture from clipboard (Maximum size: 48.8 MB)