mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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
This commit is contained in:
parent
a12936dca9
commit
3247335770
@ -6,11 +6,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#if SOC_MCPWM_SUPPORTED
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#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, /*!<Enable oneshot mode*/
|
||||
MCPWM_ONESHOT_MODE_EN, /*!<Disable oneshot mode*/
|
||||
} mcpwm_carrier_os_t;
|
||||
|
||||
/**
|
||||
* @brief MCPWM carrier output inversion, high frequency carrier signal active with MCPWM signal is high
|
||||
*/
|
||||
@ -138,7 +131,7 @@ typedef enum {
|
||||
MCPWM_SELECT_GPIO_SYNC2, /*!<Select GPIO SYNC2 as input*/
|
||||
} mcpwm_sync_signal_t;
|
||||
|
||||
// backward compatibility
|
||||
// backward compatibility
|
||||
#define MCPWM_SELCT_SYNC0 MCPWM_SELCT_GPIO_SYNC0
|
||||
#define MCPWM_SELCT_SYNC1 MCPWM_SELCT_GPIO_SYNC1
|
||||
#define MCPWM_SELCT_SYNC2 MCPWM_SELCT_GPIO_SYNC2
|
||||
@ -288,7 +281,6 @@ typedef struct {
|
||||
uint8_t carrier_period; /*!<Set carrier period = (carrier_period + 1)*800ns, carrier_period should be < 16*/
|
||||
uint8_t carrier_duty; /*!<Set carrier duty cycle, carrier_duty should be less than 8 (increment every 12.5%)*/
|
||||
uint8_t pulse_width_in_os; /*!<Set pulse width of first pulse in one shot mode = (carrier period)*(pulse_width_in_os + 1), should be less then 16*/
|
||||
mcpwm_carrier_os_t carrier_os_mode; /*!<Enable or disable carrier oneshot mode*/
|
||||
mcpwm_carrier_out_ivt_t carrier_ivt_mode; /*!<Invert output of carrier*/
|
||||
} mcpwm_carrier_config_t;
|
||||
|
||||
@ -449,14 +441,14 @@ esp_err_t mcpwm_set_duty_in_us(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,
|
||||
esp_err_t mcpwm_set_duty_type(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, mcpwm_generator_t gen, mcpwm_duty_type_t duty_type);
|
||||
|
||||
/**
|
||||
* @brief Get frequency of timer
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
*
|
||||
* @return
|
||||
* - frequency of timer
|
||||
*/
|
||||
* @brief Get frequency of timer
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
*
|
||||
* @return
|
||||
* - frequency of timer
|
||||
*/
|
||||
uint32_t mcpwm_get_frequency(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num);
|
||||
|
||||
/**
|
||||
@ -489,7 +481,7 @@ uint32_t mcpwm_get_duty_in_us(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, m
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
* @param gen set the operator(MCPWMXA/MCPWMXB), 'x' is timer number selected
|
||||
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -503,7 +495,7 @@ esp_err_t mcpwm_set_signal_high(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
* @param gen set the operator(MCPWMXA/MCPWMXB), 'x' is timer number selected
|
||||
|
||||
*
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
@ -549,15 +541,15 @@ esp_err_t mcpwm_stop(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num);
|
||||
esp_err_t mcpwm_carrier_init(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, const mcpwm_carrier_config_t *carrier_conf);
|
||||
|
||||
/**
|
||||
* @brief Enable MCPWM carrier submodule, for respective timer
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
* @brief Enable MCPWM carrier submodule, for respective timer
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t mcpwm_carrier_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num);
|
||||
|
||||
/**
|
||||
@ -603,6 +595,8 @@ esp_err_t mcpwm_carrier_set_duty_cycle(mcpwm_unit_t mcpwm_num, mcpwm_timer_t tim
|
||||
/**
|
||||
* @brief Enable and set width of first pulse in carrier oneshot mode
|
||||
*
|
||||
* @note The carrier oneshot pulse can't disabled.
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
* @param pulse_width set pulse width of first pulse in oneshot mode, width = (carrier period)*(pulse_width +1)
|
||||
@ -614,18 +608,6 @@ esp_err_t mcpwm_carrier_set_duty_cycle(mcpwm_unit_t mcpwm_num, mcpwm_timer_t tim
|
||||
*/
|
||||
esp_err_t mcpwm_carrier_oneshot_mode_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, uint8_t pulse_width);
|
||||
|
||||
/**
|
||||
* @brief Disable oneshot mode, width of first pulse = carrier period
|
||||
*
|
||||
* @param mcpwm_num set MCPWM unit(0-1)
|
||||
* @param timer_num set timer number(0-2) of MCPWM, each MCPWM unit has 3 timers
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t mcpwm_carrier_oneshot_mode_disable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable carrier output inversion
|
||||
*
|
||||
@ -847,5 +829,3 @@ esp_err_t mcpwm_sync_invert_gpio_synchro(mcpwm_unit_t mcpwm_num, mcpwm_sync_sign
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //SOC_MCPWM_SUPPORTED
|
||||
|
@ -530,11 +530,6 @@ esp_err_t mcpwm_carrier_oneshot_mode_enable(mcpwm_unit_t mcpwm_num, mcpwm_timer_
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t mcpwm_carrier_oneshot_mode_disable(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num)
|
||||
{
|
||||
return mcpwm_carrier_oneshot_mode_enable(mcpwm_num, timer_num, 0);
|
||||
}
|
||||
|
||||
esp_err_t mcpwm_carrier_output_invert(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num,
|
||||
mcpwm_carrier_out_ivt_t carrier_ivt_mode)
|
||||
{
|
||||
@ -558,11 +553,7 @@ esp_err_t mcpwm_carrier_init(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, co
|
||||
mcpwm_carrier_enable(mcpwm_num, timer_num);
|
||||
mcpwm_carrier_set_period(mcpwm_num, timer_num, carrier_conf->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);
|
||||
|
@ -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.
|
||||
|
@ -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 <stdio.h>
|
||||
#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"
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user