aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Common
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-04-08 05:05:05 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-04-08 05:05:05 +0000
commitde9bd767dc8578a45a195fb1e37dd4ff26ae9567 (patch)
tree6fceed835501d02bdb8a0449fb8e7e035329e39b /LUFA/Common
parent70284d390f524e84e0539ad1e869366aaf94cf24 (diff)
downloadlufa-de9bd767dc8578a45a195fb1e37dd4ff26ae9567.tar.gz
lufa-de9bd767dc8578a45a195fb1e37dd4ff26ae9567.tar.bz2
lufa-de9bd767dc8578a45a195fb1e37dd4ff26ae9567.zip
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.
Diffstat (limited to 'LUFA/Common')
-rw-r--r--LUFA/Common/Common.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h
index a7e88dab5..a54512a51 100644
--- a/LUFA/Common/Common.h
+++ b/LUFA/Common/Common.h
@@ -236,18 +236,28 @@
/** Function to perform a blocking delay for a specified number of milliseconds. The actual delay will be
* at a minimum the specified number of milliseconds, however due to loop overhead and internal calculations
* may be slightly higher.
+ *
+ * \param[in] Milliseconds Number of milliseconds to delay
*/
static inline void Delay_MS(uint8_t Milliseconds)
{
+ #if (ARCH == ARCH_AVR8)
+ if (__builtin_constant_p(Milliseconds))
+ {
+ _delay_ms(Milliseconds);
+ }
+ else
+ {
+ while (Milliseconds--)
+ _delay_ms(1);
+ }
+ #elif (ARCH == ARCH_UC3)
while (Milliseconds--)
{
- #if (ARCH == ARCH_AVR8)
- _delay_ms(1);
- #elif (ARCH == ARCH_UC3)
__builtin_mtsr(AVR32_COUNT, 0);
while (__builtin_mfsr(AVR32_COUNT) < (F_CPU / 1000));
- #endif
}
+ #endif
}
#endif