LoTimer.h File Reference

Generalized timer API for Robolocust's iRobot Create Command Module control program. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define lo_suspend_timer10()   TIMSK2 &= ~0x02
#define lo_resume_timer10()   TIMSK2 |= 0x02

Typedefs

typedef void(* TimerCallback )(void)

Functions

void lo_init_timer (void)
void lo_add_timer1_cb (TimerCallback)
void lo_add_timer10_cb (TimerCallback)
unsigned long lo_ticks (void)
void lo_setup_timer (unsigned int ms)
 Setup a stop watch for the specified number of milliseconds.
char lo_timer_is_running (void)
 Check if a stop watch is running.
void lo_wait (unsigned int ms)
 Busy wait for the specified number of milliseconds.

Detailed Description

Generalized timer API for Robolocust's iRobot Create Command Module control program.

This file defines an API for "generalized" one and ten millisecond timers for the iRobot Create Command Module control program used by Robolocust. The API provides a means for other parts of the control program to setup "stop clocks" and perform whatever operations they need while this stop clock ticks away. Additionally, these timers are "generalized" in the sense that client modules may register arbitrary callback functions that will be triggered each time the timer ISR kicks in.

Definition in file LoTimer.h.


Define Documentation

 
#define lo_resume_timer10 (  )     TIMSK2 |= 0x02

This function can be used to reenable temporarily disabled 10ms timer (i.e., the ATmega Timer2) interrupts.

Definition at line 126 of file LoTimer.h.

Referenced by lo_drive().

 
#define lo_suspend_timer10 (  )     TIMSK2 &= ~0x02

This function can be used to temporarily disable the 10ms timer's (i.e., the ATmega Timer2) interrupts.

Definition at line 122 of file LoTimer.h.

Referenced by lo_drive().


Typedef Documentation

typedef void(* TimerCallback)(void)

The ATmega128 provides three timers that tick away in parallel with the main clock. These three timers provide a means for asynchronous operations w.r.t. the main "thread" of execution. However, as there are only three such timers, if each module that required some form of asynchrony were to "capture" a timer for itself, only three modules could possibly take advantage of this feature.

To work around this limitation, the Robolocust low-level controller uses the ATmega128's two 8-bit timers to implement a 1ms timer and a 10ms timer. This timer module then associates a list of arbitrary callbacks with each of these timers and allows client modules to register their timer callbacks here, thus, enabling all modules to take advantage of asynchrony if required. Hence the term "generalized timer."

The following type defines the signature for timer callback functions.

NOTE: Timer callbacks should not be computationally involved. Rather they should perform a quick couple of assignments, if statements and other simple operations. Otherwise, the timer callbacks run the risk of not being triggered every one and ten milliseconds.

NOTE 2: This timer module supports a maximum of ten callbacks per generalized timer.

Definition at line 84 of file LoTimer.h.


Function Documentation

void lo_add_timer10_cb ( TimerCallback   ) 

This function adds a timer callback to the 10ms timer's callback list.

NOTE: A maximum of 10 such callbacks are supported.

Definition at line 297 of file LoTimer.c.

Referenced by lo_init_drive().

void lo_add_timer1_cb ( TimerCallback   ) 

This function adds a timer callback to the 1ms timer's callback list.

NOTE: A maximum of 10 such callbacks are supported.

Definition at line 290 of file LoTimer.c.

Referenced by lo_init_sensors().

void lo_init_timer ( void   ) 

This function sets up the ATmega's two 8-bit timers, one to fire every millisecond and the other to fire every ten milliseconds. Client modules can then register their timer callbacks to take advantage of the asynchrony supported by the ATmega128.

Definition at line 283 of file LoTimer.c.

void lo_setup_timer ( unsigned int  ms  ) 

Setup a stop watch for the specified number of milliseconds.

Definition at line 351 of file LoTimer.c.

Referenced by lo_rx().

unsigned long lo_ticks ( void   ) 

Return the current total number of milliseconds that have elapsed since the low-level controller's 1ms timer was setup.

Definition at line 345 of file LoTimer.c.

Referenced by lo_remote().

char lo_timer_is_running ( void   ) 

Check if a stop watch is running.

Definition at line 358 of file LoTimer.c.

Referenced by lo_rx().

void lo_wait ( unsigned int  ms  ) 

Busy wait for the specified number of milliseconds.

Definition at line 364 of file LoTimer.c.

Referenced by lo_backup(), lo_init_beeps(), lo_io_to_usb(), lo_reset_baud(), and lo_spin().

Generated on Sun May 8 08:42:49 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3