Skip to content

Commit ae88902

Browse files
franckduriezcfriedt
authored andcommitted
driver: pwm/pca9685: handle POLARITY flag
Handle polarity flag in pca9685 driver Signed-off-by: Franck Duriez <[email protected]>
1 parent fc5ded2 commit ae88902

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

boards/shields/adafruit_pca9685/adafruit_pca9685.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
status = "okay";
1414
compatible = "nxp,pca9685-pwm";
1515
reg = <0x40>;
16-
#pwm-cells = <2>;
16+
#pwm-cells = <3>;
1717
};
1818
};
1919

drivers/pwm/pwm_pca9685.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ static int pca9685_set_cycles(const struct device *dev,
173173
int32_t pre_scale;
174174
int ret;
175175

176-
ARG_UNUSED(flags);
176+
if (flags & PWM_POLARITY_INVERTED) {
177+
pulse_count = period_count - pulse_count;
178+
}
177179

178180
if (channel >= CHANNEL_CNT) {
179181
LOG_WRN("channel out of range: %u", channel);

dts/bindings/pwm/nxp,pca9685.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ properties:
3030
used.
3131

3232
"#pwm-cells":
33-
const: 2
33+
const: 3
3434

3535
pwm-cells:
3636
- channel
3737
- period
38+
- flags

tests/drivers/build_all/pwm/boards/native_sim.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
status = "okay";
3434
compatible = "nxp,pca9685-pwm";
3535
reg = <0x1>;
36-
#pwm-cells = <2>;
36+
#pwm-cells = <3>;
3737
};
3838
};
3939
};

0 commit comments

Comments
 (0)