changeset 2291:dcfe5eba9ea7

* cdl/usbs_at91.c: Read actual EP addresses from the EP configuartion rather than relying on the order in the configuration list.
author jlarmour
date Thu, 07 Sep 2006 12:38:34 +0000
parents d2e08e32ef04
children 102f517b1248
files packages/devs/usb/at91/current/ChangeLog packages/devs/usb/at91/current/src/usbs_at91.c
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/usb/at91/current/ChangeLog
+++ b/packages/devs/usb/at91/current/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-07  John Eigelaar  <jeigelaar@mweb.co.za>
+
+	* cdl/usbs_at91.c: Read actual EP addresses from the EP configuartion
+	rather than relying on the order in the configuration list.
+
 2006-06-06  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/usbs_at91.cdl: Allow EP0 to be enabled when there are no
--- a/packages/devs/usb/at91/current/src/usbs_at91.c
+++ b/packages/devs/usb/at91/current/src/usbs_at91.c
@@ -472,6 +472,8 @@ usbs_at91_handle_reset (void)
   const usb_endpoint_descriptor *usb_endpoints;
   cyg_uint8 endpoint_type;
   
+   cyg_uint8 endpoint_number;
+
   usbs_end_all_transfers (-EPIPE);
   
   HAL_WRITE_UINT32 (AT91_UDP + AT91_UDP_IDR, 0xffffffff);
@@ -502,9 +504,13 @@ usbs_at91_handle_reset (void)
                       USB_ENDPOINT_DESCRIPTOR_ENDPOINT_IN ?
                       USB_ENDPOINT_DESCRIPTOR_ENDPOINT_IN : 
                       USB_ENDPOINT_DESCRIPTOR_ENDPOINT_OUT));
-    usbs_at91_endpoint_init((usbs_rx_endpoint *)usbs_at91_endpoints[epn],
-                            endpoint_type,
-                            true);
+    endpoint_number = usb_endpoints[epn-1].endpoint & ~(USB_ENDPOINT_DESCRIPTOR_ENDPOINT_IN); 
+    if ( endpoint_number < AT91_USB_ENDPOINTS )
+    {
+        usbs_at91_endpoint_init((usbs_rx_endpoint *)usbs_at91_endpoints[endpoint_number],
+                                endpoint_type,
+                                true);
+    }
   }
 }