Browse Source

AP_Scheduler: replace tabs with spaces

master
Lucas De Marchi 10 years ago committed by Andrew Tridgell
parent
commit
5dfb3ed70c
  1. 76
      libraries/AP_Scheduler/AP_Scheduler.h

76
libraries/AP_Scheduler/AP_Scheduler.h

@ -29,7 +29,7 @@
A task scheduler for APM main loops A task scheduler for APM main loops
Sketches should call scheduler.init() on startup, then call Sketches should call scheduler.init() on startup, then call
scheduler.tick() at regular intervals (typically every 10ms). scheduler.tick() at regular intervals (typically every 10ms).
To run tasks use scheduler.run(), passing the amount of time that To run tasks use scheduler.run(), passing the amount of time that
the scheduler is allowed to use before it must return the scheduler is allowed to use before it must return
@ -53,25 +53,25 @@ public:
typedef void (*task_fn_t)(void); typedef void (*task_fn_t)(void);
#endif #endif
struct Task { struct Task {
task_fn_t function; task_fn_t function;
uint16_t interval_ticks; uint16_t interval_ticks;
uint16_t max_time_micros; uint16_t max_time_micros;
}; };
// initialise scheduler // initialise scheduler
void init(const Task *tasks, uint8_t num_tasks, void *classptr); void init(const Task *tasks, uint8_t num_tasks, void *classptr);
// call when one tick has passed // call when one tick has passed
void tick(void); void tick(void);
// run the tasks. Call this once per 'tick'. // run the tasks. Call this once per 'tick'.
// time_available is the amount of time available to run // time_available is the amount of time available to run
// tasks in microseconds // tasks in microseconds
void run(uint16_t time_available); void run(uint16_t time_available);
// return the number of microseconds available for the current task // return the number of microseconds available for the current task
uint16_t time_available_usec(void); uint16_t time_available_usec(void);
// return debug parameter // return debug parameter
uint8_t debug(void) { return _debug; } uint8_t debug(void) { return _debug; }
@ -81,33 +81,33 @@ public:
// end of a run() // end of a run()
float load_average(uint32_t tick_time_usec) const; float load_average(uint32_t tick_time_usec) const;
static const struct AP_Param::GroupInfo var_info[]; static const struct AP_Param::GroupInfo var_info[];
// current running task, or -1 if none. Used to debug stuck tasks // current running task, or -1 if none. Used to debug stuck tasks
static int8_t current_task; static int8_t current_task;
private: private:
// used to enable scheduler debugging // used to enable scheduler debugging
AP_Int8 _debug; AP_Int8 _debug;
// progmem list of tasks to run // progmem list of tasks to run
const struct Task *_tasks; const struct Task *_tasks;
// number of tasks in _tasks list // number of tasks in _tasks list
uint8_t _num_tasks; uint8_t _num_tasks;
// number of 'ticks' that have passed (number of times that // number of 'ticks' that have passed (number of times that
// tick() has been called // tick() has been called
uint16_t _tick_counter; uint16_t _tick_counter;
// tick counter at the time we last ran each task // tick counter at the time we last ran each task
uint16_t *_last_run; uint16_t *_last_run;
// number of microseconds allowed for the current task // number of microseconds allowed for the current task
uint32_t _task_time_allowed; uint32_t _task_time_allowed;
// the time in microseconds when the task started // the time in microseconds when the task started
uint32_t _task_time_started; uint32_t _task_time_started;
// number of spare microseconds accumulated // number of spare microseconds accumulated
uint32_t _spare_micros; uint32_t _spare_micros;

Loading…
Cancel
Save