Skip to content

Commit 348388b

Browse files
Ayush1325nashif
authored andcommitted
drivers: cc13xx_cc26xx: pwm: Add polarity flag support
- Allow setting polarity from DT. - At least on bcf, going from 0 to 255 causes brightness to decrease (although 0 is still off and 255 is still on). - Seems to work as expcted by using TnPWML register. Signed-off-by: Ayush Singh <[email protected]>
1 parent e224a41 commit 348388b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/pwm/pwm_cc13xx_cc26xx_timer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ static int set_cycles(const struct device *dev, uint32_t channel, uint32_t perio
104104
return -EIO;
105105
}
106106

107+
if (flags & PWM_POLARITY_INVERTED) {
108+
HWREG(config->gpt_base + GPT_O_CTL) |= GPT_CTL_TBPWML_INVERTED;
109+
} else {
110+
HWREG(config->gpt_base + GPT_O_CTL) |= GPT_CTL_TBPWML_NORMAL;
111+
}
112+
107113
set_period_and_pulse(config, period, pulse);
108114

109115
return 0;
@@ -214,7 +220,6 @@ static int init_pwm(const struct device *dev)
214220
*/
215221
HWREG(config->gpt_base + GPT_O_CTL) |= GPT_CTL_TBSTALL;
216222

217-
/* TODO: Make PWM polarity configurable via DT PWM flag. */
218223
HWREG(config->gpt_base + GPT_O_TBMR) = GPT_TBMR_TBAMS_PWM | GPT_TBMR_TBMRSU_TOUPDATE |
219224
GPT_TBMR_TBPWMIE_EN | GPT_TBMR_TBMR_PERIODIC;
220225

0 commit comments

Comments
 (0)