Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

%----------------------------------------------------------------------------
\chapter{The CMOS real-time clock}
%----------------------------------------------------------------------------

In all PCs there is a real-time clock (with a resolution of 1 second) that can
be read or written. This clock usually has a drift of about some seconds in 24
hours. The following functions (that can be found into \texttt{rtc.h}) can be
used to set/get values; all values are passed using a \texttt{struct rtc\_time}
that contains variables for seconds, minutes, hours, days, months and years.

\vspace{7mm}

\begin{intest}
GET\_RTC\_TIME\index{get\_rtc\_time()}
\end{intest}

\begin{description}
\item [\textbf{int get\_rtc\_time(struct rtc\_time {*}time);}]
\item [\textbf{Description:}] The actual time is read from the CMOS real-time clock and
written into the structure pointed by \texttt{time}. The function returns zero
on success, other values on error.
\end{description}

\begin{intest}
SET\_RTC\_TIME\index{set\_rtc\_time()}
\end{intest}

\begin{description}
\item [\textbf{int set\_rtc\_time(struct rtc\_time {*}time);}]
\item [\textbf{Description:}] The values contained in the structure pointed by
\texttt{time} are converted in seconds and written into the CMOS real-time
clock; the function returns zero on success, other values on error.
\end{description}

\begin{intest}
RTC\_TIME\index{RTC\_TIME, structure}
\end{intest}

\begin{description}
\item [\textbf{Description:}] it is a data structure containing the following fields:\\
\textbf{tm\_sec} : seconds, from 0 to 59;\\
\textbf{tm\_min}: minutes, from 0 to 59;\\
\textbf{tm\_hour}: hours, from 0 to 23;\\
\textbf{tm\_mday} : day, from 1 to 31;\\
\textbf{tm\_mon} : month, from 1 to 12;\\
\textbf{tm\_year} : year, is an integer number (no Y2K problem);\\
\textbf{tm\_wday} : day of the week, from 1 to 7;\\
\textbf{tm\_yday} : day of the year, from 1 to 365;\\
\textbf{tm\_isdst} : 0 if legal hour, 1 if solar hour (not used yet);\\
\end{description
}