mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-02 05:58:30 -04:00
SITL: added SREG declaration
This commit is contained in:
parent
9e9c08b6d7
commit
fe23d27904
@ -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"
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user