mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 17:38:32 -04:00
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:
parent
81d77d4a70
commit
74e2ba2168
@ -22,9 +22,9 @@ AVRTimer AVRScheduler::_timer;
|
|||||||
|
|
||||||
AP_HAL::TimedProc AVRScheduler::_failsafe = NULL;
|
AP_HAL::TimedProc AVRScheduler::_failsafe = NULL;
|
||||||
volatile bool AVRScheduler::_timer_suspended = false;
|
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};
|
AP_HAL::TimedProc AVRScheduler::_timer_proc[AVR_SCHEDULER_MAX_TIMER_PROCS] = {NULL};
|
||||||
uint8_t AVRScheduler::_num_timer_procs = 0;
|
uint8_t AVRScheduler::_num_timer_procs = 0;
|
||||||
bool AVRScheduler::_in_timer_proc = false;
|
|
||||||
|
|
||||||
|
|
||||||
AVRScheduler::AVRScheduler() :
|
AVRScheduler::AVRScheduler() :
|
||||||
|
@ -18,6 +18,8 @@ public:
|
|||||||
|
|
||||||
/* Scheduler implementation: */
|
/* Scheduler implementation: */
|
||||||
class AP_HAL_AVR::AVRScheduler : public AP_HAL::Scheduler {
|
class AP_HAL_AVR::AVRScheduler : public AP_HAL::Scheduler {
|
||||||
|
/* AVRSemaphore gets access to _in_timer_proc */
|
||||||
|
friend class AVRSemaphore;
|
||||||
public:
|
public:
|
||||||
AVRScheduler();
|
AVRScheduler();
|
||||||
/* AP_HAL::Scheduler methods */
|
/* AP_HAL::Scheduler methods */
|
||||||
@ -39,6 +41,9 @@ public:
|
|||||||
void panic(const prog_char_t *errormsg);
|
void panic(const prog_char_t *errormsg);
|
||||||
void reboot();
|
void reboot();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static volatile bool _in_timer_proc;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static AVRTimer _timer;
|
static AVRTimer _timer;
|
||||||
|
|
||||||
@ -54,7 +59,6 @@ private:
|
|||||||
static volatile bool _timer_suspended;
|
static volatile bool _timer_suspended;
|
||||||
static AP_HAL::TimedProc _timer_proc[AVR_SCHEDULER_MAX_TIMER_PROCS];
|
static AP_HAL::TimedProc _timer_proc[AVR_SCHEDULER_MAX_TIMER_PROCS];
|
||||||
static uint8_t _num_timer_procs;
|
static uint8_t _num_timer_procs;
|
||||||
static bool _in_timer_proc;
|
|
||||||
|
|
||||||
uint8_t _nested_atomic_ctr;
|
uint8_t _nested_atomic_ctr;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user