84 lines
1.3 KiB
C++
84 lines
1.3 KiB
C++
// rtc.c
|
|
// Author: Josh Holtrop
|
|
// Created: 02/26/04
|
|
// Implements Real-Time Clock function calls
|
|
// These functions are for reading and writing various values stored on the CMOS Real Time Clock
|
|
// Parameters / return values are in BCD format
|
|
|
|
#include "hos_defines.h"
|
|
#include "sys/rtc.h"
|
|
#include "sys/io.h"
|
|
|
|
unsigned char rtc_readDay()
|
|
{
|
|
outportb(0x70, 7);
|
|
return inportb(0x71);
|
|
}
|
|
|
|
unsigned char rtc_readMonth()
|
|
{
|
|
outportb(0x70, 8);
|
|
return inportb(0x71);
|
|
}
|
|
|
|
unsigned char rtc_readYear()
|
|
{
|
|
outportb(0x70, 9);
|
|
return inportb(0x71);
|
|
}
|
|
|
|
unsigned char rtc_readSecond()
|
|
{
|
|
outportb(0x70, 0);
|
|
return inportb(0x71);
|
|
}
|
|
|
|
unsigned char rtc_readMinute()
|
|
{
|
|
outportb(0x70, 2);
|
|
return inportb(0x71);
|
|
}
|
|
|
|
unsigned char rtc_readHour()
|
|
{
|
|
outportb(0x70, 4);
|
|
return inportb(0x71);
|
|
}
|
|
|
|
void rtc_setDay(unsigned char day)
|
|
{
|
|
outportb(0x70, 7);
|
|
outportb(0x71, day);
|
|
}
|
|
|
|
void rtc_setMonth(unsigned char month)
|
|
{
|
|
outportb(0x70, 8);
|
|
outportb(0x71, month);
|
|
}
|
|
|
|
void rtc_setYear(unsigned char year)
|
|
{
|
|
outportb(0x70, 9);
|
|
outportb(0x71, year);
|
|
}
|
|
|
|
void rtc_setSecond(unsigned char second)
|
|
{
|
|
outportb(0x70, 0);
|
|
outportb(0x71, second);
|
|
}
|
|
|
|
void rtc_setMinute(unsigned char minute)
|
|
{
|
|
outportb(0x70, 2);
|
|
outportb(0x71, minute);
|
|
}
|
|
|
|
void rtc_setHour(unsigned char hour)
|
|
{
|
|
outportb(0x70, 4);
|
|
outportb(0x71, hour);
|
|
}
|
|
|