// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved


// This software makes use of tools and libraries obtained from open source projects or released for

// use by relevant hardware manufactures. However, this software is NOT a part of any open source project.

// It is released only on a "need to know" basis for beta testers of the "RiceCNC Interpolation Engine".

// Recipents of this source code must respect the confidential nature of this software and prevent any

// distribution that could result in counterfeit copies of the "RiceCNC Interpolation Engine".


// © RiceMotion ( Robert Carl Rice ) 2012-2016 - All rights reserved

#ifndef QEI4X_h

#define QEI4X_h


#include "Energia.h"

#include <StepCounter.h>


class InputPin;



class QEI4X : public StepCounter {

     uint32_t qCount;


     typedef union {

          struct {

               uint     enable               : 1;

               uint     swap               : 1;

               uint     stepDir               : 1;

               uint     capture4X          : 1;

               uint     indexReset          : 1;

               uint     captureVelocity     : 1;

               uint     velocityPreDiv     : 3;

               uint     invertA               : 1;

               uint     invertB               : 1;

               uint     invertIndx          : 1;

               uint     stallEnable          : 1;

               uint     filterEnable     : 1;

               uint     reserved          : 2;

               uint     filterPreScale     : 4; } st;

          uint32_t     qeiCtl; } QEIunion;

     

     public:

          QEI4X(

               float          scale );


          ~QEI4X();


          virtual float     readScaledCount();

          virtual void     adjust( int32_t adjustment );

};


#endif