@@ -34,6 +34,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_PWM_LOG_LEVEL);
34
34
#define PWM_INITIAL_DUTY 0U /* initially off */
35
35
36
36
struct pwm_cc13xx_cc26xx_data {
37
+ bool standby_disabled ;
37
38
};
38
39
39
40
struct pwm_cc13xx_cc26xx_config {
@@ -56,14 +57,17 @@ static void write_value(const struct pwm_cc13xx_cc26xx_config *config, uint32_t
56
57
}
57
58
58
59
static 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 )
60
61
{
61
62
uint32_t match_value = pulse ;
62
63
63
64
if (pulse == 0U ) {
64
65
TimerDisable (config -> gpt_base , TIMER_B );
65
66
#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
+ }
67
71
#endif
68
72
match_value = period + 1 ;
69
73
}
@@ -86,7 +90,10 @@ static int set_period_and_pulse(const struct pwm_cc13xx_cc26xx_config *config, u
86
90
87
91
if (pulse > 0U ) {
88
92
#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
+ }
90
97
#endif
91
98
TimerEnable (config -> gpt_base , TIMER_B );
92
99
}
@@ -110,7 +117,7 @@ static int set_cycles(const struct device *dev, uint32_t channel, uint32_t perio
110
117
HWREG (config -> gpt_base + GPT_O_CTL ) |= GPT_CTL_TBPWML_NORMAL ;
111
118
}
112
119
113
- set_period_and_pulse (config , period , pulse );
120
+ set_period_and_pulse (config , period , pulse , dev -> data );
114
121
115
122
return 0 ;
116
123
}
@@ -223,7 +230,7 @@ static int init_pwm(const struct device *dev)
223
230
HWREG (config -> gpt_base + GPT_O_TBMR ) = GPT_TBMR_TBAMS_PWM | GPT_TBMR_TBMRSU_TOUPDATE |
224
231
GPT_TBMR_TBPWMIE_EN | GPT_TBMR_TBMR_PERIODIC ;
225
232
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 );
227
234
228
235
return 0 ;
229
236
}
0 commit comments