RTC Driver

A RTC (Real-Time Clock) provides accurate real-time clock time, which can be used to generate information such as year, month, day, hour, minute, and second.

The application accesses the RTC hardware via the RTC device management interface. The relevant interfaces are listed as follows:

Table 1. RTC Interfaces
Function Description
set_date() Sets date, year, month, and day.
set_time() Sets time, hour, minute, and second.
time() Obtains the current time.

The RTOS contains a RTC driver and a test program that is located at rtthread/bsp/starfive/libraries/driver/drv_rtc.c.

Figure 1. RTC Test Case

Test description: Start the RTC device and set the current time to 13:29:35 on May 19, 2025. After one second, read the time from the RTC and it will show the current time as above.