AP_HAL_AVR Scheduler: _in_timer_proc is volatile protected

* and AVRSemaphore is a friend, so it can read _in_timer_proc
  to know the current context.
This commit is contained in:
Pat Hickey 2013-01-02 16:32:23 -08:00
parent 81d77d4a70
commit 74e2ba2168
2 changed files with 6 additions and 2 deletions

View File

@ -22,9 +22,9 @@ AVRTimer AVRScheduler::_timer;
AP_HAL::TimedProc AVRScheduler::_failsafe = NULL;
volatile bool AVRScheduler::_timer_suspended = false;
volatile bool AVRScheduler::_in_timer_proc = false;
AP_HAL::TimedProc AVRScheduler::_timer_proc[AVR_SCHEDULER_MAX_TIMER_PROCS] = {NULL};
uint8_t AVRScheduler::_num_timer_procs = 0;
bool AVRScheduler::_in_timer_proc = false;
AVRScheduler::AVRScheduler() :

View File

@ -18,6 +18,8 @@ public:
/* Scheduler implementation: */
class AP_HAL_AVR::AVRScheduler : public AP_HAL::Scheduler {
/* AVRSemaphore gets access to _in_timer_proc */
friend class AVRSemaphore;
public:
AVRScheduler();
/* AP_HAL::Scheduler methods */
@ -39,6 +41,9 @@ public:
void panic(const prog_char_t *errormsg);
void reboot();
protected:
static volatile bool _in_timer_proc;
private:
static AVRTimer _timer;
@ -54,7 +59,6 @@ private:
static volatile bool _timer_suspended;
static AP_HAL::TimedProc _timer_proc[AVR_SCHEDULER_MAX_TIMER_PROCS];
static uint8_t _num_timer_procs;
static bool _in_timer_proc;
uint8_t _nested_atomic_ctr;