Rev 1676 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1676 | tullio | 1 | %---------------------------------------------------------------------------- |
2 | \chapter{The CMOS real-time clock} |
||
3 | %---------------------------------------------------------------------------- |
||
4 | |||
5 | In all PCs there is a real-time clock (with a resolution of 1 second) that can |
||
6 | be read or written. This clock usually has a drift of about some seconds in 24 |
||
7 | hours. The following functions (that can be found into \texttt{rtc.h}) can be |
||
8 | used to set/get values; all values are passed using a \texttt{struct rtc\_time} |
||
9 | that contains variables for seconds, minutes, hours, days, months and years. |
||
10 | |||
11 | \vspace{7mm} |
||
12 | |||
13 | \begin{intest} |
||
14 | GET\_RTC\_TIME\index{get\_rtc\_time()} |
||
15 | \end{intest} |
||
16 | |||
17 | \begin{description} |
||
18 | \item [\textbf{int get\_rtc\_time(struct rtc\_time {*}time);}] |
||
19 | \item [\textbf{Description:}] The actual time is read from the CMOS real-time clock and |
||
20 | written into the structure pointed by \texttt{time}. The function returns zero |
||
21 | on success, other values on error. |
||
22 | \end{description} |
||
23 | |||
24 | \begin{intest} |
||
25 | SET\_RTC\_TIME\index{set\_rtc\_time()} |
||
26 | \end{intest} |
||
27 | |||
28 | \begin{description} |
||
29 | \item [\textbf{int set\_rtc\_time(struct rtc\_time {*}time);}] |
||
30 | \item [\textbf{Description:}] The values contained in the structure pointed by |
||
31 | \texttt{time} are converted in seconds and written into the CMOS real-time |
||
32 | clock; the function returns zero on success, other values on error. |
||
33 | \end{description} |
||
34 | |||
35 | \begin{intest} |
||
36 | RTC\_TIME\index{RTC\_TIME, structure} |
||
37 | \end{intest} |
||
38 | |||
39 | \begin{description} |
||
40 | \item [\textbf{Description:}] it is a data structure containing the following fields:\\ |
||
41 | \textbf{tm\_sec} : seconds, from 0 to 59;\\ |
||
42 | \textbf{tm\_min}: minutes, from 0 to 59;\\ |
||
43 | \textbf{tm\_hour}: hours, from 0 to 23;\\ |
||
44 | \textbf{tm\_mday} : day, from 1 to 31;\\ |
||
45 | \textbf{tm\_mon} : month, from 1 to 12;\\ |
||
46 | \textbf{tm\_year} : year, is an integer number (no Y2K problem);\\ |
||
47 | \textbf{tm\_wday} : day of the week, from 1 to 7;\\ |
||
48 | \textbf{tm\_yday} : day of the year, from 1 to 365;\\ |
||
49 | \textbf{tm\_isdst} : 0 if legal hour, 1 if solar hour (not used yet);\\ |
||
50 | \end{description} |