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// HW/IPCore
32// HW/IPCore end
33
34#include "../../__device.h"
35
36/*\note Refer to template/README.md for usage cases.
37 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
38 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
39 * For emulated drivers, **** No reimplementation ****.
40 */
41
42/*\note Includes CAN ONLY be put here. */
43/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
44
45// IPCore
46#if defined(__VSF_HAL_${TIMER_IP}_TIMER_CLASS_IMPLEMENT)
47# define __VSF_CLASS_IMPLEMENT__
48#elif defined(__VSF_HAL_${TIMER_IP}_TIMER_CLASS_INHERIT__)
49# define __VSF_CLASS_INHERIT__
50#endif
51
52#include "utilities/ooc_class.h"
53// IPCore end
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59/*============================ MACROS ========================================*/
60
61/*\note VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
62 * while VSF_HW_TIMER_CFG_MULTI_CLASS should be in timer.c.
63 */
64
65// IPCore
66#ifndef VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS
67# define VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS VSF_TIMER_CFG_MULTI_CLASS
68#endif
69// IPCore end
70
71// HW
72/*\note hw TIMER driver can reimplement following types:
73 * To enable reimplementation, please enable macro below:
74 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE for vsf_timer_channel_mode_t
75 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_timer_irq_mask_t
76 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_STATUS for vsf_timer_status_t
77 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG for vsf_timer_cfg_t
78 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CTRL for vsf_timer_ctrl_t
79 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG for vsf_timer_channel_cfg_t
80 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CTRL for vsf_timer_channel_ctrl_t
81 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_REQUEST for vsf_timer_channel_request_t
82 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_timer_capability_t
83 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
84 * *** DO NOT reimplement these in emulated drivers. ***
85 */
86
87#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE ENABLED
88#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
89#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
90#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG ENABLED
91#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG ENABLED
92#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
93#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG ENABLED
94#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CTRL ENABLED
95#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_REQUEST ENABLED
96#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
97// HW end
98
99/*============================ MACROFIED FUNCTIONS ===========================*/
100/*============================ TYPES =========================================*/
101
102// IPCore
103vsf_class(vsf_${timer_ip}_timer_t) {
104#if VSF_${TIMER_IP}_CFG_MULTI_CLASS == ENABLED
105 public_member(
106 vsf_timer_t vsf_timer;
107 )
108#endif
109
110/*\note You can add more member in vsf_${timer_ip}_timer_t instance.
111 * For members accessible from child, put in protected_member.
112 * Else, put in private_member.
113 */
114
115 protected_member(
116 vsf_${timer_ip}_timer_reg_t *reg;
119};
120// IPCore end
121
122// HW/IPCore, not for emulated drivers
123#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE == ENABLED
128
129 // more vendor specified modes can be added here
131#endif
132
133#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
136
137 // more vendor specified irq_masks can be added here
139#endif
140
141#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
142typedef enum vsf_timer_ctrl_t {
144
145 // more vendor specified ctrl can be added here
147#endif
148
149#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CTRL == ENABLED
152
153 // more vendor specified channel ctrl can be added here
155#endif
156
160#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
162typedef void vsf_timer_isr_handler_t(void *target_ptr,
163 vsf_timer_t *timer_ptr,
165
166typedef struct vsf_timer_isr_t {
168 void *target_ptr;
171typedef struct vsf_timer_cfg_t {
173 union {
176 };
179#endif
180
184#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == ENABLED
185typedef struct vsf_timer_channel_cfg_t {
188
189 // more vendor specified channel cfg can be added here
191#endif
192
196#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_REQUEST == ENABLED
197typedef struct vsf_timer_channel_request_t {
199 union {
203 struct {
206 };
207 };
208
209 // more vendor specified channel request can be added here
211#endif
212
216#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
217typedef struct vsf_timer_status_t {
218 union {
219 struct {
221 };
223 };
224
225 // more vendor specified status can be added here
227#endif
228
232#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
233typedef struct vsf_timer_capability_t {
241
242 // more vendor specified capability can be added here
244#endif
245// HW/IPCore end
246
247/*============================ INCLUDES ======================================*/
248
249// IPCore
250/*\note Extern APIs for ip core diriver.
251 * There is no requirement about how APIs of IPCore drivers should be implemented.
252 * Just consider the simplicity for actual peripheral drivers.
253 */
254// IPCore end
255
256#ifdef __cplusplus
257}
258#endif
259
260// IPCore
261#undef __VSF_HAL_${TIMER_IP}_TIMER_CLASS_IMPLEMENT
262#undef __VSF_HAL_${TIMER_IP}_TIMER_CLASS_INHERIT__
263// IPCore end
264
265#endif // VSF_HAL_USE_TIMER
266#endif // __HAL_DRIVER_${SERIES/TIMER_IP}_TIMER_H__
267/* EOF */
Definition adc.h:94
vsf_arch_prio_t
Definition cortex_a_generic.h:88
vsf_timer_irq_mask_t
Definition timer.h:134
@ VSF_TIMER_IRQ_MASK_OVERFLOW
Definition timer.h:135
vsf_timer_channel_mode_t
Definition timer.h:124
@ VSF_TIMER_CHANNEL_MODE_BASE
Definition timer.h:125
@ VSF_TIMER_BASE_ONESHOT
Definition timer.h:126
@ VSF_TIMER_BASE_CONTINUES
Definition timer.h:127
class vsf_$ * reg
vsf_timer_ctrl_t
Definition timer.h:142
@ __VSF_TIMER_CTRL_DUMMY
Definition timer.h:143
void vsf_timer_isr_handler_t(void *target_ptr, vsf_timer_t *timer_ptr, vsf_timer_irq_mask_t irq_mask)
Definition timer.h:162
vsf_timer_channel_ctrl_t
Definition timer.h:150
@ __VSF_TIMER_CHANNEL_CTRL_DUMMY
Definition timer.h:151
vsf_timer_isr_t isr
Definition timer.h:118
#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
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_timer.h:598
uint8_t support_output_compare
Definition vsf_template_timer.h:613
uint8_t timer_bitlen
Definition vsf_template_timer.h:606
vsf_timer_irq_mask_t irq_mask
Definition timer.h:234
uint8_t support_one_pulse
Definition vsf_template_timer.h:615
uint8_t channel_cnt
Definition vsf_template_timer.h:608
uint8_t support_input_capture
Definition vsf_template_timer.h:614
uint8_t support_pwm
Definition vsf_template_timer.h:612
timer configuration
Definition vsf_template_timer.h:498
uint32_t freq
Definition vsf_template_timer.h:501
uint32_t min_freq
Definition vsf_template_timer.h:502
uint32_t period
Period in Tick.
Definition vsf_template_timer.h:499
vsf_timer_isr_t isr
ISR config.
Definition vsf_template_timer.h:504
Definition vsf_template_timer.h:509
vsf_timer_channel_mode_t mode
Definition vsf_template_timer.h:510
uint32_t pulse
Definition vsf_template_timer.h:511
Definition vsf_template_timer.h:561
uint16_t length
Definition vsf_template_timer.h:562
uint32_t * pulse_buffer
Definition vsf_template_timer.h:567
uint32_t * channel_a_buffer
Definition vsf_template_timer.h:572
uint32_t * input_capture_buffer
Definition vsf_template_timer.h:569
uint32_t * channel_b_buffer
Definition vsf_template_timer.h:573
uint32_t * period_buffer
Definition vsf_template_timer.h:565
Definition vsf_template_timer.h:484
vsf_arch_prio_t prio
Definition vsf_template_timer.h:487
vsf_timer_isr_handler_t * handler_fn
Definition vsf_template_timer.h:485
void * target_ptr
Definition vsf_template_timer.h:486
TIMER status information structure Contains the current status of TIMER operations.
Definition vsf_template_timer.h:588
uint32_t value
Definition timer.h:222
uint32_t is_busy
Definition timer.h:220
Definition vsf_template_timer.h:629
vsf_timer_irq_mask_t
Definition vsf_template_timer.h:448
vsf_timer_channel_mode_t
Definition vsf_template_timer.h:237
vsf_timer_ctrl_t
Predefined VSF TIMER control command that can be reimplemented in specific hal drivers....
Definition vsf_template_timer.h:533
vsf_timer_channel_ctrl_t
Predefined VSF TIMER control command that can be reimplemented in specific hal drivers....
Definition vsf_template_timer.h:555
Generated from commit: vsfteam/vsf@2b286be