Time

Time functions. More...

Defines

#define SIXTEENTH_SECOND   1
 A sixteenth of a second.
#define EIGTH_SECOND   2
 An eighth of a second.
#define QUARTER_SECOND   4
 A quarter of a second.
#define HALF_SECOND   8
 Half of a second.
#define SECOND   16
 One second.
#define TWO_SECOND   32
 Two seconds.
#define FOUR_SECOND   64
 Four seconds.

Functions

void delay_ms (int ms)
 Delay execution for the specified time.
void rtc_init (int prescale_opt, void(*rtc_func)(void))
 Enable the realtime clock.
int rtc_get (void)
 Get the value of the realtime clock.
void rtc_reset (void)
 Reset the counter of the realtime clock.

Detailed Description

Time functions.

Functions dealing with time.


Function Documentation

void delay_ms ( int  ms  ) 

Delay execution for the specified time.

Delays for the specified number of milliseconds. It depends on F_CPU to be defined in order to calculate how many cycles it should delay. If it is not defined, a default clock of 8MHz is assumed.

We use _delay_loop_2 which will run assembly instructions that should be 4 cycles long. Optimizations must be enabled for this to be true. That function is called to ensure around 1ms per execution. To generate multiple ms we run a for loop of how many milliseconds are desired.

The error should be just the skew on the oscillator as the formula to calculate delay cycles should always be a whole number. The is some skew in practice though it is unavoidable. Delaying for less than 1s should make the error negligable.

Parameters:
ms the number of milliseconds to delay for

Referenced by button1_wait(), button2_wait(), buzzer_chirp(), flash_red(), lcd_init(), and odometry_init().

int rtc_get ( void   ) 

Get the value of the realtime clock.

Returns the time elapsed in seconds since the last call to rtc_init or rtc_reset.

Returns:
the number of seconds since the last call to rtc_init or rtc_reset
See also:
rtc_init, rtc_reset

void rtc_init ( int  prescale_opt,
void(*)(void)  rtc_func 
)

Enable the realtime clock.

Initializes the real time clock. Prescales are defined in time.h. For example, SECOND will give 1 second. The specified function is called every clock tick. For the real time clock to activate, interrupts must be enabled. (through sei() )

Parameters:
prescale_opt the period with which the timer is triggered
rtc_func the function called when the timer is triggered
See also:
rtc_get, rtc_reset

void rtc_reset ( void   ) 

Reset the counter of the realtime clock.

Resets the real time clock counter to 0.

See also:
rtc_init, rtc_get


Generated on Thu Apr 16 18:33:23 2009 for libdragonfly by  doxygen 1.5.5