summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2007-08-30 19:23:37 +0000
committerChristian Gmeiner <christian.gmeiner@gmail.com>2007-08-30 19:23:37 +0000
commit3a0c78bb76c2f8a89208121194f0706689254c6a (patch)
treef31121fa38df9c0df5e0926e7818dc0bf6917611
parent771752010280ac3c10fcb46e14cb622249bc56d9 (diff)
downloadrockbox-3a0c78bb76c2f8a89208121194f0706689254c6a.zip
rockbox-3a0c78bb76c2f8a89208121194f0706689254c6a.tar.gz
rockbox-3a0c78bb76c2f8a89208121194f0706689254c6a.tar.bz2
rockbox-3a0c78bb76c2f8a89208121194f0706689254c6a.tar.xz
add usb state handling and other small fixes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14541 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/usb/arcotg_dcd.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/firmware/drivers/usb/arcotg_dcd.c b/firmware/drivers/usb/arcotg_dcd.c
index 41f3e90..9ffc6aa 100644
--- a/firmware/drivers/usb/arcotg_dcd.c
+++ b/firmware/drivers/usb/arcotg_dcd.c
@@ -283,6 +283,7 @@ static void setup_received_int(struct usb_ctrlrequest* request)
{
int error = 0;
uint8_t address = 0;
+ bool set_config = false;
int handled = 0; /* set to zero if we do not handle the message, */
/* and should pass it to the driver */
@@ -295,15 +296,17 @@ static void setup_received_int(struct usb_ctrlrequest* request)
switch (request->bRequest) {
case USB_REQ_SET_ADDRESS:
-
/* store address as we need to ack before setting it */
address = (uint8_t)request->wValue;
handled = 1;
break;
- case USB_REQ_GET_STATUS:
+ case USB_REQ_SET_CONFIGURATION:
+ set_config = true;
+ break;
+ case USB_REQ_GET_STATUS:
logf("sending status..");
response.buf = &dcd_controller.usb_state;
response.length = 2;
@@ -365,9 +368,18 @@ static void setup_received_int(struct usb_ctrlrequest* request)
/* ack transfer */
usb_ack(request, error);
+ /* set address and usb state after USB_REQ_SET_ADDRESS */
if (address != 0) {
logf("setting address to %d", address);
UDC_DEVICEADDR = address << 25;
+ dcd_controller.usb_state = USB_STATE_ADDRESS;
+ }
+
+ /* update usb state after successfull USB_REQ_SET_CONFIGURATION */
+ if (set_config) {
+ if (handled > 0) {
+ dcd_controller.usb_state = USB_STATE_CONFIGURED;
+ }
}
}
@@ -444,9 +456,14 @@ static void resume_int(void)
static void reset_int(void)
{
- //logf("reset_int");
struct timer t;
+ /* clear device address */
+ UDC_DEVICEADDR = 0 << 25;
+
+ /* update usb state */
+ dcd_controller.usb_state = USB_STATE_DEFAULT;
+
timer_set(&t, RESET_TIMER);
UDC_ENDPTSETUPSTAT = UDC_ENDPTSETUPSTAT;
@@ -682,7 +699,7 @@ int usb_arcotg_dcd_set_halt(struct usb_ep* ep, bool halt)
}
status = 0;
- dir = ep_is_in(ep) ? USB_SEND : USB_RECV;
+ dir = ep_is_in(ep) ? USB_RECV : USB_SEND;
tmp_epctrl = UDC_ENDPTCTRL(ep->ep_num);
@@ -706,7 +723,7 @@ int usb_arcotg_dcd_set_halt(struct usb_ep* ep, bool halt)
UDC_ENDPTCTRL(ep->ep_num) = tmp_epctrl;
out:
- logf(" %s %s halt rc=%d", ep->name, halt ? "set" : "clear", status);
+ logf("%s %s halt rc=%d", ep->name, halt ? "set" : "clear", status);
return status;
}