From 73f3b0636a369f9e89fe44b56825eead5361601c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 5 Jun 2016 15:07:57 -0400 Subject: [PATCH] generic: Move simulator/irq.h to new file generic/irq.h Move the generic irq definitions into generic/irq.h and move the simulator irq code into main.c. Signed-off-by: Kevin O'Connor --- src/generic/irq.h | 11 +++++++++++ src/{simulator => generic}/pgm.h | 6 +++--- src/simulator/irq.h | 31 ------------------------------- src/simulator/main.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 src/generic/irq.h rename src/{simulator => generic}/pgm.h (77%) delete mode 100644 src/simulator/irq.h diff --git a/src/generic/irq.h b/src/generic/irq.h new file mode 100644 index 00000000..597ff96d --- /dev/null +++ b/src/generic/irq.h @@ -0,0 +1,11 @@ +#ifndef __GENERIC_IRQ_H +#define __GENERIC_IRQ_H + +#include + +void irq_disable(void); +void irq_enable(void); +uint8_t irq_save(void); +void irq_restore(uint8_t flag); + +#endif // irq.h diff --git a/src/simulator/pgm.h b/src/generic/pgm.h similarity index 77% rename from src/simulator/pgm.h rename to src/generic/pgm.h index e5f3787d..bbdc0ba3 100644 --- a/src/simulator/pgm.h +++ b/src/generic/pgm.h @@ -1,7 +1,7 @@ -#ifndef __SIMU_PGM_H -#define __SIMU_PGM_H +#ifndef __GENERIC_PGM_H +#define __GENERIC_PGM_H // This header provides wrappers for the AVR specific "PROGMEM" -// declarations. +// declarations on non-avr platforms. #define PROGMEM #define PSTR(S) S diff --git a/src/simulator/irq.h b/src/simulator/irq.h deleted file mode 100644 index 63f51290..00000000 --- a/src/simulator/irq.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __SIMU_IRQ_H -#define __SIMU_IRQ_H -// Definitions for irq enable/disable on host simulator - -#include -#include "compiler.h" // barrier - -extern uint8_t Interrupt_off; - -static inline void irq_disable(void) { - Interrupt_off = 1; - barrier(); -} - -static inline void irq_enable(void) { - barrier(); - Interrupt_off = 0; -} - -static inline uint8_t irq_save(void) { - uint8_t flag = Interrupt_off; - irq_disable(); - return flag; -} - -static inline void irq_restore(uint8_t flag) { - barrier(); - Interrupt_off = flag; -} - -#endif // irq.h diff --git a/src/simulator/main.c b/src/simulator/main.c index e871864a..419fa531 100644 --- a/src/simulator/main.c +++ b/src/simulator/main.c @@ -7,10 +7,42 @@ #include #include #include +#include "board/misc.h" // timer_from_us +#include "board/irq.h" // irq_disable #include "sched.h" // sched_main + +/**************************************************************** + * Interrupts + ****************************************************************/ + uint8_t Interrupt_off; +void irq_disable(void) +{ + Interrupt_off = 1; + barrier(); +} + +void irq_enable(void) +{ + barrier(); + Interrupt_off = 0; +} + +uint8_t irq_save(void) +{ + uint8_t flag = Interrupt_off; + irq_disable(); + return flag; +} + +void irq_restore(uint8_t flag) +{ + barrier(); + Interrupt_off = flag; +} + /**************************************************************** * Timers