\section{aversive\_\-10-03-12/modules/base/time/time.c File Reference}
\label{time_8c}\index{aversive\_\-10-03-12/modules/base/time/time.c@{aversive\_\-10-03-12/modules/base/time/time.c}}
Implementation of the TIME module. 

{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$scheduler.h$>$}\par
{\tt \#include $<$time.h$>$}\par
{\tt \#include $<$time\_\-config.h$>$}\par
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf NB\_\-SCHEDULER\_\-UNIT}~( ((float)(TIME\_\-PRECISION)) / SCHEDULER\_\-UNIT\_\-FLOAT )
\item 
\#define {\bf NB\_\-SCHEDULER\_\-UNIT\_\-NOT\_\-NULL}~(NB\_\-SCHEDULER\_\-UNIT == 0 ? 1.0 : NB\_\-SCHEDULER\_\-UNIT)
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf time\_\-increment} (void $\ast$dummy)
\item 
void {\bf time\_\-init} (uint8\_\-t priority)
\item 
{\bf seconds} {\bf time\_\-get\_\-s} (void)
\item 
{\bf microseconds} {\bf time\_\-get\_\-us} (void)
\item 
{\bf microseconds} {\bf time\_\-get\_\-us2} (void)
\item 
{\bf time\_\-h} {\bf time\_\-get\_\-time} (void)
\item 
void {\bf time\_\-reset} (void)
\item 
void {\bf time\_\-set} ({\bf seconds} {\bf s}, {\bf microseconds} us)
\item 
void {\bf time\_\-wait\_\-ms} (uint16\_\-t ms)
\end{CompactItemize}


\subsection{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 {\bf time.c}.

\subsection{Define Documentation}
\index{time.c@{time.c}!NB\_\-SCHEDULER\_\-UNIT@{NB\_\-SCHEDULER\_\-UNIT}}
\index{NB\_\-SCHEDULER\_\-UNIT@{NB\_\-SCHEDULER\_\-UNIT}!time.c@{time.c}}
\subsubsection[NB\_\-SCHEDULER\_\-UNIT]{\setlength{\rightskip}{0pt plus 5cm}\#define NB\_\-SCHEDULER\_\-UNIT~( ((float)(TIME\_\-PRECISION)) / SCHEDULER\_\-UNIT\_\-FLOAT )}\label{time_8c_9b98c974632d0fedb99c4ebd88a7a71d}




Definition at line 46 of file time.c.\index{time.c@{time.c}!NB\_\-SCHEDULER\_\-UNIT\_\-NOT\_\-NULL@{NB\_\-SCHEDULER\_\-UNIT\_\-NOT\_\-NULL}}
\index{NB\_\-SCHEDULER\_\-UNIT\_\-NOT\_\-NULL@{NB\_\-SCHEDULER\_\-UNIT\_\-NOT\_\-NULL}!time.c@{time.c}}
\subsubsection[NB\_\-SCHEDULER\_\-UNIT\_\-NOT\_\-NULL]{\setlength{\rightskip}{0pt plus 5cm}\#define NB\_\-SCHEDULER\_\-UNIT\_\-NOT\_\-NULL~(NB\_\-SCHEDULER\_\-UNIT == 0 ? 1.0 : NB\_\-SCHEDULER\_\-UNIT)}\label{time_8c_e9e96c26c917ab6547cb48cfc06ae327}




Definition at line 47 of file time.c.

Referenced by time\_\-increment(), and time\_\-init().

\subsection{Function Documentation}
\index{time.c@{time.c}!time\_\-get\_\-s@{time\_\-get\_\-s}}
\index{time\_\-get\_\-s@{time\_\-get\_\-s}!time.c@{time.c}}
\subsubsection[time\_\-get\_\-s]{\setlength{\rightskip}{0pt plus 5cm}{\bf seconds} time\_\-get\_\-s (void)}\label{time_8c_29713bbbd9e53bd49f06a91a781bfc85}


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().\index{time.c@{time.c}!time\_\-get\_\-time@{time\_\-get\_\-time}}
\index{time\_\-get\_\-time@{time\_\-get\_\-time}!time.c@{time.c}}
\subsubsection[time\_\-get\_\-time]{\setlength{\rightskip}{0pt plus 5cm}{\bf time\_\-h} time\_\-get\_\-time (void)}\label{time_8c_6cd922e6e2a1b3a2a81bd34f0c474526}


get the complete time struct since last init/reset 

Definition at line 103 of file time.c.

References IRQ\_\-LOCK, and IRQ\_\-UNLOCK.\index{time.c@{time.c}!time\_\-get\_\-us@{time\_\-get\_\-us}}
\index{time\_\-get\_\-us@{time\_\-get\_\-us}!time.c@{time.c}}
\subsubsection[time\_\-get\_\-us]{\setlength{\rightskip}{0pt plus 5cm}{\bf microseconds} time\_\-get\_\-us (void)}\label{time_8c_9b565ae55efc5ce3a2ff6f33740fe535}


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.\index{time.c@{time.c}!time\_\-get\_\-us2@{time\_\-get\_\-us2}}
\index{time\_\-get\_\-us2@{time\_\-get\_\-us2}!time.c@{time.c}}
\subsubsection[time\_\-get\_\-us2]{\setlength{\rightskip}{0pt plus 5cm}{\bf microseconds} time\_\-get\_\-us2 (void)}\label{time_8c_85f8c81d123f40e4db70f8d15cb0a310}


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().\index{time.c@{time.c}!time\_\-increment@{time\_\-increment}}
\index{time\_\-increment@{time\_\-increment}!time.c@{time.c}}
\subsubsection[time\_\-increment]{\setlength{\rightskip}{0pt plus 5cm}void time\_\-increment (void $\ast$ {\em dummy})}\label{time_8c_a5da5c6c1296efac3b7933a5a124ce1c}




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().\index{time.c@{time.c}!time\_\-init@{time\_\-init}}
\index{time\_\-init@{time\_\-init}!time.c@{time.c}}
\subsubsection[time\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void time\_\-init (uint8\_\-t {\em priority})}\label{time_8c_f5aa9e3e1575de34d6198119e1705b21}


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().\index{time.c@{time.c}!time\_\-reset@{time\_\-reset}}
\index{time\_\-reset@{time\_\-reset}!time.c@{time.c}}
\subsubsection[time\_\-reset]{\setlength{\rightskip}{0pt plus 5cm}void time\_\-reset (void)}\label{time_8c_9be668f970503804224b78e50f3ed196}


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().\index{time.c@{time.c}!time\_\-set@{time\_\-set}}
\index{time\_\-set@{time\_\-set}!time.c@{time.c}}
\subsubsection[time\_\-set]{\setlength{\rightskip}{0pt plus 5cm}void time\_\-set ({\bf seconds} {\em s}, \/  {\bf microseconds} {\em us})}\label{time_8c_3be56d9c58a6394e063de7e1fb7094d6}


set time 

Definition at line 126 of file time.c.

References IRQ\_\-LOCK, IRQ\_\-UNLOCK, time\_\-h::s, and time\_\-h::us.\index{time.c@{time.c}!time\_\-wait\_\-ms@{time\_\-wait\_\-ms}}
\index{time\_\-wait\_\-ms@{time\_\-wait\_\-ms}!time.c@{time.c}}
\subsubsection[time\_\-wait\_\-ms]{\setlength{\rightskip}{0pt plus 5cm}void time\_\-wait\_\-ms (uint16\_\-t {\em ms})}\label{time_8c_452cb16c0acbddc35290865f35e0bdbf}


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().