-
Notifications
You must be signed in to change notification settings - Fork 18.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f5a83d
commit 1e2e086
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "Task.h" | ||
#include <AP_HAL/AP_HAL.h> | ||
|
||
extern const AP_HAL::HAL &hal; | ||
|
||
namespace Linux { | ||
|
||
bool Task::_run() | ||
{ | ||
if (!_task_init) { | ||
return false; | ||
} | ||
if (!_task_body) { | ||
return false; | ||
} | ||
|
||
_task_init(); | ||
while (true) { | ||
const uint32_t delay_us = _task_body(); | ||
hal.scheduler->delay_microseconds(delay_us); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "Thread.h" | ||
|
||
namespace Linux { | ||
class Task : public Thread { | ||
public: | ||
FUNCTOR_TYPEDEF(task_body_t, uint32_t); | ||
|
||
Task(task_t t_init, task_body_t t_body) : | ||
Thread(t_init), // t_init not used from here | ||
_task_init{t_init}, | ||
_task_body{t_body} | ||
{ } | ||
|
||
protected: | ||
|
||
bool _run() override; | ||
|
||
private: | ||
task_t _task_init; | ||
task_body_t _task_body; | ||
|
||
}; | ||
} |