Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

time.h File Reference

Real time clock driver header. More...

Go to the source code of this file.

Defines

#define RTC_EPOCH_YEAR   1970
 The base epoch year.

#define EPOCH_DAY   0
 The base epoch day (Jan 1).

#define RTC_SECONDS   0
 RTC port for seconds.

#define RTC_MINUTES   2
 RTC port for minutes.

#define RTC_HOURS   4
 RTC port for hours.

#define RTC_DAY_OF_WEEK   6
 RTC port for the day of the week.

#define RTC_DAY_OF_MONTH   7
 RTC port for the month.

#define RTC_MONTH   8
 RTC port for month.

#define RTC_YEAR   9
 RTC port for year.

#define RTC_REG_A   10
 RTC control register A.

#define RTC_REG_B   11
 RTC control register B.

#define RTC_REG_C   12
 RTC control register C.

#define RTC_REG_D   13
 RTC control register D.

#define BCD2BIN(n)   ( ((n) >> 4) * 10 + ((n) & 0x0F) )
 Macro to convert from BCD to binary format.

#define BIN2BCD(n)   ( (((n) / 10) << 4) + ((n) % 10) )
 Macro to convert from binary to BCD format.

#define CMOS_CTRL   0x70
 CMOS control register.

#define CMOS_DATA   0x71
 CMOS data register.

#define CMOS_READ(port)
 Read a value from the CMOS.
Parameters:
port  The port to read from.
Returns:
The value read from the CMOS port.


#define CMOS_WRITE(port, val)
 Write a value to the CMOS.
Parameters:
port  The port to write to.
val  The value to write.


#define RTC_FREQ_SELECT   RTC_REG_A
 RTC update frequency register.

#define RTC_UIP   0x80
 Update-in-progress - set to "1" 244 microsecs before RTC goes off the bus, reset after update (may take 1.984ms @ 32768Hz RefClock) is complete, totalling to a max high interval of 2.228 ms.

#define RTC_DIV_RESET1   0x60
#define RTC_DIV_RESET2   0x70
#define RTC_CONTROL   RTC_REG_B
 RTC status register.

#define RTC_SET   0x80
 Disable updates for clock setting.

#define RTC_DM_BINARY   0x04
 RTC binary date; all time/date values are BCD if clear.

#define RTC_24H   0x02

Typedefs

typedef unsigned long time_t
 Time variable type.


Functions

__inline__ unsigned long mktime (unsigned int year, unsigned int mon, unsigned int day, unsigned int hour, unsigned int min, unsigned int sec)
 Converts Gregorian date to seconds since 1970-01-01 00:00:00.
Parameters:
year  The year value.
mon  The month value.
day  The day of the month value.
hour  The hours value.
min  The minutes value.
sec  The seconds value.
Returns:
Seconds since 1970-01-01 00:00:00 (UNIX timestamp).


void time_init ()
 Initialize the Real-Time Clock.

time_t time_read ()
 Get the seconds passed since midnight 1970-01-01 (Unix timestamp).
Returns:
The UNIX timestamp.



Detailed Description

Real time clock driver header.

Author:
Andrea Righi <drizzt@inwind.it>
Date:
Last update: 2003-08-27
Note:
Copyright (©) 2003 Andrea Righi

Definition in file time.h.


Define Documentation

#define BCD2BIN      ( ((n) >> 4) * 10 + ((n) & 0x0F) )
 

Macro to convert from BCD to binary format.

Definition at line 45 of file time.h.

#define BIN2BCD      ( (((n) / 10) << 4) + ((n) % 10) )
 

Macro to convert from binary to BCD format.

Definition at line 47 of file time.h.

#define CMOS_CTRL   0x70
 

CMOS control register.

Definition at line 50 of file time.h.

#define CMOS_DATA   0x71
 

CMOS data register.

Definition at line 52 of file time.h.

#define CMOS_READ port   
 

Value:

( \
                { \
                        out( CMOS_CTRL, (port) ); \
                        in( CMOS_DATA ); \
                })
Read a value from the CMOS.
Parameters:
port  The port to read from.
Returns:
The value read from the CMOS port.

Definition at line 57 of file time.h.

#define CMOS_WRITE port,
val   
 

Value:

( \
                { \
                        out( CMOS_CTRL, (port) ); \
                        out( CMOS_DATA, (val) ); \
                })
Write a value to the CMOS.
Parameters:
port  The port to write to.
val  The value to write.

Definition at line 66 of file time.h.

#define EPOCH_DAY   0
 

The base epoch day (Jan 1).

Definition at line 17 of file time.h.

#define RTC_24H   0x02
 

Definition at line 94 of file time.h.

#define RTC_CONTROL   RTC_REG_B
 

RTC status register.

Definition at line 87 of file time.h.

#define RTC_DAY_OF_MONTH   7
 

RTC port for the month.

Definition at line 29 of file time.h.

#define RTC_DAY_OF_WEEK   6
 

RTC port for the day of the week.

Definition at line 27 of file time.h.

#define RTC_DIV_RESET1   0x60
 

Definition at line 82 of file time.h.

#define RTC_DIV_RESET2   0x70
 

Definition at line 83 of file time.h.

#define RTC_DM_BINARY   0x04
 

RTC binary date; all time/date values are BCD if clear.

Definition at line 92 of file time.h.

#define RTC_EPOCH_YEAR   1970
 

The base epoch year.

Definition at line 15 of file time.h.

#define RTC_FREQ_SELECT   RTC_REG_A
 

RTC update frequency register.

Definition at line 75 of file time.h.

#define RTC_HOURS   4
 

RTC port for hours.

Definition at line 24 of file time.h.

#define RTC_MINUTES   2
 

RTC port for minutes.

Definition at line 22 of file time.h.

#define RTC_MONTH   8
 

RTC port for month.

Definition at line 31 of file time.h.

#define RTC_REG_A   10
 

RTC control register A.

Definition at line 36 of file time.h.

#define RTC_REG_B   11
 

RTC control register B.

Definition at line 38 of file time.h.

#define RTC_REG_C   12
 

RTC control register C.

Definition at line 40 of file time.h.

#define RTC_REG_D   13
 

RTC control register D.

Definition at line 42 of file time.h.

#define RTC_SECONDS   0
 

RTC port for seconds.

Definition at line 20 of file time.h.

#define RTC_SET   0x80
 

Disable updates for clock setting.

Definition at line 90 of file time.h.

#define RTC_UIP   0x80
 

Update-in-progress - set to "1" 244 microsecs before RTC goes off the bus, reset after update (may take 1.984ms @ 32768Hz RefClock) is complete, totalling to a max high interval of 2.228 ms.

Definition at line 80 of file time.h.

#define RTC_YEAR   9
 

RTC port for year.

Definition at line 33 of file time.h.


Typedef Documentation

typedef unsigned long time_t
 

Time variable type.

Definition at line 12 of file time.h.


Generated on Fri Feb 20 15:32:20 2004 for Minirighi by doxygen1.2.18