This commit is contained in:
15
src/opst.cpp
15
src/opst.cpp
@@ -84,15 +84,12 @@ void pwmInFallingEdgeISR()
|
|||||||
{
|
{
|
||||||
mOpstFiFo.mData[mOpstFiFo.mIn].mFalling = micros();
|
mOpstFiFo.mData[mOpstFiFo.mIn].mFalling = micros();
|
||||||
mOpstFiFo.mIn++;
|
mOpstFiFo.mIn++;
|
||||||
|
mOpstFiFo.mIn %= OPST_FIFO_SIZE;
|
||||||
|
|
||||||
if(mOpstFiFo.mOut == mOpstFiFo.mIn)
|
if(mOpstFiFo.mOut == mOpstFiFo.mIn)
|
||||||
{
|
{
|
||||||
mOpstFiFo.mOverrun = true;
|
mOpstFiFo.mOverrun = true;
|
||||||
}
|
}
|
||||||
if(OPST_FIFO_SIZE <= mOpstFiFo.mIn)
|
|
||||||
{
|
|
||||||
mOpstFiFo.mIn = 0;
|
|
||||||
}
|
|
||||||
attachInterrupt(digitalPinToInterrupt(mOpstPin), pwmInRisingEdgeISR, RISING);
|
attachInterrupt(digitalPinToInterrupt(mOpstPin), pwmInRisingEdgeISR, RISING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,14 +128,8 @@ void opstUpdate()
|
|||||||
uint32_t pulseInterval = 0; // time between rising edge of current pulse and rising edge of following pulse
|
uint32_t pulseInterval = 0; // time between rising edge of current pulse and rising edge of following pulse
|
||||||
uint32_t pulseLen = 0; // time between rising edge of current pulse and falling edge of current pulse
|
uint32_t pulseLen = 0; // time between rising edge of current pulse and falling edge of current pulse
|
||||||
|
|
||||||
if(OPST_FIFO_SIZE > (mOpstFiFo.mOut + 1))
|
nextOut = mOpstFiFo.mOut + 1;
|
||||||
{
|
nextOut %= OPST_FIFO_SIZE;
|
||||||
nextOut = mOpstFiFo.mOut + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nextOut = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pulseInterval = mOpstFiFo.mData[nextOut].mRising - mOpstFiFo.mData[mOpstFiFo.mOut].mRising;
|
pulseInterval = mOpstFiFo.mData[nextOut].mRising - mOpstFiFo.mData[mOpstFiFo.mOut].mRising;
|
||||||
pulseLen = mOpstFiFo.mData[mOpstFiFo.mOut].mFalling - mOpstFiFo.mData[mOpstFiFo.mOut].mRising;
|
pulseLen = mOpstFiFo.mData[mOpstFiFo.mOut].mFalling - mOpstFiFo.mData[mOpstFiFo.mOut].mRising;
|
||||||
|
|||||||
Reference in New Issue
Block a user