Difference between revisions of "Modules/clock"

From MSX Game Library

< Modules

(Created page with "The {{MOD|clock}} module allow to use MSX2 Real Time Clock (RTC) features including date and time handle, but also save or load data from the embedded SRAM. == Dependencies =...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
The {{MOD|clock}} module allow to use MSX2 Real Time Clock (RTC) features including date and time handle, but also save or load data from the embedded SRAM.
+
{{MODULE
 
+
|name=clock
== Dependencies ==
+
|category=Device
* ''None''
+
|dependency1=
 
+
|dependency2=
== Settings ==
+
|dependency3=
 
+
|sample1=s_clock
== Usage ==
+
|sample2=
 
+
|sample3=
== Annexe ==
+
}}
* See also: Sample program {{SAMPLE|s_clock}}
 
 
 
== Documentation ==
 
{{FRAME_DOC|clock}}
 
 
 
[[category:Module]][[category:Module/Core]]
 

Latest revision as of 19:00, 14 January 2024

clock

Code: clock.h

Category: Device

Dependencies: None

Samples:

The clock module allow to use MSX2 Real-time Clock (RTC) features including date and time handle, but also save or load data from the embedded non-volatile RAM (CMOS).

Usage

To use this module, include "clock.h" in your source code, and add "clock" to the modules list (LibModules) in your project's configuration file (project_config.js).

For example, display the current year:

RTC_Initialize();
u8 year = RTC_GetYear();
Print_DrawFormat("This year: %i", 1980 + year);

Save data to CMOS memory:

u8 saveData[6];
saveData[0] = 0xFF;
saveData[1] = 100;
saveData[2] = 0;
RTC_SaveData(saveData);

The MSX2 real-time clock is a Ricoh RP-5C01. For more information about this device:

Samples

See module use cases in the sample programs:

Settings

Library configuration (msxgl_config.h):

#define RTC_USE_CLOCK				TRUE	// Add functions to handle date and time
#define RTC_USE_CLOCK_EXTRA			TRUE	// Add extra date and time functions that require additional data
#define RTC_USE_SAVEDATA			TRUE	// Add functions to read/write into the CMOS 
#define RTC_USE_SAVESIGNED			TRUE	// Add signature handling to validate CMOS I/O

Dependencies

Dependency on other modules: None

Documentation