VSF Documented
Macros | Functions
pwm_common.c File Reference
#include "hal/driver/driver.h"

Macros

#define VSF_PWM_CFG_FUNCTION_RENAME   DISABLED
 

Functions

vsf_err_t vsf_pwm_init (vsf_pwm_t *pwm_ptr, vsf_pwm_cfg_t *cfg_ptr)
 initialize a pwm instance.
 
void vsf_pwm_fini (vsf_pwm_t *pwm_ptr)
 finalize a pwm instance.
 
fsm_rt_t vsf_pwm_enable (vsf_pwm_t *pwm_ptr)
 enable interrupt masks of pwm instance.
 
fsm_rt_t vsf_pwm_disable (vsf_pwm_t *pwm_ptr)
 disable interrupt masks of pwm instance.
 
vsf_pwm_capability_t vsf_pwm_capability (vsf_pwm_t *pwm_ptr)
 get the capability of pwm instance.
 
vsf_err_t vsf_pwm_set (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
 
uint32_t vsf_pwm_get_freq (vsf_pwm_t *pwm_ptr)
 pwm get clock frequency
 
vsf_err_t vsf_pwm_set_ns (vsf_pwm_t *pwm_ptr, uint8_t channel, uint32_t period_ns, uint32_t pulse_ns)
 pwm set the period width and pulse width for a channel
 
vsf_err_t vsf_pwm_set_us (vsf_pwm_t *pwm_ptr, uint8_t channel, uint32_t period_us, uint32_t pulse_us)
 pwm set the period width and pulse width for a channel
 
vsf_err_t vsf_pwm_set_ms (vsf_pwm_t *pwm_ptr, uint8_t channel, uint32_t period_ms, uint32_t pulse_ms)
 pwm set the period width and pulse width for a channel
 

Macro Definition Documentation

◆ VSF_PWM_CFG_FUNCTION_RENAME

#define VSF_PWM_CFG_FUNCTION_RENAME   DISABLED

Function Documentation

◆ vsf_pwm_init()

vsf_err_t vsf_pwm_init ( vsf_pwm_t pwm_ptr,
vsf_pwm_cfg_t cfg_ptr 
)

initialize a pwm instance.

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
[in]cfg_ptra pointer to structure vsf_pwm_cfg_t
Returns
vsf_err_t: VSF_ERR_NONE if pwm was initialized, or a negative error code
Note
It is not necessary to call vsf_pwm_fini() to deinitialization. vsf_pwm_init() should be called before any other pwm API except vsf_pwm_capability().

◆ vsf_pwm_fini()

void vsf_pwm_fini ( vsf_pwm_t pwm_ptr)

finalize a pwm instance.

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
Returns
none

◆ vsf_pwm_enable()

fsm_rt_t vsf_pwm_enable ( vsf_pwm_t pwm_ptr)

enable interrupt masks of pwm instance.

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
[in]irq_maskone or more value of enum vsf_pwm_irq_mask_t
Returns
none.

◆ vsf_pwm_disable()

fsm_rt_t vsf_pwm_disable ( vsf_pwm_t pwm_ptr)

disable interrupt masks of pwm instance.

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
[in]irq_maskone or more value of enum vsf_pwm_irq_mask_t, vsf_pwm_irq_mask_t
Returns
none.

◆ vsf_pwm_capability()

vsf_pwm_capability_t vsf_pwm_capability ( vsf_pwm_t pwm_ptr)

get the capability of pwm instance.

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
Returns
vsf_pwm_capability_t: return all capability of current pwm vsf_pwm_capability_t

◆ vsf_pwm_set()

vsf_err_t vsf_pwm_set ( 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

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
[in]channelpwm channel
[in]periodpwm period width (in clock counter)
[in]pulsepwm pulse width (in clock counter)
Returns
vsf_err_t: VSF_ERR_NONE if the pwm set was successfully, or a negative error code

◆ vsf_pwm_get_freq()

uint32_t vsf_pwm_get_freq ( vsf_pwm_t pwm_ptr)

pwm get clock frequency

Get clock frequency

Parameters
[in]pwm_ptrpwm instance
Returns
clock frequency (in Hz)
Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
Returns
uint32_t: pwm clock frequency

◆ vsf_pwm_set_ns()

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

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
[in]channelpwm channel
[in]periodpwm period width (in nano-second)
[in]pulsepwm pulse width (in nano-second)
Returns
vsf_err_t: VSF_ERR_NONE if the pwm set was successfully, or a negative error code

◆ vsf_pwm_set_us()

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

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
[in]channelpwm channel
[in]periodpwm period width (in micro-second)
[in]pulsepwm pulse width (in micro-second)
Returns
vsf_err_t: VSF_ERR_NONE if the pwm set was successfully, or a negative error code

◆ vsf_pwm_set_ms()

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

Parameters
[in]pwm_ptra pointer to structure vsf_pwm_t
[in]channelpwm channel
[in]periodpwm period width (in milli-second)
[in]pulsepwm pulse width (in milli-second)
Returns
vsf_err_t: VSF_ERR_NONE if the pwm set was successfully, or a negative error code