PikeAero::CBinaryInputCapture Class Reference

Implements a binary input capture pin. More...

#include <cbinaryinputcapture.h>

Inheritance diagram for PikeAero::CBinaryInputCapture:

Inheritance graph
[legend]
Collaboration diagram for PikeAero::CBinaryInputCapture:

Collaboration graph
[legend]

Public Member Functions

CMachine::ubit16 captureA ()
CMachine::ubit16 captureB ()
 CBinaryInputCapture (CMachine::InterruptVector vector, TIM_TypeDef *TIMx, bool invertA=false, bool invertB=false, CMachine::ubit32 freqency=BASE_TIMER_FREQUENCY)
 Constructor. Target counter frequency is expressed in Hz, default is 2MHz counter.
void disableInterruptsA ()
 disable channel interrupts.
void disableInterruptsB ()
void enableInterruptsA ()
 enable channel interrupts.
void enableInterruptsB ()
virtual void irq (CMachine::InterruptVector v)
 receive a hardware interrupt
CMachine::ubit16 pulseWidthA ()
 return current pulse width
CMachine::ubit16 pulseWidthB ()
void resetPulseWidthA ()
 reset pulse width.
void resetPulseWidthB ()
virtual ~CBinaryInputCapture ()

Protected Member Functions

CMachine::ubit32 statusRegister ()

Private Attributes

CMachine::ubit16 mCaptureA
CMachine::ubit16 mCaptureB
CMachine::ubit16 mPulseWidthA
CMachine::ubit16 mPulseWidthB
CMachine::ubit32 mStatusRegister

Detailed Description

Implements a binary input capture pin.

Author:
Michael Sharkey <mike@pikeaero.com>

Definition at line 31 of file cbinaryinputcapture.h.


Constructor & Destructor Documentation

PikeAero::CBinaryInputCapture::CBinaryInputCapture ( CMachine::InterruptVector  vector,
TIM_TypeDef TIMx,
bool  invertA = false,
bool  invertB = false,
CMachine::ubit32  frequency = BASE_TIMER_FREQUENCY 
)

Constructor. Target counter frequency is expressed in Hz, default is 2MHz counter.

Install self into interupt vector

Select Input Capture mode

Enable Interrupts

Start counter

Parameters:
TIMx The interrupt vector table offset
invertA Pointer to a timer register set
invertB Invert channel A trigger level
frequency Invery channel B trigger level The counter frequency

Definition at line 26 of file cbinaryinputcapture.cpp.

References PikeAero::TIM_TypeDef::CR1, enableInterruptsA(), enableInterruptsB(), PikeAero::CMachine::installVectorIRQ(), PikeAero::CBinaryInputOutputTimer::start(), PikeAero::CBinaryInputOutputTimer::tim(), TIM_IEDGA, and TIM_IEDGB.

00033 : inherited(vector,TIMx,frequency)
00034 , mPulseWidthA(0)
00035 , mPulseWidthB(0)
00036 , mCaptureA(0)
00037 , mCaptureB(0)
00038 {
00039     /** Install self into interupt vector */
00040     CMachine::installVectorIRQ(vector,this);
00041 
00042     /** Select Input Capture mode */
00043     if ( invertA )
00044     {
00045         tim()->CR1 &= ~TIM_IEDGA;
00046     }
00047     else
00048     {
00049         tim()->CR1 |= TIM_IEDGA;
00050     }
00051 
00052     if ( invertB )
00053     {
00054         tim()->CR1 &= ~TIM_IEDGB;
00055     }
00056     else
00057     {
00058         tim()->CR1 |= TIM_IEDGB;
00059     }
00060 
00061     /** Enable Interrupts */
00062     enableInterruptsA();
00063     enableInterruptsB();
00064 
00065     /** Start counter */
00066     start();
00067 }

Here is the call graph for this function:

PikeAero::CBinaryInputCapture::~CBinaryInputCapture (  )  [virtual]

Remove self from interrupt vector

Definition at line 70 of file cbinaryinputcapture.cpp.

References PikeAero::CMachine::removeVectorIRQ().

00071 {
00072     /** Remove self from interrupt vector */
00073     CMachine::removeVectorIRQ(this);
00074 }

Here is the call graph for this function:


Member Function Documentation

CMachine::ubit16 PikeAero::CBinaryInputCapture::captureA (  )  [inline]

Definition at line 46 of file cbinaryinputcapture.h.

References mCaptureA.

00046 { return mCaptureA; }

CMachine::ubit16 PikeAero::CBinaryInputCapture::captureB (  )  [inline]

Definition at line 47 of file cbinaryinputcapture.h.

References mCaptureB.

00047 { return mCaptureB; }

void PikeAero::CBinaryInputCapture::disableInterruptsA (  )  [inline]

disable channel interrupts.

Definition at line 70 of file cbinaryinputcapture.h.

References PikeAero::TIM_TypeDef::CR2, PikeAero::CBinaryInputOutputTimer::tim(), and TIM_ICAIE.

Referenced by resetPulseWidthA().

00070 { tim()->CR2 &= ~TIM_ICAIE; }

Here is the call graph for this function:

Here is the caller graph for this function:

void PikeAero::CBinaryInputCapture::disableInterruptsB (  )  [inline]

Definition at line 71 of file cbinaryinputcapture.h.

References PikeAero::TIM_TypeDef::CR2, PikeAero::CBinaryInputOutputTimer::tim(), and TIM_ICBIE.

Referenced by resetPulseWidthB().

00071 { tim()->CR2 &= ~TIM_ICBIE; }

Here is the call graph for this function:

Here is the caller graph for this function:

void PikeAero::CBinaryInputCapture::enableInterruptsA (  )  [inline]

enable channel interrupts.

Definition at line 64 of file cbinaryinputcapture.h.

References PikeAero::TIM_TypeDef::CR2, PikeAero::CBinaryInputOutputTimer::tim(), and TIM_ICAIE.

Referenced by CBinaryInputCapture(), and resetPulseWidthA().

00064 { tim()->CR2 |= TIM_ICAIE; }

Here is the call graph for this function:

Here is the caller graph for this function:

void PikeAero::CBinaryInputCapture::enableInterruptsB (  )  [inline]

Definition at line 65 of file cbinaryinputcapture.h.

References PikeAero::TIM_TypeDef::CR2, PikeAero::CBinaryInputOutputTimer::tim(), and TIM_ICBIE.

Referenced by CBinaryInputCapture(), and resetPulseWidthB().

00065 { tim()->CR2 |= TIM_ICBIE; }

Here is the call graph for this function:

Here is the caller graph for this function:

void PikeAero::CBinaryInputCapture::irq ( CMachine::InterruptVector  v  )  [virtual]

receive a hardware interrupt

capture the status register state

Input Capture Flag A

Input Capture Flag B

Reimplemented from PikeAero::CObject.

Reimplemented in PikeAero::CInputTiming, and PikeAero::CInputTimingToothCounter.

Definition at line 79 of file cbinaryinputcapture.cpp.

References PikeAero::TIM_TypeDef::ICAR, PikeAero::TIM_TypeDef::ICBR, mCaptureA, mCaptureB, mPulseWidthA, mPulseWidthB, mStatusRegister, PikeAero::TIM_TypeDef::SR, statusRegister(), PikeAero::CBinaryInputOutputTimer::tim(), TIM_ICFA, and TIM_ICFB.

00080 {
00081     /** capture the status register state */
00082     mStatusRegister = tim()->SR;
00083 
00084     /** Input Capture Flag A */
00085     if ( statusRegister() & TIM_ICFA )
00086     {
00087         tim()->SR = (CMachine::ubit16)(~TIM_ICFA);
00088         mPulseWidthA = (tim()->ICAR - mCaptureA);
00089         mCaptureA = tim()->ICAR;
00090     }
00091 
00092     /** Input Capture Flag B */
00093     if ( statusRegister() & TIM_ICFB )
00094     {
00095         tim()->SR = (CMachine::ubit16)(~TIM_ICFB);
00096         mPulseWidthB = (tim()->ICBR - mCaptureB);
00097         mCaptureB = tim()->ICBR;
00098     }
00099 }

Here is the call graph for this function:

CMachine::ubit16 PikeAero::CBinaryInputCapture::pulseWidthA (  )  [inline]

return current pulse width

Definition at line 52 of file cbinaryinputcapture.h.

References mPulseWidthA.

Referenced by PikeAero::CTaskAggregator::calculateRPM(), and PikeAero::CInputTimingToothCounter::irq().

00052 {return mPulseWidthA;}

Here is the caller graph for this function:

CMachine::ubit16 PikeAero::CBinaryInputCapture::pulseWidthB (  )  [inline]

Definition at line 53 of file cbinaryinputcapture.h.

References mPulseWidthB.

Referenced by PikeAero::CTaskAggregator::calculateRPM(), and PikeAero::CInputTimingToothCounter::irq().

00053 {return mPulseWidthB;}

Here is the caller graph for this function:

void PikeAero::CBinaryInputCapture::resetPulseWidthA (  )  [inline]

reset pulse width.

Definition at line 58 of file cbinaryinputcapture.h.

References disableInterruptsA(), enableInterruptsA(), and mPulseWidthA.

Here is the call graph for this function:

void PikeAero::CBinaryInputCapture::resetPulseWidthB (  )  [inline]

Definition at line 59 of file cbinaryinputcapture.h.

References disableInterruptsB(), enableInterruptsB(), and mPulseWidthB.

Here is the call graph for this function:

CMachine::ubit32 PikeAero::CBinaryInputCapture::statusRegister (  )  [inline, protected]

Definition at line 79 of file cbinaryinputcapture.h.

References mStatusRegister.

Referenced by PikeAero::CInputTimingToothCounter::irq(), PikeAero::CInputTiming::irq(), and irq().

00079 {return mStatusRegister;}

Here is the caller graph for this function:


Field Documentation

Definition at line 84 of file cbinaryinputcapture.h.

Referenced by captureA(), and irq().

Definition at line 85 of file cbinaryinputcapture.h.

Referenced by captureB(), and irq().

Definition at line 82 of file cbinaryinputcapture.h.

Referenced by irq(), pulseWidthA(), and resetPulseWidthA().

Definition at line 83 of file cbinaryinputcapture.h.

Referenced by irq(), pulseWidthB(), and resetPulseWidthB().

Definition at line 86 of file cbinaryinputcapture.h.

Referenced by irq(), and statusRegister().


The documentation for this class was generated from the following files:

Generated on Sun Oct 25 13:59:43 2009 for stingray3 by  doxygen 1.5.8