WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

_rtc_common.h

Defines the functions that are common to all RTC devices.
This file is automatically included if you are using an RTC.

 

Function

 


rtcInit(RTC clock)

Initialise the RTC ready for use.
This should be called from appInitHardware.
For example: if your clock is called 'myClock':
rtcInit(myClock);

const DATE_TIME* rtcRead(RTC clock)

Read the current time from the clock and return a pointer to the information or NULL if there is a problem communicating with the clock.
Your code MUST check the return value and can the access the individual date and time fields. For example if your RTC is called 'myClock':
const DATE_TIME* dt = rtcRead(myClock);
if(dt != NULL){
uint16_t year = dt->year; // ie 2011
uint8_t month = dt->month; // 1 to 12
uint8_t date = dt->date; // 1 to 31
uint8_t hours = dt->hours; // 0 to 23
uint8_t minutes = dt->minutes; // 0 to 59
uint8_t seconds = dt->seconds; // 0 to 59
}

boolean rtcSet( RTC clock, uint16_t y,uint8_t m, uint8_t d, uint8_t h, uint8_t min, uint8_t sec )

Set the clock to the specified date and time.
The function will return TRUE if the time has been set successfully or FALSE if there was a problem (for example the clock may not be plugged in).
If you have not used the RTC device before then you should use this function to set it to the current date and time.
For example: if your clock is called 'myClock' and you want to set the date and time to 09:10:30 on 1 July 2011 then you can use:
rtcSet( myClock, 2011, 7, 1, 9,10,30);

rtcDump(RTC clock)

Dumps the current date and time to the standard output device.

rtcDumpTo( FILE* f, RTC clock )

Dumps the current date and time to the specified output stream.

Valid XHTML 1.0 Transitional