cmos.h

00001 /***************************************************************************
00002                           cmos.h  -  description
00003                              -------------------
00004     begin                : Mon Mar 14 2004
00005     copyright            : (C) 2004 by Dynacube Team
00006     email                :
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #ifndef __CMOS_H
00018 #define __CMOS_H
00019 
00020         #define CMOS_OUT_PORT 0x70
00021         #define CMOS_IN_PORT 0x71
00022         
00023         #define SECOND_ADDR 0x00
00024         #define MINUTE_ADDR 0x02
00025         #define HOUR_ADDR 0x04
00026         #define DAY_ADDR 0x06
00027         #define DATE_ADDR 0x07
00028         #define MONTH_ADDR 0x08
00029         #define YEAR_ADDR 0x09
00030         
00031         #define CMOS_READ(addr) ({ \
00032                                                                 outb(CMOS_OUT_PORT,0x80|addr); \
00033                                                                 inb(CMOS_IN_PORT); \
00034                                                         })
00035 
00036         #define CMOS_WRITE(addr,val) ({ \
00037                                                                         outb(CMOS_OUT_PORT,0x80|addr); \
00038                                                                         outb(CMOS_IN_PORT,val); \
00039                                                                  })
00040 
00041         #define BCD2BIN(bcd) ((bcd&0xF) + ((bcd>>4)*10))
00042         #define BIN2BCD(bin)  (((bin / 10) << 4) | (bin % 10))
00043 
00044         typedef struct
00045         {
00046                 char mm,dd;
00047                 int yy;
00048         }DATE;
00049         typedef struct
00050         {
00051                 int hour,min,sec;
00052         }TIME;
00053         
00054          void gettime(TIME *t);
00055          void settime(TIME *t);
00056          void getdate(DATE *d);
00057          void setdate(DATE *d);
00058  
00059 #endif

Generated on Thu Jul 27 23:52:25 2006 for Dynacube by  doxygen 1.4.7