VSF Documented
pwm.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/PWM_IP}_PWM_H__
19#define __HAL_DRIVER_${SERIES/PWM_IP}_PWM_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_PWM == 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_${PWM_IP}_PWM_CLASS_IMPLEMENT)
45# define __VSF_CLASS_IMPLEMENT__
46#elif defined(__VSF_HAL_${PWM_IP}_PWM_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_${PWM_IP}_PWM_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
60 * while VSF_HW_PWM_CFG_MULTI_CLASS should be in pwm.c.
61 */
62
63// IPCore
64#ifndef VSF_${PWM_IP}_PWM_CFG_MULTI_CLASS
65# define VSF_${PWM_IP}_PWM_CFG_MULTI_CLASS VSF_PWM_CFG_MULTI_CLASS
66#endif
67// IPCore end
68
69// HW
70/*\note hw PWM driver can reimplement following types:
71 * To enable reimplementation, please enable macro below:
72 * VSF_PWM_CFG_REIMPLEMENT_TYPE_CFG for vsf_pwm_cfg_t
73 * VSF_PWM_CFG_REIMPLEMENT_TYPE_CTRL for vsf_pwm_ctrl_t
74 * VSF_PWM_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_pwm_capability_t
75 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
76 * *** DO NOT reimplement these in emulated drivers. ***
77 */
78
79#define VSF_PWM_CFG_REIMPLEMENT_TYPE_CFG ENABLED
80#define VSF_PWM_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
81#define VSF_PWM_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
82// HW end
83
84/*============================ MACROFIED FUNCTIONS ===========================*/
85/*============================ TYPES =========================================*/
86
87// IPCore
88vsf_class(vsf_${pwm_ip}_pwm_t) {
89#if VSF_${PWM_IP}_CFG_MULTI_CLASS == ENABLED
90 public_member(
91 vsf_pwm_t vsf_pwm;
92 )
93#endif
94
95/*\note You can add more member in vsf_${pwm_ip}_pwm_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_${pwm_ip}_pwm_reg_t *reg;
102 vsf_pwm_isr_t isr;
104};
105// IPCore end
106
107// HW/IPCore, not for emulated drivers
108#if VSF_PWM_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
109typedef struct vsf_pwm_cfg_t {
110 union {
113 };
115#endif
116
117#if VSF_PWM_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
118typedef struct vsf_pwm_capability_t {
119#if VSF_PWM_CFG_INHERIT_HAL_CAPABILITY == ENABLED
121#endif
122 uint32_t max_freq;
125#endif
126
127#if VSF_PWM_CFG_REIMPLEMENT_TYPE_CTRL == ENABLED
128typedef enum vsf_pwm_ctrl_t {
131#endif
132// HW/IPCore end
133
134/*============================ INCLUDES ======================================*/
135
136// IPCore
137/*\note Extern APIs for ip core diriver.
138 * There is no requirement about how APIs of IPCore drivers should be implemented.
139 * Just consider the simplicity for actual peripheral drivers.
140 */
141// IPCore end
142
143#ifdef __cplusplus
144}
145#endif
146
147// IPCore
148#undef __VSF_HAL_${PWM_IP}_PWM_CLASS_IMPLEMENT
149#undef __VSF_HAL_${PWM_IP}_PWM_CLASS_INHERIT__
150// IPCore end
151
152#endif // VSF_HAL_USE_PWM
153#endif // __HAL_DRIVER_${SERIES/PWM_IP}_PWM_H__
154/* EOF */
Definition adc.h:98
#define vsf_class(__name)
Definition ooc_class.h:52
unsigned uint32_t
Definition stdint.h:9
Definition vsf_template_hal_driver.h:204
PWM capability structure. Describes the capabilities and limitations of the PWM hardware.
Definition vsf_template_pwm.h:204
inherit(vsf_peripheral_capability_t) uint32_t max_freq
uint32_t min_freq
Minimum supported PWM frequency in Hz. The lower limit of the PWM generator's frequency range.
Definition vsf_template_pwm.h:227
PWM configuration structure. Used to configure the PWM generator's frequency settings.
Definition vsf_template_pwm.h:170
uint32_t freq
The PWM clock frequency in Hz. Determines the base time period for the PWM generator.
Definition vsf_template_pwm.h:180
uint32_t min_freq
The minimum allowed PWM clock frequency in Hz. Used when configuring adaptive frequency ranges.
Definition vsf_template_pwm.h:190
Definition vsf_template_pwm.h:274
vsf_pwm_isr_t isr
Definition pwm.h:103
class vsf_$ * reg
vsf_pwm_ctrl_t
Definition pwm.h:128
@ __VSF_PWM_CTRL_DUMMY
Definition pwm.h:129
vsf_pwm_ctrl_t
PWM control commands for hardware-specific operations.
Definition vsf_template_pwm.h:240
Generated from commit: vsfteam/vsf@b2e9e8a