Skip to content

Commit bc2faf3

Browse files
QiuPeiyangAnas Nashif
authored andcommitted
tests/pwm: enable PWM case to work on D2000 board
This test case uses PWM0 port to test PWM on Quark Se. However PWM0 port on Quark D2000 is initialized as tdo, not PWM0 and disabling tdo will kill JTAG on D2000. So use PWM1 and add PINMUX setting code to configure PIN_24 as PWM1 port, then the case will work on D2000 board. Change-Id: Ib28d4750dac7396529388b781fb64bde048139d6 Signed-off-by: Qiu Peiyang <[email protected]>
1 parent 484f07c commit bc2faf3

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

tests/drivers/pwm/pwm_api/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
BOARD ?= quark_se_c1000_devboard
2-
CONF_FILE = prj.conf
2+
CONF_FILE ?= prj.conf
33

44
include ${ZEPHYR_BASE}/Makefile.test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_PWM=y
2+
CONFIG_PINMUX=y
3+
CONFIG_PWM_QMSI_NUM_PORTS=2
4+
CONFIG_ZTEST=y

tests/drivers/pwm/pwm_api/src/test_pwm.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* through usec or cycle.
1313
* @details
1414
* - Test Steps
15-
* -# Bind PWM port 0.
15+
* -# Bind PWM_0 port 0 (This case uses port 1 on D2000).
1616
* -# Set PWM period and pulse using pwm_pin_set_cycles() or
1717
* pwm_pin_set_usec().
1818
* -# Use multimeter or other instruments to measure the output
@@ -34,12 +34,20 @@
3434

3535
#define PWM_DEV_NAME CONFIG_PWM_QMSI_DEV_NAME
3636

37-
#define DEFAULT_PWM_PORT 0
3837
#define DEFAULT_PERIOD_CYCLE 64000
3938
#define DEFAULT_PULSE_CYCLE 32000
4039
#define DEFAULT_PERIOD_USEC 2000
4140
#define DEFAULT_PULSE_USEC 1000
4241

42+
#ifdef CONFIG_BOARD_QUARK_D2000_CRB
43+
#include <pinmux.h>
44+
#define PINMUX_NAME CONFIG_PINMUX_NAME
45+
#define PWM1_PIN 24
46+
#define DEFAULT_PWM_PORT 1
47+
#else
48+
#define DEFAULT_PWM_PORT 0
49+
#endif
50+
4351
static int test_task(uint32_t port, uint32_t period, uint32_t pulse, bool cycle)
4452
{
4553
TC_PRINT("[PWM]: %" PRIu8 ", [period]: %" PRIu32 ", [pulse]: %" PRIu32 "\n",
@@ -52,6 +60,32 @@ static int test_task(uint32_t port, uint32_t period, uint32_t pulse, bool cycle)
5260
return TC_FAIL;
5361
}
5462

63+
#ifdef CONFIG_BOARD_QUARK_D2000_CRB
64+
struct device *pinmux = device_get_binding(PINMUX_NAME);
65+
uint32_t function;
66+
67+
if (!pinmux) {
68+
TC_PRINT("Cannot get PINMUX\n");
69+
return TC_FAIL;
70+
}
71+
72+
if (pinmux_pin_set(pinmux, PWM1_PIN, PINMUX_FUNC_C)) {
73+
TC_PRINT("Fail to set pin func, %u : %u\n",
74+
PWM1_PIN, PINMUX_FUNC_C);
75+
return TC_FAIL;
76+
}
77+
78+
if (pinmux_pin_get(pinmux, PWM1_PIN, &function)) {
79+
TC_PRINT("Fail to get pin func\n");
80+
return TC_FAIL;
81+
}
82+
83+
if (function != PINMUX_FUNC_C) {
84+
TC_PRINT("Error. PINMUX get doesn't match PINMUX set\n");
85+
return TC_FAIL;
86+
}
87+
#endif
88+
5589
if (cycle) {
5690
/* Verify pwm_pin_set_cycles() */
5791
if (pwm_pin_set_cycles(pwm_dev, port, period, pulse)) {
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[test_pwm]
22
tags = drivers
3-
platform_whitelist = quark_se_c1000_devboard quark_se_c1000_ss_devboard_quark_d2000_crb arduino_101 arduino_101_sss
3+
platform_whitelist = quark_se_c1000_devboard quark_se_c1000_ss_devboard arduino_101 arduino_101_sss
4+
5+
[test_pwm_d2000_crb]
6+
tags = drivers
7+
extra_args = CONF_FILE=prj_d2000.conf
8+
platform_whitelist = quark_d2000_crb

0 commit comments

Comments
 (0)