1
|
/* 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
|
#include <errno.h>
|
21
|
#include <string.h>
|
22
|
#include <lib_AT91SAM7.h>
|
23
|
#include <os/led.h>
|
24
|
#include <os/dbgu.h>
|
25
|
#include <os/pcd_enumerate.h>
|
26
|
#include <os/usb_handler.h>
|
27
|
#include <os/req_ctx.h>
|
28
|
#include "../openpcd.h"
|
29
|
|
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
|
struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data;
|
36
|
struct req_ctx *rctx_new;
|
37
|
int i;
|
38
|
|
39
|
switch (poh->cmd) {
|
40
|
case OPENPCD_CMD_USBTEST_IN:
|
41
|
DEBUGP("USBTEST_IN ");
|
42
|
/* test bulk in pipe */
|
43
|
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
|
}
|
51
|
|
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
|
break;
|
56
|
case OPENPCD_CMD_USBTEST_OUT:
|
57
|
DEBUGP("USBTEST_IN ");
|
58
|
/* test bulk out pipe */
|
59
|
return USB_ERR(USB_ERR_CMD_NOT_IMPL);
|
60
|
break;
|
61
|
}
|
62
|
|
63
|
req_ctx_put(rctx);
|
64
|
return 1;
|
65
|
}
|
66
|
|
67
|
void usbtest_init(void)
|
68
|
{
|
69
|
dummy_rctx.tot_len = 64;
|
70
|
memset(dummy_rctx.data, 0x23, 64);
|
71
|
|
72
|
empty_rctx.tot_len = 0;
|
73
|
|
74
|
usb_hdlr_register(&usbtest_rx, OPENPCD_CMD_CLS_USBTEST);
|
75
|
}
|