aboutsummaryrefslogtreecommitdiffstats
path: root/src/avr/irq.h
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2016-06-08 21:13:53 -0400
committerKevin O'Connor <kevin@koconnor.net>2016-06-13 23:18:59 -0400
commitfa85094cbb139c734150802b02e22913abcfccb3 (patch)
tree980eccc8282acfb602a96523488f033bb368fcd4 /src/avr/irq.h
parent9dd101c26fff95e596039d6168d4ad25e080071c (diff)
downloadkutter-fa85094cbb139c734150802b02e22913abcfccb3.tar.gz
kutter-fa85094cbb139c734150802b02e22913abcfccb3.tar.xz
kutter-fa85094cbb139c734150802b02e22913abcfccb3.zip
irq: Allow boards to define the return type of irq_save()
The AVR wants a uint8_t return type for irq_save(), but other architectures will generally prefer int. Allow the board to configure the size of the flag by introducing an irqstatus_t typedef. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/avr/irq.h')
-rw-r--r--src/avr/irq.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/avr/irq.h b/src/avr/irq.h
index bfc6cb51..f586273a 100644
--- a/src/avr/irq.h
+++ b/src/avr/irq.h
@@ -15,13 +15,15 @@ static inline void irq_enable(void) {
sei();
}
-static inline uint8_t irq_save(void) {
+typedef uint8_t irqstatus_t;
+
+static inline irqstatus_t irq_save(void) {
uint8_t flag = SREG;
irq_disable();
return flag;
}
-static inline void irq_restore(uint8_t flag) {
+static inline void irq_restore(irqstatus_t flag) {
barrier();
SREG = flag;
}