aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Common/Common.h
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-04-08 04:49:20 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-04-08 04:49:20 +0000
commit70284d390f524e84e0539ad1e869366aaf94cf24 (patch)
treeb250bd819829b6e2807f4c85bd1342aa979eeb28 /LUFA/Common/Common.h
parent0c5afda7e8d7c3bbaa15297c05d39dc4c90e4d5b (diff)
downloadlufa-70284d390f524e84e0539ad1e869366aaf94cf24.tar.gz
lufa-70284d390f524e84e0539ad1e869366aaf94cf24.tar.bz2
lufa-70284d390f524e84e0539ad1e869366aaf94cf24.zip
Add in a new common Delay_MS() function, which provides a blocking delay for all architectures.
Remove use of avr-libc specific ATOMIC_BLOCK, replace with a new per-architecture set of inline functions to retrieve and manipulate the global interrupt enable bit for each architecture. Add in documentation for the USB controller common interrupt routine which must be linked to the interrupt controller in the user application on the AVR32 UC3 architecture.
Diffstat (limited to 'LUFA/Common/Common.h')
-rw-r--r--LUFA/Common/Common.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h
index 42662ef39..a7e88dab5 100644
--- a/LUFA/Common/Common.h
+++ b/LUFA/Common/Common.h
@@ -75,7 +75,6 @@
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/boot.h>
- #include <util/atomic.h>
#include <util/delay.h>
typedef uint8_t uint_reg_t;
@@ -90,12 +89,8 @@
#include <avr32/io.h>
// === TODO: Find abstracted way to handle these ===
- #define ISR(Name) void Name (void) __attribute__((__interrupt__)); void Name (void)
#define PROGMEM const
- #define ATOMIC_BLOCK(x) if (1)
- #define ATOMIC_RESTORESTATE
#define pgm_read_byte(x) *x
- #define _delay_ms(x)
#define memcmp_P(...) memcmp(__VA_ARGS__)
#define memcpy_P(...) memcpy(__VA_ARGS__)
// ==================================================
@@ -238,6 +233,23 @@
return Byte;
}
+ /** 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.
+ */
+ static inline void Delay_MS(uint8_t Milliseconds)
+ {
+ 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
/** @} */