libdragon
Loading...
Searching...
No Matches
Macros | Enumerations | Functions

Real-Time Clock Subsystem. More...

Macros

#define JOYBUS_RTC_IDENTIFIER   0x1000
 Joybus real-time clock identifier.
 
#define JOYBUS_RTC_WRITE_BLOCK_DELAY   20
 Duration (in milliseconds) to wait after writing a Joybus RTC block.
 
#define JOYBUS_RTC_WRITE_FINISHED_DELAY   500
 Duration (in milliseconds) to wait after setting Joybus RTC time.
 
#define JOYBUS_RTC_STATUS_RUNNING   0x00
 The Joybus RTC is running.
 
#define JOYBUS_RTC_STATUS_STOPPED   0x80
 The Joybus RTC is stopped.
 
#define JOYBUS_RTC_CONTROL_MODE_SET   0x0004
 Control mode for setting the Joybus RTC date/time.
 
#define JOYBUS_RTC_CONTROL_MODE_RUN   0x0300
 Control mode for normal operation of the Joybus RTC.
 
#define RTC_GET_CACHE_INVALIDATE_TICKS   (TICKS_PER_SECOND)
 Invalidate the most-recent RTC time cache after 1 second.
 

Enumerations

enum  rtc_type_t { RTC_NONE = 0 , RTC_JOYBUS = 1 , RTC_DD = 2 , RTC_UNKNOWN = -1 }
 Real-time clock detection values. More...
 

Functions

bool rtc_init (void)
 High-level convenience helper to initialize the RTC subsystem.
 
void rtc_close (void)
 Close the RTC Subsystem, disabling system hooks.
 
void rtc_normalize_time (rtc_time_t *rtc_time)
 Calculate sane values for arbitrary time inputs.
 
bool rtc_get (rtc_time_t *rtc_time)
 Read the current date/time from the real-time clock.
 
bool rtc_set (rtc_time_t *write_time)
 High-level convenience helper to set the RTC date/time.
 
bool rtc_is_writable (void)
 Determine whether the RTC supports writing the time.
 

Detailed Description

Real-Time Clock Subsystem.

Macro Definition Documentation

◆ JOYBUS_RTC_IDENTIFIER

#define JOYBUS_RTC_IDENTIFIER   0x1000

Joybus real-time clock identifier.

A magic value in the SI RTC status response that indicates the Joybus RTC is present.

◆ JOYBUS_RTC_WRITE_BLOCK_DELAY

#define JOYBUS_RTC_WRITE_BLOCK_DELAY   20

Duration (in milliseconds) to wait after writing a Joybus RTC block.

The software should wait for the previous RTC write to finish before issuing another Joybus RTC command. Ideally, you could read the RTC status byte to determine when to proceed, but some RTC reproductions do not correctly implement the RTC status response, so a delay is used for compatibility.

◆ JOYBUS_RTC_WRITE_FINISHED_DELAY

#define JOYBUS_RTC_WRITE_FINISHED_DELAY   500

Duration (in milliseconds) to wait after setting Joybus RTC time.

64drive hw2 only updates the RTC readout a few times per second, so it is possible to write a new time, then read back the previous time before the 64drive clock ticks to update the "shadow interface" that the SI reads from.

Without this delay, the rtc_is_writable test may fail intermittently on 64drive hw2.

◆ JOYBUS_RTC_STATUS_RUNNING

#define JOYBUS_RTC_STATUS_RUNNING   0x00

The Joybus RTC is running.

It is safe to read the current time from the RTC.

◆ JOYBUS_RTC_STATUS_STOPPED

#define JOYBUS_RTC_STATUS_STOPPED   0x80

The Joybus RTC is stopped.

It is safe to write new time data to the RTC.

◆ JOYBUS_RTC_CONTROL_MODE_SET

#define JOYBUS_RTC_CONTROL_MODE_SET   0x0004

Control mode for setting the Joybus RTC date/time.

Clears the write-protection bits and sets the stop bit.

◆ JOYBUS_RTC_CONTROL_MODE_RUN

#define JOYBUS_RTC_CONTROL_MODE_RUN   0x0300

Control mode for normal operation of the Joybus RTC.

Clears the stop bit sets the write-protection bits.

0x0100 is the block 1 write-protection bit. 0x0200 is the block 2 write-protection bit.

Enumeration Type Documentation

◆ rtc_type_t

enum rtc_type_t

Real-time clock detection values.

Enumerator
RTC_NONE 

No RTC detected.

RTC_JOYBUS 

Joybus RTC detected.

RTC_DD 

N64 Disk Drive RTC detected. (Not implemented)

RTC_UNKNOWN 

RTC detection has not been occurred yet.