/***************************************************************
 * PrITimer.h
 *
 * This class provides the interface to the timer based on interrupt.
 *
 ****************************************************************/

/*
 * modification history
 *----------------------
 *
 * 10/26/97: K.C. Chang: created.
 */

#ifndef _PrITimer_h
#define _PrITimer_h

#include "PrGlobalDefn.h"

#define PR_ITIMER_OK              1
#define PR_ITIMER_ERROR           0

#define PR_ITIMER_FREQUENCY_DEFAULT       1000   // (2 <= freq <= 2000)Hz
#define PR_ITIMER_FREQUENCY_MAX           2000 // 0.5 msec(1.0/PR_ITIMER_RESOLUTION_SEC)
#define PR_ITIMER_FREQUENCY_MIN           2 

class PrITimer
{
 public:
    PrITimer(int frequency = PR_ITIMER_FREQUENCY_DEFAULT);
    ~PrITimer();

    int flag() { return flag_; }
    int frequency() { return frequency_; }
    int zero();
    int start();
    int wait();
    double time();
    int usleep(long usec);
    int selfTest(int loop);

 private:
    int flag_;
    int frequency_;
    int interruptHandlerID_;

    int Initialize();
    int Error(char *mesg);
    int Resolution();
    int Quit();

    PrITimer(const PrITimer &) {}
};

#endif // _PrITimer_h



