aversive_10-03-12/modules/base/time/time.c File Reference

Implementation of the TIME module. More...

#include <stdlib.h>
#include <scheduler.h>
#include <time.h>
#include <time_config.h>

Go to the source code of this file.

Defines

#define NB_SCHEDULER_UNIT   ( ((float)(TIME_PRECISION)) / SCHEDULER_UNIT_FLOAT )
#define NB_SCHEDULER_UNIT_NOT_NULL   (NB_SCHEDULER_UNIT == 0 ? 1.0 : NB_SCHEDULER_UNIT)

Functions

void time_increment (void *dummy)
void time_init (uint8_t priority)
seconds time_get_s (void)
microseconds time_get_us (void)
microseconds time_get_us2 (void)
time_h time_get_time (void)
void time_reset (void)
void time_set (seconds s, microseconds us)
void time_wait_ms (uint16_t ms)


Detailed Description

Implementation of the TIME module.

This module can be used to get a human readable time. It uses the scheduler module. Its goal is not to be very precise, but just simple to use.

Definition in file time.c.


Define Documentation

#define NB_SCHEDULER_UNIT   ( ((float)(TIME_PRECISION)) / SCHEDULER_UNIT_FLOAT )

Definition at line 46 of file time.c.

#define NB_SCHEDULER_UNIT_NOT_NULL   (NB_SCHEDULER_UNIT == 0 ? 1.0 : NB_SCHEDULER_UNIT)

Definition at line 47 of file time.c.

Referenced by time_increment(), and time_init().


Function Documentation

seconds time_get_s ( void   ) 

get time in second since last init/reset

Definition at line 67 of file time.c.

References IRQ_LOCK, IRQ_UNLOCK, and time_h::s.

Referenced by main().

time_h time_get_time ( void   ) 

get the complete time struct since last init/reset

Definition at line 103 of file time.c.

References IRQ_LOCK, and IRQ_UNLOCK.

microseconds time_get_us ( void   ) 

get time in microsecond since last init/reset

Definition at line 79 of file time.c.

References IRQ_LOCK, IRQ_UNLOCK, and time_h::us.

microseconds time_get_us2 ( void   ) 

get a microsecond timer that overflows naturally

Definition at line 91 of file time.c.

References IRQ_LOCK, and IRQ_UNLOCK.

Referenced by time_wait_ms().

void time_increment ( void *  dummy  ) 

Definition at line 147 of file time.c.

References IRQ_LOCK, IRQ_UNLOCK, NB_SCHEDULER_UNIT_NOT_NULL, time_h::s, SCHEDULER_UNIT, and time_h::us.

Referenced by time_init().

void time_init ( uint8_t  priority  ) 

init time module : schedule the event with the givent priority

Definition at line 58 of file time.c.

References NB_SCHEDULER_UNIT_NOT_NULL, time_increment(), and time_reset().

Referenced by main().

void time_reset ( void   ) 

reset time counter

Definition at line 115 of file time.c.

References IRQ_LOCK, IRQ_UNLOCK, time_h::s, and time_h::us.

Referenced by time_init().

void time_set ( seconds  s,
microseconds  us 
)

set time

Definition at line 126 of file time.c.

References IRQ_LOCK, IRQ_UNLOCK, time_h::s, and time_h::us.

void time_wait_ms ( uint16_t  ms  ) 

This is an equivalent of 'wait_ms(x)', but uses time value, so it is independant of CPU load. Warning, you should not use this function in a irq locked context, or in a scheduled function with higher priority than time module

Definition at line 137 of file time.c.

References time_get_us2().

Referenced by test_sched().


Generated on Fri Mar 12 06:32:05 2010 for AVR by  doxygen 1.5.6