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#include "../../__device.h"
28
29/*\note Refer to template/README.md for usage cases.
30 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
31 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
32 * For emulated drivers, **** No reimplementation ****.
33 */
34
35/*\note Includes CAN ONLY be put here. */
36/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
37
38// IPCore
39#if defined(__VSF_HAL_${RTC_IP}_RTC_CLASS_IMPLEMENT)
40# define __VSF_CLASS_IMPLEMENT__
41#elif defined(__VSF_HAL_${RTC_IP}_RTC_CLASS_INHERIT__)
42# define __VSF_CLASS_INHERIT__
43#endif
44
45#include "utilities/ooc_class.h"
46// IPCore end
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/*============================ MACROS ========================================*/
53
54/*\note VSF_${RTC_IP}_RTC_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
55 * while VSF_HW_RTC_CFG_MULTI_CLASS should be in rtc.c.
56 */
57
58// IPCore
59#ifndef VSF_${RTC_IP}_RTC_CFG_MULTI_CLASS
60# define VSF_${RTC_IP}_RTC_CFG_MULTI_CLASS VSF_RTC_CFG_MULTI_CLASS
61#endif
62// IPCore end
63
64// HW
74#define VSF_RTC_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
75#define VSF_RTC_CFG_REIMPLEMENT_TYPE_CFG 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// HW/IPCore end
139
140/*============================ INCLUDES ======================================*/
141
142// IPCore
143/*\note Extern APIs for ip core diriver.
144 * There is no requirement about how APIs of IPCore drivers should be implemented.
145 * Just consider the simplicity for actual peripheral drivers.
146 */
147// IPCore end
148
149#ifdef __cplusplus
150}
151#endif
152
153// IPCore
154#undef __VSF_HAL_${RTC_IP}_RTC_CLASS_IMPLEMENT
155#undef __VSF_HAL_${RTC_IP}_RTC_CLASS_INHERIT__
156// IPCore end
157
158#endif // VSF_HAL_USE_RTC
159#endif // __HAL_DRIVER_${SERIES/RTC_IP}_RTC_H__
160/* EOF */
Definition adc.h:94
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:363
inherit(vsf_peripheral_capability_t) vsf_rtc_irq_mask_t irq_mask
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 instance structure, used for RTC Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_rtc.h:406
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_irq_mask_t
RTC interrupt mask definition. Used to identify and manage different types of RTC interrupts.
Definition vsf_template_rtc.h:186
Generated from commit: vsfteam/vsf@2b286be