From 25a02432e72542015015b37d4ddfd518f4aea111 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Thu, 19 Dec 2013 23:44:23 +0100 Subject: AVR8: Add option to keep 3.3V regulator enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The documentation contains example code[1] on how to restart into the bootloader. In the process of preparing for the reset, USB is disabled using “USB_Disable()”. For hardware making use of the AVR8's internal 3.3V regulator that call would also disable the regulator, resetting the processor immediately rather than setting the boot key and letting the watchdog reset the processor. This patch adds a new flag to be given to “USB_Init()” or to be defined in “USE_STATIC_OPTIONS” telling “USB_Disable()” to keep the regulator enabled. On November 1st, 2013 this issue was already mentioned on the mailing list[2], but no fix came from that discussion. [1] [2] Signed-off-by: Michael Hanselmann --- LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c') diff --git a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c index 8faec1df0..dc96c0fe7 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c @@ -112,7 +112,8 @@ void USB_Disable(void) if (!(USB_Options & USB_OPT_MANUAL_PLL)) USB_PLL_Off(); - USB_REG_Off(); + if (!(USB_Options & USB_OPT_REG_KEEP_ENABLED)) + USB_REG_Off(); #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) USB_OTGPAD_Off(); -- cgit v1.2.3