SITL: added SREG declaration

This commit is contained in:
Andrew Tridgell 2012-11-19 08:26:53 +11:00
parent 7c90931306
commit 0534406f6d
3 changed files with 8 additions and 14 deletions

View File

@ -15,6 +15,10 @@ extern "C" volatile uint8_t __iomem[1024];
#define _SFR_IO8(addr) __iomem[addr]
extern "C" volatile uint8_t SREG;
#define _interrupts_are_blocked() ((SREG&0x80)==0)
#define __ATmegaxx0__
#include "iom2560.h"

View File

@ -11,6 +11,7 @@
extern "C" {
volatile uint8_t __iomem[1024];
volatile uint8_t SREG = 0x80;
unsigned __brkval = 0x2000;
unsigned __bss_end = 0x1000;
@ -18,19 +19,13 @@ unsigned __bss_end = 0x1000;
// disable interrupts
void cli(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigprocmask(SIG_BLOCK,&set,NULL);
SREG &= ~0x80;
}
// enable interrupts
void sei(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigprocmask(SIG_UNBLOCK,&set,NULL);
SREG |= 0x80;
}
void pinMode(uint8_t pin, uint8_t mode)

View File

@ -228,12 +228,10 @@ static void sitl_simulator_output(void)
static void timer_handler(int signum)
{
static uint32_t last_update_count;
static bool running;
if (running) {
if (_interrupts_are_blocked()) {
return;
}
running = true;
cli();
#ifndef __CYGWIN__
@ -271,13 +269,11 @@ static void timer_handler(int signum)
if (update_count == 0) {
sitl_update_gps(0, 0, 0, 0, 0, false);
sei();
running = false;
return;
}
if (update_count == last_update_count) {
sei();
running = false;
return;
}
last_update_count = update_count;
@ -297,7 +293,6 @@ static void timer_handler(int signum)
ADCSRA &= ~_BV(ADSC);
sei();
running = false;
}