#include <cfuelinjector.h>


Public Types | |
Public Member Functions | |
| CFuelInjector (CMachine::InterruptVector vector, TIM_TypeDef *TIMx, GPIO_TypeDef *GPIOx, CMachine::ubit16 bits, bool invertA=false, bool invertB=false, CMachine::ubit32 frequency=2000000) | |
| Constructor. Target counter frequency is expressed in Hz, default is 2MHz counter. | |
| void | fire () |
| Fire the injector. | |
| tInjectorMode | getInjectorMode () |
| Get the injector mode. | |
| virtual void | irq (CMachine::InterruptVector v) |
| Receive a hardware interrupt. | |
| void | setInjectorMode (tInjectorMode mode) |
| Set the injector mode. | |
| void | setOnTime (CMachine::ubit32 onTime) |
| Set the total injector pulse width "on time" in microseconds. | |
| void | setTurnOnTime (CMachine::ubit32 turnOnTime) |
| Set the injector "turn on" period in microseconds. | |
| void | startCurrentLimiting () |
| Start current limiting by configurign output pin as Open Drain (allow PWM to drive output when timer output is hi). | |
| void | stopCurrentLimiting () |
| Stop Current Limiting by configuring output pin as push-pull (disallow PWM to drive output). | |
| virtual | ~CFuelInjector () |
Private Attributes | |
| CMachine::ubit16 | mBits |
| GPIO_TypeDef * | mGPIO |
| tInjectorMode | mInjectorMode |
| CMachine::ubit16 | mOnTicks |
| bool | mOpened |
| CMachine::ubit32 | mTurnOnTicks |
Definition at line 31 of file cfuelinjector.h.
Definition at line 35 of file cfuelinjector.h.
00036 { 00037 ModeOff=0, /** Injector disabled. */ 00038 ModeNormal, /** Normal "On" for full injector pulse duration. */ 00039 ModePWM, /** Pulse Width Modulation for full injector pulse duration. */ 00040 ModeOpenPWM /** Injector full "On" for first part of duration, and then PWM for remainder. */ 00041 } tInjectorMode;
| PikeAero::CFuelInjector::CFuelInjector | ( | CMachine::InterruptVector | vector, | |
| TIM_TypeDef * | TIMx, | |||
| GPIO_TypeDef * | GPIOx, | |||
| CMachine::ubit16 | bits, | |||
| bool | invertA = false, |
|||
| bool | invertB = false, |
|||
| CMachine::ubit32 | frequency = 2000000 | |||
| ) |
Constructor. Target counter frequency is expressed in Hz, default is 2MHz counter.
Definition at line 26 of file cfuelinjector.cpp.
References PikeAero::TIM_TypeDef::CR1, PikeAero::CMachine::installVectorIRQ(), stopCurrentLimiting(), PikeAero::CBinaryInputOutputTimer::tim(), TIM_EN, and TIM_OLVLB.
00027 : inherited(vector,TIMx,frequency) 00028 , mGPIO(GPIOx) 00029 , mBits(bits) 00030 , mInjectorMode(ModeOff) 00031 , mOnTicks(0) 00032 , mTurnOnTicks(0) 00033 { 00034 stopCurrentLimiting(); 00035 tim()->CR1 |= ( TIM_EN | TIM_OLVLB); 00036 CMachine::installVectorIRQ(vector,this); 00037 }

| PikeAero::CFuelInjector::~CFuelInjector | ( | ) | [virtual] |
Definition at line 40 of file cfuelinjector.cpp.
References PikeAero::CMachine::removeVectorIRQ().
00041 { 00042 CMachine::removeVectorIRQ(this); 00043 }

| void PikeAero::CFuelInjector::fire | ( | ) |
Fire the injector.
Begine an injector cycle.
Injector disabled.
Pulse Width Modulation for full injector pulse duration.
enable gating PWM current limiting...
Normal "On" for full injector pulse duration.
Injector full "On" for first part of duration, and then PWM for remainder.
Definition at line 48 of file cfuelinjector.cpp.
References PikeAero::TIM_TypeDef::CNTR, PikeAero::TIM_TypeDef::CR1, PikeAero::TIM_TypeDef::CR2, mInjectorMode, ModeNormal, ModeOff, ModeOpenPWM, ModePWM, mOnTicks, mOpened, mTurnOnTicks, PikeAero::TIM_TypeDef::OCAR, PikeAero::TIM_TypeDef::OCBR, PikeAero::CBinaryInputOutputTimer::start(), startCurrentLimiting(), stopCurrentLimiting(), PikeAero::CBinaryInputOutputTimer::tim(), TIM_DMAIE, TIM_ICAIE, TIM_ICBIE, TIM_OCAE, TIM_OCAIE, TIM_OCBIE, TIM_OLVLA, TIM_PWM, and TIM_TOIE.
00049 { 00050 switch( mInjectorMode ) 00051 { 00052 default: 00053 case ModeOff: /** Injector disabled. */ 00054 { 00055 /* Disable Current Limiting */ 00056 stopCurrentLimiting(); 00057 /* Disable all device interrupt sources */ 00058 tim()->CR2 &= ~(TIM_ICAIE|TIM_OCAIE|TIM_TOIE|TIM_ICBIE|TIM_OCBIE|TIM_DMAIE); 00059 /* Default mode, stop counting. */ 00060 tim()->CR1 = 0; 00061 } 00062 break; 00063 case ModePWM: /** Pulse Width Modulation for full injector pulse duration. */ 00064 { 00065 /** enable gating PWM current limiting... */ 00066 startCurrentLimiting(); 00067 } 00068 /* fall through... */ 00069 case ModeNormal: /** Normal "On" for full injector pulse duration. */ 00070 { 00071 /* Disable all device interrupt sources */ 00072 tim()->CR2 &= ~(TIM_ICAIE|TIM_OCAIE|TIM_TOIE|TIM_ICBIE|TIM_OCBIE|TIM_DMAIE); 00073 /* Stop Counting, Output Level A=hi,B=lo, Output Compare A Enabled, PWM Mode */ 00074 tim()->CR1 = TIM_OLVLA | TIM_OCAE | TIM_PWM; 00075 /* Reset PWM output A... */ 00076 tim()->OCAR = 0x0000; 00077 /* Terminate PWM output after injector delay. */ 00078 tim()->OCBR = mOnTicks; 00079 /* Reset the count register. */ 00080 tim()->CNTR = 0; 00081 /* Enable Output Compare B Interrupt. */ 00082 tim()->CR2 |= TIM_OCBIE; 00083 /* Start Counting. */ 00084 start(); 00085 } 00086 break; 00087 case ModeOpenPWM: /** Injector full "On" for first part of duration, and then PWM for remainder. */ 00088 { 00089 /* Disable all device interrupt sources */ 00090 tim()->CR2 &= ~(TIM_ICAIE|TIM_OCAIE|TIM_TOIE|TIM_ICBIE|TIM_OCBIE|TIM_DMAIE); 00091 /* Stop Counting, Output Level A=hi,B=lo, Output Compare A Enabled, PWM Mode */ 00092 tim()->CR1 = TIM_OLVLA | TIM_OCAE | TIM_PWM; 00093 /* Reset PWM output A... */ 00094 tim()->OCAR = 0x0000; 00095 /* Terminate PWM output after turn-on delay. */ 00096 tim()->OCBR = mTurnOnTicks; 00097 /* Reset the count register. */ 00098 tim()->CNTR = 0; 00099 /* Enable Output Compare B Interrupt. */ 00100 tim()->CR2 |= TIM_OCBIE; 00101 /* Make sure current limiting is off... */ 00102 stopCurrentLimiting(); 00103 /* Injector has not been opened yet... */ 00104 mOpened = false; 00105 /* Start Counting. */ 00106 start(); 00107 } 00108 break; 00109 } 00110 }

| tInjectorMode PikeAero::CFuelInjector::getInjectorMode | ( | ) | [inline] |
Get the injector mode.
Definition at line 54 of file cfuelinjector.h.
References mInjectorMode.
00054 {return mInjectorMode;}
| void PikeAero::CFuelInjector::irq | ( | CMachine::InterruptVector | v | ) | [virtual] |
Receive a hardware interrupt.
Injector disabled.
Pulse Width Modulation for full injector pulse duration.
Normal "On" for full injector pulse duration.
output Compare B interrupt means injector duration complete
stop counting
clear the interrupt flag
Injector full "On" for first part of duration, and then PWM for remainder.
output Compare B interrupt means injector duration complete
stop counting
clear the interrupt flag
Reimplemented from PikeAero::CObject.
Definition at line 115 of file cfuelinjector.cpp.
References PikeAero::TIM_TypeDef::CNTR, mInjectorMode, ModeNormal, ModeOff, ModeOpenPWM, ModePWM, mOnTicks, mOpened, mTurnOnTicks, PikeAero::TIM_TypeDef::OCAR, PikeAero::TIM_TypeDef::OCBR, PikeAero::TIM_TypeDef::SR, PikeAero::CBinaryInputOutputTimer::start(), startCurrentLimiting(), PikeAero::CBinaryInputOutputTimer::stop(), stopCurrentLimiting(), PikeAero::CBinaryInputOutputTimer::tim(), and TIM_OCFB.
00116 { 00117 switch( mInjectorMode ) 00118 { 00119 default: 00120 case ModeOff: /** Injector disabled. */ 00121 /* Disable CUrrent Limiting */ 00122 stopCurrentLimiting(); 00123 break; 00124 case ModePWM: /** Pulse Width Modulation for full injector pulse duration. */ 00125 { 00126 /* Disable CUrrent Limiting */ 00127 stopCurrentLimiting(); 00128 } 00129 /* fall through... */ 00130 case ModeNormal: /** Normal "On" for full injector pulse duration. */ 00131 { 00132 if ( tim()->SR & TIM_OCFB ) /** output Compare B interrupt means injector duration complete */ 00133 { 00134 stop(); /** stop counting */ 00135 tim()->SR &= ~TIM_OCFB; /** clear the interrupt flag */ 00136 } 00137 } 00138 break; 00139 case ModeOpenPWM: /** Injector full "On" for first part of duration, and then PWM for remainder. */ 00140 { 00141 if ( tim()->SR & TIM_OCFB ) /** output Compare B interrupt means injector duration complete */ 00142 { 00143 stop(); /** stop counting */ 00144 tim()->SR &= ~TIM_OCFB; /** clear the interrupt flag */ 00145 if ( !mOpened ) 00146 { 00147 /* Reset PWM output A... */ 00148 tim()->OCAR = 0x0000; 00149 /* Terminate PWM output after remainder injector delay. */ 00150 tim()->OCBR = mOnTicks - mTurnOnTicks; 00151 /* Reset the count register. */ 00152 tim()->CNTR = 0; 00153 /* Make sure current limiting is on for second phase... */ 00154 startCurrentLimiting(); 00155 /* Injector is opened... */ 00156 mOpened = true; 00157 /* Start the second (current limiting) phase */ 00158 start(); 00159 } 00160 } 00161 } 00162 break; 00163 } 00164 }

| void PikeAero::CFuelInjector::setInjectorMode | ( | tInjectorMode | mode | ) | [inline] |
Set the injector mode.
Definition at line 51 of file cfuelinjector.h.
References mInjectorMode.
00051 {mInjectorMode=mode;}
| void PikeAero::CFuelInjector::setOnTime | ( | CMachine::ubit32 | onTime | ) | [inline] |
Set the total injector pulse width "on time" in microseconds.
Definition at line 57 of file cfuelinjector.h.
References PikeAero::CBinaryInputOutputTimer::durationToTicks(), and mOnTicks.
00057 {mOnTicks=durationToTicks(onTime);}

| void PikeAero::CFuelInjector::setTurnOnTime | ( | CMachine::ubit32 | turnOnTime | ) | [inline] |
Set the injector "turn on" period in microseconds.
Definition at line 60 of file cfuelinjector.h.
References PikeAero::CBinaryInputOutputTimer::durationToTicks(), and mTurnOnTicks.
00060 {mTurnOnTicks=durationToTicks(turnOnTime);}

| void PikeAero::CFuelInjector::startCurrentLimiting | ( | ) | [inline] |
Start current limiting by configurign output pin as Open Drain (allow PWM to drive output when timer output is hi).
Definition at line 66 of file cfuelinjector.h.
References mBits, mGPIO, and PikeAero::GPIO_TypeDef::PC0.
Referenced by fire(), and irq().

| void PikeAero::CFuelInjector::stopCurrentLimiting | ( | ) | [inline] |
Stop Current Limiting by configuring output pin as push-pull (disallow PWM to drive output).
Definition at line 69 of file cfuelinjector.h.
References mBits, mGPIO, and PikeAero::GPIO_TypeDef::PC0.
Referenced by CFuelInjector(), fire(), and irq().

The GPIO pins
Definition at line 73 of file cfuelinjector.h.
Referenced by startCurrentLimiting(), and stopCurrentLimiting().
GPIO_TypeDef* PikeAero::CFuelInjector::mGPIO [private] |
Definition at line 72 of file cfuelinjector.h.
Referenced by startCurrentLimiting(), and stopCurrentLimiting().
The GPIO Bit
Definition at line 74 of file cfuelinjector.h.
Referenced by fire(), getInjectorMode(), irq(), and setInjectorMode().
The current injector mode
Definition at line 75 of file cfuelinjector.h.
Referenced by fire(), irq(), and setOnTime().
bool PikeAero::CFuelInjector::mOpened [private] |
Turn On ticks (high current on time) in timer ticks
Definition at line 77 of file cfuelinjector.h.
On time in timer ticks
Definition at line 76 of file cfuelinjector.h.
Referenced by fire(), irq(), and setTurnOnTime().
1.5.8