MentOS  0.8.0
The Mentoring Operating System
Macros | Functions | Variables
Real Time Clock (RTC)

Routines for interfacing with the real-time clock. More...

Macros

#define __DEBUG_HEADER__   "[RTC ]"
 Change header.
 
#define __DEBUG_LEVEL__   LOGLEVEL_NOTICE
 Set log level.
 
#define CMOS_ADDR   0x70
 Addess where we need to write the Address.
 
#define CMOS_DATA   0x71
 Addess where we need to write the Data.
 

Functions

void gettime (tm_t *time)
 Copies the global time inside the provided variable. More...
 
int rtc_initialize (void)
 Initializes the Real Time Clock (RTC). More...
 
int rtc_finalize (void)
 De-initializes the Real Time Clock (RTC). More...
 
static unsigned int rtc_are_different (tm_t *t0, tm_t *t1)
 Checks if the two time values are different. More...
 
static unsigned int is_updating_rtc (void)
 Check if rtc is updating time currently. More...
 
static unsigned char read_register (unsigned char reg)
 Reads the given register. More...
 
static void write_register (unsigned char reg, unsigned char value)
 Writes on the given register. More...
 
static unsigned char bcd2bin (unsigned char bcd)
 Transforms a Binary-Coded Decimal (BCD) to decimal. More...
 
static void rtc_read_datetime (void)
 Reads the current datetime value from a real-time clock.
 
static void rtc_update_datetime (void)
 Updates the internal datetime value.
 
static void rtc_handler_isr (pt_regs *f)
 Callback for RTC. More...
 

Variables

tm_t global_time
 Current global time.
 
tm_t previous_global_time
 Previous global time.
 
int is_bcd
 Data type is BCD.
 

Detailed Description

Routines for interfacing with the real-time clock.

Function Documentation

◆ bcd2bin()

static unsigned char bcd2bin ( unsigned char  bcd)
inlinestatic

Transforms a Binary-Coded Decimal (BCD) to decimal.

Parameters
bcdthe BCD value.
Returns
the decimal value.

◆ gettime()

void gettime ( tm_t time)

Copies the global time inside the provided variable.

Parameters
timePointer where we store the global time.

◆ is_updating_rtc()

static unsigned int is_updating_rtc ( void  )
inlinestatic

Check if rtc is updating time currently.

Returns
1 if RTC is updating, 0 otherwise.

◆ read_register()

static unsigned char read_register ( unsigned char  reg)
inlinestatic

Reads the given register.

Parameters
regthe register to read.
Returns
the value we read.

◆ rtc_are_different()

static unsigned int rtc_are_different ( tm_t t0,
tm_t t1 
)
inlinestatic

Checks if the two time values are different.

Parameters
t0the first time value.
t1the second time value.
Returns
1 if they are different, 0 otherwise.

◆ rtc_finalize()

int rtc_finalize ( void  )

De-initializes the Real Time Clock (RTC).

Returns
0 on success, 1 on error.

◆ rtc_handler_isr()

static void rtc_handler_isr ( pt_regs f)
inlinestatic

Callback for RTC.

Parameters
fthe current registers.

◆ rtc_initialize()

int rtc_initialize ( void  )

Initializes the Real Time Clock (RTC).

Returns
0 on success, 1 on error.

◆ write_register()

static void write_register ( unsigned char  reg,
unsigned char  value 
)
inlinestatic

Writes on the given register.

Parameters
regthe register on which we need to write.
valuethe value we want to write.