From a6772540268fb53aa2509b07f17167ca92642c5a Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 5 Feb 2012 15:19:01 +0000 Subject: Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options (thanks to Opendous Inc.). --- LUFA/DoxygenPages/ChangeLog.txt | 1 + LUFA/DoxygenPages/CompileTimeTokens.txt | 12 ++++++++++++ LUFA/DoxygenPages/LUFAPoweredProjects.txt | 2 ++ LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 5 +++++ LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h | 12 ++++++++++++ LUFA/Drivers/USB/Core/UC3/Host_UC3.c | 5 +++++ LUFA/Drivers/USB/Core/UC3/USBController_UC3.c | 4 ++++ 7 files changed, 41 insertions(+) (limited to 'LUFA') diff --git a/LUFA/DoxygenPages/ChangeLog.txt b/LUFA/DoxygenPages/ChangeLog.txt index 614acecda..ac9b543f7 100644 --- a/LUFA/DoxygenPages/ChangeLog.txt +++ b/LUFA/DoxygenPages/ChangeLog.txt @@ -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) diff --git a/LUFA/DoxygenPages/CompileTimeTokens.txt b/LUFA/DoxygenPages/CompileTimeTokens.txt index e96f7c163..91b74875b 100644 --- a/LUFA/DoxygenPages/CompileTimeTokens.txt +++ b/LUFA/DoxygenPages/CompileTimeTokens.txt @@ -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. * @@ -123,6 +124,7 @@ * 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. * @@ -204,5 +206,15 @@ * 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. + * + * INVERTED_VBUS_ENABLE_LINE - (\ref Group_Host) - All Architectures + * 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. + * + * NO_AUTO_VBUS_MANAGEMENT - (\ref Group_Host) - All Architectures + * 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. */ diff --git a/LUFA/DoxygenPages/LUFAPoweredProjects.txt b/LUFA/DoxygenPages/LUFAPoweredProjects.txt index 9dbace6e0..c69b51b68 100644 --- a/LUFA/DoxygenPages/LUFAPoweredProjects.txt +++ b/LUFA/DoxygenPages/LUFAPoweredProjects.txt @@ -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 @@ -149,4 +150,5 @@ * - 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" */ diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c index d40a7f2f5..6d7e9688e 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c @@ -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; } diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h index 4baaf3a73..09c58bcd6 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h @@ -64,6 +64,10 @@ #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 @@ -310,7 +314,11 @@ 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; @@ -322,7 +330,11 @@ 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; diff --git a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c index d40a7f2f5..9d3026614 100644 --- a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c @@ -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; } diff --git a/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c b/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c index 2b2a23f73..a9a6d35d9 100644 --- a/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/USBController_UC3.c @@ -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; -- cgit v1.2.3