/***************************************************************
 * PrADCTRC.h
 *
 * This is an TRC A/D converter class.
 *
 ****************************************************************/

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

#ifndef _PrADCTRC_h
#define _PrADCTRC_h

#include "PrDriverIntf.h"

class PrUtility;

class PrADCTRC : public PrDriverIntf
{
 public:
    // constructor sets flag
    // flag() should be called before using
    PrADCTRC(int &discreteReg);
    ~PrADCTRC();

    // hardware reset: calls ResetDiscreteBit()
    virtual int zero();

    // read a channel value to 'volt': calls ReadValue()
    virtual int value(int channel,Float &volt);

 private:
    PrUtility *utility_;
    int &discreteReg_;

    // select the channel to read
    int SelectMuxChannel(int channel);

    // toggle the reset discrete bit (interrupt)
    int ResetDiscreteBit();

    // sets the trigger reg to initiate reading
    void TriggerToRead();

    // wait for ~128msec while the value settles down
    void WaitForStatusBit();

    // returns the channel value
    Float ReadValue(int channel);
};

#endif // _PrADCTRC_h
