Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options...
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 5 Feb 2012 15:19:01 +0000 (15:19 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 5 Feb 2012 15:19:01 +0000 (15:19 +0000)
LUFA/DoxygenPages/ChangeLog.txt
LUFA/DoxygenPages/CompileTimeTokens.txt
LUFA/DoxygenPages/LUFAPoweredProjects.txt
LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c
LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h
LUFA/Drivers/USB/Core/UC3/Host_UC3.c
LUFA/Drivers/USB/Core/UC3/USBController_UC3.c

index 614acec..ac9b543 100644 (file)
@@ -18,6 +18,7 @@
   *   - Added new CALLBACK_Audio_Device_GetSetInterfaceProperty() callback to the Audio Device Class driver
   *   - Added new LEDs_Disable(), Buttons_Disable() and Joystick_Disable() functions to the board hardware drivers
   *   - Added support for the Micropendous family of boards
+  *   - Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options (thanks to Opendous Inc.)
   *  - Library Applications:
   *   - Added User Application APIs to the CDC and DFU class bootloaders
   *   - Added INVERTED_ISP_MISO compile time option to the AVRISP-MKII clone project (thanks to Chuck Rohs)
index e96f7c1..91b7487 100644 (file)
@@ -78,6 +78,7 @@
  *  the compile time token may be defined in the application's makefile to disable automatic flushing during calls to the class driver USB
  *  management tasks.
  *
+ *
  *  \section Sec_SummaryUSBTokens General USB Driver Related Tokens
  *  This section describes compile tokens which affect USB driver stack as a whole in the LUFA library.
  *
  *  the ability to receive USB Start of Frame events via the \ref EVENT_USB_Device_StartOfFrame() or \ref EVENT_USB_Host_StartOfFrame() events is removed,
  *  reducing the compiled program's binary size.
  *
+ *
  *  \section Sec_SummaryUSBDeviceTokens USB Device Mode Driver Related Tokens
  *  This section describes compile tokens which affect USB driver stack of the LUFA library when used in Device mode.
  *
  *  they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled
  *  back to a known idle state before communications occur with the device. This token may be defined to a 16-bit value to set the device
  *  settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.
+ *
+ *  <b>INVERTED_VBUS_ENABLE_LINE</b> - (\ref Group_Host) - <i>All Architectures</i> 
+ *  If enabled, this will indicate that the USB target VBUS line polarity is inverted; i.e. it should be pulled low to enable VBUS to the
+ *  target, and pulled high to stop the target VBUS generation.
+ *
+ *  \note On AVR8 architecture devices, this compile time option requires \c NO_AUTO_VBUS_MANAGEMENT to be set.
+ *
+ *  <b>NO_AUTO_VBUS_MANAGEMENT</b> - (\ref Group_Host) - <i>All Architectures</i> 
+ *  Disables the automatic management of VBUS to the target, i.e. automatic shut down in the even of an overcurrent situation. When enabled, VBUS
+ *  is enabled while the USB controller is initialized in USB Host mode.
  */
 
index 9dbace6..c69b51b 100644 (file)
@@ -68,6 +68,7 @@
  *  - MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g
  *  - MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster
  *  - MIDI Theremin: http://baldwisdom.com/usb-midi-controller-theremin-style-on-arduino-uno/
+ *  - MIDI interface hack of a toy Guitar: http://blog.x37v.info/2011/06/26/toy-guitar-hacked-midi-conroller
  *  - MiniBloq, a graphical Ardunio programming environment : http://minibloq.org/
  *  - MiXley, a port of the Teacup 3D printer firmware for the USB AVRs: http://codaset.com/michielh/mixley
  *  - Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3
  *  - Adafruit "Ask an Engineer", 7th November 2010
  *  - Arduino 2010 Keynote speech
  *  - The Amp Hour podcast blog #11
+ *  - Blackhat 2011 conference, "Exploiting USB Devices with Arduino"
  */
index d40a7f2..6d7e968 100644 (file)
@@ -79,6 +79,11 @@ void USB_Host_ProcessNextHostState(void)
                                USB_OTGPAD_On();
                                USB_Host_VBUS_Auto_Enable();
                                USB_Host_VBUS_Auto_On();
+                               
+                               #if defined(NO_AUTO_VBUS_MANAGEMENT)
+                               USB_Host_VBUS_Manual_Enable();
+                               USB_Host_VBUS_Manual_On();
+                               #endif
 
                                USB_HostState = HOST_STATE_Powered_WaitForConnect;
                        }
index 4baaf3a..09c58bc 100644 (file)
                        #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
                #endif
 
+               #if defined(INVERTED_VBUS_ENABLE_LINE) && !defined(NO_AUTO_VBUS_MANAGEMENT)
+                       #error The INVERTED_VBUS_ENABLE_LINE compile option requires NO_AUTO_VBUS_MANAGEMENT for the AVR8 architecture.
+               #endif
+
        /* Public Interface - May be used in end-application: */
                /* Macros: */
                        /** Indicates the fixed USB device address which any attached device is enumerated to when in
                        static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
                        static inline void USB_Host_VBUS_Manual_On(void)
                        {
+                               #if defined(INVERTED_VBUS_ENABLE_LINE)
+                               PORTE  &= ~(1 << 7);
+                               #else
                                PORTE  |=  (1 << 7);
+                               #endif
                        }
 
                        static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
                        static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
                        static inline void USB_Host_VBUS_Manual_Off(void)
                        {
+                               #if defined(INVERTED_VBUS_ENABLE_LINE)
+                               PORTE  |=  (1 << 7);
+                               #else
                                PORTE  &= ~(1 << 7);
+                               #endif
                        }
 
                        static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
index d40a7f2..9d30266 100644 (file)
@@ -80,6 +80,11 @@ void USB_Host_ProcessNextHostState(void)
                                USB_Host_VBUS_Auto_Enable();
                                USB_Host_VBUS_Auto_On();
 
+                               #if defined(NO_AUTO_VBUS_MANAGEMENT)
+                               USB_Host_VBUS_Manual_Enable();
+                               USB_Host_VBUS_Manual_On();
+                               #endif
+
                                USB_HostState = HOST_STATE_Powered_WaitForConnect;
                        }
 
index 2b2a23f..a9a6d35 100644 (file)
@@ -134,6 +134,10 @@ void USB_ResetInterface(void)
        }
        else if (USB_CurrentMode == USB_MODE_Host)
        {
+               #if defined(INVERTED_VBUS_ENABLE_LINE)
+               AVR32_USBB.USBCON.vbuspol = true;
+               #endif
+               
                #if defined(USB_CAN_BE_HOST)
                AVR32_USBB.USBCON.uimod = false;