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
72#define VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
73#define VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG ENABLED
74#define VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
75
79#define VSF_RTC_CFG_TIME_TYPE uint64_t
80// HW end
81
82/*============================ MACROFIED FUNCTIONS ===========================*/
83/*============================ TYPES =========================================*/
84
85// IPCore
86vsf_class(vsf_${rtc_ip}_rtc_t) {
87#if VSF_${RTC_IP}_CFG_MULTI_CLASS == ENABLED
88 public_member(
89 vsf_rtc_t vsf_rtc;
90 )
91#endif
92
93/*\note You can add more member in vsf_${rtc_ip}_rtc_t instance.
94 * For members accessible from child, put in protected_member.
95 * Else, put in private_member.
96 */
97
98 protected_member(
99 vsf_${rtc_ip}_rtc_reg_t *reg;
102};
103// IPCore end
104
105// HW/IPCore, not for emulated drivers
106#if VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
107typedef enum vsf_rtc_irq_mask_t {
109
110 // more vendor-specific irq mask
112#endif
113
114#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
115typedef struct vsf_rtc_t vsf_rtc_t;
116typedef void vsf_rtc_isr_handler_t(void *target_ptr, vsf_rtc_t *rtc_ptr, vsf_rtc_irq_mask_t irq_mask);
117typedef struct vsf_rtc_isr_t {
119 void *target_ptr;
122typedef struct vsf_rtc_cfg_t {
125#endif
126
127#if VSF_RTC_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
128typedef struct vsf_rtc_capability_t {
129#if VSF_RTC_CFG_INHERIT_HAL_CAPABILITY == ENABLED
131#endif
134#endif
135
136// HW/IPCore end
137
138/*============================ INCLUDES ======================================*/
139
140// IPCore
141/*\note Extern APIs for ip core diriver.
142 * There is no requirement about how APIs of IPCore drivers should be implemented.
143 * Just consider the simplicity for actual peripheral drivers.
144 */
145// IPCore end
146
147#ifdef __cplusplus
148}
149#endif
150
151// IPCore
152#undef __VSF_HAL_${RTC_IP}_RTC_CLASS_IMPLEMENT
153#undef __VSF_HAL_${RTC_IP}_RTC_CLASS_INHERIT__
154// IPCore end
155
156#endif // VSF_HAL_USE_RTC
157#endif // __HAL_DRIVER_${SERIES/RTC_IP}_RTC_H__
158/* EOF */
Definition adc.h:92
vsf_arch_prio_t
Definition cortex_a_generic.h:88
#define vsf_class(__name)
Definition ooc_class.h:48
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
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:364
inherit(vsf_peripheral_capability_t) vsf_rtc_irq_mask_t irq_mask
RTC configuration structure.
Definition vsf_template_rtc.h:350
vsf_rtc_isr_t isr
Interrupt service routine configuration.
Definition vsf_template_rtc.h:351
RTC interrupt service routine configuration structure.
Definition vsf_template_rtc.h:338
vsf_arch_prio_t prio
Priority level for RTC interrupts.
Definition vsf_template_rtc.h:341
void * target_ptr
User context pointer passed to the handler.
Definition vsf_template_rtc.h:340
vsf_rtc_isr_handler_t * handler_fn
Interrupt handler function to process RTC interrupts.
Definition vsf_template_rtc.h:339
RTC instance structure, used for RTC Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_rtc.h:407
vsf_rtc_isr_t isr
Definition rtc.h:101
class vsf_$ * reg
vsf_rtc_irq_mask_t
Definition rtc.h:107
@ VSF_RTC_IRQ_MASK_ALARM
Definition rtc.h:108
void vsf_rtc_isr_handler_t(void *target_ptr, vsf_rtc_t *rtc_ptr, vsf_rtc_irq_mask_t irq_mask)
Definition rtc.h:116
vsf_rtc_irq_mask_t
RTC interrupt mask definition. Used to identify and manage different types of RTC interrupts.
Definition vsf_template_rtc.h:187
Generated from commit: vsfteam/vsf@74aa6ce