@@ -34,6 +34,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_PWM_LOG_LEVEL);
3434#define PWM_INITIAL_DUTY 0U /* initially off */
3535
3636struct pwm_cc13xx_cc26xx_data {
37+ bool standby_disabled ;
3738};
3839
3940struct pwm_cc13xx_cc26xx_config {
@@ -56,14 +57,17 @@ static void write_value(const struct pwm_cc13xx_cc26xx_config *config, uint32_t
5657}
5758
5859static int set_period_and_pulse (const struct pwm_cc13xx_cc26xx_config * config , uint32_t period ,
59- uint32_t pulse )
60+ uint32_t pulse , struct pwm_cc13xx_cc26xx_data * data )
6061{
6162 uint32_t match_value = pulse ;
6263
6364 if (pulse == 0U ) {
6465 TimerDisable (config -> gpt_base , TIMER_B );
6566#ifdef CONFIG_PM
66- Power_releaseConstraint (PowerCC26XX_DISALLOW_STANDBY );
67+ if (data -> standby_disabled ) {
68+ Power_releaseConstraint (PowerCC26XX_DISALLOW_STANDBY );
69+ data -> standby_disabled = false;
70+ }
6771#endif
6872 match_value = period + 1 ;
6973 }
@@ -86,7 +90,10 @@ static int set_period_and_pulse(const struct pwm_cc13xx_cc26xx_config *config, u
8690
8791 if (pulse > 0U ) {
8892#ifdef CONFIG_PM
89- Power_setConstraint (PowerCC26XX_DISALLOW_STANDBY );
93+ if (!data -> standby_disabled ) {
94+ Power_setConstraint (PowerCC26XX_DISALLOW_STANDBY );
95+ data -> standby_disabled = true;
96+ }
9097#endif
9198 TimerEnable (config -> gpt_base , TIMER_B );
9299 }
@@ -110,7 +117,7 @@ static int set_cycles(const struct device *dev, uint32_t channel, uint32_t perio
110117 HWREG (config -> gpt_base + GPT_O_CTL ) |= GPT_CTL_TBPWML_NORMAL ;
111118 }
112119
113- set_period_and_pulse (config , period , pulse );
120+ set_period_and_pulse (config , period , pulse , dev -> data );
114121
115122 return 0 ;
116123}
@@ -223,7 +230,7 @@ static int init_pwm(const struct device *dev)
223230 HWREG (config -> gpt_base + GPT_O_TBMR ) = GPT_TBMR_TBAMS_PWM | GPT_TBMR_TBMRSU_TOUPDATE |
224231 GPT_TBMR_TBPWMIE_EN | GPT_TBMR_TBMR_PERIODIC ;
225232
226- set_period_and_pulse (config , PWM_INITIAL_PERIOD , PWM_INITIAL_DUTY );
233+ set_period_and_pulse (config , PWM_INITIAL_PERIOD , PWM_INITIAL_DUTY , dev -> data );
227234
228235 return 0 ;
229236}
0 commit comments