18#ifndef __VSF_TEMPLATE_RTC_H__
19#define __VSF_TEMPLATE_RTC_H__
38#ifndef VSF_RTC_CFG_MULTI_CLASS
39# define VSF_RTC_CFG_MULTI_CLASS ENABLED
52#if defined(VSF_HW_RTC_COUNT) && !defined(VSF_HW_RTC_MASK)
53# define VSF_HW_RTC_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_RTC_COUNT)
62#if defined(VSF_HW_RTC_MASK) && !defined(VSF_HW_RTC_COUNT)
63# define VSF_HW_RTC_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_RTC_MASK)
74#ifndef VSF_RTC_CFG_PREFIX
75# if VSF_RTC_CFG_MULTI_CLASS == ENABLED
76# define VSF_RTC_CFG_PREFIX vsf
77# elif defined(VSF_HW_RTC_COUNT) && (VSF_HW_RTC_COUNT != 0)
78# define VSF_RTC_CFG_PREFIX vsf_hw
80# define VSF_RTC_CFG_PREFIX vsf
92#ifndef VSF_RTC_CFG_FUNCTION_RENAME
93# define VSF_RTC_CFG_FUNCTION_RENAME ENABLED
104#ifndef VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK
105# define VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
114#ifndef VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG
115# define VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG DISABLED
124#ifndef VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY
125# define VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
136#ifndef VSF_RTC_CFG_TIME_TYPE
137# define VSF_RTC_CFG_TIME_TYPE uint64_t
148#ifndef VSF_RTC_CFG_INHERIT_HAL_CAPABILITY
149# define VSF_RTC_CFG_INHERIT_HAL_CAPABILITY ENABLED
164#define VSF_RTC_APIS(__prefix_name) \
165 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, init, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr, vsf_rtc_cfg_t *cfg_ptr) \
166 __VSF_HAL_TEMPLATE_API(__prefix_name, void, rtc, fini, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr) \
167 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, rtc, enable, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr) \
168 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, rtc, disable, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr) \
169 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_rtc_capability_t, rtc, capability, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr) \
170 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, get, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr, vsf_rtc_tm_t *rtc_tm) \
171 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, set, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr, const vsf_rtc_tm_t *rtc_tm) \
172 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, get_time, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr, vsf_rtc_time_t *second_ptr, vsf_rtc_time_t *millisecond_ptr) \
173 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, set_time, VSF_MCONNECT(__prefix_name, _rtc_t) *rtc_ptr, vsf_rtc_time_t seconds, vsf_rtc_time_t milliseconds)
177#if VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
208#ifndef VSF_RTC_IRQ_ALL_BITS_MASK
314#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
362#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
364#if VSF_RTC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
394#undef __VSF_HAL_TEMPLATE_API
395#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
401#if VSF_RTC_CFG_MULTI_CLASS == ENABLED
555#if VSF_RTC_CFG_FUNCTION_RENAME == ENABLED
556# define __vsf_rtc_t VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_t)
557# define vsf_rtc_init(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_init) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
558# define vsf_rtc_enable(__RTC) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_enable) ((__vsf_rtc_t *)(__RTC))
559# define vsf_rtc_disable(__RTC) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_disable) ((__vsf_rtc_t *)(__RTC))
560# define vsf_rtc_capability(__RTC) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_capability) ((__vsf_rtc_t *)(__RTC))
561# define vsf_rtc_get(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_get) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
562# define vsf_rtc_set(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_set) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
563# define vsf_rtc_get_time(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_get_time) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
564# define vsf_rtc_set_time(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_set_time) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
vsf_err_t
Definition __type.h:42
vsf_arch_prio_t
Definition cortex_a_generic.h:88
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_hal_driver.h:203
RTC capability structure. Describes the features and capabilities supported by the RTC hardware.
Definition vsf_template_rtc.h:363
inherit(vsf_peripheral_capability_t) vsf_rtc_irq_mask_t irq_mask
Inherit common peripheral capabilities. Must be the first member of the structure.
RTC configuration structure.
Definition vsf_template_rtc.h:349
vsf_rtc_isr_t isr
Interrupt service routine configuration.
Definition vsf_template_rtc.h:350
RTC interrupt service routine configuration structure.
Definition vsf_template_rtc.h:337
vsf_arch_prio_t prio
Priority level for RTC interrupts.
Definition vsf_template_rtc.h:340
void * target_ptr
User context pointer passed to the handler.
Definition vsf_template_rtc.h:339
vsf_rtc_isr_handler_t * handler_fn
Interrupt handler function to process RTC interrupts.
Definition vsf_template_rtc.h:338
RTC operation function pointer type, used for RTC Multi Class support.
Definition vsf_template_rtc.h:392
RTC instance structure, used for RTC Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_rtc.h:406
const vsf_rtc_op_t * op
Definition vsf_template_rtc.h:409
Time structure for RTC operations. Used to represent date and time information in a standardized form...
Definition vsf_template_rtc.h:239
uint16_t tm_ms
Milliseconds component of time [0-999]. Provides sub-second precision.
Definition vsf_template_rtc.h:310
uint8_t tm_sec
Seconds component of time [0-59].
Definition vsf_template_rtc.h:246
uint16_t tm_year
Year value [0-65535].
Definition vsf_template_rtc.h:300
uint8_t tm_mon
Month [1-12]. January=1, February=2, ..., December=12.
Definition vsf_template_rtc.h:292
uint8_t tm_wday
Day of week [1-7]. Sunday=1, Monday=2, ..., Saturday=7.
Definition vsf_template_rtc.h:282
uint8_t tm_mday
Day of month [1-31].
Definition vsf_template_rtc.h:272
uint8_t tm_hour
Hours component of time [0-23]. Uses 24-hour format.
Definition vsf_template_rtc.h:264
uint8_t tm_min
Minutes component of time [0-59].
Definition vsf_template_rtc.h:254
vsf_rtc_irq_mask_t
Definition rtc.h:109
void vsf_rtc_isr_handler_t(void *target_ptr, vsf_rtc_t *rtc_ptr, vsf_rtc_irq_mask_t irq_mask)
Definition rtc.h:118
fsm_rt_t
Definition vsf_fsm.h:315
@ VSF_RTC_IRQ_ALL_BITS_MASK
All supported RTC interrupt masks combined. Includes all interrupt types the RTC hardware supports.
Definition vsf_template_rtc.h:217
vsf_err_t vsf_rtc_init(vsf_rtc_t *rtc_ptr, vsf_rtc_cfg_t *cfg_ptr)
Initialize a RTC instance.
Definition rtc_common.c:39
#define VSF_RTC_CFG_TIME_TYPE
Configure the data type used for time representation.
Definition vsf_template_rtc.h:137
vsf_err_t vsf_rtc_get(vsf_rtc_t *rtc_ptr, vsf_rtc_tm_t *rtc_tm)
Get RTC date and time.
Definition rtc_common.c:75
struct vsf_rtc_cfg_t vsf_rtc_cfg_t
RTC configuration structure.
fsm_rt_t vsf_rtc_enable(vsf_rtc_t *rtc_ptr)
Enable a RTC instance.
Definition rtc_common.c:57
#define VSF_RTC_APIS(__prefix_name)
RTC API template macro, used to generate RTC type, specific prefix function declarations,...
Definition vsf_template_rtc.h:164
vsf_err_t vsf_rtc_set(vsf_rtc_t *rtc_ptr, const vsf_rtc_tm_t *rtc_tm)
Set RTC date and time.
Definition rtc_common.c:84
void vsf_rtc_fini(vsf_rtc_t *rtc_ptr)
Finalize a RTC instance.
Definition rtc_common.c:48
fsm_rt_t vsf_rtc_disable(vsf_rtc_t *rtc_ptr)
Disable a RTC instance.
Definition rtc_common.c:66
vsf_rtc_capability_t vsf_rtc_capability(vsf_rtc_t *rtc_ptr)
Get the capability of RTC instance.
Definition rtc_common.c:111
vsf_err_t vsf_rtc_get_time(vsf_rtc_t *rtc_ptr, vsf_rtc_time_t *second_ptr, vsf_rtc_time_t *millisecond_ptr)
Get RTC time in seconds and milliseconds.
Definition rtc_common.c:93
VSF_RTC_CFG_TIME_TYPE vsf_rtc_time_t
RTC time type definition.
Definition vsf_template_rtc.h:229
vsf_rtc_irq_mask_t
RTC interrupt mask definition. Used to identify and manage different types of RTC interrupts.
Definition vsf_template_rtc.h:186
@ VSF_RTC_IRQ_MASK_ALARM
Alarm interrupt mask. Triggers when the RTC time matches the configured alarm time.
Definition vsf_template_rtc.h:195
void vsf_rtc_isr_handler_t(void *target_ptr, vsf_rtc_t *rtc_ptr, vsf_rtc_irq_mask_t irq_mask)
RTC interrupt handler function type.
Definition vsf_template_rtc.h:329
struct vsf_rtc_capability_t vsf_rtc_capability_t
RTC capability structure. Describes the features and capabilities supported by the RTC hardware.
vsf_err_t vsf_rtc_set_time(vsf_rtc_t *rtc_ptr, vsf_rtc_time_t seconds, vsf_rtc_time_t milliseconds)
Set RTC time in seconds and milliseconds.
Definition rtc_common.c:102
struct vsf_rtc_isr_t vsf_rtc_isr_t
RTC interrupt service routine configuration structure.