From 776b92803d5f34b07b0154e01f69e0e6cd57ef8b Mon Sep 17 00:00:00 2001 From: wanlei Date: Mon, 9 Oct 2023 12:28:08 +0800 Subject: [PATCH] fix(mcpwm): foc example enable build on all supported target --- examples/peripherals/.build-test-rules.yml | 5 ++-- .../mcpwm/mcpwm_foc_svpwm_open_loop/README.md | 15 ++++++----- .../mcpwm_foc_svpwm_open_loop/main/app_main.c | 25 +++---------------- .../pytest_foc_open_loop.py | 3 --- 4 files changed, 15 insertions(+), 33 deletions(-) diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index d5bc6686d6..01c66bbe82 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -151,9 +151,10 @@ examples/peripherals/mcpwm/mcpwm_bldc_hall_control: examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop: disable: - if: SOC_MCPWM_SUPPORTED != 1 - - if: IDF_TARGET == "esp32p4" + disable_test: + - if: IDF_TARGET != "esp32s3" temporary: true - reason: not supported on p4 yet # TODO: IDF-8075 + reason: lack of runners examples/peripherals/parlio: disable: diff --git a/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/README.md b/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/README.md index 1be28172d0..983423720a 100644 --- a/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/README.md +++ b/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C6 | ESP32-H2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | # MCPWM FOC SVPWM Generation Open Loop Example @@ -29,10 +29,13 @@ These three-phase sine signals are generated at 50Hz by **open loop FOC**, pleas ### Hardware Required -1. An ESP board with MCPWM peripheral supported (e.g. ESP32-S3-Motor-DevKit) -2. A three-phase gate driver, for example, the [DRV8302](https://www.ti.com.cn/product/zh-cn/DRV8302) -3. Six N-MOSFETs, for example, the [IRF540NS](https://www.infineon.com/cms/en/product/power/mosfet/12v-300v-n-channel-power-mosfet/irf540ns/) -4. A USB cable for Power supply and programming +1. An **ESP32-S3-Motor-DevKit**, or independent circuit module follows: +1.1. Any ESP board with MCPWM peripheral supported (e.g. ESP32S3, ESP32C6, ESP32H2 ,,,) +1.2. A three-phase gate driver, for example, the [DRV8302](https://www.ti.com.cn/product/zh-cn/DRV8302) +1.3. Six N-MOSFETs, for example, the [IRF540NS](https://www.infineon.com/cms/en/product/power/mosfet/12v-300v-n-channel-power-mosfet/irf540ns/) +2. A USB cable for programming +3. A Power supply at least 9V +4. Any 3-phases load (e.g. PMSM, ACIM, or transformer) ### Connection Using only `delta/triangle` connect to the output. diff --git a/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/main/app_main.c b/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/main/app_main.c index e21301adf1..34fd5a3328 100644 --- a/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/main/app_main.c +++ b/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/main/app_main.c @@ -14,17 +14,9 @@ static const char *TAG = "example_foc"; -#if CONFIG_IDF_TARGET_ESP32 -#define EXAMPLE_FOC_DRV_EN_GPIO 4 -#define EXAMPLE_FOC_DRV_FAULT_GPIO 5 -#define EXAMPLE_FOC_PWM_UH_GPIO 12 -#define EXAMPLE_FOC_PWM_UL_GPIO 13 -#define EXAMPLE_FOC_PWM_VH_GPIO 14 -#define EXAMPLE_FOC_PWM_VL_GPIO 15 -#define EXAMPLE_FOC_PWM_WH_GPIO 16 -#define EXAMPLE_FOC_PWM_WL_GPIO 17 - -#elif CONFIG_IDF_TARGET_ESP32S3 +////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////// Please update the following configuration according to your HardWare spec ///////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////// #define EXAMPLE_FOC_DRV_EN_GPIO 46 #define EXAMPLE_FOC_DRV_FAULT_GPIO 10 #define EXAMPLE_FOC_PWM_UH_GPIO 47 @@ -34,17 +26,6 @@ static const char *TAG = "example_foc"; #define EXAMPLE_FOC_PWM_WH_GPIO 12 #define EXAMPLE_FOC_PWM_WL_GPIO 11 -#elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 -#define EXAMPLE_FOC_DRV_EN_GPIO 1 -#define EXAMPLE_FOC_DRV_FAULT_GPIO 2 -#define EXAMPLE_FOC_PWM_UH_GPIO 3 -#define EXAMPLE_FOC_PWM_UL_GPIO 4 -#define EXAMPLE_FOC_PWM_VH_GPIO 5 -#define EXAMPLE_FOC_PWM_VL_GPIO 10 -#define EXAMPLE_FOC_PWM_WH_GPIO 11 -#define EXAMPLE_FOC_PWM_WL_GPIO 13 -#endif - #define EXAMPLE_FOC_MCPWM_TIMER_RESOLUTION_HZ 10000000 // 10MHz, 1 tick = 0.1us #define EXAMPLE_FOC_MCPWM_PERIOD 1000 // 1000 * 0.1us = 100us, 10KHz diff --git a/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/pytest_foc_open_loop.py b/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/pytest_foc_open_loop.py index 1b8f901822..2e7735c8eb 100644 --- a/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/pytest_foc_open_loop.py +++ b/examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop/pytest_foc_open_loop.py @@ -5,10 +5,7 @@ import pytest from pytest_embedded import Dut -@pytest.mark.esp32 @pytest.mark.esp32s3 -@pytest.mark.esp32c6 -@pytest.mark.esp32h2 @pytest.mark.generic def test_open_foc(dut: Dut) -> None: dut.expect_exact('example_foc: Hello FOC')