18#if VSF_HAL_USE_RTC == ENABLED
23#if VSF_RTC_CFG_GET_API_TEMPLATE == ENABLED && VSF_RTC_CFG_GET_TIME_API_TEMPLATE == ENABLED
24# error "VSF_RTC_CFG_GET_API_TEMPLATE and VSF_RTC_CFG_GET_TIME_API_TEMPLATE Only one can be defined at a time"
27#if VSF_RTC_CFG_SET_API_TEMPLATE == ENABLED && VSF_RTC_CFG_SET_TIME_API_TEMPLATE == ENABLED
28# error "VSF_RTC_CFG_SET_API_TEMPLATE and VSF_RTC_CFG_SET_TIME_API_TEMPLATE Only one can be defined at a time"
31#ifndef VSF_RTC_CFG_REIMPLEMENT_API_CAPABILITY
32# define VSF_RTC_CFG_REIMPLEMENT_API_CAPABILITY DISABLED
35#ifdef VSF_RTC_CFG_IMP_REMAP_PREFIX
36# undef VSF_RTC_CFG_REIMPLEMENT_API_CAPABILITY
37# define VSF_RTC_CFG_REIMPLEMENT_API_CAPABILITY ENABLED
40#if VSF_RTC_CFG_REIMPLEMENT_API_CAPABILITY == DISABLED
41# ifndef VSF_RTC_CFG_CAPABILITY_T_IRQ_MASK
42# define VSF_RTC_CFG_CAPABILITY_T_IRQ_MASK VSF_RTC_IRQ_ALL_BITS_MASK
46#define vsf_real_rtc_t VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_t)
47#define vsf_real_rtc_capability VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_capability)
48#define vsf_real_rtc_get VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_get)
49#define vsf_real_rtc_set VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_set)
50#define vsf_real_rtc_get_time VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_get_time)
51#define vsf_real_rtc_set_time VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_set_time)
60#if VSF_RTC_CFG_GET_API_TEMPLATE == ENABLED
66 time_t second, milliseconds;
67 vsf_err_t result = vsf_real_rtc_get_time(rtc_ptr, &second, &milliseconds);
84 rtc_tm->
tm_ms = milliseconds;
90#if VSF_RTC_CFG_SET_API_TEMPLATE == ENABLED
101 .tm_mon = rtc_tm->
tm_mon - 1,
102 .tm_year = rtc_tm->
tm_year - 1900,
106 return vsf_real_rtc_set_time(rtc_ptr, second, rtc_tm->
tm_ms);
110#if VSF_RTC_CFG_GET_TIME_API_TEMPLATE == ENABLED
117 vsf_err_t result = vsf_real_rtc_get(rtc_ptr, &rtc_tm);
122 if (second_ptr !=
NULL) {
128 .tm_mon = rtc_tm.
tm_mon - 1,
129 .tm_year = rtc_tm.
tm_year - 1900,
134 if (milliseconds_ptr !=
NULL) {
135 *milliseconds_ptr = rtc_tm.
tm_ms;
142#if VSF_RTC_CFG_SET_TIME_API_TEMPLATE == ENABLED
159 .tm_ms = milliseconds,
162 return vsf_real_rtc_set(rtc_ptr, &rtc_tm);
166#if VSF_RTC_CFG_REIMPLEMENT_API_CAPABILITY == DISABLED
173 return rtc_capability;
179#undef VSF_RTC_CFG_REIMPLEMENT_API_CAPABILITY
180#undef VSF_RTC_CFG_CAPABILITY_T_IRQ_MASK
182#undef vsf_real_rtc_capability
186#ifdef VSF_RTC_CFG_IMP_REMAP_PREFIX
188# define vsf_imp_rtc_t VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_t)
189# define vsf_imp_rtc_init VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_init)
190# define vsf_imp_rtc_enable VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_enable)
191# define vsf_imp_rtc_disable VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_disable)
192# define vsf_imp_rtc_capability VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_capability)
193# define vsf_imp_rtc_get VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_get)
194# define vsf_imp_rtc_set VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_set)
195# define vsf_imp_rtc_get_time VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_get_time)
196# define vsf_imp_rtc_set_time VSF_MCONNECT(VSF_RTC_CFG_IMP_PREFIX, _rtc_set_time)
198# define vsf_remap_rtc_t VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_t)
199# define vsf_remap_rtc_init VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_init)
200# define vsf_remap_rtc_enable VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_enable)
201# define vsf_remap_rtc_disable VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_disable)
202# define vsf_remap_rtc_capability VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_capability)
203# define vsf_remap_rtc_get VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_get)
204# define vsf_remap_rtc_set VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_set)
205# define vsf_remap_rtc_get_time VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_get_time)
206# define vsf_remap_rtc_set_time VSF_MCONNECT(VSF_RTC_CFG_IMP_REMAP_PREFIX, _rtc_set_time)
208# define VSF_RTC_CFG_IMP_REMAP_FUNCTIONS \
209 vsf_err_t vsf_imp_rtc_init(vsf_imp_rtc_t *rtc_ptr, vsf_rtc_cfg_t *cfg_ptr) \
211 VSF_HAL_ASSERT(rtc_ptr != NULL); \
212 return vsf_remap_rtc_init(rtc_ptr, cfg_ptr); \
214 void vsf_imp_rtc_fini(vsf_imp_rtc_t *rtc_ptr) \
216 VSF_HAL_ASSERT(rtc_ptr != NULL); \
217 vsf_remap_rtc_fini(rtc_ptr); \
219 fsm_rt_t vsf_imp_rtc_enable(vsf_imp_rtc_t *rtc_ptr) \
221 VSF_HAL_ASSERT(rtc_ptr != NULL); \
222 return vsf_remap_rtc_enable(rtc_ptr); \
224 fsm_rt_t vsf_imp_rtc_disable(vsf_imp_rtc_t *rtc_ptr) \
226 VSF_HAL_ASSERT(rtc_ptr != NULL); \
227 return vsf_remap_rtc_disable(rtc_ptr); \
229 vsf_err_t vsf_imp_rtc_get(vsf_imp_rtc_t *rtc_ptr, vsf_imp_rtc_tm_t *rtc_tm) \
231 VSF_HAL_ASSERT(rtc_ptr != NULL); \
232 return vsf_remap_rtc_get(rtc_ptr, rtc_tm); \
234 vsf_err_t vsf_imp_rtc_set(vsf_imp_rtc_t *rtc_ptr, const vsf_imp_rtc_tm_t *rtc_tm) \
236 VSF_HAL_ASSERT(rtc_ptr != NULL); \
237 return vsf_remap_rtc_set(rtc_ptr, rtc_tm); \
239 vsf_err_t vsf_imp_rtc_get_time(vsf_imp_rtc_t *rtc_ptr, vsf_imp_rtc_time_t *second_ptr,\
240 vsf_imp_rtc_time_t *millisecond_ptr) \
242 VSF_HAL_ASSERT(rtc_ptr != NULL); \
243 return vsf_remap_rtc_get_time(rtc_ptr, second_ptr, millisecond_ptr); \
245 vsf_err_t vsf_imp_rtc_set_time(vsf_imp_rtc_t *rtc_ptr, vsf_imp_rtc_time_t second, \
246 vsf_imp_rtc_time_t millisecond) \
248 VSF_HAL_ASSERT(rtc_ptr != NULL); \
249 return vsf_remap_rtc_set_time(rtc_ptr, second, millisecond); \
251 vsf_rtc_capability_t vsf_imp_rtc_capability(vsf_imp_rtc_t *rtc_ptr) \
253 VSF_HAL_ASSERT(rtc_ptr != NULL); \
254 return vsf_remap_rtc_capability(rtc_ptr); \
260#define VSF_HAL_TEMPLATE_IMP_NAME _rtc
261#define VSF_HAL_TEMPLATE_IMP_UPCASE_NAME _RTC
263#ifndef VSF_RTC_CFG_IMP_PREFIX
264# error "Please define VSF_RTC_CFG_IMP_PREFIX in rtc driver"
267#ifndef VSF_RTC_CFG_IMP_UPCASE_PREFIX
268# error "Please define VSF_RTC_CFG_IMP_UPCASE_PREFIX in rtc driver"
271#ifndef VSF_RTC_CFG_IMP_COUNT_MASK_PREFIX
272# define VSF_RTC_CFG_IMP_COUNT_MASK_PREFIX VSF_RTC_CFG_IMP_UPCASE_PREFIX
275#ifdef VSF_RTC_CFG_IMP_REMAP_FUNCTIONS
276# define VSF_HAL_CFG_IMP_REMAP_FUNCTIONS VSF_RTC_CFG_IMP_REMAP_FUNCTIONS
281#undef VSF_RTC_CFG_IMP_PREFIX
282#undef VSF_RTC_CFG_IMP_COUNT_MASK_PREFIX
283#undef VSF_RTC_CFG_IMP_UPCASE_PREFIX
284#undef VSF_RTC_CFG_IMP_LV0
285#undef VSF_RTC_CFG_IMP_REMAP_FUNCTIONS
286#undef VSF_RTC_CFG_IMP_HAS_OP
287#undef VSF_RTC_CFG_IMP_EXTERN_OP
290#undef vsf_imp_rtc_init
291#undef vsf_imp_rtc_enable
292#undef vsf_imp_rtc_disable
293#undef vsf_imp_rtc_capability
294#undef vsf_imp_rtc_get
295#undef vsf_imp_rtc_set
296#undef vsf_imp_rtc_get_time
297#undef vsf_imp_rtc_set_time
299#undef vsf_remap_rtc_t
300#undef vsf_remap_rtc_init
301#undef vsf_remap_rtc_enable
302#undef vsf_remap_rtc_disable
303#undef vsf_remap_rtc_capability
304#undef vsf_remap_rtc_get
305#undef vsf_remap_rtc_set
306#undef vsf_remap_rtc_get_time
307#undef vsf_remap_rtc_set_time
vsf_err_t
Definition __type.h:42
@ VSF_ERR_NONE
none error
Definition __type.h:44
@ VSF_ERR_FAIL
failed
Definition __type.h:51
#define VSF_RTC_CFG_CAPABILITY_IRQ_MASK
Definition rtc.c:148
__TIME_T time_t
Definition types.h:122
#define NULL
Definition lvgl.h:26
struct tm * gmtime(const time_t *t)
Definition vsf_linux_glibc_time.c:338
time_t mktime(struct tm *tm)
Definition vsf_linux_glibc_time.c:70
int tm_mon
Definition time.h:57
int tm_year
Definition time.h:58
int tm_hour
Definition time.h:55
int tm_sec
Definition time.h:53
int tm_mday
Definition time.h:56
int tm_min
Definition time.h:54
int tm_wday
Definition time.h:59
Definition vsf_template_rtc.h:143
Definition vsf_template_rtc.h:114
uint16_t tm_ms
Definition vsf_template_rtc.h:122
uint8_t tm_sec
Definition vsf_template_rtc.h:115
uint16_t tm_year
Definition vsf_template_rtc.h:121
uint8_t tm_mon
Definition vsf_template_rtc.h:120
uint8_t tm_wday
Definition vsf_template_rtc.h:119
uint8_t tm_mday
Definition vsf_template_rtc.h:118
uint8_t tm_hour
Definition vsf_template_rtc.h:117
uint8_t tm_min
Definition vsf_template_rtc.h:116
#define VSF_HAL_ASSERT(__CON)
all hal modules use this configuration file
Definition vsf_hal_cfg.h:36
VSF_RTC_CFG_TIME_TYPE vsf_rtc_time_t
Definition vsf_template_rtc.h:112