VSF Documented
rtc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __HAL_DRIVER_${SERIES/RTC_IP}_RTC_H__
19#define __HAL_DRIVER_${SERIES/RTC_IP}_RTC_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_RTC == ENABLED
26
27/*\note Refer to template/README.md for usage cases.
28 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
29 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
30 * For emulated drivers, **** No reimplementation ****.
31 */
32
33/*\note Includes CAN ONLY be put here. */
34/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
35
36// IPCore
37#if defined(__VSF_HAL_${RTC_IP}_RTC_CLASS_IMPLEMENT)
38# define __VSF_CLASS_IMPLEMENT__
39#elif defined(__VSF_HAL_${RTC_IP}_RTC_CLASS_INHERIT__)
40# define __VSF_CLASS_INHERIT__
41#endif
42
43#include "utilities/ooc_class.h"
44// IPCore end
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/*============================ MACROS ========================================*/
51
52/*\note VSF_${RTC_IP}_RTC_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
53 * while VSF_HW_RTC_CFG_MULTI_CLASS should be in rtc.c.
54 */
55
56// IPCore
57#ifndef VSF_${RTC_IP}_RTC_CFG_MULTI_CLASS
58# define VSF_${RTC_IP}_RTC_CFG_MULTI_CLASS VSF_RTC_CFG_MULTI_CLASS
59#endif
60// IPCore end
61
62// HW
73#define VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
74#define VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG ENABLED
75#define VSF_RTC_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
76#define VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
77
81#define VSF_RTC_CFG_TIME_TYPE uint64_t
82// HW end
83
84/*============================ MACROFIED FUNCTIONS ===========================*/
85/*============================ TYPES =========================================*/
86
87// IPCore
88vsf_class(vsf_${rtc_ip}_rtc_t) {
89#if VSF_${RTC_IP}_CFG_MULTI_CLASS == ENABLED
90 public_member(
91 vsf_rtc_t vsf_rtc;
92 )
93#endif
94
95/*\note You can add more member in vsf_${rtc_ip}_rtc_t instance.
96 * For members accessible from child, put in protected_member.
97 * Else, put in private_member.
98 */
99
100 protected_member(
101 vsf_${rtc_ip}_rtc_reg_t *reg;
104};
105// IPCore end
106
107// HW/IPCore, not for emulated drivers
108#if VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
109typedef enum vsf_rtc_irq_mask_t {
111
112 // more vendor-specific irq mask
114#endif
115
116#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
117typedef struct vsf_rtc_t vsf_rtc_t;
118typedef void vsf_rtc_isr_handler_t(void *target_ptr, vsf_rtc_t *rtc_ptr, vsf_rtc_irq_mask_t irq_mask);
119typedef struct vsf_rtc_isr_t {
121 void *target_ptr;
124typedef struct vsf_rtc_cfg_t {
127#endif
128
129#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
130typedef struct vsf_rtc_capability_t {
131#if VSF_RTC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
133#endif
136#endif
137
138#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CTRL == ENABLED
139typedef enum vsf_rtc_ctrl_t {
142#endif
143
144// HW/IPCore end
145
146/*============================ INCLUDES ======================================*/
147
148// IPCore
149/*\note Extern APIs for ip core diriver.
150 * There is no requirement about how APIs of IPCore drivers should be implemented.
151 * Just consider the simplicity for actual peripheral drivers.
152 */
153// IPCore end
154
155#ifdef __cplusplus
156}
157#endif
158
159// IPCore
160#undef __VSF_HAL_${RTC_IP}_RTC_CLASS_IMPLEMENT
161#undef __VSF_HAL_${RTC_IP}_RTC_CLASS_INHERIT__
162// IPCore end
163
164#endif // VSF_HAL_USE_RTC
165#endif // __HAL_DRIVER_${SERIES/RTC_IP}_RTC_H__
166/* EOF */
Definition adc.h:98
vsf_arch_prio_t
Definition cortex_a_generic.h:88
#define vsf_class(__name)
Definition ooc_class.h:52
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
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
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 instance structure, used for RTC Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_rtc.h:453
vsf_rtc_ctrl_t
Definition rtc.h:139
@ __VSF_RTC_CTRL_DUMMY
Definition rtc.h:140
vsf_rtc_isr_t isr
Definition rtc.h:103
class vsf_$ * reg
vsf_rtc_irq_mask_t
Definition rtc.h:109
@ VSF_RTC_IRQ_MASK_ALARM
Definition rtc.h:110
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
vsf_rtc_ctrl_t
RTC control commands for hardware-specific operations.
Definition vsf_template_rtc.h:413
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
Generated from commit: vsfteam/vsf@ab3a251