From a228519b18a5e5fef1c1a74c0c953b35f0de6e6d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 10 Jan 2013 13:50:32 -0800 Subject: [PATCH] AP_HAL_AVR_SITL: Implement new Scheduler methods --- libraries/AP_HAL_AVR_SITL/Scheduler.cpp | 16 ++++++++++++++++ libraries/AP_HAL_AVR_SITL/Scheduler.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/libraries/AP_HAL_AVR_SITL/Scheduler.cpp b/libraries/AP_HAL_AVR_SITL/Scheduler.cpp index 62fa7ae6f4..03e60febcd 100644 --- a/libraries/AP_HAL_AVR_SITL/Scheduler.cpp +++ b/libraries/AP_HAL_AVR_SITL/Scheduler.cpp @@ -117,6 +117,22 @@ void SITLScheduler::resume_timer_procs() { } } +bool SITLScheduler::in_timerprocess() { + return _in_timer_proc; +} + +bool SITLScheduler::system_initializing() { + return !_initialized; +} + +void SITLScheduler::system_initialized() { + if (_initialized) { + panic( + PSTR("PANIC: scheduler system initialized called more than once")); + } + _initialized = true; +} + void SITLScheduler::sitl_end_atomic() { if (_nested_atomic_ctr == 0) hal.uartA->println_P(PSTR("NESTED ATOMIC ERROR")); diff --git a/libraries/AP_HAL_AVR_SITL/Scheduler.h b/libraries/AP_HAL_AVR_SITL/Scheduler.h index 4931ec862e..3efbf33a81 100644 --- a/libraries/AP_HAL_AVR_SITL/Scheduler.h +++ b/libraries/AP_HAL_AVR_SITL/Scheduler.h @@ -26,7 +26,13 @@ public: void suspend_timer_procs(); void resume_timer_procs(); + bool in_timerprocess(); + void register_timer_failsafe(AP_HAL::TimedProc, uint32_t period_us); + + bool system_initializing(); + void system_initialized(); + void reboot(); void panic(const prog_char_t *errormsg); @@ -54,6 +60,8 @@ private: static uint8_t _num_timer_procs; static bool _in_timer_proc; + bool _initialized; + }; #endif #endif // __AP_HAL_SITL_SCHEDULER_H__