// © 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

#include <StepCounter.h>

#include <GPIO.h>

#include <Timers.h>

#include <InputPin.h>


// derived classes

#include <StepDirectionCounter.h>

#include <QuadratureCounter4X.h>

#include <HallCounter.h>

#include <ClosedLoopCounter.h>


#include <driverlib/interrupt.h>



StepCounter::StepCounter() {

//     Serial.println( " StepCounter" );

     stepCount     = 0; };


StepCounter::~StepCounter() {

#ifdef DebugDelete

     Serial.println( " delete StepCounter" );

#endif

};


float

     StepCounter::readScaledCount() {


     IntMasterDisable();

          int32_t counter     = stepCount;

          stepCount          = 0;

     IntMasterEnable();


     return

          scale

     *     counter; };


void

     StepCounter::adjust( int32_t adjustment ) {

     

     stepCount += adjustment; };