From 7be5212f06f0c715b0cf1e907ee12ed335923ed1 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Thu, 30 Jul 2015 23:09:11 +0200 Subject: [PATCH] ARM: introduce sei() and cli(). No test, because it's tricky to test, but it compiles and the firmware still works as before. --- cpu.h | 34 ++++++++++++++++++++++++++++++++++ dda.c | 4 +--- dda_queue.c | 4 +--- gcode_process.c | 4 +--- intercom.c | 7 +------ mendel.c | 2 ++ timer.c | 6 ++---- 7 files changed, 42 insertions(+), 19 deletions(-) diff --git a/cpu.h b/cpu.h index c61a8d2..7660464 100644 --- a/cpu.h +++ b/cpu.h @@ -2,6 +2,40 @@ #ifndef _CPU_H #define _CPU_H +#if defined __AVR__ + + #include + +#elif defined __ARMEL__ + + #include "cmsis-lpc11xx.h" // For __ASM(). + + /** Enable interrupts. + + This enables interrupts by clearing the I-bit in the CPSR. + + Code copied from MBED, __enable_irq(), in file + mbed/libraries/mbed/targets/cmsis/core_cmFunc.h. + */ + static void sei(void) __attribute__ ((always_inline)); + inline void sei(void) { + __ASM volatile ("cpsie i" ::: "memory"); + } + + /** Disable interrupts. + + This disables interrupts by setting the I-bit in the CPSR. + + Code copied from MBED, __disable_irq(), in file + mbed/libraries/mbed/targets/cmsis/core_cmFunc.h. + */ + static void cli(void) __attribute__ ((always_inline)); + inline void cli(void) { + __ASM volatile ("cpsid i" ::: "memory"); + } + +#endif /* __AVR__, __ARMEL__ */ + void cpu_init(void); #endif /* _CPU_H */ diff --git a/dda.c b/dda.c index e9b3912..aba9608 100644 --- a/dda.c +++ b/dda.c @@ -7,14 +7,12 @@ #include #include #include -#ifdef __AVR__ -#include -#endif #include "dda_maths.h" #include "preprocessor_math.h" #include "dda_kinematics.h" #include "dda_lookahead.h" +#include "cpu.h" #include "timer.h" #include "serial.h" #include "sermsg.h" diff --git a/dda_queue.c b/dda_queue.c index f89742f..df8a1e6 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -5,9 +5,6 @@ */ #include -#ifdef __AVR__ -#include -#endif #include "config_wrapper.h" #include "timer.h" @@ -17,6 +14,7 @@ #include "delay.h" #include "sersendf.h" #include "clock.h" +#include "cpu.h" #include "memory_barrier.h" /// movebuffer head pointer. Points to the last move in the queue. diff --git a/gcode_process.c b/gcode_process.c index 8e0a782..890eea9 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -5,12 +5,10 @@ */ #include -#ifdef __AVR__ -#include -#endif #include "gcode_parse.h" +#include "cpu.h" #include "dda.h" #include "dda_queue.h" #include "watchdog.h" diff --git a/intercom.c b/intercom.c index e7a0aa6..e80d29e 100644 --- a/intercom.c +++ b/intercom.c @@ -4,15 +4,10 @@ \brief motherboard <-> extruder board protocol */ -#ifdef __AVR__ -#include -#include -#endif -#include "memory_barrier.h" - #include "config_wrapper.h" #include "pinio.h" #include "delay.h" +#include "memory_barrier.h" #if (defined TEMP_INTERCOM) || (defined EXTRUDER) #define INTERCOM_BAUD 57600 diff --git a/mendel.c b/mendel.c index e636b9c..4c1a6be 100644 --- a/mendel.c +++ b/mendel.c @@ -114,10 +114,12 @@ void init(void) { #ifdef SD sd_init(); #endif + #endif /* __ARMEL_NOTYET__ */ // enable interrupts sei(); + #ifndef __ARMEL_NOTYET__ // reset watchdog wd_reset(); #endif /* __ARMEL_NOTYET__ */ diff --git a/timer.c b/timer.c index f766634..a8880c9 100644 --- a/timer.c +++ b/timer.c @@ -10,15 +10,13 @@ Teacup has tried numerous timer management methods, and this is the best so far. */ -#ifdef __AVR__ -#include -#endif -#include "memory_barrier.h" #include "arduino.h" #include "config_wrapper.h" #include "pinio.h" #include "clock.h" +#include "cpu.h" +#include "memory_barrier.h" #ifdef MOTHERBOARD #include "dda_queue.h"