#include <ctasktimebase.h>


Public Member Functions | |
| CTaskTimeBase (CMachine::InterruptVector vector, TB_TypeDef *TBx, CMachine::ubit32 usec) | |
| virtual CMachine::bit32 | fault () |
| The CTaskScheduler will call the fault() method when a fault code was returned by any of the task's other methods. | |
| virtual void | irq (CMachine::InterruptVector v) |
| receive a hardware interrupt | |
| virtual const char * | name () |
| returns a CString containing an human readable name for the task | |
| virtual CMachine::bit32 | run () |
| called exactly once. perform task initialization such as initializing private variable. Other tasks are not guaranteed so do not interract with other tasks at this stage. | |
| bool | running () |
| determin the running state of the time base. return true of time base is running. | |
| bool | set (CMachine::ubit32 usec) |
| set the timebase period in microseconds. | |
| virtual CMachine::bit32 | start () |
| initialize the class. | |
| virtual CMachine::bit32 | stop () |
| The CTaskScheduler will call the stop () method after the task was scheduled for cancelation. | |
| ~CTaskTimeBase () | |
Private Attributes | |
| CMachine::ubit64 | mLastTicks |
| TB_TypeDef * | mTB |
| CMachine::ubit64 | mTicks |
| CMachine::ubit32 | mUSec |
Definition at line 31 of file ctasktimebase.h.
| PikeAero::CTaskTimeBase::CTaskTimeBase | ( | CMachine::InterruptVector | vector, | |
| TB_TypeDef * | TBx, | |||
| CMachine::ubit32 | usec | |||
| ) |
Definition at line 26 of file ctasktimebase.cpp.
References PikeAero::CMachine::installVectorIRQ(), and stop().
00027 : ITask() 00028 , mTB(TBx) 00029 , mUSec(usec) 00030 , mTicks(0) 00031 , mLastTicks(0) 00032 { 00033 stop(); 00034 CMachine::installVectorIRQ(vector,this); 00035 }

| PikeAero::CTaskTimeBase::~CTaskTimeBase | ( | ) |
stop counting.
Remove self from interrupt vector
Definition at line 38 of file ctasktimebase.cpp.
References PikeAero::CMachine::removeVectorIRQ(), and stop().
00039 { 00040 /** stop counting. **/ 00041 stop(); 00042 /** Remove self from interrupt vector */ 00043 CMachine::removeVectorIRQ(this); 00044 }

| CMachine::bit32 PikeAero::CTaskTimeBase::fault | ( | ) | [virtual] |
The CTaskScheduler will call the fault() method when a fault code was returned by any of the task's other methods.
Reimplemented from PikeAero::ITask.
Definition at line 108 of file ctasktimebase.cpp.
References PikeAero::CObject::errOK.
00109 { 00110 return errOK; 00111 }
| void PikeAero::CTaskTimeBase::irq | ( | CMachine::InterruptVector | v | ) | [virtual] |
receive a hardware interrupt
receive a hardware interrupt [ top half ]
increment hi rez tick count
wake up the bottom half
clear the End of Count flag
Reimplemented from PikeAero::CObject.
Definition at line 148 of file ctasktimebase.cpp.
References mTB, mTicks, PikeAero::ITask::setSleeping(), PikeAero::TB_TypeDef::SR, and TB_EC.
00149 { 00150 if ( mTB->SR & TB_EC ) 00151 { 00152 /** increment hi rez tick count */ 00153 ++mTicks; 00154 /** wake up the bottom half */ 00155 setSleeping(false); 00156 /** clear the End of Count flag **/ 00157 mTB->SR &= ~TB_EC; 00158 } 00159 }

| virtual const char* PikeAero::CTaskTimeBase::name | ( | ) | [inline, virtual] |
returns a CString containing an human readable name for the task
Reimplemented from PikeAero::ITask.
Definition at line 38 of file ctasktimebase.h.
| CMachine::bit32 PikeAero::CTaskTimeBase::run | ( | ) | [virtual] |
called exactly once. perform task initialization such as initializing private variable. Other tasks are not guaranteed so do not interract with other tasks at this stage.
called periodically by CTaskScheduler to do a piece of work. [ bottom half ]
Dispatch a wall clock event approximately every 1/10th second.
disable interrupts on this time base channel.
enable interrupts on this time base channel.
put the task back to sleep
Reimplemented from PikeAero::ITask.
Definition at line 69 of file ctasktimebase.cpp.
References disableInterrupts, PikeAero::CObject::dispatch(), enableInterrupts, PikeAero::CObject::errOK, PikeAero::CObject::event(), mLastTicks, PikeAero::TB_TypeDef::MR, mTB, mTicks, PikeAero::ITask::setSleeping(), and TB_ECM.
00070 { 00071 /** 00072 ** Dispatch a wall clock event approximately every 1/10th second. 00073 */ 00074 if ( mLastTicks <= mTicks ) 00075 { 00076 CEventTick* event = new CEventTick(this); 00077 mTB->MR &= ~TB_ECM; /** disable interrupts on this time base channel. */ 00078 event->setTicks(mTicks); 00079 mTB->MR |= TB_ECM; /** enable interrupts on this time base channel. */ 00080 dispatch( event ); 00081 disableInterrupts(); 00082 mLastTicks = mTicks; 00083 enableInterrupts(); 00084 } 00085 setSleeping(true); /** put the task back to sleep */ 00086 return errOK; 00087 }

| bool PikeAero::CTaskTimeBase::running | ( | ) |
determin the running state of the time base. return true of time base is running.
Reimplemented from PikeAero::ITask.
Definition at line 140 of file ctasktimebase.cpp.
References PikeAero::TB_TypeDef::CR, PikeAero::TB_TypeDef::MR, mTB, TB_ECM, and TB_SC.
| bool PikeAero::CTaskTimeBase::set | ( | CMachine::ubit32 | usec | ) |
set the timebase period in microseconds.
| usec | specifies the timer period in microseconds or 0 to use the default full duration. |
| usec | specifies the timer period in microseconds or 0 to use the default full duration. |
set the default period
Definition at line 122 of file ctasktimebase.cpp.
References PikeAero::CMachine::fpMCLK(), mTB, PikeAero::TB_TypeDef::PR, and PikeAero::TB_TypeDef::VR.
00123 { 00124 CMachine::ubit32 min = mTB->PR * 1 * static_cast<CMachine::bit32>(CMachine::fpMCLK()) / 1000; 00125 CMachine::ubit32 max = mTB->PR * 65536 * static_cast<CMachine::bit32>(CMachine::fpMCLK()) / 1000; 00126 if ( usec >= min && usec <= max ) 00127 { 00128 mTB->VR = static_cast<CMachine::ubit16>(65536/(max/(usec))); 00129 return true; 00130 } 00131 /** set the default period */ 00132 mTB->VR = 0xFFFF; 00133 return false; 00134 }

| CMachine::bit32 PikeAero::CTaskTimeBase::start | ( | ) | [virtual] |
initialize the class.
load the default prescaler.
enable interrupts on this time base channel.
start counting
Reimplemented from PikeAero::ITask.
Definition at line 49 of file ctasktimebase.cpp.
References PikeAero::TB_TypeDef::CR, PikeAero::CObject::errOK, PikeAero::CObject::errOutOfRange, PikeAero::TB_TypeDef::MR, mTB, mUSec, PikeAero::TB_TypeDef::PR, PikeAero::ITask::setSleeping(), TB_ECM, and TB_SC.
00050 { 00051 setSleeping(true); 00052 if ( set( mUSec ) ) 00053 { 00054 /** load the default prescaler. */ 00055 mTB->PR = 0x00FF; 00056 /** enable interrupts on this time base channel. */ 00057 mTB->MR |= TB_ECM; 00058 /** start counting */ 00059 mTB->CR = TB_SC; 00060 return errOK; 00061 } 00062 return errOutOfRange; 00063 }

| CMachine::bit32 PikeAero::CTaskTimeBase::stop | ( | ) | [virtual] |
The CTaskScheduler will call the stop () method after the task was scheduled for cancelation.
stop and select fMCLK as clock source.
disable interrupts on this time base channel.
clear the End of Count flag
Reimplemented from PikeAero::ITask.
Definition at line 93 of file ctasktimebase.cpp.
References PikeAero::TB_TypeDef::CR, PikeAero::CObject::errOK, PikeAero::TB_TypeDef::MR, mTB, PikeAero::ITask::setSleeping(), PikeAero::TB_TypeDef::SR, TB_EC, TB_ECM, and TB_SC.
Referenced by CTaskTimeBase(), and ~CTaskTimeBase().
00094 { 00095 setSleeping(true); 00096 /** stop and select fMCLK as clock source. */ 00097 mTB->CR &= ~TB_SC; 00098 /** disable interrupts on this time base channel. */ 00099 mTB->MR &= ~TB_ECM; 00100 /** clear the End of Count flag **/ 00101 mTB->SR &= ~TB_EC; 00102 return errOK; 00103 }


TB_TypeDef* PikeAero::CTaskTimeBase::mTB [private] |
1.5.8