Ensure device address latch bit is not set at the same time as the new address, as...
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 19 Sep 2010 05:46:17 +0000 (05:46 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 19 Sep 2010 05:46:17 +0000 (05:46 +0000)
Minor documentation fixes.

Fix broken USB host mode due to the USB frame counter not being updated during the early enumeration steps, causing USB_Host_DelayMS() to spinloop forever.

Demos/Device/ClassDriver/DualVirtualSerial/DualVirtualSerial.txt
Demos/DualRole/ClassDriver/MouseHostDevice/DeviceFunctions.c
Demos/DualRole/ClassDriver/MouseHostDevice/MouseHostDevice.c
LUFA/Drivers/USB/HighLevel/StdDescriptors.h
LUFA/Drivers/USB/LowLevel/Device.h
LUFA/Drivers/USB/LowLevel/Host.c
LUFA/Drivers/USB/LowLevel/USBInterrupt.c
LUFA/ManPages/FutureChanges.txt

index 03a97ce..3959f89 100644 (file)
@@ -50,7 +50,7 @@
  *
  *  Dual Communications Device Class demonstration application.
  *  This gives a simple reference application for implementing
- *  a compound device with dual CDC functions acting as a pair
+ *  a composite device with dual CDC functions acting as a pair
  *  of virtual serial ports. This demo uses Interface Association
  *  Descriptors to link together the pair of related CDC
  *  descriptors for each virtual serial port, which may not be
index e2a2128..8d1cae9 100644 (file)
@@ -62,12 +62,14 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Device_Interface =
 /** Event handler for the library USB WakeUp event. */
 void EVENT_USB_Device_Connect(void)
 {
+       puts_P(PSTR("Device Connected.\r\n"));
        LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
 }
 
 /** Event handler for the library USB Suspend event. */
 void EVENT_USB_Device_Disconnect(void)
 {
+       puts_P(PSTR("Device Disconnected.\r\n"));
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
 }
 
index cd6bf59..1b905b1 100644 (file)
@@ -82,3 +82,12 @@ void SetupHardware(void)
        Buttons_Init();
        USB_Init(USB_MODE_UID);
 }
+
+/** Event handler for the library USB mode change event. */
+void EVENT_USB_UIDChange(void)
+{
+       printf_P(PSTR(ESC_FG_YELLOW "UID Change to %S mode\r\n" ESC_FG_WHITE),
+                (USB_CurrentMode == USB_MODE_DEVICE) ? PSTR("Device") : PSTR("Host"));
+                        
+       LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
+}
index 89c2c97..4339479 100644 (file)
                         *  to make each element's purpose clearer.
                         *
                         *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
-                        *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
+                        *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
                         *  devices with multiple interfaces related to the same function to have the multiple interfaces bound
                         *  together at the point of enumeration, loading one generic driver for all the interfaces in the single
                         *  function. Read the ECN for more information.
                         *  element names to ensure compatibility with the standard.
                         *
                         *  This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at
-                        *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows compound
+                        *  <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite
                         *  devices with multiple interfaces related to the same function to have the multiple interfaces bound
                         *  together at the point of enumeration, loading one generic driver for all the interfaces in the single
                         *  function. Read the ECN for more information.
index 3007936..a37e6d9 100644 (file)
                        static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
                        static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
                        {
-                               UDADDR = ((1 << ADDEN) | (Address & 0x7F));
+                               UDADDR  = ((UDADDR & (1 << ADDEN)) | (Address & 0x7F));
+                               UDADDR |= (1 << ADDEN);
                        }                       
        #endif
 
index 2b66e28..6c66083 100644 (file)
@@ -194,19 +194,21 @@ void USB_Host_ProcessNextHostState(void)
 
 uint8_t USB_Host_WaitMS(uint8_t MS)
 {
-       bool     BusSuspended        = USB_Host_IsBusSuspended();
-       uint8_t  ErrorCode           = HOST_WAITERROR_Successful;
-       uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();
+       bool    BusSuspended = USB_Host_IsBusSuspended();
+       uint8_t ErrorCode    = HOST_WAITERROR_Successful;
        
        USB_Host_ResumeBus();
 
+       bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);
+
+       USB_INT_Disable(USB_INT_HSOFI);
+       USB_INT_Clear(USB_INT_HSOFI);
+
        while (MS)
        {
-               uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
-
-               if (CurrentFrameNumber != PreviousFrameNumber)
+               if (USB_INT_HasOccurred(USB_INT_HSOFI))
                {
-                       PreviousFrameNumber = CurrentFrameNumber;
+                       USB_INT_Clear(USB_INT_HSOFI);
                        MS--;
                }
                                        
@@ -234,6 +236,9 @@ uint8_t USB_Host_WaitMS(uint8_t MS)
                }
        }
 
+       if (HSOFIEnabled)
+         USB_INT_Enable(USB_INT_HSOFI);
+
        if (BusSuspended)
          USB_Host_SuspendBus();
 
index a49b8da..52951fc 100644 (file)
 void USB_INT_DisableAllInterrupts(void)
 {
        #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
-       USBCON &= ~((1 << VBUSTE) | (1 << IDTE));                               
+       USBCON &= ~((1 << OTGPADE) | (1 << VBUSTE) | (1 << IDTE));                              
        #elif defined(USB_SERIES_4_AVR)
        USBCON &= ~(1 << VBUSTE);
        #endif
        
+       #if defined(USB_CAN_BE_BOTH)
+       OTGIEN  = 0;
+       #endif
+       
        #if defined(USB_CAN_BE_HOST)
        UHIEN   = 0;
-       OTGIEN  = 0;
        #endif
        
        #if defined(USB_CAN_BE_DEVICE)
@@ -55,9 +58,12 @@ void USB_INT_ClearAllInterrupts(void)
        USBINT  = 0;
        #endif
        
+       #if defined(USB_CAN_BE_BOTH)
+       OTGINT  = 0;
+       #endif
+       
        #if defined(USB_CAN_BE_HOST)
        UHINT   = 0;
-       OTGINT  = 0;
        #endif
        
        #if defined(USB_CAN_BE_DEVICE)
index 555971f..6e77eff 100644 (file)
@@ -14,7 +14,7 @@
   *  <b>Targeted for Future Releases:</b>
   *  - Code Features
   *      -# Add hub support when in Host mode for multiple devices
-  *      -# Investigate virtual hubs when in device mode instead of compound devices
+  *      -# Investigate virtual hubs when in device mode instead of composite devices
   *      -# Add ability to get number of bytes not written with pipe/endpoint write routines after an error
   *      -# Change makefiles to allow for absolute LUFA location to be used
   *      -# Re-add interrupt Pipe/Endpoint support