Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: drivers: pwm: add PWM loopback test
Add test cases for the PWM capture API using PWM signal loopback. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
- Loading branch information
1 parent
54fed42
commit 90825a8
Showing
8 changed files
with
501 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.13.1) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(pwm_loopback) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright (c) 2020-2021 Vestas Wind Systems A/S | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <dt-bindings/pwm/pwm.h> | ||
|
||
/ { | ||
pwm_loopback_0 { | ||
compatible = "test,pwm_loopback"; | ||
pwms = <&ftm0 0 0 PWM_POLARITY_NORMAL>, /* PTC1, J1 pin 5 */ | ||
<&ftm3 4 0 PWM_POLARITY_NORMAL>; /* PTC8, J1 pin 7 */ | ||
}; | ||
}; |
22 changes: 22 additions & 0 deletions
22
tests/drivers/pwm/pwm_loopback/dts/bindings/test,pwm_loopback.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright (c) 2020-2021 Vestas Wind Systems A/S | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
description: | | ||
This binding provides resources required to build and run the | ||
tests/drivers/pwm/pwm_loopback test in Zephyr. | ||
compatible: "test,pwm_loopback" | ||
|
||
properties: | ||
pwms: | ||
type: phandle-array | ||
required: true | ||
description: | | ||
PWM pins that will be used for generating and capturing a pulse-width | ||
modulated signal. The pin at the first index will be used for signal | ||
generation while the pin at the second index will be used for capuring | ||
the generated signal. The two pins must be physically connected to | ||
each other. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CONFIG_ZTEST=y | ||
CONFIG_TEST_USERSPACE=y | ||
|
||
CONFIG_PWM=y | ||
CONFIG_PWM_CAPTURE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2020-2021 Vestas Wind Systems A/S | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr.h> | ||
#include <ztest.h> | ||
|
||
#include "test_pwm_loopback.h" | ||
|
||
void test_main(void) | ||
{ | ||
struct test_pwm in; | ||
struct test_pwm out; | ||
|
||
get_test_pwms(&in, &out); | ||
|
||
k_object_access_grant(out.dev, k_current_get()); | ||
k_object_access_grant(in.dev, k_current_get()); | ||
|
||
ztest_test_suite(pwm_loopback_test, | ||
ztest_user_unit_test(test_pulse_capture), | ||
ztest_user_unit_test(test_pulse_capture_inverted), | ||
ztest_user_unit_test(test_period_capture), | ||
ztest_user_unit_test(test_period_capture_inverted), | ||
ztest_user_unit_test(test_pulse_and_period_capture), | ||
ztest_user_unit_test(test_capture_timeout), | ||
ztest_unit_test(test_continuous_capture), | ||
ztest_unit_test(test_capture_busy)); | ||
ztest_run_test_suite(pwm_loopback_test); | ||
} |
Oops, something went wrong.