Main Page   Hardware Class Hierarchy   Hardware API     Mapping Class Hierarchy  Mapping API 

oTimer Class Reference

A simple timer that tracks elapsed time in seconds. More...

#include <otimer.h>

Inheritance diagram for oTimer:

OOMRM

Public Member Functions

 oTimer ()
 Constructor.


Static Public Member Functions

void reset ()
 Reset timer to 0.

SECOND value ()
 Return seconds elapsed.

MILLISECOND millisecond ()
 Return milliseconds elapsed.

void wait (SECOND sec)
 Delay loop for 'sec' real seconds.


Static Private Member Functions

int TCR1 (void)
void TMCR (int iarb)
bool HSQR (int chan, int val)
 Configures the host sequence register.

bool HSRR (int chan, int val)
 Configures the host sequence request register.

bool CPR (int chan, int val)
 Configures the channel priority register (Ref. TPU Channel Utilization).

bool CIER (int chan, int cie)
 Configures the channel interrupt enable register.

int CISR (int chan)
 Returns the channel interrupt status register.

void CISR_clear (int chan)
 Clears the channel interrupt status register for the channel.

bool TICR (int cirl, int cibv)
 Configures the TPU interrupt configuration register.

int tpu_vector (IOLINE channel)
 Given a channel, returns the vector number to use for an interrupt.


Detailed Description

A simple timer that tracks elapsed time in seconds.

Operation
The oTimer uses the oSchedule object; thus be sure to account for this is you are using many scheduled functions.
Remarks
Since with the MRM, the Watchdog timer is disabled, a (somewhat bogus) tentative replacement I use is to insert a test for the timer in a scheduled function.
Note:
Unless you are using a timer in isolation, do not reset the timer; being a static object, Several objects use the timer, and thus the best way to handle this is just pull the time from the timer and compare a later time with previous rather than resetting the timer.
Sample Code
#include <hardware/otimer.h>
#include <hardware/oschedule.h>
oSchedule events;
oTimer stopwatch;
void watchdog()
{
  // if my robots is jammed in a corner going nowhere etc. then it will timeout and just quit.
  // NOTE: this is especially good for when executing turns and waiting for X encoder clicks, but wheels are moving.
  if (stopwatch.value() > 10)
  exit(0);       // or more general shutdown routine.
}
int main()
{
oSchedule events;
  int watchID = events.add(watchdog);
  // error checking...
  stopwatch.reset();
  events.run(watchID);
  while (true)
  {
    stopwatch.reset();
    // do my processing...
  }
}


Member Function Documentation

bool CIER int  chan,
int  cie
[static, inherited]
 

Configures the channel interrupt enable register.

Parameters:
int: channel
int: 1 enables; 0 disables

bool CPR int  chan,
int  val
[static, inherited]
 

Configures the channel priority register (Ref. TPU Channel Utilization).

Parameters:
int: channel
int: priority

bool HSQR int  chan,
int  val
[static, inherited]
 

Configures the host sequence register.

Parameters:
int: channel
int dependent upon function (CFSR) selected

bool HSRR int  chan,
int  val
[static, inherited]
 

Configures the host sequence request register.

Parameters:
int: channel
int: dependend upon function

int TCR1 void   )  [static, inherited]
 

misnomer--should be TCR1 divisor--return number of clocks (PSCK,TCR1P modifications) Globally available object. Can be used in combination with TPU_REGISTER definition to say TPU_REGISTER->CFSR.BITS...

void TMCR int  iarb  )  [static, inherited]
 

was tpu_init Configures the channel function select register


The documentation for this class was generated from the following file:
Generated on Mon Oct 8 19:32:45 2007 for OOMRM Hardware API by doxygen1.3