SITL: implement cli()/sei() properly for desktop build

this disables simulated hardware interrupts during critical sections
This commit is contained in:
Andrew Tridgell 2012-02-28 18:05:05 +11:00
parent c84d864cd6
commit c9031f1d36
2 changed files with 23 additions and 2 deletions

View File

@ -6,7 +6,9 @@
#define ISR(vector,...) void vector(void); \
void vector(void)
#define cli()
#define sei()
extern "C" {
void cli(void);
void sei(void);
}
#endif

View File

@ -5,6 +5,7 @@
#include "avr/pgmspace.h"
#include <BetterStream.h>
#include <sys/time.h>
#include <signal.h>
#include "desktop.h"
extern "C" {
@ -14,6 +15,24 @@ volatile uint8_t __iomem[1024];
unsigned __brkval = 0x2000;
unsigned __bss_end = 0x1000;
// disable interrupts
void cli(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigprocmask(SIG_BLOCK,&set,NULL);
}
// enable interrupts
void sei(void)
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGALRM);
sigprocmask(SIG_UNBLOCK,&set,NULL);
}
void pinMode(uint8_t pin, uint8_t mode)
{