This is an automated email from the ASF dual-hosted git repository.
wes3 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new f2b4e4102 pwm/pwm_da1469x: Preserve timer state on frequency change.
f2b4e4102 is described below
commit f2b4e4102edaa6afaff1dac6ba0af2ddddb8c3c4
Author: Will San Filippo <[email protected]>
AuthorDate: Tue May 21 13:00:21 2024 -0400
pwm/pwm_da1469x: Preserve timer state on frequency change.
Read the current timer state (timer control reg) and preserve
its running state when setting frequency. The only bits that
should be set in the control register are the bits to enable
the timer in the proper mode and enable the clock.
---
hw/drivers/pwm/pwm_da1469x/src/pwm_da1469x.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/drivers/pwm/pwm_da1469x/src/pwm_da1469x.c
b/hw/drivers/pwm/pwm_da1469x/src/pwm_da1469x.c
index b6c74da6c..1f7c5b804 100644
--- a/hw/drivers/pwm/pwm_da1469x/src/pwm_da1469x.c
+++ b/hw/drivers/pwm/pwm_da1469x/src/pwm_da1469x.c
@@ -91,7 +91,7 @@ da1469x_pwm_configure_channel(struct pwm_dev *dev, uint8_t
channel,
pwm = da1469x_pwm_resolve(dev->pwm_instance_id);
if (!pwm || !pwm->in_use) {
- return SYS_EINVAL;
+ return SYS_EINVAL;
}
mcu_gpio_set_pin_function(cfg->pin, MCU_GPIO_MODE_OUTPUT, pwm->gpio_func);
@@ -220,6 +220,7 @@ da1469x_pwm_set_freq(struct pwm_dev *dev, uint32_t freq)
int tim_pwm_freq;
uint32_t sys_clk_en;
uint32_t actual_freq;
+ uint32_t clk_reg;
pwm = da1469x_pwm_resolve(dev->pwm_instance_id);
if (!pwm || !pwm->in_use) {
@@ -232,7 +233,8 @@ da1469x_pwm_set_freq(struct pwm_dev *dev, uint32_t freq)
}
pwm->timer_regs->TIMER_PRESCALER_REG = 0;
- pwm->timer_regs->TIMER_CTRL_REG = sys_clk_en;
+ clk_reg = pwm->timer_regs->TIMER_CTRL_REG &
~TIMER_TIMER_CTRL_REG_TIM_SYS_CLK_EN_Msk;
+ pwm->timer_regs->TIMER_CTRL_REG = (sys_clk_en | clk_reg);
pwm->timer_regs->TIMER_PWM_FREQ_REG = tim_pwm_freq;
pwm->freq = actual_freq;