From 8f744bba6362cb356df6986034c4498568aaa84a Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 24 Aug 2010 18:31:58 -0300 Subject: [PATCH] Minor potential improvements of USB robustness. - atrf/fw/atspi/atspi.c (main): add a delay to give the host more time to - atrf/fw/atspi/descr.c: we don't use EP1, so simplify the descriptors we send. Keep the EP1 descriptors around (commented out) in case we need them later, e.g., for interrupts. --- atrf/fw/atspi/atspi.c | 8 ++++++++ atrf/fw/atspi/descr.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/atrf/fw/atspi/atspi.c b/atrf/fw/atspi/atspi.c index 94ac6a2..cee1732 100644 --- a/atrf/fw/atspi/atspi.c +++ b/atrf/fw/atspi/atspi.c @@ -90,8 +90,16 @@ static void init_io(void) void main(void) { + int i; + init_io(); + /* + * Make sure the host has enough time (2.5 us) to detect that we reset + * our USB stack. + */ + for (i = 0; i != 10; i++); + usb_init(); ep0_init(); diff --git a/atrf/fw/atspi/descr.c b/atrf/fw/atspi/descr.c index de30add..167b9fa 100644 --- a/atrf/fw/atspi/descr.c +++ b/atrf/fw/atspi/descr.c @@ -41,19 +41,22 @@ const uint8_t device_descriptor[18] = { /* * Our configuration * - * While in DFU mode, we're always bus-powered. + * We're always bus-powered. */ const uint8_t config_descriptor[] = { 9, /* bLength */ USB_DT_CONFIG, /* bDescriptorType */ +#if 0 LE(9+9+7+7), /* wTotalLength */ +#else + LE(9+9), /* wTotalLength */ +#endif 1, /* bNumInterfaces */ 1, /* bConfigurationValue (> 0 !) */ 0, /* iConfiguration */ -// USB_ATTR_SELF_POWERED | USB_ATTR_BUS_POWERED, USB_ATTR_BUS_POWERED, /* bmAttributes */ - 15, /* bMaxPower */ + 50/2, /* bMaxPower (50 mA) */ /* Interface #0 */ @@ -61,12 +64,17 @@ const uint8_t config_descriptor[] = { USB_DT_INTERFACE, /* bDescriptorType */ 0, /* bInterfaceNumber */ 0, /* bAlternateSetting */ +#if 0 2, /* bNumEndpoints */ +#else + 0, +#endif USB_CLASS_VENDOR_SPEC, /* bInterfaceClass */ 0, /* bInterfaceSubClass */ 0, /* bInterfaceProtocol */ 0, /* iInterface */ +#if 0 /* EP OUT */ 7, /* bLength */ @@ -84,5 +92,5 @@ const uint8_t config_descriptor[] = { 0x02, /* bmAttributes (bulk) */ LE(EP1_SIZE), /* wMaxPacketSize */ 0, /* bInterval */ - +#endif };