VSF Documented
timer.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/TIMER_IP}_TIMER_H__
19#define __HAL_DRIVER_${SERIES/TIMER_IP}_TIMER_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_TIMER == 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_${TIMER_IP}_TIMER_CLASS_IMPLEMENT)
40# define __VSF_CLASS_IMPLEMENT__
41#elif defined(__VSF_HAL_${TIMER_IP}_TIMER_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_${TIMER_IP}_TIMER_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
55 * while VSF_HW_TIMER_CFG_MULTI_CLASS should be in timer.c.
56 */
57
58// IPCore
59#ifndef VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS
60# define VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS VSF_TIMER_CFG_MULTI_CLASS
61#endif
62// IPCore end
63
64// HW
65/*\note hw TIMER driver can reimplement vsf_usart_mode_t/vsf_usart_irq_mask_t/vsf_usart_status_t.
66 * To enable reimplementation, please enable macro below:
67 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE for vsf_timer_mode_t
68 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_timer_irq_mask_t
69 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
70 * *** DO NOT reimplement these in emulated drivers. ***
71 */
72
73#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE ENABLED
74#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
75// HW end
76
77/*============================ MACROFIED FUNCTIONS ===========================*/
78/*============================ TYPES =========================================*/
79
80// IPCore
81vsf_class(vsf_${timer_ip}_timer_t) {
82#if VSF_${TIMER_IP}_CFG_MULTI_CLASS == ENABLED
83 public_member(
84 vsf_timer_t vsf_timer;
85 )
86#endif
87
88/*\note You can add more member in vsf_${timer_ip}_timer_t instance.
89 * For members accessible from child, put in protected_member.
90 * Else, put in private_member.
91 */
92
93 protected_member(
94 vsf_${timer_ip}_timer_reg_t *reg;
96 )
97};
98// IPCore end
99
100// HW/IPCore, not for emulated drivers
101typedef enum vsf_timer_mode_t {
104
105 VSF_TIMER_MODE_PWM = (0x01 << 1),
107
108 // more vendor specified modes can be added here
110
113
114 // more vendor specified irq_masks can be added here
116// HW/IPCore end
117
118/*============================ INCLUDES ======================================*/
119
120// IPCore
121/*\note Extern APIs for ip core diriver.
122 * There is no requirement about how APIs of IPCore drivers should be implemented.
123 * Just consider the simplicity for actual peripheral drivers.
124 */
125// IPCore end
126
127#ifdef __cplusplus
128}
129#endif
130
131// IPCore
132#undef __VSF_HAL_${TIMER_IP}_TIMER_CLASS_IMPLEMENT
133#undef __VSF_HAL_${TIMER_IP}_TIMER_CLASS_INHERIT__
134// IPCore end
135
136#endif // VSF_HAL_USE_TIMER
137#endif // __HAL_DRIVER_${SERIES/TIMER_IP}_TIMER_H__
138/* EOF */
Definition adc.h:68
vsf_timer_irq_mask_t
Definition timer.h:111
@ VSF_TIMER_IRQ_MASK_OVERFLOW
Definition timer.h:112
class vsf_$ * reg
vsf_timer_mode_t
Definition timer.h:101
@ VSF_TIMER_MODE_CONTINUES
Definition timer.h:103
@ VSF_TIMER_MODE_NO_PWM
Definition timer.h:106
@ VSF_TIMER_MODE_PWM
Definition timer.h:105
@ VSF_TIMER_MODE_ONESHOT
Definition timer.h:102
vsf_timer_isr_t isr
Definition timer.h:96
#define vsf_class(__name)
Definition ooc_class.h:48
Definition vsf_template_timer.h:140
Definition vsf_template_timer.h:184
vsf_timer_irq_mask_t
Definition vsf_template_timer.h:123
vsf_timer_mode_t
Definition vsf_template_timer.h:100