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
162#ifndef VSF_RTC_CFG_REIMPLEMENT_TYPE_CTRL
163# define VSF_RTC_CFG_REIMPLEMENT_TYPE_CTRL DISABLED
178#define VSF_RTC_APIS(__prefix_name) \
179 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, init, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr, vsf_rtc_cfg_t *cfg_ptr) \
180 __VSF_HAL_TEMPLATE_API(__prefix_name, void, rtc, fini, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr) \
181 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, get_configuration, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr, vsf_rtc_cfg_t *cfg_ptr) \
182 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, rtc, enable, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr) \
183 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, rtc, disable, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr) \
184 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_rtc_capability_t, rtc, capability, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr) \
185 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, get, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr, vsf_rtc_tm_t *rtc_tm) \
186 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, set, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr, const vsf_rtc_tm_t *rtc_tm) \
187 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, get_time, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr, vsf_rtc_time_t *second_ptr, vsf_rtc_time_t *millisecond_ptr) \
188 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, set_time, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr, vsf_rtc_time_t seconds, vsf_rtc_time_t milliseconds) \
189 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, rtc, ctrl, VSF_MCONNECT(__prefix_name, _t) *rtc_ptr, vsf_rtc_ctrl_t ctrl, void* param)
193#if VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
224#ifndef VSF_RTC_IRQ_ALL_BITS_MASK
330#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
378#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
380#if VSF_RTC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
404#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CTRL == DISABLED
441#undef __VSF_HAL_TEMPLATE_API
442#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
448#if VSF_RTC_CFG_MULTI_CLASS == ENABLED
640#if VSF_RTC_CFG_FUNCTION_RENAME == ENABLED
641# define __vsf_rtc_t VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_t)
642# define vsf_rtc_init(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_init) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
643# define vsf_rtc_get_configuration(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_get_configuration) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
644# define vsf_rtc_enable(__RTC) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_enable) ((__vsf_rtc_t *)(__RTC))
645# define vsf_rtc_disable(__RTC) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_disable) ((__vsf_rtc_t *)(__RTC))
646# define vsf_rtc_capability(__RTC) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_capability) ((__vsf_rtc_t *)(__RTC))
647# define vsf_rtc_get(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_get) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
648# define vsf_rtc_set(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_set) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
649# define vsf_rtc_get_time(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_get_time) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
650# define vsf_rtc_set_time(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_set_time) ((__vsf_rtc_t *)(__RTC), ##__VA_ARGS__)
651# define vsf_rtc_ctrl(__RTC, ...) VSF_MCONNECT(VSF_RTC_CFG_PREFIX, _rtc_ctrl) ((__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:204
RTC capability structure. Describes the features and capabilities supported by the RTC hardware.
Definition vsf_template_rtc.h:379
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:365
vsf_rtc_isr_t isr
Interrupt service routine configuration.
Definition vsf_template_rtc.h:366
RTC interrupt service routine configuration structure.
Definition vsf_template_rtc.h:353
vsf_arch_prio_t prio
Priority level for RTC interrupts.
Definition vsf_template_rtc.h:356
void * target_ptr
User context pointer passed to the handler.
Definition vsf_template_rtc.h:355
vsf_rtc_isr_handler_t * handler_fn
Interrupt handler function to process RTC interrupts.
Definition vsf_template_rtc.h:354
RTC operation function pointer type, used for RTC Multi Class support.
Definition vsf_template_rtc.h:439
RTC instance structure, used for RTC Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_rtc.h:453
const vsf_rtc_op_t * op
Definition vsf_template_rtc.h:456
Time structure for RTC operations. Used to represent date and time information in a standardized form...
Definition vsf_template_rtc.h:255
uint16_t tm_ms
Milliseconds component of time [0-999]. Provides sub-second precision.
Definition vsf_template_rtc.h:326
uint8_t tm_sec
Seconds component of time [0-59].
Definition vsf_template_rtc.h:262
uint16_t tm_year
Year value [0-65535].
Definition vsf_template_rtc.h:316
uint8_t tm_mon
Month [1-12]. January=1, February=2, ..., December=12.
Definition vsf_template_rtc.h:308
uint8_t tm_wday
Day of week [1-7]. Sunday=1, Monday=2, ..., Saturday=7.
Definition vsf_template_rtc.h:298
uint8_t tm_mday
Day of month [1-31].
Definition vsf_template_rtc.h:288
uint8_t tm_hour
Hours component of time [0-23]. Uses 24-hour format.
Definition vsf_template_rtc.h:280
uint8_t tm_min
Minutes component of time [0-59].
Definition vsf_template_rtc.h:270
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:233
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
vsf_rtc_ctrl_t
RTC control commands for hardware-specific operations.
Definition vsf_template_rtc.h:413
@ __VSF_RTC_CTRL_DUMMY
Dummy value for compilation, required when no actual control commands are defined.
Definition vsf_template_rtc.h:431
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:178
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:245
vsf_rtc_irq_mask_t
RTC interrupt mask definition. Used to identify and manage different types of RTC interrupts.
Definition vsf_template_rtc.h:202
@ VSF_RTC_IRQ_MASK_ALARM
Alarm interrupt mask. Triggers when the RTC time matches the configured alarm time.
Definition vsf_template_rtc.h:211
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:345
vsf_err_t vsf_rtc_get_configuration(vsf_rtc_t *rtc_ptr, vsf_rtc_cfg_t *cfg_ptr)
Get the current configuration of an RTC instance.
Definition rtc_common.c:120
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
vsf_err_t vsf_rtc_ctrl(vsf_rtc_t *rtc_ptr, vsf_rtc_ctrl_t ctrl, void *param)
Calls the specified RTC command.
Definition rtc_common.c:130
struct vsf_rtc_isr_t vsf_rtc_isr_t
RTC interrupt service routine configuration structure.