|
|
|
@ -16,29 +16,29 @@ using namespace HALSITL;
@@ -16,29 +16,29 @@ using namespace HALSITL;
|
|
|
|
|
extern const AP_HAL::HAL& hal; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AP_HAL::Proc SITLScheduler::_failsafe = NULL; |
|
|
|
|
volatile bool SITLScheduler::_timer_suspended = false; |
|
|
|
|
volatile bool SITLScheduler::_timer_event_missed = false; |
|
|
|
|
AP_HAL::Proc Scheduler::_failsafe = NULL; |
|
|
|
|
volatile bool Scheduler::_timer_suspended = false; |
|
|
|
|
volatile bool Scheduler::_timer_event_missed = false; |
|
|
|
|
|
|
|
|
|
AP_HAL::MemberProc SITLScheduler::_timer_proc[SITL_SCHEDULER_MAX_TIMER_PROCS] = {NULL}; |
|
|
|
|
uint8_t SITLScheduler::_num_timer_procs = 0; |
|
|
|
|
bool SITLScheduler::_in_timer_proc = false; |
|
|
|
|
AP_HAL::MemberProc Scheduler::_timer_proc[SITL_SCHEDULER_MAX_TIMER_PROCS] = {NULL}; |
|
|
|
|
uint8_t Scheduler::_num_timer_procs = 0; |
|
|
|
|
bool Scheduler::_in_timer_proc = false; |
|
|
|
|
|
|
|
|
|
AP_HAL::MemberProc SITLScheduler::_io_proc[SITL_SCHEDULER_MAX_TIMER_PROCS] = {NULL}; |
|
|
|
|
uint8_t SITLScheduler::_num_io_procs = 0; |
|
|
|
|
bool SITLScheduler::_in_io_proc = false; |
|
|
|
|
AP_HAL::MemberProc Scheduler::_io_proc[SITL_SCHEDULER_MAX_TIMER_PROCS] = {NULL}; |
|
|
|
|
uint8_t Scheduler::_num_io_procs = 0; |
|
|
|
|
bool Scheduler::_in_io_proc = false; |
|
|
|
|
|
|
|
|
|
SITLScheduler::SITLScheduler(SITL_State *sitlState) : |
|
|
|
|
Scheduler::Scheduler(SITL_State *sitlState) : |
|
|
|
|
_sitlState(sitlState), |
|
|
|
|
_stopped_clock_usec(0) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::init() |
|
|
|
|
void Scheduler::init() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::delay_microseconds(uint16_t usec) |
|
|
|
|
void Scheduler::delay_microseconds(uint16_t usec) |
|
|
|
|
{ |
|
|
|
|
uint64_t start = AP_HAL::micros64(); |
|
|
|
|
uint64_t dtime; |
|
|
|
@ -51,7 +51,7 @@ void SITLScheduler::delay_microseconds(uint16_t usec)
@@ -51,7 +51,7 @@ void SITLScheduler::delay_microseconds(uint16_t usec)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::delay(uint16_t ms) |
|
|
|
|
void Scheduler::delay(uint16_t ms) |
|
|
|
|
{ |
|
|
|
|
while (ms > 0) { |
|
|
|
|
delay_microseconds(1000); |
|
|
|
@ -64,14 +64,14 @@ void SITLScheduler::delay(uint16_t ms)
@@ -64,14 +64,14 @@ void SITLScheduler::delay(uint16_t ms)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::register_delay_callback(AP_HAL::Proc proc, |
|
|
|
|
void Scheduler::register_delay_callback(AP_HAL::Proc proc, |
|
|
|
|
uint16_t min_time_ms) |
|
|
|
|
{ |
|
|
|
|
_delay_cb = proc; |
|
|
|
|
_min_delay_cb_ms = min_time_ms; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::register_timer_process(AP_HAL::MemberProc proc) |
|
|
|
|
void Scheduler::register_timer_process(AP_HAL::MemberProc proc) |
|
|
|
|
{ |
|
|
|
|
for (uint8_t i = 0; i < _num_timer_procs; i++) { |
|
|
|
|
if (_timer_proc[i] == proc) { |
|
|
|
@ -86,7 +86,7 @@ void SITLScheduler::register_timer_process(AP_HAL::MemberProc proc)
@@ -86,7 +86,7 @@ void SITLScheduler::register_timer_process(AP_HAL::MemberProc proc)
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::register_io_process(AP_HAL::MemberProc proc) |
|
|
|
|
void Scheduler::register_io_process(AP_HAL::MemberProc proc) |
|
|
|
|
{ |
|
|
|
|
for (uint8_t i = 0; i < _num_io_procs; i++) { |
|
|
|
|
if (_io_proc[i] == proc) { |
|
|
|
@ -101,16 +101,16 @@ void SITLScheduler::register_io_process(AP_HAL::MemberProc proc)
@@ -101,16 +101,16 @@ void SITLScheduler::register_io_process(AP_HAL::MemberProc proc)
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::register_timer_failsafe(AP_HAL::Proc failsafe, uint32_t period_us) |
|
|
|
|
void Scheduler::register_timer_failsafe(AP_HAL::Proc failsafe, uint32_t period_us) |
|
|
|
|
{ |
|
|
|
|
_failsafe = failsafe; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::suspend_timer_procs() { |
|
|
|
|
void Scheduler::suspend_timer_procs() { |
|
|
|
|
_timer_suspended = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::resume_timer_procs() { |
|
|
|
|
void Scheduler::resume_timer_procs() { |
|
|
|
|
_timer_suspended = false; |
|
|
|
|
if (_timer_event_missed) { |
|
|
|
|
_timer_event_missed = false; |
|
|
|
@ -118,15 +118,15 @@ void SITLScheduler::resume_timer_procs() {
@@ -118,15 +118,15 @@ void SITLScheduler::resume_timer_procs() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SITLScheduler::in_timerprocess() { |
|
|
|
|
bool Scheduler::in_timerprocess() { |
|
|
|
|
return _in_timer_proc || _in_io_proc; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool SITLScheduler::system_initializing() { |
|
|
|
|
bool Scheduler::system_initializing() { |
|
|
|
|
return !_initialized; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::system_initialized() { |
|
|
|
|
void Scheduler::system_initialized() { |
|
|
|
|
if (_initialized) { |
|
|
|
|
AP_HAL::panic( |
|
|
|
|
"PANIC: scheduler system initialized called more than once"); |
|
|
|
@ -144,19 +144,19 @@ void SITLScheduler::system_initialized() {
@@ -144,19 +144,19 @@ void SITLScheduler::system_initialized() {
|
|
|
|
|
_initialized = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::sitl_end_atomic() { |
|
|
|
|
void Scheduler::sitl_end_atomic() { |
|
|
|
|
if (_nested_atomic_ctr == 0) |
|
|
|
|
hal.uartA->println("NESTED ATOMIC ERROR"); |
|
|
|
|
else |
|
|
|
|
_nested_atomic_ctr--; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::reboot(bool hold_in_bootloader) |
|
|
|
|
void Scheduler::reboot(bool hold_in_bootloader) |
|
|
|
|
{ |
|
|
|
|
hal.uartA->println("REBOOT NOT IMPLEMENTED\r\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::_run_timer_procs(bool called_from_isr) |
|
|
|
|
void Scheduler::_run_timer_procs(bool called_from_isr) |
|
|
|
|
{ |
|
|
|
|
if (_in_timer_proc) { |
|
|
|
|
// the timer calls took longer than the period of the
|
|
|
|
@ -195,7 +195,7 @@ void SITLScheduler::_run_timer_procs(bool called_from_isr)
@@ -195,7 +195,7 @@ void SITLScheduler::_run_timer_procs(bool called_from_isr)
|
|
|
|
|
_in_timer_proc = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SITLScheduler::_run_io_procs(bool called_from_isr) |
|
|
|
|
void Scheduler::_run_io_procs(bool called_from_isr) |
|
|
|
|
{ |
|
|
|
|
if (_in_io_proc) { |
|
|
|
|
return; |
|
|
|
@ -215,17 +215,17 @@ void SITLScheduler::_run_io_procs(bool called_from_isr)
@@ -215,17 +215,17 @@ void SITLScheduler::_run_io_procs(bool called_from_isr)
|
|
|
|
|
|
|
|
|
|
_in_io_proc = false; |
|
|
|
|
|
|
|
|
|
SITLUARTDriver::from(hal.uartA)->_timer_tick(); |
|
|
|
|
SITLUARTDriver::from(hal.uartB)->_timer_tick(); |
|
|
|
|
SITLUARTDriver::from(hal.uartC)->_timer_tick(); |
|
|
|
|
SITLUARTDriver::from(hal.uartD)->_timer_tick(); |
|
|
|
|
SITLUARTDriver::from(hal.uartE)->_timer_tick(); |
|
|
|
|
UARTDriver::from(hal.uartA)->_timer_tick(); |
|
|
|
|
UARTDriver::from(hal.uartB)->_timer_tick(); |
|
|
|
|
UARTDriver::from(hal.uartC)->_timer_tick(); |
|
|
|
|
UARTDriver::from(hal.uartD)->_timer_tick(); |
|
|
|
|
UARTDriver::from(hal.uartE)->_timer_tick(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
set simulation timestamp |
|
|
|
|
*/ |
|
|
|
|
void SITLScheduler::stop_clock(uint64_t time_usec) |
|
|
|
|
void Scheduler::stop_clock(uint64_t time_usec) |
|
|
|
|
{ |
|
|
|
|
_stopped_clock_usec = time_usec; |
|
|
|
|
_run_io_procs(false); |
|
|
|
|