mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-08 17:03:57 -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]
|
#define _SFR_IO8(addr) __iomem[addr]
|
||||||
|
|
||||||
|
extern "C" volatile uint8_t SREG;
|
||||||
|
|
||||||
|
#define _interrupts_are_blocked() ((SREG&0x80)==0)
|
||||||
|
|
||||||
#define __ATmegaxx0__
|
#define __ATmegaxx0__
|
||||||
#include "iom2560.h"
|
#include "iom2560.h"
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
volatile uint8_t __iomem[1024];
|
volatile uint8_t __iomem[1024];
|
||||||
|
volatile uint8_t SREG = 0x80;
|
||||||
|
|
||||||
unsigned __brkval = 0x2000;
|
unsigned __brkval = 0x2000;
|
||||||
unsigned __bss_end = 0x1000;
|
unsigned __bss_end = 0x1000;
|
||||||
@ -18,19 +19,13 @@ unsigned __bss_end = 0x1000;
|
|||||||
// disable interrupts
|
// disable interrupts
|
||||||
void cli(void)
|
void cli(void)
|
||||||
{
|
{
|
||||||
sigset_t set;
|
SREG &= ~0x80;
|
||||||
sigemptyset(&set);
|
|
||||||
sigaddset(&set, SIGALRM);
|
|
||||||
sigprocmask(SIG_BLOCK,&set,NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable interrupts
|
// enable interrupts
|
||||||
void sei(void)
|
void sei(void)
|
||||||
{
|
{
|
||||||
sigset_t set;
|
SREG |= 0x80;
|
||||||
sigemptyset(&set);
|
|
||||||
sigaddset(&set, SIGALRM);
|
|
||||||
sigprocmask(SIG_UNBLOCK,&set,NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pinMode(uint8_t pin, uint8_t mode)
|
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 void timer_handler(int signum)
|
||||||
{
|
{
|
||||||
static uint32_t last_update_count;
|
static uint32_t last_update_count;
|
||||||
static bool running;
|
|
||||||
|
|
||||||
if (running) {
|
if (_interrupts_are_blocked()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
running = true;
|
|
||||||
cli();
|
cli();
|
||||||
|
|
||||||
#ifndef __CYGWIN__
|
#ifndef __CYGWIN__
|
||||||
@ -271,13 +269,11 @@ static void timer_handler(int signum)
|
|||||||
if (update_count == 0) {
|
if (update_count == 0) {
|
||||||
sitl_update_gps(0, 0, 0, 0, 0, false);
|
sitl_update_gps(0, 0, 0, 0, 0, false);
|
||||||
sei();
|
sei();
|
||||||
running = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_count == last_update_count) {
|
if (update_count == last_update_count) {
|
||||||
sei();
|
sei();
|
||||||
running = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
last_update_count = update_count;
|
last_update_count = update_count;
|
||||||
@ -297,7 +293,6 @@ static void timer_handler(int signum)
|
|||||||
ADCSRA &= ~_BV(ADSC);
|
ADCSRA &= ~_BV(ADSC);
|
||||||
|
|
||||||
sei();
|
sei();
|
||||||
running = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user