HAL_Linux: update for new scheduler API
This commit is contained in:
parent
1d820761be
commit
cca59ce3c9
@ -1,5 +1,7 @@
|
||||
|
||||
#include <AP_HAL.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
#include "I2CDriver.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -145,3 +147,4 @@ uint8_t LinuxI2CDriver::lockup_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif // CONFIG_HAL_BOARD
|
||||
|
@ -1,3 +1,6 @@
|
||||
#include <AP_HAL.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
|
||||
#include "Scheduler.h"
|
||||
#include "Storage.h"
|
||||
@ -81,7 +84,7 @@ void LinuxScheduler::register_delay_callback(AP_HAL::Proc proc,
|
||||
_min_delay_cb_ms = min_time_ms;
|
||||
}
|
||||
|
||||
void LinuxScheduler::register_timer_process(AP_HAL::TimedProc proc)
|
||||
void LinuxScheduler::register_timer_process(AP_HAL::TimedProc proc, void *arg)
|
||||
{
|
||||
for (uint8_t i = 0; i < _num_timer_procs; i++) {
|
||||
if (_timer_proc[i] == proc) {
|
||||
@ -91,13 +94,14 @@ void LinuxScheduler::register_timer_process(AP_HAL::TimedProc proc)
|
||||
|
||||
if (_num_timer_procs < LINUX_SCHEDULER_MAX_TIMER_PROCS) {
|
||||
_timer_proc[_num_timer_procs] = proc;
|
||||
_timer_arg[_num_timer_procs] = arg;
|
||||
_num_timer_procs++;
|
||||
} else {
|
||||
hal.console->printf("Out of timer processes\n");
|
||||
}
|
||||
}
|
||||
|
||||
void LinuxScheduler::register_io_process(AP_HAL::TimedProc proc)
|
||||
void LinuxScheduler::register_io_process(AP_HAL::TimedProc proc, void *arg)
|
||||
{
|
||||
for (uint8_t i = 0; i < _num_io_procs; i++) {
|
||||
if (_io_proc[i] == proc) {
|
||||
@ -107,6 +111,7 @@ void LinuxScheduler::register_io_process(AP_HAL::TimedProc proc)
|
||||
|
||||
if (_num_io_procs < LINUX_SCHEDULER_MAX_TIMER_PROCS) {
|
||||
_io_proc[_num_io_procs] = proc;
|
||||
_io_arg[_num_io_procs] = arg;
|
||||
_num_io_procs++;
|
||||
} else {
|
||||
hal.console->printf("Out of IO processes\n");
|
||||
@ -145,7 +150,7 @@ void LinuxScheduler::_run_timers(bool called_from_timer_thread)
|
||||
// now call the timer based drivers
|
||||
for (int i = 0; i < _num_timer_procs; i++) {
|
||||
if (_timer_proc[i] != NULL) {
|
||||
_timer_proc[i](tnow);
|
||||
_timer_proc[i](_timer_arg[i]);
|
||||
}
|
||||
}
|
||||
} else if (called_from_timer_thread) {
|
||||
@ -154,7 +159,7 @@ void LinuxScheduler::_run_timers(bool called_from_timer_thread)
|
||||
|
||||
// and the failsafe, if one is setup
|
||||
if (_failsafe != NULL) {
|
||||
_failsafe(tnow);
|
||||
_failsafe(NULL);
|
||||
}
|
||||
|
||||
_in_timer_proc = false;
|
||||
@ -184,7 +189,7 @@ void LinuxScheduler::_run_io(void)
|
||||
// now call the IO based drivers
|
||||
for (int i = 0; i < _num_io_procs; i++) {
|
||||
if (_io_proc[i] != NULL) {
|
||||
_io_proc[i](tnow);
|
||||
_io_proc[i](_io_arg[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,3 +256,5 @@ void LinuxScheduler::reboot(bool hold_in_bootloader)
|
||||
{
|
||||
for(;;);
|
||||
}
|
||||
|
||||
#endif // CONFIG_HAL_BOARD
|
||||
|
@ -3,6 +3,8 @@
|
||||
#define __AP_HAL_LINUX_SCHEDULER_H__
|
||||
|
||||
#include <AP_HAL_Linux.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
@ -24,8 +26,8 @@ public:
|
||||
void register_delay_callback(AP_HAL::Proc,
|
||||
uint16_t min_time_ms);
|
||||
|
||||
void register_timer_process(AP_HAL::TimedProc);
|
||||
void register_io_process(AP_HAL::TimedProc);
|
||||
void register_timer_process(AP_HAL::TimedProc, void *arg);
|
||||
void register_io_process(AP_HAL::TimedProc, void *arg);
|
||||
void suspend_timer_procs();
|
||||
void resume_timer_procs();
|
||||
|
||||
@ -58,10 +60,12 @@ private:
|
||||
volatile bool _timer_suspended;
|
||||
|
||||
AP_HAL::TimedProc _timer_proc[LINUX_SCHEDULER_MAX_TIMER_PROCS];
|
||||
void * _timer_arg[LINUX_SCHEDULER_MAX_TIMER_PROCS];
|
||||
uint8_t _num_timer_procs;
|
||||
volatile bool _in_timer_proc;
|
||||
|
||||
AP_HAL::TimedProc _io_proc[LINUX_SCHEDULER_MAX_TIMER_PROCS];
|
||||
void * _io_arg[LINUX_SCHEDULER_MAX_TIMER_PROCS];
|
||||
uint8_t _num_io_procs;
|
||||
volatile bool _in_io_proc;
|
||||
|
||||
@ -79,4 +83,6 @@ private:
|
||||
void _run_io(void);
|
||||
};
|
||||
|
||||
#endif // CONFIG_HAL_BOARD
|
||||
|
||||
#endif // __AP_HAL_LINUX_SCHEDULER_H__
|
||||
|
@ -1,3 +1,7 @@
|
||||
#include <AP_HAL.h>
|
||||
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
|
||||
#include "UARTDriver.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -172,3 +176,5 @@ size_t LinuxUARTDriver::write(uint8_t c)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // CONFIG_HAL_BOARD
|
||||
|
Loading…
Reference in New Issue
Block a user