Skip to content

Commit 67e0f61

Browse files
committed
add PWM test for ecap0 (P9_42) and ecap2 (P9_28)
1 parent f58cabe commit 67e0f61

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

source/c_pwm.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,13 @@ BBIO_err pwm_setup(const char *key, float duty, float freq, int polarity)
318318
return BBIO_CAPE;
319319
}
320320
// Do pinmuxing
321-
fprintf(stderr, "DEBUG: do pinmuxing: key=%s\n", key);
322321
if(!strcmp(key, "P9_28")) {
323-
fprintf(stderr, "DEBUG: P9_28: use pwm2\n");
322+
// ecap2 (P9_28) requires mode pwm2
323+
// based on bonescript commit 23bf443 by Matthew West
324324
strncpy(pin_mode, "pwm2", PIN_MODE_LEN);
325325
} else {
326-
fprintf(stderr, "DEBUG: use pwm\n");
327326
strncpy(pin_mode, "pwm", PIN_MODE_LEN);
328327
}
329-
fprintf(stderr, "DEBUG: set_pin_mode(key=%s, pin_mode=%s)\n", key, pin_mode);
330328
set_pin_mode(key, pin_mode);
331329

332330
// Get info for pwm

test/test_pwm_setup.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,38 @@ def test_start_pwm(self):
4848
assert int(period) == 500000
4949
PWM.cleanup()
5050

51+
def test_start_pwm_ecap0(self):
52+
print("test_start_pwm_ecap0\n");
53+
PWM.cleanup()
54+
PWM.start("P9_42", 0)
55+
pwm_dir = get_pwm_dir()
56+
assert os.path.exists(pwm_dir)
57+
if kernel >= '4.1.0':
58+
duty = open(pwm_dir + '/duty_cycle').read()
59+
else:
60+
duty = open(pwm_dir + '/duty').read()
61+
period = open(pwm_dir + '/period').read()
62+
assert int(duty) == 0
63+
assert int(period) == 500000
64+
PWM.cleanup()
65+
66+
# test not enabled as default as
67+
# cape-universala overlay required
68+
#def test_start_pwm_ecap2(self):
69+
#print("test_start_pwm_ecap2\n");
70+
#PWM.cleanup()
71+
#PWM.start("P9_28", 0)
72+
#pwm_dir = get_pwm_dir()
73+
#assert os.path.exists(pwm_dir)
74+
#if kernel >= '4.1.0':
75+
#duty = open(pwm_dir + '/duty_cycle').read()
76+
#else:
77+
#duty = open(pwm_dir + '/duty').read()
78+
#period = open(pwm_dir + '/period').read()
79+
#assert int(duty) == 0
80+
#assert int(period) == 500000
81+
#PWM.cleanup()
82+
5183
def test_start_pwm_with_polarity_one(self):
5284
PWM.cleanup()
5385
PWM.start("P9_14", 0, 2000, 1)

0 commit comments

Comments
 (0)