#include <cbinaryinputcapture.h>


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 |
Definition at line 31 of file cbinaryinputcapture.h.
| 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
| 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 }

| 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 }

| 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().


| 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().


| 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().


| 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().


| 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 }

| 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;}

| 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;}

| void PikeAero::CBinaryInputCapture::resetPulseWidthA | ( | ) | [inline] |
reset pulse width.
Definition at line 58 of file cbinaryinputcapture.h.
References disableInterruptsA(), enableInterruptsA(), and mPulseWidthA.
00058 { disableInterruptsA(); mPulseWidthA=0; enableInterruptsA(); }

| void PikeAero::CBinaryInputCapture::resetPulseWidthB | ( | ) | [inline] |
Definition at line 59 of file cbinaryinputcapture.h.
References disableInterruptsB(), enableInterruptsB(), and mPulseWidthB.
00059 { disableInterruptsB(); mPulseWidthB=0; enableInterruptsB(); }

| 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;}

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().
1.5.8