Difference between revisions of "Unit RTC"
Line 280: | Line 280: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 295: | Line 295: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 307: | Line 307: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 319: | Line 319: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 331: | Line 331: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 343: | Line 343: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! RTC |
| The RTC device to get properties from | | The RTC device to get properties from | ||
|- | |- | ||
− | ! | + | ! Properties |
| Pointer to a PRTCProperties structure to fill in | | Pointer to a PRTCProperties structure to fill in | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
− | ! | + | ! Note |
| Replaced by RTCDeviceGetProperties for consistency | | Replaced by RTCDeviceGetProperties for consistency | ||
|- | |- | ||
Line 364: | Line 364: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! RTC |
| The RTC device to get properties from | | The RTC device to get properties from | ||
|- | |- | ||
− | ! | + | ! Properties |
| Pointer to a PRTCProperties structure to fill in | | Pointer to a PRTCProperties structure to fill in | ||
|- | |- | ||
− | ! | + | ! Return |
| ERROR_SUCCESS if completed or another error code on failure | | ERROR_SUCCESS if completed or another error code on failure | ||
|- | |- | ||
Line 382: | Line 382: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new RTC entry or nil if RTC could not be created | | Pointer to new RTC entry or nil if RTC could not be created | ||
|- | |- | ||
Line 394: | Line 394: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Size |
| Size in bytes to allocate for new RTC (Including the RTC entry) | | Size in bytes to allocate for new RTC (Including the RTC entry) | ||
|- | |- | ||
− | ! | + | ! Return |
| Pointer to new RTC entry or nil if RTC could not be created | | Pointer to new RTC entry or nil if RTC could not be created | ||
|- | |- | ||
Line 409: | Line 409: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 421: | Line 421: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 433: | Line 433: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 445: | Line 445: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 457: | Line 457: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 469: | Line 469: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 481: | Line 481: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 493: | Line 493: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 508: | Line 508: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 520: | Line 520: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| Returned time is 100 nanosecond ticks since 1 January 1601 | | Returned time is 100 nanosecond ticks since 1 January 1601 | ||
|- | |- | ||
Line 532: | Line 532: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Time |
| The time to be set | | The time to be set | ||
|- | |- | ||
− | ! | + | ! Return |
| The device time after setting (or 0 on failure) | | The device time after setting (or 0 on failure) | ||
|- | |- | ||
− | ! | + | ! Note |
| Time and returned time is 100 nanosecond ticks since 1 January 1601 | | Time and returned time is 100 nanosecond ticks since 1 January 1601 | ||
|- | |- | ||
Line 553: | Line 553: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 565: | Line 565: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 577: | Line 577: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 589: | Line 589: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 601: | Line 601: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 613: | Line 613: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 625: | Line 625: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 637: | Line 637: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 649: | Line 649: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 661: | Line 661: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 673: | Line 673: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- | ||
Line 685: | Line 685: | ||
{| class="wikitable" style="font-size: 14px; background: white;" | {| class="wikitable" style="font-size: 14px; background: white;" | ||
|- | |- | ||
− | ! | + | ! Note |
| None documented | | None documented | ||
|- | |- |
Revision as of 05:13, 20 April 2018
Return to Unit Reference
Description
Ultibo Real Time Clock device interface unit
The RTC unit provides the device interface for real time clock modules to be registered with Ultibo core. Each RTC module requires a driver that communicates with the specific hardware to implement the device interface although many devices may use the same chip and will be covered by a single driver.
This unit registers the RTCGetTime
and RTCSetTime
functions with the Platform unit to enable hardware independent access to a real time clock module.
Constants
RTC_*
RTC_NAME_PREFIX = 'RTC';
|
Name prefix for RTC Devices |
RTC_TYPE_*
RTC_TYPE_NONE = 0;
|
RTC_STATE_*
RTC_STATE_DISABLED = 0;
|
|
RTC_STATE_ENABLED = 1;
|
RTC_FLAG_*
RTC_FLAG_NONE = $00000000;
|
|
RTC_FLAG_ALARM = $00000001;
|
Device supports one or more alarms |
RTC_FLAG_WATCHDOG = $00000002;
|
Device has a watchdog timer function |
RTC_LOG_*
RTC_LOG_LEVEL_DEBUG = LOG_LEVEL_DEBUG;
|
RTC debugging messages |
RTC_LOG_LEVEL_INFO = LOG_LEVEL_INFO;
|
RTC informational messages, such as a device being attached or detached |
RTC_LOG_LEVEL_WARN = LOG_LEVEL_WARN;
|
RTC warning messages |
RTC_LOG_LEVEL_ERROR = LOG_LEVEL_ERROR;
|
RTC error messages |
RTC_LOG_LEVEL_NONE = LOG_LEVEL_NONE;
|
No RTC messages |
Type definitions
RTC properties
PRTCProperties = ^TRTCProperties;
TRTCProperties = record
Flags:LongWord;
|
Device flags (eg RTC_FLAG_ALARM) |
MinTime:Int64;
|
Minimum time value represented by the device (Normally the power on reset value) |
MaxTime:Int64;
|
Maximum time value represented by the device (Time when a rollover will occur) |
AlarmCount:LongWord;
|
Number of alarms supported by the device (0 if not supported) |
RTC enumeration callback
TRTCEnumerate = function(RTC:PRTCDevice; Data:Pointer):LongWord;
|
RTC notification callback
TRTCNotification = function(Device:PDevice; Data:Pointer; Notification:LongWord):LongWord;
|
RTC device start
TRTCDeviceStart = function(RTC:PRTCDevice):LongWord;
|
RTC device stop
TRTCDeviceStop = function(RTC:PRTCDevice):LongWord;
|
RTC device get time
TRTCDeviceGetTime = function(RTC:PRTCDevice):Int64;
|
RTC device set time
TRTCDeviceSetTime = function(RTC:PRTCDevice; const Time:Int64):Int64;
|
RTC device get properties
TRTCDeviceGetProperties = function(RTC:PRTCDevice; Properties:PRTCProperties):LongWord;
|
RTC device
PRTCDevice = ^TRTCDevice;
TRTCDevice = record
Device Properties | |
Device:TDevice;
|
The Device entry for this RTC |
RTC Properties | |
RTCId:LongWord;
|
Unique Id of this RTC in the RTC table |
RTCState:LongWord;
|
RTC state (eg RTC_STATE_ENABLED) |
DeviceStart:TRTCDeviceStart;
|
A Device specific DeviceStart method implementing the standard RTC device interface |
DeviceStop:TRTCDeviceStop;
|
A Device specific DeviceStop method implementing the standard RTC device interface |
DeviceGetTime:TRTCDeviceGetTime;
|
A Device specific DeviceGetTime method implementing the standard RTC device interface |
DeviceSetTime:TRTCDeviceSetTime;
|
A Device specific DeviceSetTime method implementing the standard RTC device interface |
DeviceGetProperties:TRTCDeviceGetProperties;
|
A Device specific DeviceGetProperties method implementing the standard RTC device interface |
Statistics Properties | |
GetCount:LongWord;
|
|
SetCount:LongWord;
|
|
Driver Properties | |
Lock:TMutexHandle;
|
Device lock |
Properties:TRTCProperties;
|
Device properties |
Internal Properties | |
Prev:PRTCDevice;
|
Previous entry in RTC table |
Next:PRTCDevice;
|
Next entry in RTC table |
Public variables
RTC logging
RTC_DEFAULT_LOG_LEVEL:LongWord = RTC_LOG_LEVEL_DEBUG;
|
Minimum level for RTC messages. Only messages with level greater than or equal to this will be printed. |
RTC_LOG_ENABLED:Boolean;
|
Function declarations
Initialization functions
procedure RTCInit;
Note | None documented |
---|
RTC functions
function RTCDeviceStart(RTC:PRTCDevice):LongWord;
Note | None documented |
---|
function RTCDeviceStop(RTC:PRTCDevice):LongWord;
Note | None documented |
---|
function RTCDeviceGetTime(RTC:PRTCDevice):Int64;
Note | None documented |
---|
function RTCDeviceSetTime(RTC:PRTCDevice; const Time:Int64):Int64;
Note | None documented |
---|
function RTCDeviceProperties(RTC:PRTCDevice; Properties:PRTCProperties):LongWord; inline;
RTC | The RTC device to get properties from |
---|---|
Properties | Pointer to a PRTCProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
Note | Replaced by RTCDeviceGetProperties for consistency |
function RTCDeviceGetProperties(RTC:PRTCDevice;Properties:PRTCProperties):LongWord;
RTC | The RTC device to get properties from |
---|---|
Properties | Pointer to a PRTCProperties structure to fill in |
Return | ERROR_SUCCESS if completed or another error code on failure |
function RTCDeviceCreate:PRTCDevice;
Return | Pointer to new RTC entry or nil if RTC could not be created |
---|
function RTCDeviceCreateEx(Size:LongWord):PRTCDevice;
Size | Size in bytes to allocate for new RTC (Including the RTC entry) |
---|---|
Return | Pointer to new RTC entry or nil if RTC could not be created |
function RTCDeviceDestroy(RTC:PRTCDevice):LongWord;
Note | None documented |
---|
function RTCDeviceRegister(RTC:PRTCDevice):LongWord;
Note | None documented |
---|
function RTCDeviceDeregister(RTC:PRTCDevice):LongWord;
Note | None documented |
---|
function RTCDeviceFind(RTCId:LongWord):PRTCDevice;
Note | None documented |
---|
function RTCDeviceFindByName(const Name:String):PRTCDevice; inline;
Note | None documented |
---|
function RTCDeviceFindByDescription(const Description:String):PRTCDevice; inline;
Note | None documented |
---|
function RTCDeviceEnumerate(Callback:TRTCEnumerate; Data:Pointer):LongWord;
Note | None documented |
---|
function RTCDeviceNotification(RTC:PRTCDevice; Callback:TRTCNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Note | None documented |
---|
RTL RTC functions
function SysRTCAvailable:Boolean;
Note | None documented |
---|
function SysRTCGetTime:Int64;
Note | Returned time is 100 nanosecond ticks since 1 January 1601 |
---|
function SysRTCSetTime(const Time:Int64):Int64;
Time | The time to be set |
---|---|
Return | The device time after setting (or 0 on failure) |
Note | Time and returned time is 100 nanosecond ticks since 1 January 1601 |
RTC helper functions
function RTCGetCount:LongWord; inline;
Note | None documented |
---|
function RTCDeviceGetDefault:PRTCDevice; inline;
Note | None documented |
---|
function RTCDeviceSetDefault(RTC:PRTCDevice):LongWord;
Note | None documented |
---|
function RTCDeviceCheck(RTC:PRTCDevice):PRTCDevice;
Note | None documented |
---|
function RTCTimeIsValid(const Time:TSystemTime):Boolean;
Note | None documented |
---|
function RTCSystemTimeToFileTime(const SystemTime:TSystemTime; var FileTime:Int64):Boolean;
Note | None documented |
---|
function RTCFileTimeToSystemTime(const FileTime:Int64; var SystemTime:TSystemTime):Boolean;
Note | None documented |
---|
procedure RTCLog(Level:LongWord; RTC:PRTCDevice; const AText:String);
Note | None documented |
---|
procedure RTCLogInfo(RTC:PRTCDevice; const AText:String); inline;
Note | None documented |
---|
procedure RTCLogWarn(RTC:PRTCDevice; const AText:String); inline;
Note | None documented |
---|
procedure RTCLogError(RTC:PRTCDevice; const AText:String); inline;
Note | None documented |
---|
procedure RTCLogDebug(RTC:PRTCDevice; const AText:String); inline;
Note | None documented |
---|
Return to Unit Reference