Difference between revisions of "Modules/clock"
From MSX Game Library
< Modules
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{MODULE | {{MODULE | ||
|name=clock | |name=clock | ||
− | |category= | + | |category=Device |
|dependency1= | |dependency1= | ||
|dependency2= | |dependency2= | ||
Line 9: | Line 9: | ||
|sample3= | |sample3= | ||
}} | }} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 18:00, 14 January 2024
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:
- Ricoh RP-5C01 manual (MSX Assembly Page),
- Real Time Clock Programming (MSX Resource Center).
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