2011-11-12 23:02:24 -04:00
|
|
|
|
|
|
|
#ifndef __AP_TIMERPROCESS_H__
|
|
|
|
#define __AP_TIMERPROCESS_H__
|
|
|
|
|
|
|
|
#include "PeriodicProcess.h"
|
|
|
|
#include "../Arduino_Mega_ISR_Registry/Arduino_Mega_ISR_Registry.h"
|
|
|
|
|
2011-12-16 03:50:28 -04:00
|
|
|
// default to 1kHz timer interrupt
|
|
|
|
#define TIMERPROCESS_PER_DEFAULT (256-62) // 1kHz
|
2011-11-12 23:02:24 -04:00
|
|
|
|
2011-12-09 01:27:50 -04:00
|
|
|
#define AP_TIMERPROCESS_MAX_PROCS 3
|
|
|
|
|
2011-11-12 23:02:24 -04:00
|
|
|
class AP_TimerProcess : public AP_PeriodicProcess
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AP_TimerProcess(int period = TIMERPROCESS_PER_DEFAULT);
|
|
|
|
void init( Arduino_Mega_ISR_Registry * isr_reg );
|
2011-12-21 08:21:39 -04:00
|
|
|
void register_process(ap_procedure proc);
|
|
|
|
void set_failsafe(ap_procedure proc);
|
2011-11-12 23:02:24 -04:00
|
|
|
static void run(void);
|
|
|
|
protected:
|
2011-12-09 01:27:50 -04:00
|
|
|
static int _period;
|
|
|
|
static ap_procedure _proc[AP_TIMERPROCESS_MAX_PROCS];
|
2011-12-21 08:21:39 -04:00
|
|
|
static ap_procedure _failsafe;
|
2011-12-09 01:27:50 -04:00
|
|
|
static int _pidx;
|
2011-12-21 08:21:39 -04:00
|
|
|
static bool _in_timer_call;
|
2011-11-12 23:02:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __AP_TIMERPROCESS_H__
|