Skip to content

Commit 4bd2ab7

Browse files
jbehrensnxkartben
authored andcommitted
drivers: stepper: test: Added drv8424 driver tests
Adds 2 test suites for the drv8424 stepper driver, testing API conformity and return values in the first suite and gpio pin values in the second suite Signed-off-by: Jan Behrens <[email protected]>
1 parent 79d6294 commit 4bd2ab7

File tree

14 files changed

+890
-0
lines changed

14 files changed

+890
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2024 Navimatix GmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
6+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
7+
project(stepper_drv8424_api)
8+
target_sources(app PRIVATE
9+
src/main.c
10+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024 Navimatix GmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config ENTROPY_GENERATOR
5+
depends on ZTEST_SHUFFLE
6+
bool "Shuffle the order of tests and suites"
7+
default y
8+
9+
source "Kconfig.zephyr"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2024 Navimatix GmbH
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/gpio/gpio.h>
7+
8+
/ {
9+
zephyr,user {
10+
stepper-motors = <&drv8424 0>;
11+
};
12+
};
13+
14+
&lpi2c1 {
15+
status = "okay";
16+
17+
mikroe_stepper_gpios: mikroe_stepper_ctrl_tca9538a@70 {
18+
status = "okay";
19+
compatible = "ti,tca9538";
20+
21+
reg = <0x70>;
22+
23+
gpio-controller;
24+
ngpios = <8>;
25+
#gpio-cells = <2>;
26+
27+
gpio-reserved-ranges = <7 1>;
28+
29+
gpio-line-names =
30+
"M0",
31+
"M1",
32+
"DEC0",
33+
"DEC1",
34+
"TOFF",
35+
"STP",
36+
"DIR";
37+
};
38+
};
39+
40+
/ {
41+
drv8424: drv8424 {
42+
status = "okay";
43+
compatible = "ti,drv8424";
44+
45+
dir-gpios = <&arduino_header 9 0>; /* D3 */
46+
step-gpios = <&arduino_header 10 0>; /* D4 */
47+
sleep-gpios = <&arduino_header 8 GPIO_ACTIVE_LOW>; /* D2 */
48+
en-gpios = <&arduino_header 11 0>; /* D5 */
49+
m0-gpios = <&mikroe_stepper_gpios 0 0>;
50+
m1-gpios = <&mikroe_stepper_gpios 1 0>;
51+
counter = <&pit0_channel0>;
52+
53+
#address-cells = <1>;
54+
#size-cells = <0>;
55+
#stepper-motor-cells = <0>;
56+
};
57+
};
58+
59+
&pit0_channel0 {
60+
status = "okay";
61+
};
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright (c) 2024 Navimatix GmbH
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/gpio/gpio.h>
7+
8+
/ {
9+
drv8424: drv8424 {
10+
status = "okay";
11+
compatible = "ti,drv8424";
12+
13+
14+
dir-gpios = <&gpio1 0 0>; /* D3 */
15+
step-gpios = <&gpio1 1 0>; /* D4 */
16+
sleep-gpios = <&gpio2 0 GPIO_ACTIVE_LOW>; /* D2 */
17+
en-gpios = <&gpio2 1 0>; /* 5 */
18+
m0-gpios = <&gpio3 0 0>;
19+
m1-gpios = <&gpio3 1 0>;
20+
counter = <&counter0>;
21+
22+
#address-cells = <1>;
23+
#size-cells = <0>;
24+
#stepper-motor-cells = <0>;
25+
};
26+
27+
gpio1: gpio1 {
28+
compatible = "zephyr,gpio-emul";
29+
#gpio-cells = <0x2>;
30+
status = "okay";
31+
gpio-controller;
32+
};
33+
34+
gpio2: gpio2 {
35+
compatible = "zephyr,gpio-emul";
36+
#gpio-cells = <0x2>;
37+
status = "okay";
38+
gpio-controller;
39+
};
40+
41+
gpio3: gpio3 {
42+
compatible = "zephyr,gpio-emul";
43+
#gpio-cells = <0x2>;
44+
status = "okay";
45+
gpio-controller;
46+
};
47+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2024 Navimatix GmbH
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/dt-bindings/gpio/gpio.h>
7+
8+
/ {
9+
zephyr,user {
10+
stepper-motors = <&drv8424 0>;
11+
};
12+
};
13+
14+
&i2c1 {
15+
status = "okay";
16+
17+
mikroe_stepper_gpios: mikroe_stepper_ctrl_tca9538a@70 {
18+
status = "okay";
19+
compatible = "ti,tca9538";
20+
21+
reg = <0x70>;
22+
23+
gpio-controller;
24+
ngpios = <8>;
25+
#gpio-cells = <2>;
26+
27+
gpio-reserved-ranges = <7 1>;
28+
29+
gpio-line-names =
30+
"M0",
31+
"M1",
32+
"DEC0",
33+
"DEC1",
34+
"TOFF",
35+
"STP",
36+
"DIR";
37+
};
38+
};
39+
40+
/ {
41+
drv8424: drv8424 {
42+
status = "okay";
43+
compatible = "ti,drv8424";
44+
45+
dir-gpios = <&arduino_header 18 0>; /* D12 */
46+
step-gpios = <&arduino_header 19 0>; /* D13 */
47+
sleep-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
48+
en-gpios = <&arduino_header 14 0>; /* D8 */
49+
m0-gpios = <&mikroe_stepper_gpios 0 0>;
50+
m1-gpios = <&mikroe_stepper_gpios 1 0>;
51+
counter = <&counter2>;
52+
53+
#address-cells = <1>;
54+
#size-cells = <0>;
55+
#stepper-motor-cells = <0>;
56+
};
57+
};
58+
59+
&timers2 {
60+
status = "okay";
61+
counter2: counter {
62+
status = "okay";
63+
};
64+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2024 Navimatix GmbH
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_ZTEST=y
5+
CONFIG_TEST=y
6+
CONFIG_TEST_USERSPACE=y
7+
CONFIG_LOG=y
8+
CONFIG_STEPPER_LOG_LEVEL_DBG=y
9+
CONFIG_STEPPER=y
10+
CONFIG_POLL=y
11+
CONFIG_I2C=y
12+
CONFIG_GPIO=y

0 commit comments

Comments
 (0)