Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
Loading...
Searching...
No Matches
rtc.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2026 Efinix Inc. All rights reserved.
3// Full license header bsp/efinix/EfxSapphireSocRV64/include/LICENSE.MD
5
6#ifndef SRC_RTC_H_
7#define SRC_RTC_H_
8
19
20#include "i2c/i2c.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
37
38
39/* ========================================================================== */
40/* SUB-GROUP : Data Types */
41/* ========================================================================== */
42
49
55
56
60 typedef enum {
61 RTC_OK = 0,
62 RTC_ERR = 1,
66 // End of RTC_ENUM group
68
69
70/* ========================================================================== */
71/* SUB-GROUP : DATA STRUCTS */
72/* ========================================================================== */
108
111
127
137
151 // End of RTC_Types group
153
154/* ========================================================================== */
155/* SUB-GROUP: FUNCTIONS */
156/* ========================================================================== */
157
170 u8 convert_hour_register(u8 old_reg_val, u8 to_12h);
181 static inline u8 bcd2bin(u8 val) { return (val & 0x0F) + ((val >> 4) * 10); }
188 static inline u8 bin2bcd(u8 val) { return ((val / 10) << 4) + (val % 10); } // End of RTC Internal Functions group
190
199 extern const char* Day_ordinal [];
204 extern const char* const DayStrings[];
209 extern const char* const MonthStrings[];
214 extern const char* const meridiem[];
220 extern const char* get_ordinal(u8 day); // End of RTC Public API - String Based Functions group
222 // End of RTC_Funcs group
224
225/* ========================================================================== */
226/* SUB-GROUP: RTC CONFIGURATION */
227/* ========================================================================== */
228
230 #include "rtc/rtc_config.h"
231
232#ifdef __cplusplus
233
234}
235#endif // End of MAIN RTC Group
237
238#endif /* SRC_RTC_H_ */
rtc_status_t
RTC Status List.
Definition rtc.h:60
@ RTC_SKIP
Skip the function *‍/.
Definition rtc.h:64
@ RTC_ERR
Failed to retrieve/write value *‍/.
Definition rtc.h:62
@ RTC_OK
Successful Operation *‍/.
Definition rtc.h:61
@ RTC_USER_ERR
User provide wrong input *‍/.
Definition rtc.h:63
const char *const DayStrings[]
Get string representations for Sunday,Monday ,etc..
Definition rtc.c:31
const char *const meridiem[]
Get string representations for meridiem (AM/PM).
Definition rtc.c:61
u8 convert_hour_register(u8 old_reg_val, u8 to_12h)
Convert hour register between 12-hour and 24-hour format.
Definition rtc.c:80
const char * get_ordinal(u8 day)
Get ordinal suffix for a given day.
Definition rtc.c:68
const char *const MonthStrings[]
Get string representations for months.
Definition rtc.c:43
const char * Day_ordinal[]
Get ordinal suffix for a given day.
Definition rtc.c:23
struct rtc_instance rtc_instance_t
Forward declaration of RTC instance.
Definition rtc.h:110
I2C driver API definitions.
RTC Configuration and Driver Selection.
I2C instance. Holds the software registers and hardware pointer.
Definition i2c.h:259
RTC API structure.
Definition rtc.h:132
rtc_status_t(* getTime)(rtc_instance_t *rtc)
Get time function pointer *‍/.
Definition rtc.h:133
rtc_status_t(* setTime)(rtc_instance_t *rtc)
Set time function pointer *‍/.
Definition rtc.h:134
rtc_status_t(* setTimeSystem)(rtc_instance_t *rtc, u8 mode)
Set time system function pointer *‍/.
Definition rtc.h:135
RTC time data structure.
Definition rtc.h:116
u8 hours
Hours (0-23 or 1-12) *‍/.
Definition rtc.h:119
u8 timesystem
Time System (0 = 24-hour, 1 = 12-hour) *‍/.
Definition rtc.h:121
u8 days
Day of the month (1-31) *‍/.
Definition rtc.h:123
u8 minutes
Minutes (0-59) *‍/.
Definition rtc.h:118
u8 years
Year (0-99) *‍/.
Definition rtc.h:125
u8 seconds
Seconds (0-59) *‍/.
Definition rtc.h:117
u8 PM
PM Indicator for 12-hour format (0 = AM, 1 = PM) *‍/.
Definition rtc.h:120
u8 months
Month (1-12) *‍/.
Definition rtc.h:124
u8 weekdays
Day of the week (1-7) *‍/.
Definition rtc.h:122
RTC instance structure.
Definition rtc.h:146
rtc_data_t current_time
Current time data *‍/.
Definition rtc.h:149
const rtc_api_t * drv
Pointer to RTC API structure *‍/.
Definition rtc.h:148
i2c_instance_t * inst
Pointer to I2C instance *‍/.
Definition rtc.h:147
uint8_t u8
Definition type.h:26