Skip to content

Commit adc6815

Browse files
committed
[nrf fromlist] tests: drivers: pwm_gpio_loopback: Test improvement
Improve corss-channel test by setting different duty cycle on channels. This modification will enable detection of inter-channel effects like crosstalk. Upstream PR #: 93776 Signed-off-by: Piotr Krzyzanowski <[email protected]>
1 parent e8a162c commit adc6815

File tree

1 file changed

+19
-7
lines changed
  • tests/drivers/pwm/pwm_gpio_loopback/src

1 file changed

+19
-7
lines changed

tests/drivers/pwm/pwm_gpio_loopback/src/main.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,28 @@ ZTEST(pwm_gpio_loopback, test_pwm)
234234

235235
ZTEST(pwm_gpio_loopback, test_pwm_cross)
236236
{
237+
uint8_t duty[TEST_PWM_COUNT];
238+
237239
for (int i = 0; i < TEST_PWM_COUNT; i++) {
238-
/* Test case: [Duty: 40%] */
239-
test_run(&pwms_dt[i], &gpios_dt[i], 40, true);
240+
duty[i] = i % 5 * 25;
241+
/* Sets Duty[%] one by one, in order from the list
242+
* (0, 25, 50, 75, 100)
243+
*/
244+
test_run(&pwms_dt[i], &gpios_dt[i], duty[i], true);
240245
}
241246

242-
/* Set all channels and check if they retain the original
243-
* configuration without calling pwm_set again
244-
*/
245-
for (int i = 0; i < TEST_PWM_COUNT; i++) {
246-
test_run(&pwms_dt[i], &gpios_dt[i], 40, false);
247+
for (int j = 1; j < 5; j++) {
248+
/* Check if all channels retain the original
249+
* configuration without calling pwm_set again
250+
*/
251+
for (int i = 0; i < TEST_PWM_COUNT; i++) {
252+
test_run(&pwms_dt[i], &gpios_dt[i], duty[i], false);
253+
}
254+
for (int i = 0; i < TEST_PWM_COUNT; i++) {
255+
duty[i] = (j + i) % 5 * 25;
256+
/* Test case: [Duty: (0, 25, 50, 75, 100)%] */
257+
test_run(&pwms_dt[i], &gpios_dt[i], duty[i], true);
258+
}
247259
}
248260
}
249261

0 commit comments

Comments
 (0)