8.1 Reading the RTC


LeoReadRTC( )function

#include <PR/leo.h>

s32 LeoReadRTC(LEOCmd *cmdBlock, OSMesgQueue *mq);

Reads the RTC time and stores it in cmdBlock->data.time.

cmdBlock->data.time is LEODiskTime structure.

typedef struct

{

u8 pad;

u8 yearhi; /* in BCD */

u8 yearlo; /* in BCD */

u8 month; /* in BCD */

u8 day; /* in BCD */

u8 hour; /* in BCD */

u8 minute; /* in BCD */

u8 second; /* in BCD */

} LEODiskTime;

Please note that each element is a BCD .

The RTC retains only the last 2 digits of a year (yearlo) and cannot by itself return the first two digits (yearhi). Thus, the LeoReadRTC function uses software methods to determine and return the yearhi values shown below in response to the yearlo value read from the RTC.

yearlo yearhi
96 - 99 19
00 - 95 20

If the value of yearlo that is read from RTC is other value than the above mentioned values (21 - 95), the yearlo of RTC is changed to 96 inside the function automatically.

For return values, cmdBlock, and mq, please see Section 7.2, "Asynchronous Functions."