From 3247335770ea6d1003a208c0d1dd8c221f3602e2 Mon Sep 17 00:00:00 2001 From: morris Date: Sat, 28 May 2022 17:02:07 +0800 Subject: [PATCH] mcpwm: don't support disable carrier first pulse The first pulse of MCPWM carrier can not be disabled, this commit will remove the feature. Closes https://github.com/espressif/esp-idf/issues/8984 --- components/driver/include/driver/mcpwm.h | 72 +++++++------------ components/driver/mcpwm.c | 11 +-- docs/en/migration-guides/peripherals.rst | 17 ++--- .../mcpwm_bldc_hall_control_example_main.c | 14 ++-- .../main/mcpwm_capture_hc_sr04.c | 15 +--- .../main/mcpwm_sync_example.c | 22 ++---- tools/ci/check_copyright_ignore.txt | 3 - 7 files changed, 46 insertions(+), 108 deletions(-) diff --git a/components/driver/include/driver/mcpwm.h b/components/driver/include/driver/mcpwm.h index 7f900f78d4..0779076996 100644 --- a/components/driver/include/driver/mcpwm.h +++ b/components/driver/include/driver/mcpwm.h @@ -6,11 +6,12 @@ #pragma once -#include "soc/soc_caps.h" -#if SOC_MCPWM_SUPPORTED +#include +#include #include "esp_err.h" -#include "driver/gpio.h" +#include "esp_bit_defs.h" #include "esp_intr_alloc.h" +#include "soc/soc_caps.h" #include "hal/mcpwm_types.h" #ifdef __cplusplus @@ -100,14 +101,6 @@ typedef enum { #define MCPWM_OPR_MAX MCPWM_GEN_MAX ///< @deprecated typedef mcpwm_generator_t mcpwm_operator_t; ///< @deprecated -/** - * @brief MCPWM carrier oneshot mode, in this mode the width of the first pulse of carrier can be programmed - */ -typedef enum { - MCPWM_ONESHOT_MODE_DIS, /*!carrier_period); mcpwm_carrier_set_duty_cycle(mcpwm_num, timer_num, carrier_conf->carrier_duty); - if (carrier_conf->carrier_os_mode == MCPWM_ONESHOT_MODE_EN) { - mcpwm_carrier_oneshot_mode_enable(mcpwm_num, timer_num, carrier_conf->pulse_width_in_os); - } else { - mcpwm_carrier_oneshot_mode_disable(mcpwm_num, timer_num); - } + mcpwm_carrier_oneshot_mode_enable(mcpwm_num, timer_num, carrier_conf->pulse_width_in_os); mcpwm_carrier_output_invert(mcpwm_num, timer_num, carrier_conf->carrier_ivt_mode); mcpwm_critical_enter(mcpwm_num); diff --git a/docs/en/migration-guides/peripherals.rst b/docs/en/migration-guides/peripherals.rst index 19230105db..4b3c9a88ea 100644 --- a/docs/en/migration-guides/peripherals.rst +++ b/docs/en/migration-guides/peripherals.rst @@ -243,15 +243,8 @@ LCD MCPWM ----- - +---------------------------+---------------------------------------------------+-----------------------------------------------------------+ - | Removed/Deprecated items | Replacement | Remarks | - +===========================+===================================================+===========================================================+ - | ``mcpwm_capture_enable`` | :cpp:func:`mcpwm_capture_enable_channel` | Enable capture channel. | - +---------------------------+---------------------------------------------------+-----------------------------------------------------------+ - | ``mcpwm_capture_disable`` | :cpp:func:`mcpwm_capture_capture_disable_channel` | Disable capture channel. | - +---------------------------+---------------------------------------------------+-----------------------------------------------------------+ - | ``mcpwm_sync_enable`` | :cpp:func:`mcpwm_sync_configure` | Configure synchronization. | - +---------------------------+---------------------------------------------------+-----------------------------------------------------------+ - | ``mcpwm_isr_register`` | By registering event callbacks, e.g. | MCPWM interrupt handling is implemented by driver itself. | - | | :cpp:member:`mcpwm_capture_config_t::capture_cb` | | - +---------------------------+---------------------------------------------------+-----------------------------------------------------------+ + - ``mcpwm_capture_enable`` is removed. To enable capture channel, please use :cpp:func:`mcpwm_capture_enable_channel`. + - ``mcpwm_capture_disable`` is remove. To disable capture channel, please use :cpp:func:`mcpwm_capture_capture_disable_channel`. + - ``mcpwm_sync_enable`` is removed. To configure synchronization, please use :cpp:func:`mcpwm_sync_configure`. + - ``mcpwm_isr_register`` is removed. You can register event callbacks, for capture channels. e.g. :cpp:member:`mcpwm_capture_config_t::capture_cb`. + - ``mcpwm_carrier_oneshot_mode_disable`` is removed. Disable the first pulse (a.k.a the one-shot pulse) in the carrier is not supported by hardware. diff --git a/examples/peripherals/mcpwm/mcpwm_bldc_hall_control/main/mcpwm_bldc_hall_control_example_main.c b/examples/peripherals/mcpwm/mcpwm_bldc_hall_control/main/mcpwm_bldc_hall_control_example_main.c index 6acbbdbd17..6de0aee093 100644 --- a/examples/peripherals/mcpwm/mcpwm_bldc_hall_control/main/mcpwm_bldc_hall_control_example_main.c +++ b/examples/peripherals/mcpwm/mcpwm_bldc_hall_control/main/mcpwm_bldc_hall_control_example_main.c @@ -1,17 +1,15 @@ -/* MCPWM BLDC control with Hall sensor - - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ +/* + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/mcpwm.h" +#include "driver/gpio.h" #include "esp_timer.h" #include "esp_attr.h" #include "esp_log.h" diff --git a/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c b/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c index d79f422d1c..e7fefeb6d2 100644 --- a/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c +++ b/examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c @@ -1,25 +1,16 @@ -/* MCPWM capture example: HC-SR04 - - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ - /* - * This example will show you how to use capture function to read HC-SR04 sonar sensor. + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * - * HC_SR04_SAMPLE_PERIOD_MS should be at least 50ms + * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/queue.h" #include "esp_log.h" -#include "esp_check.h" #include "esp_private/esp_clk.h" #include "driver/mcpwm.h" +#include "driver/gpio.h" const static char *TAG = "hc-sr04"; diff --git a/examples/peripherals/mcpwm/mcpwm_sync_example/main/mcpwm_sync_example.c b/examples/peripherals/mcpwm/mcpwm_sync_example/main/mcpwm_sync_example.c index b1f17de8a2..bc7b6c30a1 100644 --- a/examples/peripherals/mcpwm/mcpwm_sync_example/main/mcpwm_sync_example.c +++ b/examples/peripherals/mcpwm/mcpwm_sync_example/main/mcpwm_sync_example.c @@ -1,28 +1,16 @@ -/* MCPWM sync example - - This example code is in the Public Domain (or CC0 licensed, at your option.) - - Unless required by applicable law or agreed to in writing, this - software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. -*/ - /* - * This example will show you how to use capture function to read HC-SR04 sonar sensor. + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "freertos/queue.h" -#include "esp_rom_gpio.h" -#include "soc/mcpwm_periph.h" -#include "hal/gpio_hal.h" #include "esp_log.h" -#include "esp_check.h" -#include "soc/rtc.h" #include "driver/mcpwm.h" +#include "driver/gpio.h" -const static char *TAG = "sync_example"; +const static char *TAG = "example"; #define TARGET_MCPWM_UNIT MCPWM_UNIT_0 #define TIMER0_OUTPUT_GPIO GPIO_NUM_16 diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 2b505b6d23..ee840f9ed4 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -1994,13 +1994,10 @@ examples/peripherals/i2s/i2s_audio_recorder_sdcard/main/i2s_recorder_main.c examples/peripherals/i2s/i2s_basic/main/i2s_example_main.c examples/peripherals/ledc/ledc_basic/main/ledc_basic_example_main.c examples/peripherals/ledc/ledc_fade/main/ledc_fade_example_main.c -examples/peripherals/mcpwm/mcpwm_bldc_hall_control/main/mcpwm_bldc_hall_control_example_main.c examples/peripherals/mcpwm/mcpwm_brushed_dc_control/main/cmd_mcpwm_motor.c examples/peripherals/mcpwm/mcpwm_brushed_dc_control/main/mcpwm_brushed_dc_control_example.c examples/peripherals/mcpwm/mcpwm_brushed_dc_control/main/mcpwm_brushed_dc_control_example.h -examples/peripherals/mcpwm/mcpwm_capture_hc_sr04/main/mcpwm_capture_hc_sr04.c examples/peripherals/mcpwm/mcpwm_servo_control/main/mcpwm_servo_control_example_main.c -examples/peripherals/mcpwm/mcpwm_sync_example/main/mcpwm_sync_example.c examples/peripherals/sdio/host/main/app_main.c examples/peripherals/sdio/sdio_test.py examples/peripherals/sdio/slave/main/app_main.c