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/*\note Refer to template/README.md for usage cases.
35 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
36 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
37 * For emulated drivers, **** No reimplementation ****.
38 */
39
40/*\note Includes CAN ONLY be put here. */
41/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
42
43// IPCore
44#if defined(__VSF_HAL_${TIMER_IP}_TIMER_CLASS_IMPLEMENT)
45# define __VSF_CLASS_IMPLEMENT__
46#elif defined(__VSF_HAL_${TIMER_IP}_TIMER_CLASS_INHERIT__)
47# define __VSF_CLASS_INHERIT__
48#endif
49
50#include "utilities/ooc_class.h"
51// IPCore end
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57/*============================ MACROS ========================================*/
58
59/*\note VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
60 * while VSF_HW_TIMER_CFG_MULTI_CLASS should be in timer.c.
61 */
62
63// IPCore
64#ifndef VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS
65# define VSF_${TIMER_IP}_TIMER_CFG_MULTI_CLASS VSF_TIMER_CFG_MULTI_CLASS
66#endif
67// IPCore end
68
69// HW
70/*\note hw TIMER driver can reimplement following types:
71 * To enable reimplementation, please enable macro below:
72 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE for vsf_timer_channel_mode_t
73 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_timer_irq_mask_t
74 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_STATUS for vsf_timer_status_t
75 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG for vsf_timer_cfg_t
76 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CTRL for vsf_timer_ctrl_t
77 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG for vsf_timer_channel_cfg_t
78 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CTRL for vsf_timer_channel_ctrl_t
79 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_REQUEST for vsf_timer_channel_request_t
80 * VSF_TIMER_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_timer_capability_t
81 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
82 * *** DO NOT reimplement these in emulated drivers. ***
83 */
84
85#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE ENABLED
86#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
87#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
88#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG ENABLED
89#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG ENABLED
90#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
91#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG ENABLED
92#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CTRL ENABLED
93#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_REQUEST ENABLED
94#define VSF_TIMER_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
95// HW end
96
97/*============================ MACROFIED FUNCTIONS ===========================*/
98/*============================ TYPES =========================================*/
99
100// IPCore
101vsf_class(vsf_${timer_ip}_timer_t) {
102#if VSF_${TIMER_IP}_CFG_MULTI_CLASS == ENABLED
103 public_member(
104 vsf_timer_t vsf_timer;
105 )
106#endif
107
108/*\note You can add more member in vsf_${timer_ip}_timer_t instance.
109 * For members accessible from child, put in protected_member.
110 * Else, put in private_member.
111 */
112
113 protected_member(
114 vsf_${timer_ip}_timer_reg_t *reg;
117};
118// IPCore end
119
120// HW/IPCore, not for emulated drivers
121#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_MODE == ENABLED
126
127 // more vendor specified modes can be added here
129#endif
130
131#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
134
135 // more vendor specified irq_masks can be added here
137#endif
138
139#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
140typedef enum vsf_timer_ctrl_t {
142
143 // more vendor specified ctrl can be added here
145#endif
146
147#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CTRL == ENABLED
150
151 // more vendor specified channel ctrl can be added here
153#endif
154
158#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
160typedef void vsf_timer_isr_handler_t(void *target_ptr,
161 vsf_timer_t *timer_ptr,
163
164typedef struct vsf_timer_isr_t {
166 void *target_ptr;
169typedef struct vsf_timer_cfg_t {
171 union {
174 };
177#endif
178
182#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_CFG == ENABLED
183typedef struct vsf_timer_channel_cfg_t {
186
187 // more vendor specified channel cfg can be added here
189#endif
190
194#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CHANNEL_REQUEST == ENABLED
195typedef struct vsf_timer_channel_request_t {
197 union {
201 struct {
204 };
205 };
206
207 // more vendor specified channel request can be added here
209#endif
210
214#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
215typedef struct vsf_timer_status_t {
216 union {
217 struct {
219 };
221 };
222
223 // more vendor specified status can be added here
225#endif
226
230#if VSF_TIMER_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
231typedef struct vsf_timer_capability_t {
239
240 // more vendor specified capability can be added here
242#endif
243// HW/IPCore end
244
245/*============================ INCLUDES ======================================*/
246
247// IPCore
248/*\note Extern APIs for ip core diriver.
249 * There is no requirement about how APIs of IPCore drivers should be implemented.
250 * Just consider the simplicity for actual peripheral drivers.
251 */
252// IPCore end
253
254#ifdef __cplusplus
255}
256#endif
257
258// IPCore
259#undef __VSF_HAL_${TIMER_IP}_TIMER_CLASS_IMPLEMENT
260#undef __VSF_HAL_${TIMER_IP}_TIMER_CLASS_INHERIT__
261// IPCore end
262
263#endif // VSF_HAL_USE_TIMER
264#endif // __HAL_DRIVER_${SERIES/TIMER_IP}_TIMER_H__
265/* EOF */
Definition adc.h:92
vsf_arch_prio_t
Definition cortex_a_generic.h:88
vsf_timer_irq_mask_t
Definition timer.h:132
@ VSF_TIMER_IRQ_MASK_OVERFLOW
Definition timer.h:133
vsf_timer_channel_mode_t
Definition timer.h:122
@ VSF_TIMER_CHANNEL_MODE_BASE
Definition timer.h:123
@ VSF_TIMER_BASE_ONESHOT
Definition timer.h:124
@ VSF_TIMER_BASE_CONTINUES
Definition timer.h:125
class vsf_$ * reg
vsf_timer_ctrl_t
Definition timer.h:140
@ __VSF_TIMER_CTRL_DUMMY
Definition timer.h:141
void vsf_timer_isr_handler_t(void *target_ptr, vsf_timer_t *timer_ptr, vsf_timer_irq_mask_t irq_mask)
Definition timer.h:160
vsf_timer_channel_ctrl_t
Definition timer.h:148
@ __VSF_TIMER_CHANNEL_CTRL_DUMMY
Definition timer.h:149
vsf_timer_isr_t isr
Definition timer.h:116
#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:599
uint8_t support_output_compare
Definition vsf_template_timer.h:614
uint8_t timer_bitlen
Definition vsf_template_timer.h:607
vsf_timer_irq_mask_t irq_mask
Definition timer.h:232
uint8_t support_one_pulse
Definition vsf_template_timer.h:616
uint8_t channel_cnt
Definition vsf_template_timer.h:609
uint8_t support_input_capture
Definition vsf_template_timer.h:615
uint8_t support_pwm
Definition vsf_template_timer.h:613
timer configuration
Definition vsf_template_timer.h:499
uint32_t freq
Definition vsf_template_timer.h:502
uint32_t min_freq
Definition vsf_template_timer.h:503
uint32_t period
Period in Tick.
Definition vsf_template_timer.h:500
vsf_timer_isr_t isr
ISR config.
Definition vsf_template_timer.h:505
Definition vsf_template_timer.h:510
vsf_timer_channel_mode_t mode
Definition vsf_template_timer.h:511
uint32_t pulse
Definition vsf_template_timer.h:512
Definition vsf_template_timer.h:562
uint16_t length
Definition vsf_template_timer.h:563
uint32_t * pulse_buffer
Definition vsf_template_timer.h:568
uint32_t * channel_a_buffer
Definition vsf_template_timer.h:573
uint32_t * input_capture_buffer
Definition vsf_template_timer.h:570
uint32_t * channel_b_buffer
Definition vsf_template_timer.h:574
uint32_t * period_buffer
Definition vsf_template_timer.h:566
Definition vsf_template_timer.h:485
vsf_arch_prio_t prio
Definition vsf_template_timer.h:488
vsf_timer_isr_handler_t * handler_fn
Definition vsf_template_timer.h:486
void * target_ptr
Definition vsf_template_timer.h:487
TIMER status information structure Contains the current status of TIMER operations.
Definition vsf_template_timer.h:589
uint32_t value
Definition timer.h:220
uint32_t is_busy
Definition timer.h:218
Definition vsf_template_timer.h:630
vsf_timer_irq_mask_t
Definition vsf_template_timer.h:449
vsf_timer_channel_mode_t
Definition vsf_template_timer.h:238
vsf_timer_ctrl_t
Predefined VSF TIMER control command that can be reimplemented in specific hal drivers....
Definition vsf_template_timer.h:534
vsf_timer_channel_ctrl_t
Predefined VSF TIMER control command that can be reimplemented in specific hal drivers....
Definition vsf_template_timer.h:556
Generated from commit: vsfteam/vsf@74aa6ce