drivers: pwm: use new API naming (no pin)
Use the API names without `_pin`. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
95b56cdffd
commit
e2852ef985
23 changed files with 139 additions and 148 deletions
|
@ -55,10 +55,10 @@ static int pwm_b91_init(const struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* API implementation: pin_set */
|
||||
static int pwm_b91_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
/* API implementation: set_cycles */
|
||||
static int pwm_b91_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
|
@ -119,7 +119,7 @@ static int pwm_b91_get_cycles_per_sec(const struct device *dev,
|
|||
|
||||
/* PWM driver APIs structure */
|
||||
static const struct pwm_driver_api pwm_b91_driver_api = {
|
||||
.pin_set = pwm_b91_pin_set,
|
||||
.set_cycles = pwm_b91_set_cycles,
|
||||
.get_cycles_per_sec = pwm_b91_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -132,9 +132,9 @@ static uint32_t pwm_gd32_get_tim_clk(const struct device *dev)
|
|||
#endif /* RCU_CFG1_TIMERSEL */
|
||||
}
|
||||
|
||||
static int pwm_gd32_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_gd32_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_gd32_config *config = dev->config;
|
||||
|
||||
|
@ -219,7 +219,7 @@ static int pwm_gd32_get_cycles_per_sec(const struct device *dev,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_gd32_driver_api = {
|
||||
.pin_set = pwm_gd32_pin_set,
|
||||
.set_cycles = pwm_gd32_set_cycles,
|
||||
.get_cycles_per_sec = pwm_gd32_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ struct pwm_gecko_config {
|
|||
uint8_t pin;
|
||||
};
|
||||
|
||||
static int pwm_gecko_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_gecko_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
TIMER_InitCC_TypeDef compare_config = TIMER_INITCC_DEFAULT;
|
||||
const struct pwm_gecko_config *cfg = dev->config;
|
||||
|
@ -73,7 +73,7 @@ static int pwm_gecko_get_cycles_per_sec(const struct device *dev,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_gecko_driver_api = {
|
||||
.pin_set = pwm_gecko_pin_set,
|
||||
.set_cycles = pwm_gecko_set_cycles,
|
||||
.get_cycles_per_sec = pwm_gecko_get_cycles_per_sec
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ static bool imx_pwm_is_enabled(PWM_Type *base)
|
|||
}
|
||||
|
||||
static int imx_pwm_get_cycles_per_sec(const struct device *dev, uint32_t pwm,
|
||||
uint64_t *cycles)
|
||||
uint64_t *cycles)
|
||||
{
|
||||
PWM_Type *base = DEV_BASE(dev);
|
||||
const struct imx_pwm_config *config = dev->config;
|
||||
|
@ -47,9 +47,9 @@ static int imx_pwm_get_cycles_per_sec(const struct device *dev, uint32_t pwm,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int imx_pwm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int imx_pwm_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
PWM_Type *base = DEV_BASE(dev);
|
||||
const struct imx_pwm_config *config = dev->config;
|
||||
|
@ -149,7 +149,7 @@ static int imx_pwm_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api imx_pwm_driver_api = {
|
||||
.pin_set = imx_pwm_pin_set,
|
||||
.set_cycles = imx_pwm_set_cycles,
|
||||
.get_cycles_per_sec = imx_pwm_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -73,16 +73,16 @@ static int pwm_it8xxx2_get_cycles_per_sec(const struct device *dev,
|
|||
ARG_UNUSED(channel);
|
||||
|
||||
/*
|
||||
* There are three ways to call pwm_it8xxx2_pin_set() from pwm api:
|
||||
* 1) pwm_pin_set_usec() -> pwm_pin_set_cycles() -> pwm_it8xxx2_pin_set()
|
||||
* There are three ways to call pwm_it8xxx2_set_cycles() from pwm api:
|
||||
* 1) pwm_set_cycles_usec() -> pwm_set_cycles_cycles() -> pwm_it8xxx2_set_cycles()
|
||||
* target_freq = pwm_clk_src / period_cycles
|
||||
* = cycles / (period * cycles / USEC_PER_SEC)
|
||||
* = USEC_PER_SEC / period
|
||||
* 2) pwm_pin_set_nsec() -> pwm_pin_set_cycles() -> pwm_it8xxx2_pin_set()
|
||||
* 2) pwm_set_cycles_nsec() -> pwm_set_cycles_cycles() -> pwm_it8xxx2_set_cycles()
|
||||
* target_freq = pwm_clk_src / period_cycles
|
||||
* = cycles / (period * cycles / NSEC_PER_SEC)
|
||||
* = NSEC_PER_SEC / period
|
||||
* 3) pwm_pin_set_cycles() -> pwm_it8xxx2_pin_set()
|
||||
* 3) pwm_set_cycles_cycles() -> pwm_it8xxx2_set_cycles()
|
||||
* target_freq = pwm_clk_src / period_cycles
|
||||
* = cycles / period
|
||||
*
|
||||
|
@ -95,9 +95,9 @@ static int pwm_it8xxx2_get_cycles_per_sec(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_it8xxx2_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_it8xxx2_set_cycles(const struct device *dev,
|
||||
uint32_t channel, uint32_t period_cycles,
|
||||
uint32_t pulse_cycles, pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_it8xxx2_cfg *config = dev->config;
|
||||
struct pwm_it8xxx2_regs *const inst = config->base;
|
||||
|
@ -251,7 +251,7 @@ static int pwm_it8xxx2_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_it8xxx2_api = {
|
||||
.pin_set = pwm_it8xxx2_pin_set,
|
||||
.set_cycles = pwm_it8xxx2_set_cycles,
|
||||
.get_cycles_per_sec = pwm_it8xxx2_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -294,11 +294,9 @@ static int pwm_led_esp32_timer_set(int speed_mode, int timer,
|
|||
}
|
||||
|
||||
/* period_cycles is not used, set frequency on menuconfig instead. */
|
||||
static int pwm_led_esp32_pin_set_cycles(const struct device *dev,
|
||||
uint32_t channel,
|
||||
uint32_t period_cycles,
|
||||
uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_led_esp32_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles,
|
||||
uint32_t pulse_cycles, pwm_flags_t flags)
|
||||
{
|
||||
int speed_mode;
|
||||
int channel;
|
||||
|
@ -375,7 +373,7 @@ static int pwm_led_esp32_get_cycles_per_sec(const struct device *dev,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_led_esp32_api = {
|
||||
.pin_set = pwm_led_esp32_pin_set_cycles,
|
||||
.set_cycles = pwm_led_esp32_set_cycles,
|
||||
.get_cycles_per_sec = pwm_led_esp32_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ int pwm_litex_init(const struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int pwm_litex_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles,
|
||||
uint32_t pulse_cycles, pwm_flags_t flags)
|
||||
int pwm_litex_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles,
|
||||
uint32_t pulse_cycles, pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_litex_cfg *cfg = dev->config;
|
||||
|
||||
|
@ -75,8 +75,8 @@ int pwm_litex_get_cycles_per_sec(const struct device *dev, uint32_t channel,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_litex_driver_api = {
|
||||
.pin_set = pwm_litex_pin_set,
|
||||
.get_cycles_per_sec = pwm_litex_get_cycles_per_sec,
|
||||
.set_cycles = pwm_litex_set_cycles,
|
||||
.get_cycles_per_sec = pwm_litex_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
/* Device Instantiation */
|
||||
|
|
|
@ -313,9 +313,9 @@ done:
|
|||
regs->CONFIG = cfgval;
|
||||
}
|
||||
|
||||
static int pwm_xec_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_xec_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_xec_config * const cfg = dev->config;
|
||||
struct pwm_regs * const regs = cfg->regs;
|
||||
|
@ -375,7 +375,7 @@ static int pwm_xec_get_cycles_per_sec(const struct device *dev,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_xec_driver_api = {
|
||||
.pin_set = pwm_xec_pin_set,
|
||||
.set_cycles = pwm_xec_set_cycles,
|
||||
.get_cycles_per_sec = pwm_xec_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ struct pwm_mcux_data {
|
|||
pwm_signal_param_t channel[CHANNEL_COUNT];
|
||||
};
|
||||
|
||||
static int mcux_pwm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int mcux_pwm_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_mcux_config *config = dev->config;
|
||||
struct pwm_mcux_data *data = dev->data;
|
||||
|
@ -167,7 +167,7 @@ static int pwm_mcux_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_mcux_driver_api = {
|
||||
.pin_set = mcux_pwm_pin_set,
|
||||
.set_cycles = mcux_pwm_set_cycles,
|
||||
.get_cycles_per_sec = mcux_pwm_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -58,9 +58,9 @@ struct mcux_ftm_data {
|
|||
#endif /* CONFIG_PWM_CAPTURE */
|
||||
};
|
||||
|
||||
static int mcux_ftm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int mcux_ftm_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct mcux_ftm_config *config = dev->config;
|
||||
struct mcux_ftm_data *data = dev->data;
|
||||
|
@ -136,10 +136,10 @@ static int mcux_ftm_pin_set(const struct device *dev, uint32_t channel,
|
|||
}
|
||||
|
||||
#ifdef CONFIG_PWM_CAPTURE
|
||||
static int mcux_ftm_pin_configure_capture(const struct device *dev,
|
||||
uint32_t channel, pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb,
|
||||
void *user_data)
|
||||
static int mcux_ftm_configure_capture(const struct device *dev,
|
||||
uint32_t channel, pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
const struct mcux_ftm_config *config = dev->config;
|
||||
struct mcux_ftm_data *data = dev->data;
|
||||
|
@ -206,8 +206,7 @@ static int mcux_ftm_pin_configure_capture(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_ftm_pin_enable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int mcux_ftm_enable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
const struct mcux_ftm_config *config = dev->config;
|
||||
struct mcux_ftm_data *data = dev->data;
|
||||
|
@ -245,8 +244,7 @@ static int mcux_ftm_pin_enable_capture(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_ftm_pin_disable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int mcux_ftm_disable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
const struct mcux_ftm_config *config = dev->config;
|
||||
struct mcux_ftm_data *data = dev->data;
|
||||
|
@ -440,12 +438,12 @@ static int mcux_ftm_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api mcux_ftm_driver_api = {
|
||||
.pin_set = mcux_ftm_pin_set,
|
||||
.set_cycles = mcux_ftm_set_cycles,
|
||||
.get_cycles_per_sec = mcux_ftm_get_cycles_per_sec,
|
||||
#ifdef CONFIG_PWM_CAPTURE
|
||||
.pin_configure_capture = mcux_ftm_pin_configure_capture,
|
||||
.pin_enable_capture = mcux_ftm_pin_enable_capture,
|
||||
.pin_disable_capture = mcux_ftm_pin_disable_capture,
|
||||
.configure_capture = mcux_ftm_configure_capture,
|
||||
.enable_capture = mcux_ftm_enable_capture,
|
||||
.disable_capture = mcux_ftm_disable_capture,
|
||||
#endif /* CONFIG_PWM_CAPTURE */
|
||||
};
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ static inline bool mcux_pwt_is_active(const struct device *dev)
|
|||
return !!(config->base->CS & PWT_CS_PWTEN_MASK);
|
||||
}
|
||||
|
||||
static int mcux_pwt_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int mcux_pwt_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
ARG_UNUSED(channel);
|
||||
|
@ -65,10 +65,10 @@ static int mcux_pwt_pin_set(const struct device *dev, uint32_t channel,
|
|||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int mcux_pwt_pin_configure_capture(const struct device *dev,
|
||||
uint32_t channel, pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb,
|
||||
void *user_data)
|
||||
static int mcux_pwt_configure_capture(const struct device *dev,
|
||||
uint32_t channel, pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
const struct mcux_pwt_config *config = dev->config;
|
||||
struct mcux_pwt_data *data = dev->data;
|
||||
|
@ -101,8 +101,7 @@ static int mcux_pwt_pin_configure_capture(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_pwt_pin_enable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int mcux_pwt_enable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
const struct mcux_pwt_config *config = dev->config;
|
||||
struct mcux_pwt_data *data = dev->data;
|
||||
|
@ -130,8 +129,7 @@ static int mcux_pwt_pin_enable_capture(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mcux_pwt_pin_disable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int mcux_pwt_disable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
const struct mcux_pwt_config *config = dev->config;
|
||||
|
||||
|
@ -307,11 +305,11 @@ static int mcux_pwt_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api mcux_pwt_driver_api = {
|
||||
.pin_set = mcux_pwt_pin_set,
|
||||
.set_cycles = mcux_pwt_set_cycles,
|
||||
.get_cycles_per_sec = mcux_pwt_get_cycles_per_sec,
|
||||
.pin_configure_capture = mcux_pwt_pin_configure_capture,
|
||||
.pin_enable_capture = mcux_pwt_pin_enable_capture,
|
||||
.pin_disable_capture = mcux_pwt_pin_disable_capture,
|
||||
.configure_capture = mcux_pwt_configure_capture,
|
||||
.enable_capture = mcux_pwt_enable_capture,
|
||||
.disable_capture = mcux_pwt_disable_capture,
|
||||
};
|
||||
|
||||
#define TO_PWT_PRESCALE_DIVIDE(val) _DO_CONCAT(kPWT_Prescale_Divide_, val)
|
||||
|
|
|
@ -35,9 +35,9 @@ struct pwm_mcux_sctimer_data {
|
|||
sctimer_pwm_signal_param_t channel[CHANNEL_COUNT];
|
||||
};
|
||||
|
||||
static int mcux_sctimer_pwm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int mcux_sctimer_pwm_set_cycles(const struct device *dev,
|
||||
uint32_t channel, uint32_t period_cycles,
|
||||
uint32_t pulse_cycles, pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_mcux_sctimer_config *config = dev->config;
|
||||
struct pwm_mcux_sctimer_data *data = dev->data;
|
||||
|
@ -167,7 +167,7 @@ static int mcux_sctimer_pwm_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_mcux_sctimer_driver_api = {
|
||||
.pin_set = mcux_sctimer_pwm_pin_set,
|
||||
.set_cycles = mcux_sctimer_pwm_set_cycles,
|
||||
.get_cycles_per_sec = mcux_sctimer_pwm_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ struct mcux_tpm_data {
|
|||
tpm_chnl_pwm_signal_param_t channel[MAX_CHANNELS];
|
||||
};
|
||||
|
||||
static int mcux_tpm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int mcux_tpm_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct mcux_tpm_config *config = dev->config;
|
||||
struct mcux_tpm_data *data = dev->data;
|
||||
|
@ -175,7 +175,7 @@ static int mcux_tpm_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api mcux_tpm_driver_api = {
|
||||
.pin_set = mcux_tpm_pin_set,
|
||||
.set_cycles = mcux_tpm_set_cycles,
|
||||
.get_cycles_per_sec = mcux_tpm_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ static void pwm_npcx_configure(const struct device *dev, int clk_bus)
|
|||
}
|
||||
|
||||
/* PWM api functions */
|
||||
static int pwm_npcx_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_npcx_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
/* Single channel for each pwm device */
|
||||
ARG_UNUSED(channel);
|
||||
|
@ -173,7 +173,7 @@ static int pwm_npcx_get_cycles_per_sec(const struct device *dev,
|
|||
|
||||
/* PWM driver registration */
|
||||
static const struct pwm_driver_api pwm_npcx_driver_api = {
|
||||
.pin_set = pwm_npcx_pin_set,
|
||||
.set_cycles = pwm_npcx_set_cycles,
|
||||
.get_cycles_per_sec = pwm_npcx_get_cycles_per_sec
|
||||
};
|
||||
|
||||
|
|
|
@ -107,9 +107,9 @@ static uint32_t pwm_period_check(struct pwm_data *data, uint8_t map_size,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_nrf5_sw_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_nrf5_sw_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_config *config = dev->config;
|
||||
NRF_TIMER_Type *timer = pwm_config_timer(config);
|
||||
|
@ -298,7 +298,7 @@ static int pwm_nrf5_sw_get_cycles_per_sec(const struct device *dev,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_nrf5_sw_drv_api_funcs = {
|
||||
.pin_set = pwm_nrf5_sw_pin_set,
|
||||
.set_cycles = pwm_nrf5_sw_set_cycles,
|
||||
.get_cycles_per_sec = pwm_nrf5_sw_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -121,9 +121,9 @@ static bool channel_psel_get(uint32_t channel, uint32_t *psel,
|
|||
== PWM_PSEL_OUT_CONNECT_Connected);
|
||||
}
|
||||
|
||||
static int pwm_nrfx_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_nrfx_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
/* We assume here that period_cycles will always be 16MHz
|
||||
* peripheral clock. Since pwm_nrfx_get_cycles_per_sec() function might
|
||||
|
@ -141,9 +141,9 @@ static int pwm_nrfx_pin_set(const struct device *dev, uint32_t channel,
|
|||
}
|
||||
|
||||
/* Check if nrfx_pwm_stop function was called in previous
|
||||
* pwm_nrfx_pin_set call. Relying only on state returned by
|
||||
* nrfx_pwm_is_stopped may cause race condition if the pwm_nrfx_pin_set
|
||||
* is called multiple times in quick succession.
|
||||
* pwm_nrfx_set_cycles call. Relying only on state returned by
|
||||
* nrfx_pwm_is_stopped may cause race condition if the
|
||||
* pwm_nrfx_set_cycles is called multiple times in quick succession.
|
||||
*/
|
||||
was_stopped = !pwm_channel_is_active(channel, data) &&
|
||||
!any_other_channel_is_active(channel, data);
|
||||
|
@ -239,7 +239,7 @@ static int pwm_nrfx_get_cycles_per_sec(const struct device *dev, uint32_t channe
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_nrfx_drv_api_funcs = {
|
||||
.pin_set = pwm_nrfx_pin_set,
|
||||
.set_cycles = pwm_nrfx_set_cycles,
|
||||
.get_cycles_per_sec = pwm_nrfx_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ struct rv32m1_tpm_data {
|
|||
tpm_chnl_pwm_signal_param_t channel[MAX_CHANNELS];
|
||||
};
|
||||
|
||||
static int rv32m1_tpm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int rv32m1_tpm_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct rv32m1_tpm_config *config = dev->config;
|
||||
struct rv32m1_tpm_data *data = dev->data;
|
||||
|
@ -166,7 +166,7 @@ static int rv32m1_tpm_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api rv32m1_tpm_driver_api = {
|
||||
.pin_set = rv32m1_tpm_pin_set,
|
||||
.set_cycles = rv32m1_tpm_set_cycles,
|
||||
.get_cycles_per_sec = rv32m1_tpm_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@ static int sam_pwm_get_cycles_per_sec(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int sam_pwm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int sam_pwm_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct sam_pwm_config *config = dev->config;
|
||||
|
||||
|
@ -104,7 +104,7 @@ static int sam_pwm_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api sam_pwm_driver_api = {
|
||||
.pin_set = sam_pwm_pin_set,
|
||||
.set_cycles = sam_pwm_set_cycles,
|
||||
.get_cycles_per_sec = sam_pwm_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@ static int pwm_sam0_get_cycles_per_sec(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_sam0_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_sam0_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_sam0_config *const cfg = dev->config;
|
||||
Tcc *regs = cfg->regs;
|
||||
|
@ -136,7 +136,7 @@ static int pwm_sam0_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_sam0_driver_api = {
|
||||
.pin_set = pwm_sam0_pin_set,
|
||||
.set_cycles = pwm_sam0_set_cycles,
|
||||
.get_cycles_per_sec = pwm_sam0_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -106,9 +106,9 @@ static int pwm_sifive_init(const struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_sifive_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_sifive_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_sifive_cfg *config = dev->config;
|
||||
uint32_t count_max = 0U;
|
||||
|
@ -209,7 +209,7 @@ static int pwm_sifive_get_cycles_per_sec(const struct device *dev,
|
|||
/* Device Instantiation */
|
||||
|
||||
static const struct pwm_driver_api pwm_sifive_api = {
|
||||
.pin_set = pwm_sifive_pin_set,
|
||||
.set_cycles = pwm_sifive_set_cycles,
|
||||
.get_cycles_per_sec = pwm_sifive_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
|
@ -231,9 +231,9 @@ static int get_tim_clk(const struct stm32_pclken *pclken, uint32_t *tim_clk)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_stm32_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int pwm_stm32_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
const struct pwm_stm32_config *cfg = dev->config;
|
||||
|
||||
|
@ -395,9 +395,10 @@ static int init_capture_channel(const struct device *dev, uint32_t channel,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_stm32_pin_configure_capture(
|
||||
const struct device *dev, uint32_t channel, pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb, void *user_data)
|
||||
static int pwm_stm32_configure_capture(const struct device *dev,
|
||||
uint32_t channel, pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
|
||||
/*
|
||||
|
@ -470,8 +471,7 @@ static int pwm_stm32_pin_configure_capture(
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_stm32_pin_enable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int pwm_stm32_enable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
const struct pwm_stm32_config *cfg = dev->config;
|
||||
struct pwm_stm32_data *data = dev->data;
|
||||
|
@ -511,8 +511,7 @@ static int pwm_stm32_pin_enable_capture(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int pwm_stm32_pin_disable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int pwm_stm32_disable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
const struct pwm_stm32_config *cfg = dev->config;
|
||||
|
||||
|
@ -576,7 +575,7 @@ static void pwm_stm32_isr(const struct device *dev)
|
|||
}
|
||||
|
||||
if (!cpt->continuous) {
|
||||
pwm_stm32_pin_disable_capture(dev, in_ch);
|
||||
pwm_stm32_disable_capture(dev, in_ch);
|
||||
} else {
|
||||
cpt->overflows = 0u;
|
||||
}
|
||||
|
@ -615,12 +614,12 @@ static int pwm_stm32_get_cycles_per_sec(const struct device *dev,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api pwm_stm32_driver_api = {
|
||||
.pin_set = pwm_stm32_pin_set,
|
||||
.set_cycles = pwm_stm32_set_cycles,
|
||||
.get_cycles_per_sec = pwm_stm32_get_cycles_per_sec,
|
||||
#ifdef CONFIG_PWM_CAPTURE
|
||||
.pin_configure_capture = pwm_stm32_pin_configure_capture,
|
||||
.pin_enable_capture = pwm_stm32_pin_enable_capture,
|
||||
.pin_disable_capture = pwm_stm32_pin_disable_capture,
|
||||
.configure_capture = pwm_stm32_configure_capture,
|
||||
.enable_capture = pwm_stm32_enable_capture,
|
||||
.disable_capture = pwm_stm32_disable_capture,
|
||||
#endif /* CONFIG_PWM_CAPTURE */
|
||||
};
|
||||
|
||||
|
|
|
@ -15,30 +15,28 @@
|
|||
|
||||
#define DT_DRV_COMPAT vnd_pwm
|
||||
|
||||
static int vnd_pwm_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int vnd_pwm_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PWM_CAPTURE
|
||||
static int vnd_pwm_pin_configure_capture(const struct device *dev,
|
||||
uint32_t channel, pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb,
|
||||
void *user_data)
|
||||
static int vnd_pwm_configure_capture(const struct device *dev, uint32_t channel,
|
||||
pwm_flags_t flags,
|
||||
pwm_capture_callback_handler_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int vnd_pwm_pin_enable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int vnd_pwm_enable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static int vnd_pwm_pin_disable_capture(const struct device *dev,
|
||||
uint32_t channel)
|
||||
static int vnd_pwm_disable_capture(const struct device *dev, uint32_t channel)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
@ -51,11 +49,11 @@ static int vnd_pwm_get_cycles_per_sec(const struct device *dev,
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api vnd_pwm_api = {
|
||||
.pin_set = vnd_pwm_pin_set,
|
||||
.set_cycles = vnd_pwm_set_cycles,
|
||||
#ifdef CONFIG_PWM_CAPTURE
|
||||
.pin_configure_capture = vnd_pwm_pin_configure_capture,
|
||||
.pin_enable_capture = vnd_pwm_pin_enable_capture,
|
||||
.pin_disable_capture = vnd_pwm_pin_disable_capture,
|
||||
.configure_capture = vnd_pwm_configure_capture,
|
||||
.enable_capture = vnd_pwm_enable_capture,
|
||||
.disable_capture = vnd_pwm_disable_capture,
|
||||
#endif /* CONFIG_PWM_CAPTURE */
|
||||
.get_cycles_per_sec = vnd_pwm_get_cycles_per_sec,
|
||||
};
|
||||
|
|
|
@ -60,9 +60,9 @@ static inline void xlnx_axi_timer_write32(const struct device *dev,
|
|||
sys_write32(value, config->base + offset);
|
||||
}
|
||||
|
||||
static int xlnx_axi_timer_pin_set(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles, uint32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
static int xlnx_axi_timer_set_cycles(const struct device *dev, uint32_t channel,
|
||||
uint32_t period_cycles,
|
||||
uint32_t pulse_cycles, pwm_flags_t flags)
|
||||
{
|
||||
const struct xlnx_axi_timer_config *config = dev->config;
|
||||
uint32_t tcsr0 = TCSR_PWM;
|
||||
|
@ -176,7 +176,7 @@ static int xlnx_axi_timer_init(const struct device *dev)
|
|||
}
|
||||
|
||||
static const struct pwm_driver_api xlnx_axi_timer_driver_api = {
|
||||
.pin_set = xlnx_axi_timer_pin_set,
|
||||
.set_cycles = xlnx_axi_timer_set_cycles,
|
||||
.get_cycles_per_sec = xlnx_axi_timer_get_cycles_per_sec,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue