Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/drivers/pwm/pwm_api/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
# SPDX-License-Identifier: Apache-2.0

mainmenu "PWM api test"

source "Kconfig.zephyr"

config ENABLE_TIMING_CHECK
bool "Enable PWM timing check with GPIO and systimer"
help
Enables timing checks on PWM signals by using a GPIO pin and interrupts
along with the system timer to automatically measure period and duty cycle.
Assumes the system timer is accurate and uses it as reference tick.

config ALLOWED_DEVIATION
int "Allowed deviation (%) for PWM timing checks"
default 5
range 0 100
help
Maximum allowed deviation (%) from the programmed values for the test to be
considered a PASS. For example, if set to 5, the measured period or duty cycle
can deviate by up to 5% from the programmed values for the test to pass.

config TEST_DELAY
int "Test delay duration (ms)"
default 1000
help
Sets delay duration in milliseconds for testing purposes.
It configures the delay period in between test cases.

This file was deleted.

This file was deleted.

18 changes: 18 additions & 0 deletions tests/drivers/pwm/pwm_api/dts/bindings/test-pwm-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
#
# SPDX-License-Identifier: Apache-2.0
#

description: |
This binding provides resources required to build and run the test
tests/drivers/pwm/pwm_api when CONFIG_ENABLE_TIMING_CHECK is enabled.

compatible: "test-pwm-api"

properties:
in-gpios:
type: phandle-array
required: true
description: |
GPIO to be used as input to check and validate PWM timing.
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
*/

#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>

/ {
aliases {
pwm-0 = &ledc0;
};

resources {
compatible = "test-pwm-api";
in-gpios = <&gpio0 2 ESP32_GPIO_PIN_OUT_EN>;
};
};

&pinctrl {
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO2>;
output-enable;
input-enable;
};
};
};
Expand Down
9 changes: 8 additions & 1 deletion tests/drivers/pwm/pwm_api/socs/esp32c2.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
*/

#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>

/ {
aliases {
pwm-0 = &ledc0;
};

resources {
compatible = "test-pwm-api";
in-gpios = <&gpio0 2 ESP32_GPIO_PIN_OUT_EN>;
};
};

&pinctrl {
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO2>;
output-enable;
input-enable;
};
};
};
Expand Down
9 changes: 8 additions & 1 deletion tests/drivers/pwm/pwm_api/socs/esp32c3.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
*/

#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>

/ {
aliases {
pwm-0 = &ledc0;
};

resources {
compatible = "test-pwm-api";
in-gpios = <&gpio0 2 ESP32_GPIO_PIN_OUT_EN>;
};
};

&pinctrl {
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO2>;
output-enable;
input-enable;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
*/

#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>

/ {
aliases {
pwm-0 = &ledc0;
};

resources {
compatible = "test-pwm-api";
in-gpios = <&gpio0 2 ESP32_GPIO_PIN_OUT_EN>;
};
};

&pinctrl {
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO2>;
output-enable;
input-enable;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
*/

#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>

/ {
aliases {
pwm-0 = &ledc0;
};

resources {
compatible = "test-pwm-api";
in-gpios = <&gpio0 2 ESP32_GPIO_PIN_OUT_EN>;
};
};

&pinctrl {
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO2>;
output-enable;
input-enable;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2023 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
*/

#include <zephyr/dt-bindings/pwm/pwm.h>
#include <zephyr/dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>

/ {
aliases {
pwm-0 = &ledc0;
};

resources {
compatible = "test-pwm-api";
in-gpios = <&gpio0 2 ESP32_GPIO_PIN_OUT_EN>;
};
};

&pinctrl {
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO2>;
output-enable;
input-enable;
};
};
};
Expand Down
Loading
Loading