From de9bd767dc8578a45a195fb1e37dd4ff26ae9567 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 8 Apr 2011 05:05:05 +0000 Subject: Correct UC3 global interrupt functions. Replace all calls and references to _delay_ms() in the code with the architecture-agnostic Delay_MS() function. Improve code generation for the Delay_MS() function on the AVR8 architecture when called with a constant input. --- LUFA/Drivers/Board/LEDs.h | 10 +++++----- LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 2 +- LUFA/Drivers/USB/Core/UC3/Host_UC3.c | 2 +- LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h | 5 +++-- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'LUFA/Drivers') diff --git a/LUFA/Drivers/Board/LEDs.h b/LUFA/Drivers/Board/LEDs.h index 7a135b8bc..628f2587b 100644 --- a/LUFA/Drivers/Board/LEDs.h +++ b/LUFA/Drivers/Board/LEDs.h @@ -79,17 +79,17 @@ * * // Turn on each of the four LEDs in turn * LEDs_SetAllLEDs(LEDS_LED1); - * _delay_ms(500); + * Delay_MS(500); * LEDs_SetAllLEDs(LEDS_LED1); - * _delay_ms(500); + * Delay_MS(500); * LEDs_SetAllLEDs(LEDS_LED1); - * _delay_ms(500); + * Delay_MS(500); * LEDs_SetAllLEDs(LEDS_LED1); - * _delay_ms(500); + * Delay_MS(500); * * // Turn on all LEDs * LEDs_SetAllLEDs(LEDS_ALL_LEDS); - * _delay_ms(1000); + * Delay_MS(1000); * * // Turn on LED 1, turn off LED 2, leaving LEDs 3 and 4 in their current state * LEDs_ChangeLEDs((LEDS_LED1 | LEDS_LED2), LEDS_LED1); diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c index 87dddd49d..6c45265d7 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c @@ -273,7 +273,7 @@ static void USB_Host_ResetDevice(void) break; } - _delay_ms(1); + Delay_MS(1); } if (HSOFIEnabled) diff --git a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c index b557ff0ed..88a7df5c4 100644 --- a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c @@ -273,7 +273,7 @@ static void USB_Host_ResetDevice(void) break; } - _delay_ms(1); + Delay_MS(1); } if (HSOFIEnabled) diff --git a/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h b/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h index 95a85cf69..a9ad56611 100644 --- a/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h @@ -87,14 +87,15 @@ static inline uint_reg_t USB_INT_GetGlobalEnableState(void) { GCC_MEMORY_BARRIER(); - return (__builtin_mfsr(AVR32_SR) & AVR32_SR_GM); + return __builtin_mfsr(AVR32_SR); } static inline void USB_INT_SetGlobalEnableState(uint_reg_t GlobalIntState) ATTR_ALWAYS_INLINE; static inline void USB_INT_SetGlobalEnableState(uint_reg_t GlobalIntState) { GCC_MEMORY_BARRIER(); - __builtin_ssrf(AVR32_SR_GM_OFFSET, GlobalIntState); + if (GlobalIntState & AVR32_SR_GM) + __builtin_ssrf(AVR32_SR_GM_OFFSET); GCC_MEMORY_BARRIER(); } -- cgit v1.2.3