mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 21:24:32 +02:00
driver/mcpwm: fix the misleading of mcpwm_capture_enable parameters
closes https://github.com/espressif/esp-idf/issues/5032
This commit is contained in:
@@ -568,6 +568,7 @@ esp_err_t mcpwm_fault_deinit(mcpwm_unit_t mcpwm_num, mcpwm_fault_signal_t fault_
|
||||
* @param cap_edge set capture edge, BIT(0) - negative edge, BIT(1) - positive edge
|
||||
* @param cap_sig capture pin, which needs to be enabled
|
||||
* @param num_of_pulse count time between rising/falling edge between 2 *(pulses mentioned), counter uses APB_CLK
|
||||
* [0~MCPWM_LL_MAX_PRESCALE] (MCPWM_LL_MAX_PRESCALE = 255 on ESP32);
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Success
|
||||
|
@@ -49,6 +49,7 @@ static const char *MCPWM_TAG = "MCPWM";
|
||||
|
||||
#define MCPWM_DRIVER_INIT_ERROR "MCPWM DRIVER NOT INITIALIZED"
|
||||
#define MCPWM_GROUP_NUM_ERROR "MCPWM GROUP NUM ERROR"
|
||||
#define MCPWM_PRESCALE_ERROR "MCPWM PRESCALE ERROR"
|
||||
#define MCPWM_TIMER_ERROR "MCPWM TIMER NUM ERROR"
|
||||
#define MCPWM_CAPTURE_ERROR "MCPWM CAPTURE NUM ERROR"
|
||||
#define MCPWM_PARAM_ADDR_ERROR "MCPWM PARAM ADDR ERROR"
|
||||
@@ -531,6 +532,7 @@ esp_err_t mcpwm_capture_enable(mcpwm_unit_t mcpwm_num, mcpwm_capture_signal_t ca
|
||||
uint32_t num_of_pulse)
|
||||
{
|
||||
MCPWM_CHECK(mcpwm_num < SOC_MCPWM_GROUPS, MCPWM_GROUP_NUM_ERROR, ESP_ERR_INVALID_ARG);
|
||||
MCPWM_CHECK(num_of_pulse <= MCPWM_LL_MAX_PRESCALE, MCPWM_PRESCALE_ERROR, ESP_ERR_INVALID_ARG);
|
||||
// enable MCPWM module incase user don't use `mcpwm_init` at all
|
||||
periph_module_enable(mcpwm_periph_signals.groups[mcpwm_num].module);
|
||||
mcpwm_hal_init_config_t init_config = {
|
||||
|
@@ -36,7 +36,7 @@ extern "C" {
|
||||
|
||||
/// Get the address of peripheral registers
|
||||
#define MCPWM_LL_GET_HW(ID) (((ID)==0)? &MCPWM0: &MCPWM1)
|
||||
|
||||
#define MCPWM_LL_MAX_PRESCALE 255
|
||||
|
||||
/********************* Global *******************/
|
||||
/**
|
||||
|
@@ -36,7 +36,7 @@ extern "C" {
|
||||
|
||||
/// Get the address of peripheral registers
|
||||
#define MCPWM_LL_GET_HW(ID) (((ID)==0)? &MCPWM0: &MCPWM1)
|
||||
|
||||
#define MCPWM_LL_MAX_PRESCALE 255
|
||||
|
||||
/********************* Global *******************/
|
||||
/**
|
||||
|
Reference in New Issue
Block a user