This module provides Generic Core functions of RTC to configure and control RTC input/output and interrupt behavior.
Usage & Initialization.
This is an example show how to instantiate Real Time Clock (RTC) Driver with rtc_instance_t.
This implementation depends on I2C Driver.
#define I2C_FREQ 100000
#define I2C_CTRL_HZ SYSTEM_CLINT_HZ
#define I2C_CTRL (i2c_hwreg_t *)SYSTEM_I2C_0_IO_CTRL
#define RTC_CTRL RTC_DS3231_ADDR
#define RTC_DRIVER ds3231_driver
.hwreg = I2C_CTRL,
.samplingClockDivider = 3,
.timeout = I2C_CTRL_HZ/1000,
.tsuDat = I2C_CTRL_HZ/(I2C_FREQ*5),
.tLow = I2C_CTRL_HZ/(I2C_FREQ*2),
.tHigh = I2C_CTRL_HZ/(I2C_FREQ*2),
.tBuf = I2C_CTRL_HZ/(I2C_FREQ),
},
};
#define RTC_CTRL
I2C Address for the currently selected RTC (PCF8523).
#define RTC_DRIVER
Driver Interface Table for the currently selected RTC (PCF8523).
struct rtc_instance rtc_instance_t
Forward declaration of RTC instance.
RTC driver API definitions.
I2C instance. Holds the software registers and hardware pointer.
rtc_status_t(* getTime)(rtc_instance_t *rtc)
Get time function pointer.
rtc_status_t(* applyConfig)(rtc_instance_t *rtc)
Apply i2c config , user can call via rtc_applyConfig as well.
rtc_status_t(* enableErrorInterrupt)(rtc_instance_t *rtc)
Enable error interrupt function pointer, user can call via rtc_enableErrorInterrupt as well.
u8 hours
Hours (0-23 or 1-12).
u8 minutes
Minutes (0-59).
u8 seconds
Seconds (0-59).
rtc_data_t current_time
Current time data.
const rtc_api_t * drv
Pointer to RTC API structure.
- See also
- Supported Devices - Learn about the supported Real Time Clock device list.
-
Example RTC Demo - Learn how to use the driver for Real-Time Clock operations.