summaryrefslogtreecommitdiff
path: root/firmware/drivers
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 /firmware/drivers
parent771752010280ac3c10fcb46e14cb622249bc56d9 (diff)
downloadrockbox-3a0c78bb76c2f8a89208121194f0706689254c6a.tar.gz
rockbox-3a0c78bb76c2f8a89208121194f0706689254c6a.zip
add usb state handling and other small fixes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14541 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-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 41f3e9058d..9ffc6aa74a 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)
283{ 283{
284 int error = 0; 284 int error = 0;
285 uint8_t address = 0; 285 uint8_t address = 0;
286 bool set_config = false;
286 int handled = 0; /* set to zero if we do not handle the message, */ 287 int handled = 0; /* set to zero if we do not handle the message, */
287 /* and should pass it to the driver */ 288 /* and should pass it to the driver */
288 289
@@ -295,15 +296,17 @@ static void setup_received_int(struct usb_ctrlrequest* request)
295 296
296 switch (request->bRequest) { 297 switch (request->bRequest) {
297 case USB_REQ_SET_ADDRESS: 298 case USB_REQ_SET_ADDRESS:
298
299 /* store address as we need to ack before setting it */ 299 /* store address as we need to ack before setting it */
300 address = (uint8_t)request->wValue; 300 address = (uint8_t)request->wValue;
301 301
302 handled = 1; 302 handled = 1;
303 break; 303 break;
304 304
305 case USB_REQ_GET_STATUS: 305 case USB_REQ_SET_CONFIGURATION:
306 set_config = true;
307 break;
306 308
309 case USB_REQ_GET_STATUS:
307 logf("sending status.."); 310 logf("sending status..");
308 response.buf = &dcd_controller.usb_state; 311 response.buf = &dcd_controller.usb_state;
309 response.length = 2; 312 response.length = 2;
@@ -365,9 +368,18 @@ static void setup_received_int(struct usb_ctrlrequest* request)
365 /* ack transfer */ 368 /* ack transfer */
366 usb_ack(request, error); 369 usb_ack(request, error);
367 370
371 /* set address and usb state after USB_REQ_SET_ADDRESS */
368 if (address != 0) { 372 if (address != 0) {
369 logf("setting address to %d", address); 373 logf("setting address to %d", address);
370 UDC_DEVICEADDR = address << 25; 374 UDC_DEVICEADDR = address << 25;
375 dcd_controller.usb_state = USB_STATE_ADDRESS;
376 }
377
378 /* update usb state after successfull USB_REQ_SET_CONFIGURATION */
379 if (set_config) {
380 if (handled > 0) {
381 dcd_controller.usb_state = USB_STATE_CONFIGURED;
382 }
371 } 383 }
372} 384}
373 385
@@ -444,9 +456,14 @@ static void resume_int(void)
444 456
445static void reset_int(void) 457static void reset_int(void)
446{ 458{
447 //logf("reset_int");
448 struct timer t; 459 struct timer t;
449 460
461 /* clear device address */
462 UDC_DEVICEADDR = 0 << 25;
463
464 /* update usb state */
465 dcd_controller.usb_state = USB_STATE_DEFAULT;
466
450 timer_set(&t, RESET_TIMER); 467 timer_set(&t, RESET_TIMER);
451 468
452 UDC_ENDPTSETUPSTAT = UDC_ENDPTSETUPSTAT; 469 UDC_ENDPTSETUPSTAT = UDC_ENDPTSETUPSTAT;
@@ -682,7 +699,7 @@ int usb_arcotg_dcd_set_halt(struct usb_ep* ep, bool halt)
682 } 699 }
683 700
684 status = 0; 701 status = 0;
685 dir = ep_is_in(ep) ? USB_SEND : USB_RECV; 702 dir = ep_is_in(ep) ? USB_RECV : USB_SEND;
686 703
687 tmp_epctrl = UDC_ENDPTCTRL(ep->ep_num); 704 tmp_epctrl = UDC_ENDPTCTRL(ep->ep_num);
688 705
@@ -706,7 +723,7 @@ int usb_arcotg_dcd_set_halt(struct usb_ep* ep, bool halt)
706 UDC_ENDPTCTRL(ep->ep_num) = tmp_epctrl; 723 UDC_ENDPTCTRL(ep->ep_num) = tmp_epctrl;
707 724
708out: 725out:
709 logf(" %s %s halt rc=%d", ep->name, halt ? "set" : "clear", status); 726 logf("%s %s halt rc=%d", ep->name, halt ? "set" : "clear", status);
710 return status; 727 return status;
711} 728}
712 729