18#ifndef __VSF_TEMPLATE_PWM_H__
19#define __VSF_TEMPLATE_PWM_H__
33#ifndef VSF_PWM_CFG_MULTI_CLASS
34# define VSF_PWM_CFG_MULTI_CLASS ENABLED
37#if defined(VSF_HW_PWM_COUNT) && !defined(VSF_HW_PWM_MASK)
38# define VSF_HW_PWM_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_PWM_COUNT)
41#if defined(VSF_HW_PWM_MASK) && !defined(VSF_HW_PWM_COUNT)
42# define VSF_HW_PWM_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_PWM_MASK)
46#ifndef VSF_PWM_CFG_PREFIX
47# if VSF_PWM_CFG_MULTI_CLASS == ENABLED
48# define VSF_PWM_CFG_PREFIX vsf
49# elif defined(VSF_HW_PWM_COUNT) && (VSF_HW_PWM_COUNT != 0)
50# define VSF_PWM_CFG_PREFIX vsf_hw
52# define VSF_PWM_CFG_PREFIX vsf
56#ifndef VSF_PWM_CFG_FUNCTION_RENAME
57# define VSF_PWM_CFG_FUNCTION_RENAME ENABLED
63#if VSF_PWM_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
64# define VSF_PWM_CFG_REIMPLEMENT_TYPE_CFG DISABLED
70#if VSF_PWM_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
71# define VSF_PWM_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
74#ifndef VSF_PWM_CFG_INHERT_HAL_CAPABILITY
75# define VSF_PWM_CFG_INHERT_HAL_CAPABILITY ENABLED
80#define VSF_PWM_APIS(__prefix_name) \
81 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, pwm, init, VSF_MCONNECT(__prefix_name, _pwm_t) *pwm_ptr, vsf_pwm_cfg_t *cfg_ptr) \
82 __VSF_HAL_TEMPLATE_API(__prefix_name, void, pwm, fini, VSF_MCONNECT(__prefix_name, _pwm_t) *pwm_ptr) \
83 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, pwm, enable, VSF_MCONNECT(__prefix_name, _pwm_t) *pwm_ptr) \
84 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, pwm, disable, VSF_MCONNECT(__prefix_name, _pwm_t) *pwm_ptr) \
85 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_pwm_capability_t, pwm, capability, VSF_MCONNECT(__prefix_name, _pwm_t) *pwm_ptr) \
86 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, pwm, set, VSF_MCONNECT(__prefix_name, _pwm_t) *pwm_ptr, uint8_t channel, uint32_t period, uint32_t pulse)\
87 __VSF_HAL_TEMPLATE_API(__prefix_name, uint32_t, pwm, get_freq, VSF_MCONNECT(__prefix_name, _pwm_t) *pwm_ptr)
91#if VSF_PWM_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
100#if VSF_PWM_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
102#if VSF_PWM_CFG_INHERT_HAL_CAPABILITY == ENABLED
114#undef __VSF_HAL_TEMPLATE_API
115#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
120#if VSF_PWM_CFG_MULTI_CLASS == ENABLED
316#if VSF_PWM_CFG_FUNCTION_RENAME == ENABLED
317# define __vsf_pwm_t VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_t)
318# define vsf_pwm_init(__PM, ...) VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_init) ((__vsf_pwm_t *)(__PM), ##__VA_ARGS__)
319# define vsf_pwm_fini(__PM) VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_fini) ((__vsf_pwm_t *)(__PM))
320# define vsf_pwm_enable(__PM) VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_enable) ((__vsf_pwm_t *)(__PM))
321# define vsf_pwm_disable(__PM) VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_disable) ((__vsf_pwm_t *)(__PM))
322# define vsf_pwm_capability(__PM) VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_capability) ((__vsf_pwm_t *)(__PM))
323# define vsf_pwm_set(__PM, ...) VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_set) ((__vsf_pwm_t *)(__PM), ##__VA_ARGS__)
324# define vsf_pwm_get_freq(__PM) VSF_MCONNECT(VSF_PWM_CFG_PREFIX, _pwm_get_freq) ((__vsf_pwm_t *)(__PM))
vsf_err_t
Definition __type.h:42
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
Definition vsf_template_hal_driver.h:203
Definition vsf_template_pwm.h:101
inherit(vsf_peripheral_capability_t) uint32_t max_freq
uint32_t min_freq
Definition vsf_template_pwm.h:107
Definition vsf_template_pwm.h:92
uint32_t freq
The clock frequency, in Hz.
Definition vsf_template_pwm.h:94
uint32_t min_freq
The minimum clock frequency, in Hz.
Definition vsf_template_pwm.h:95
Definition vsf_template_pwm.h:113
Definition vsf_template_pwm.h:121
const vsf_pwm_op_t * op
Definition vsf_template_pwm.h:122
fsm_rt_t
Definition vsf_fsm.h:315
vsf_err_t vsf_pwm_set_ns(vsf_pwm_t *pwm_ptr, uint8_t channel, uint32_t period, uint32_t pulse)
pwm set the period width and pulse width for a channel
Definition pwm_common.c:104
#define vsf_pwm_init(__PM,...)
Definition vsf_template_pwm.h:318
#define vsf_pwm_enable(__PM)
Definition vsf_template_pwm.h:320
vsf_err_t vsf_pwm_set_us(vsf_pwm_t *pwm_ptr, uint8_t channel, uint32_t period, uint32_t pulse)
pwm set the period width and pulse width for a channel
Definition pwm_common.c:113
#define vsf_pwm_get_freq(__PM)
Definition vsf_template_pwm.h:324
vsf_err_t vsf_pwm_set_ms(vsf_pwm_t *pwm_ptr, uint8_t channel, uint32_t period, uint32_t pulse)
pwm set the period width and pulse width for a channel
Definition pwm_common.c:122
#define vsf_pwm_capability(__PM)
Definition vsf_template_pwm.h:322
#define vsf_pwm_set(__PM,...)
Definition vsf_template_pwm.h:323
#define vsf_pwm_fini(__PM)
Definition vsf_template_pwm.h:319
#define VSF_PWM_APIS(__prefix_name)
Definition vsf_template_pwm.h:80
#define vsf_pwm_disable(__PM)
Definition vsf_template_pwm.h:321