ARM: introduce sei() and cli().

No test, because it's tricky to test, but it compiles and the
firmware still works as before.
This commit is contained in:
Markus Hitter 2015-07-30 23:09:11 +02:00
parent 608506719b
commit 7be5212f06
7 changed files with 42 additions and 19 deletions

34
cpu.h
View File

@ -2,6 +2,40 @@
#ifndef _CPU_H #ifndef _CPU_H
#define _CPU_H #define _CPU_H
#if defined __AVR__
#include <avr/interrupt.h>
#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); void cpu_init(void);
#endif /* _CPU_H */ #endif /* _CPU_H */

4
dda.c
View File

@ -7,14 +7,12 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#ifdef __AVR__
#include <avr/interrupt.h>
#endif
#include "dda_maths.h" #include "dda_maths.h"
#include "preprocessor_math.h" #include "preprocessor_math.h"
#include "dda_kinematics.h" #include "dda_kinematics.h"
#include "dda_lookahead.h" #include "dda_lookahead.h"
#include "cpu.h"
#include "timer.h" #include "timer.h"
#include "serial.h" #include "serial.h"
#include "sermsg.h" #include "sermsg.h"

View File

@ -5,9 +5,6 @@
*/ */
#include <string.h> #include <string.h>
#ifdef __AVR__
#include <avr/interrupt.h>
#endif
#include "config_wrapper.h" #include "config_wrapper.h"
#include "timer.h" #include "timer.h"
@ -17,6 +14,7 @@
#include "delay.h" #include "delay.h"
#include "sersendf.h" #include "sersendf.h"
#include "clock.h" #include "clock.h"
#include "cpu.h"
#include "memory_barrier.h" #include "memory_barrier.h"
/// movebuffer head pointer. Points to the last move in the queue. /// movebuffer head pointer. Points to the last move in the queue.

View File

@ -5,12 +5,10 @@
*/ */
#include <string.h> #include <string.h>
#ifdef __AVR__
#include <avr/interrupt.h>
#endif
#include "gcode_parse.h" #include "gcode_parse.h"
#include "cpu.h"
#include "dda.h" #include "dda.h"
#include "dda_queue.h" #include "dda_queue.h"
#include "watchdog.h" #include "watchdog.h"

View File

@ -4,15 +4,10 @@
\brief motherboard <-> extruder board protocol \brief motherboard <-> extruder board protocol
*/ */
#ifdef __AVR__
#include <avr/io.h>
#include <avr/interrupt.h>
#endif
#include "memory_barrier.h"
#include "config_wrapper.h" #include "config_wrapper.h"
#include "pinio.h" #include "pinio.h"
#include "delay.h" #include "delay.h"
#include "memory_barrier.h"
#if (defined TEMP_INTERCOM) || (defined EXTRUDER) #if (defined TEMP_INTERCOM) || (defined EXTRUDER)
#define INTERCOM_BAUD 57600 #define INTERCOM_BAUD 57600

View File

@ -114,10 +114,12 @@ void init(void) {
#ifdef SD #ifdef SD
sd_init(); sd_init();
#endif #endif
#endif /* __ARMEL_NOTYET__ */
// enable interrupts // enable interrupts
sei(); sei();
#ifndef __ARMEL_NOTYET__
// reset watchdog // reset watchdog
wd_reset(); wd_reset();
#endif /* __ARMEL_NOTYET__ */ #endif /* __ARMEL_NOTYET__ */

View File

@ -10,15 +10,13 @@
Teacup has tried numerous timer management methods, and this is the best so far. Teacup has tried numerous timer management methods, and this is the best so far.
*/ */
#ifdef __AVR__
#include <avr/interrupt.h>
#endif
#include "memory_barrier.h"
#include "arduino.h" #include "arduino.h"
#include "config_wrapper.h" #include "config_wrapper.h"
#include "pinio.h" #include "pinio.h"
#include "clock.h" #include "clock.h"
#include "cpu.h"
#include "memory_barrier.h"
#ifdef MOTHERBOARD #ifdef MOTHERBOARD
#include "dda_queue.h" #include "dda_queue.h"