feat(mcpwm): refactor mcpwm driver into a component

This commit is contained in:
morris 2023-10-30 10:59:17 +08:00
parent 92c4714128
commit eb5183f503
59 changed files with 167 additions and 143 deletions

View File

@ -15,7 +15,6 @@ set(includes "include"
"i2c/include" "i2c/include"
"i2s/include" "i2s/include"
"ledc/include" "ledc/include"
"mcpwm/include"
"parlio/include" "parlio/include"
"rmt/include" "rmt/include"
"sdio_slave/include" "sdio_slave/include"
@ -103,21 +102,9 @@ if(CONFIG_SOC_LEDC_SUPPORTED)
list(APPEND ldfragments "ledc/linker.lf") list(APPEND ldfragments "ledc/linker.lf")
endif() endif()
# MCPWM related source files # MCPWM legacy driver
if(CONFIG_SOC_MCPWM_SUPPORTED) if(CONFIG_SOC_MCPWM_SUPPORTED)
list(APPEND srcs "mcpwm/mcpwm_cap.c" list(APPEND srcs "deprecated/mcpwm_legacy.c")
"mcpwm/mcpwm_cmpr.c"
"mcpwm/mcpwm_com.c"
"mcpwm/mcpwm_fault.c"
"mcpwm/mcpwm_gen.c"
"mcpwm/mcpwm_oper.c"
"mcpwm/mcpwm_sync.c"
"mcpwm/mcpwm_timer.c"
"deprecated/mcpwm_legacy.c")
if(CONFIG_SOC_MCPWM_SUPPORT_ETM)
list(APPEND srcs "mcpwm/mcpwm_etm.c")
endif()
list(APPEND ldfragments "mcpwm/linker.lf")
endif() endif()
# PCNT legacy driver # PCNT legacy driver
@ -211,7 +198,7 @@ else()
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
# for backward compatibility, the driver component needs to # for backward compatibility, the driver component needs to
# have a public dependency on other "esp_driver_foo" components # have a public dependency on other "esp_driver_foo" components
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
LDFRAGMENTS ${ldfragments} LDFRAGMENTS ${ldfragments}
) )
endif() endif()

View File

@ -147,8 +147,6 @@ menu "Driver Configurations"
orsource "./rmt/Kconfig.rmt" orsource "./rmt/Kconfig.rmt"
orsource "./mcpwm/Kconfig.mcpwm"
menu "I2S Configuration" menu "I2S Configuration"
depends on SOC_I2S_SUPPORTED depends on SOC_I2S_SUPPORTED
config I2S_ISR_IRAM_SAFE config I2S_ISR_IRAM_SAFE

View File

@ -74,10 +74,14 @@ components/driver/test_apps/legacy_i2c_driver:
components/driver/test_apps/legacy_mcpwm_driver: components/driver/test_apps/legacy_mcpwm_driver:
disable: disable:
- if: SOC_MCPWM_SUPPORTED != 1 - if: SOC_MCPWM_SUPPORTED != 1
depends_filepatterns:
- components/driver/deprecated/**/*mcpwm*
components/driver/test_apps/legacy_pcnt_driver: components/driver/test_apps/legacy_pcnt_driver:
disable: disable:
- if: SOC_PCNT_SUPPORTED != 1 - if: SOC_PCNT_SUPPORTED != 1
depends_filepatterns:
- components/driver/deprecated/**/*pcnt*
components/driver/test_apps/legacy_rmt_driver: components/driver/test_apps/legacy_rmt_driver:
disable: disable:
@ -98,10 +102,8 @@ components/driver/test_apps/legacy_sigma_delta_driver:
components/driver/test_apps/legacy_timer_driver: components/driver/test_apps/legacy_timer_driver:
disable: disable:
- if: SOC_GPTIMER_SUPPORTED != 1 - if: SOC_GPTIMER_SUPPORTED != 1
depends_filepatterns:
components/driver/test_apps/mcpwm: - components/driver/deprecated/**/*timer*
disable:
- if: SOC_MCPWM_SUPPORTED != 1
components/driver/test_apps/parlio: components/driver/test_apps/parlio:
disable: disable:

View File

@ -8,5 +8,5 @@ endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver PRIV_REQUIRES unity esp_driver_gptimer
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@ -0,0 +1,21 @@
set(srcs)
set(public_include "include")
if(CONFIG_SOC_MCPWM_SUPPORTED)
list(APPEND srcs "src/mcpwm_cap.c"
"src/mcpwm_cmpr.c"
"src/mcpwm_com.c"
"src/mcpwm_fault.c"
"src/mcpwm_gen.c"
"src/mcpwm_oper.c"
"src/mcpwm_sync.c"
"src/mcpwm_timer.c")
if(CONFIG_SOC_MCPWM_SUPPORT_ETM)
list(APPEND srcs "src/mcpwm_etm.c")
endif()
endif()
idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${public_include}
PRIV_REQUIRES "esp_pm" "esp_driver_gpio"
LDFRAGMENTS "linker.lf"
)

View File

@ -1,4 +1,4 @@
menu "MCPWM Configuration" menu "ESP-Driver:MCPWM Configurations"
depends on SOC_MCPWM_SUPPORTED depends on SOC_MCPWM_SUPPORTED
config MCPWM_ISR_IRAM_SAFE config MCPWM_ISR_IRAM_SAFE
bool "Place MCPWM ISR function into IRAM" bool "Place MCPWM ISR function into IRAM"
@ -30,4 +30,4 @@ menu "MCPWM Configuration"
help help
Wether to enable the debug log message for MCPWM driver. Wether to enable the debug log message for MCPWM driver.
Note that, this option only controls the MCPWM driver log, won't affect other drivers. Note that, this option only controls the MCPWM driver log, won't affect other drivers.
endmenu # MCPWM Configuration endmenu

View File

@ -1,5 +1,5 @@
[mapping:mcpwm_driver] [mapping:mcpwm_driver]
archive: libdriver.a archive: libesp_driver_mcpwm.a
entries: entries:
if MCPWM_CTRL_FUNC_IN_IRAM = y: if MCPWM_CTRL_FUNC_IN_IRAM = y:
mcpwm_cmpr: mcpwm_comparator_set_compare_value (noflash) mcpwm_cmpr: mcpwm_comparator_set_compare_value (noflash)

View File

@ -392,8 +392,8 @@ esp_err_t mcpwm_capture_channel_register_event_callbacks(mcpwm_cap_channel_handl
int isr_flags = MCPWM_INTR_ALLOC_FLAG; int isr_flags = MCPWM_INTR_ALLOC_FLAG;
isr_flags |= mcpwm_get_intr_priority_flag(group); isr_flags |= mcpwm_get_intr_priority_flag(group);
ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags,
(uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_CAPTURE(cap_chan_id), (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_CAPTURE(cap_chan_id),
mcpwm_capture_default_isr, cap_channel, &cap_channel->intr), TAG, "install interrupt service for cap channel failed"); mcpwm_capture_default_isr, cap_channel, &cap_channel->intr), TAG, "install interrupt service for cap channel failed");
} }
portENTER_CRITICAL(&group->spinlock); portENTER_CRITICAL(&group->spinlock);

View File

@ -255,8 +255,8 @@ esp_err_t mcpwm_comparator_register_event_callbacks(mcpwm_cmpr_handle_t cmpr, co
int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ ESP_INTR_FLAG_INTRDISABLED; int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ ESP_INTR_FLAG_INTRDISABLED;
isr_flags |= mcpwm_get_intr_priority_flag(group); isr_flags |= mcpwm_get_intr_priority_flag(group);
ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags,
(uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_CMP_EQUAL(oper_id, cmpr_id), (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_CMP_EQUAL(oper_id, cmpr_id),
mcpwm_comparator_default_isr, oper_cmpr, &oper_cmpr->intr), TAG, "install interrupt service for comparator failed"); mcpwm_comparator_default_isr, oper_cmpr, &oper_cmpr->intr), TAG, "install interrupt service for comparator failed");
} }
portENTER_CRITICAL(&group->spinlock); portENTER_CRITICAL(&group->spinlock);

View File

@ -255,8 +255,8 @@ esp_err_t mcpwm_fault_register_event_callbacks(mcpwm_fault_handle_t fault, const
int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ESP_INTR_FLAG_INTRDISABLED; int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ESP_INTR_FLAG_INTRDISABLED;
isr_flags |= mcpwm_get_intr_priority_flag(group); isr_flags |= mcpwm_get_intr_priority_flag(group);
ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags,
(uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_FAULT_MASK(fault_id), (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_FAULT_MASK(fault_id),
mcpwm_gpio_fault_default_isr, gpio_fault, &gpio_fault->intr), TAG, "install interrupt service for gpio fault failed"); mcpwm_gpio_fault_default_isr, gpio_fault, &gpio_fault->intr), TAG, "install interrupt service for gpio fault failed");
} }
// different mcpwm events share the same interrupt control register // different mcpwm events share the same interrupt control register

View File

@ -167,7 +167,7 @@ esp_err_t mcpwm_generator_set_action_on_timer_event(mcpwm_gen_handle_t gen, mcpw
ESP_RETURN_ON_FALSE(false, ESP_ERR_INVALID_ARG, TAG, "UTEP and DTEZ can't be reached under MCPWM_TIMER_COUNT_MODE_UP_DOWN mode"); ESP_RETURN_ON_FALSE(false, ESP_ERR_INVALID_ARG, TAG, "UTEP and DTEZ can't be reached under MCPWM_TIMER_COUNT_MODE_UP_DOWN mode");
} }
mcpwm_ll_generator_set_action_on_timer_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_timer_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act.direction, ev_act.event, ev_act.action); ev_act.direction, ev_act.event, ev_act.action);
return ESP_OK; return ESP_OK;
} }
@ -195,7 +195,7 @@ esp_err_t mcpwm_generator_set_actions_on_timer_event(mcpwm_gen_handle_t gen, mcp
ESP_RETURN_ON_FALSE(false, ESP_ERR_INVALID_ARG, TAG, "UTEP and DTEZ can't be reached under MCPWM_TIMER_COUNT_MODE_UP_DOWN mode"); ESP_RETURN_ON_FALSE(false, ESP_ERR_INVALID_ARG, TAG, "UTEP and DTEZ can't be reached under MCPWM_TIMER_COUNT_MODE_UP_DOWN mode");
} }
mcpwm_ll_generator_set_action_on_timer_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_timer_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act_itor.direction, ev_act_itor.event, ev_act_itor.action); ev_act_itor.direction, ev_act_itor.event, ev_act_itor.action);
ev_act_itor = va_arg(it, mcpwm_gen_timer_event_action_t); ev_act_itor = va_arg(it, mcpwm_gen_timer_event_action_t);
} }
va_end(it); va_end(it);
@ -209,7 +209,7 @@ esp_err_t mcpwm_generator_set_action_on_compare_event(mcpwm_gen_handle_t gen, mc
mcpwm_oper_t *oper = gen->oper; mcpwm_oper_t *oper = gen->oper;
mcpwm_group_t *group = oper->group; mcpwm_group_t *group = oper->group;
mcpwm_ll_generator_set_action_on_compare_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_compare_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act.direction, ev_act.comparator->cmpr_id, ev_act.action); ev_act.direction, ev_act.comparator->cmpr_id, ev_act.action);
return ESP_OK; return ESP_OK;
} }
@ -223,7 +223,7 @@ esp_err_t mcpwm_generator_set_actions_on_compare_event(mcpwm_gen_handle_t gen, m
va_start(it, ev_act); va_start(it, ev_act);
while (ev_act_itor.comparator) { while (ev_act_itor.comparator) {
mcpwm_ll_generator_set_action_on_compare_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_compare_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act_itor.direction, ev_act_itor.comparator->cmpr_id, ev_act_itor.action); ev_act_itor.direction, ev_act_itor.comparator->cmpr_id, ev_act_itor.action);
ev_act_itor = va_arg(it, mcpwm_gen_compare_event_action_t); ev_act_itor = va_arg(it, mcpwm_gen_compare_event_action_t);
} }
va_end(it); va_end(it);
@ -237,7 +237,7 @@ esp_err_t mcpwm_generator_set_action_on_brake_event(mcpwm_gen_handle_t gen, mcpw
mcpwm_oper_t *oper = gen->oper; mcpwm_oper_t *oper = gen->oper;
mcpwm_group_t *group = oper->group; mcpwm_group_t *group = oper->group;
mcpwm_ll_generator_set_action_on_brake_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_brake_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act.direction, ev_act.brake_mode, ev_act.action); ev_act.direction, ev_act.brake_mode, ev_act.action);
return ESP_OK; return ESP_OK;
} }
@ -251,7 +251,7 @@ esp_err_t mcpwm_generator_set_actions_on_brake_event(mcpwm_gen_handle_t gen, mcp
va_start(it, ev_act); va_start(it, ev_act);
while (ev_act_itor.brake_mode != MCPWM_OPER_BRAKE_MODE_INVALID) { while (ev_act_itor.brake_mode != MCPWM_OPER_BRAKE_MODE_INVALID) {
mcpwm_ll_generator_set_action_on_brake_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_brake_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act_itor.direction, ev_act_itor.brake_mode, ev_act_itor.action); ev_act_itor.direction, ev_act_itor.brake_mode, ev_act_itor.action);
ev_act_itor = va_arg(it, mcpwm_gen_brake_event_action_t); ev_act_itor = va_arg(it, mcpwm_gen_brake_event_action_t);
} }
va_end(it); va_end(it);
@ -280,7 +280,7 @@ esp_err_t mcpwm_generator_set_action_on_fault_event(mcpwm_gen_handle_t gen, mcpw
mcpwm_gpio_fault_t *gpio_fault = __containerof(fault, mcpwm_gpio_fault_t, base); mcpwm_gpio_fault_t *gpio_fault = __containerof(fault, mcpwm_gpio_fault_t, base);
mcpwm_ll_operator_set_trigger_from_gpio_fault(group->hal.dev, oper->oper_id, trigger_id, gpio_fault->fault_id); mcpwm_ll_operator_set_trigger_from_gpio_fault(group->hal.dev, oper->oper_id, trigger_id, gpio_fault->fault_id);
mcpwm_ll_generator_set_action_on_trigger_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_trigger_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act.direction, trigger_id, ev_act.action); ev_act.direction, trigger_id, ev_act.action);
return ESP_OK; return ESP_OK;
} }
@ -308,7 +308,7 @@ esp_err_t mcpwm_generator_set_action_on_sync_event(mcpwm_gen_handle_t gen, mcpwm
ESP_RETURN_ON_FALSE(trigger_id >= 0, ESP_ERR_NOT_FOUND, TAG, "no free trigger in operator (%d,%d)", group->group_id, oper->oper_id); ESP_RETURN_ON_FALSE(trigger_id >= 0, ESP_ERR_NOT_FOUND, TAG, "no free trigger in operator (%d,%d)", group->group_id, oper->oper_id);
mcpwm_ll_operator_set_trigger_from_sync(group->hal.dev, oper->oper_id, trigger_id); mcpwm_ll_operator_set_trigger_from_sync(group->hal.dev, oper->oper_id, trigger_id);
mcpwm_ll_generator_set_action_on_trigger_event(group->hal.dev, oper->oper_id, gen->gen_id, mcpwm_ll_generator_set_action_on_trigger_event(group->hal.dev, oper->oper_id, gen->gen_id,
ev_act.direction, trigger_id, ev_act.action); ev_act.direction, trigger_id, ev_act.action);
return ESP_OK; return ESP_OK;
} }

View File

@ -258,8 +258,8 @@ esp_err_t mcpwm_operator_register_event_callbacks(mcpwm_oper_handle_t oper, cons
int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ ESP_INTR_FLAG_INTRDISABLED; int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ ESP_INTR_FLAG_INTRDISABLED;
isr_flags |= mcpwm_get_intr_priority_flag(group); isr_flags |= mcpwm_get_intr_priority_flag(group);
ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags,
(uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_OPER_MASK(oper_id), (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_OPER_MASK(oper_id),
mcpwm_operator_default_isr, oper, &oper->intr), TAG, "install interrupt service for operator failed"); mcpwm_operator_default_isr, oper, &oper->intr), TAG, "install interrupt service for operator failed");
} }
// enable/disable interrupt events // enable/disable interrupt events

View File

@ -0,0 +1,7 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
components/esp_driver_mcpwm/test_apps/mcpwm:
disable:
- if: SOC_MCPWM_SUPPORTED != 1
depends_components:
- esp_driver_mcpwm

View File

@ -10,7 +10,7 @@ project(mcpwm_test)
if(CONFIG_COMPILER_DUMP_RTL_FILES) if(CONFIG_COMPILER_DUMP_RTL_FILES)
add_custom_target(check_test_app_sections ALL add_custom_target(check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/ --rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_mcpwm/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--elf-file ${CMAKE_BINARY_DIR}/mcpwm_test.elf --elf-file ${CMAKE_BINARY_DIR}/mcpwm_test.elf
find-refs find-refs
--from-sections=.iram0.text --from-sections=.iram0.text

View File

@ -16,5 +16,5 @@ endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver PRIV_REQUIRES unity esp_driver_mcpwm esp_driver_gpio
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@ -163,7 +163,6 @@ TEST_CASE("mcpwm_group_set_prescale_dynamically", "[mcpwm]")
carrier_config.first_pulse_duration_us = 5; carrier_config.first_pulse_duration_us = 5;
TEST_ESP_OK(mcpwm_operator_apply_carrier(oper, &carrier_config)); TEST_ESP_OK(mcpwm_operator_apply_carrier(oper, &carrier_config));
TEST_ESP_OK(mcpwm_del_generator(generator)); TEST_ESP_OK(mcpwm_del_generator(generator));
TEST_ESP_OK(mcpwm_del_operator(oper)); TEST_ESP_OK(mcpwm_del_operator(oper));
TEST_ESP_OK(mcpwm_del_timer(timer)); TEST_ESP_OK(mcpwm_del_timer(timer));

View File

@ -170,7 +170,7 @@ TEST_CASE("mcpwm_generator_force_level_recovery", "[mcpwm]")
TEST_ESP_OK(mcpwm_generator_set_force_level(generator, 0, false)); TEST_ESP_OK(mcpwm_generator_set_force_level(generator, 0, false));
TEST_ASSERT_EQUAL(0, gpio_get_level(gen_gpio)); TEST_ASSERT_EQUAL(0, gpio_get_level(gen_gpio));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(generator, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(generator,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
// generator should output high level on tez event, the previous force level should disappear // generator should output high level on tez event, the previous force level should disappear
TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP)); TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP));
vTaskDelay(pdMS_TO_TICKS(200)); vTaskDelay(pdMS_TO_TICKS(200));
@ -181,7 +181,7 @@ TEST_CASE("mcpwm_generator_force_level_recovery", "[mcpwm]")
TEST_ESP_OK(mcpwm_generator_set_force_level(generator, 1, false)); TEST_ESP_OK(mcpwm_generator_set_force_level(generator, 1, false));
TEST_ASSERT_EQUAL(1, gpio_get_level(gen_gpio)); TEST_ASSERT_EQUAL(1, gpio_get_level(gen_gpio));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(generator, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(generator,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW)));
// generator should output low level on tez event, the previous force level should disappear // generator should output low level on tez event, the previous force level should disappear
TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP)); TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP));
vTaskDelay(pdMS_TO_TICKS(200)); vTaskDelay(pdMS_TO_TICKS(200));
@ -230,9 +230,9 @@ TEST_CASE("mcpwm_generator_action_on_timer_event", "[mcpwm]")
printf("set generator to output high on timer full\r\n"); printf("set generator to output high on timer full\r\n");
TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(gen, TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(gen,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_KEEP), MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_KEEP),
MCPWM_GEN_TIMER_EVENT_ACTION_END())); MCPWM_GEN_TIMER_EVENT_ACTION_END()));
printf("start timer\r\n"); printf("start timer\r\n");
TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP)); TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP));
vTaskDelay(pdMS_TO_TICKS(100)); vTaskDelay(pdMS_TO_TICKS(100));
@ -242,9 +242,9 @@ TEST_CASE("mcpwm_generator_action_on_timer_event", "[mcpwm]")
printf("set generator to output low on timer full\r\n"); printf("set generator to output low on timer full\r\n");
TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(gen, TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(gen,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_KEEP), MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_KEEP),
MCPWM_GEN_TIMER_EVENT_ACTION_END())); MCPWM_GEN_TIMER_EVENT_ACTION_END()));
printf("start timer\r\n"); printf("start timer\r\n");
TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP)); TEST_ESP_OK(mcpwm_timer_start_stop(timer, MCPWM_TIMER_START_NO_STOP));
vTaskDelay(pdMS_TO_TICKS(100)); vTaskDelay(pdMS_TO_TICKS(100));
@ -262,7 +262,7 @@ TEST_CASE("mcpwm_generator_action_on_timer_event", "[mcpwm]")
typedef void (*set_gen_actions_cb_t)(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb); typedef void (*set_gen_actions_cb_t)(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb);
static void mcpwm_gen_action_test_template(uint32_t timer_resolution, uint32_t period, mcpwm_timer_count_mode_t count_mode, static void mcpwm_gen_action_test_template(uint32_t timer_resolution, uint32_t period, mcpwm_timer_count_mode_t count_mode,
uint32_t cmpa, uint32_t cmpb, int gpioa, int gpiob, set_gen_actions_cb_t set_generator_actions) uint32_t cmpa, uint32_t cmpb, int gpioa, int gpiob, set_gen_actions_cb_t set_generator_actions)
{ {
mcpwm_timer_config_t timer_config = { mcpwm_timer_config_t timer_config = {
.group_id = 0, .group_id = 0,
@ -321,72 +321,72 @@ static void mcpwm_gen_action_test_template(uint32_t timer_resolution, uint32_t p
static void single_edge_active_high(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void single_edge_active_high(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW)));
} }
static void single_edge_active_low(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void single_edge_active_low(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_HIGH)));
} }
static void pulse_placement(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void pulse_placement(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_COMPARE_EVENT_ACTION_END())); MCPWM_GEN_COMPARE_EVENT_ACTION_END()));
TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(genb, TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(genb,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_TOGGLE), MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_TOGGLE),
MCPWM_GEN_TIMER_EVENT_ACTION_END())); MCPWM_GEN_TIMER_EVENT_ACTION_END()));
} }
static void dual_edge_active_low_asym(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void dual_edge_active_low_asym(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpb, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpb, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_COMPARE_EVENT_ACTION_END())); MCPWM_GEN_COMPARE_EVENT_ACTION_END()));
TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(genb, TEST_ESP_OK(mcpwm_generator_set_actions_on_timer_event(genb,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, MCPWM_TIMER_EVENT_FULL, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_TIMER_EVENT_ACTION_END())); MCPWM_GEN_TIMER_EVENT_ACTION_END()));
} }
static void dual_edge_active_low_sym(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void dual_edge_active_low_sym(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpa, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpa, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_COMPARE_EVENT_ACTION_END())); MCPWM_GEN_COMPARE_EVENT_ACTION_END()));
TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(genb, TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(genb,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpb, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpb, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_COMPARE_EVENT_ACTION_END())); MCPWM_GEN_COMPARE_EVENT_ACTION_END()));
} }
static void dual_edge_complementary(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void dual_edge_complementary(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpa, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpa, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_COMPARE_EVENT_ACTION_END())); MCPWM_GEN_COMPARE_EVENT_ACTION_END()));
TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(genb, TEST_ESP_OK(mcpwm_generator_set_actions_on_compare_event(genb,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW),
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpb, MCPWM_GEN_ACTION_HIGH), MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_DOWN, cmpb, MCPWM_GEN_ACTION_HIGH),
MCPWM_GEN_COMPARE_EVENT_ACTION_END())); MCPWM_GEN_COMPARE_EVENT_ACTION_END()));
} }
TEST_CASE("mcpwm_generator_action_on_compare_event", "[mcpwm]") TEST_CASE("mcpwm_generator_action_on_compare_event", "[mcpwm]")
@ -425,7 +425,7 @@ TEST_CASE("mcpwm_generator_action_on_compare_event", "[mcpwm]")
typedef void (*set_dead_time_cb_t)(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb); typedef void (*set_dead_time_cb_t)(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb);
static void mcpwm_deadtime_test_template(uint32_t timer_resolution, uint32_t period, uint32_t cmpa, uint32_t cmpb, int gpioa, int gpiob, static void mcpwm_deadtime_test_template(uint32_t timer_resolution, uint32_t period, uint32_t cmpa, uint32_t cmpb, int gpioa, int gpiob,
set_gen_actions_cb_t set_generator_actions, set_dead_time_cb_t set_dead_time) set_gen_actions_cb_t set_generator_actions, set_dead_time_cb_t set_dead_time)
{ {
mcpwm_timer_config_t timer_config = { mcpwm_timer_config_t timer_config = {
.group_id = 0, .group_id = 0,
@ -485,9 +485,9 @@ static void mcpwm_deadtime_test_template(uint32_t timer_resolution, uint32_t per
static void ahc_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void ahc_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
} }
static void ahc_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb) static void ahc_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
@ -506,9 +506,9 @@ static void ahc_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
static void alc_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void alc_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
} }
static void alc_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb) static void alc_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
@ -528,9 +528,9 @@ static void alc_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
static void ah_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void ah_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
} }
static void ah_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb) static void ah_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
@ -548,9 +548,9 @@ static void ah_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
static void al_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void al_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
} }
static void al_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb) static void al_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
@ -569,13 +569,13 @@ static void al_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
static void reda_only_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void reda_only_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW)));
} }
static void reda_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb) static void reda_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
@ -594,13 +594,13 @@ static void reda_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t
static void fedb_only_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void fedb_only_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW)));
} }
static void fedb_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb) static void fedb_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
@ -620,13 +620,13 @@ static void fedb_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t
static void redfedb_only_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb) static void redfedb_only_set_generator_actions(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb, mcpwm_cmpr_handle_t cmpa, mcpwm_cmpr_handle_t cmpb)
{ {
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gena,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gena,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpa, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(genb,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(genb,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, cmpb, MCPWM_GEN_ACTION_LOW)));
} }
static void redfedb_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb) static void redfedb_only_set_dead_time(mcpwm_gen_handle_t gena, mcpwm_gen_handle_t genb)
@ -727,9 +727,9 @@ TEST_CASE("mcpwm_duty_empty_full", "[mcpwm]")
printf("set generator actions on timer and compare events\r\n"); printf("set generator actions on timer and compare events\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gen,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, comparator, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, comparator, MCPWM_GEN_ACTION_LOW)));
printf("start timer\r\n"); printf("start timer\r\n");
TEST_ESP_OK(mcpwm_timer_enable(timer)); TEST_ESP_OK(mcpwm_timer_enable(timer));
@ -800,12 +800,12 @@ TEST_CASE("mcpwm_generator_action_on_fault_trigger_event", "[mcpwm]")
printf("set generator to output high on trigger0 and low on trigger1\r\n"); printf("set generator to output high on trigger0 and low on trigger1\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_fault_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_fault_event(gen,
MCPWM_GEN_FAULT_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_faults[0], MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_FAULT_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_faults[0], MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_fault_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_fault_event(gen,
MCPWM_GEN_FAULT_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_faults[1], MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_FAULT_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_faults[1], MCPWM_GEN_ACTION_LOW)));
// no free trigger // no free trigger
TEST_ESP_ERR(ESP_ERR_NOT_FOUND, mcpwm_generator_set_action_on_fault_event(gen, TEST_ESP_ERR(ESP_ERR_NOT_FOUND, mcpwm_generator_set_action_on_fault_event(gen,
MCPWM_GEN_FAULT_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_faults[2], MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_FAULT_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_faults[2], MCPWM_GEN_ACTION_LOW)));
TEST_ASSERT_EQUAL(0, gpio_get_level(generator_gpio)); TEST_ASSERT_EQUAL(0, gpio_get_level(generator_gpio));
gpio_set_level(fault_gpio_num[0], 1); gpio_set_level(fault_gpio_num[0], 1);
@ -872,13 +872,13 @@ TEST_CASE("mcpwm_generator_action_on_soft_sync_trigger_event", "[mcpwm]")
printf("set generator to output high on soft sync trigger\r\n"); printf("set generator to output high on soft sync trigger\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_sync_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_sync_event(gen,
MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, soft_sync, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, soft_sync, MCPWM_GEN_ACTION_HIGH)));
//more than 1 sync is not supported //more than 1 sync is not supported
mcpwm_sync_handle_t invalid_soft_sync = NULL; mcpwm_sync_handle_t invalid_soft_sync = NULL;
TEST_ESP_OK(mcpwm_new_soft_sync_src(&soft_sync_config, &invalid_soft_sync)); TEST_ESP_OK(mcpwm_new_soft_sync_src(&soft_sync_config, &invalid_soft_sync));
TEST_ESP_ERR(ESP_ERR_INVALID_STATE, mcpwm_generator_set_action_on_sync_event(gen, TEST_ESP_ERR(ESP_ERR_INVALID_STATE, mcpwm_generator_set_action_on_sync_event(gen,
MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, invalid_soft_sync, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, invalid_soft_sync, MCPWM_GEN_ACTION_LOW)));
TEST_ASSERT_EQUAL(0, gpio_get_level(generator_gpio)); TEST_ASSERT_EQUAL(0, gpio_get_level(generator_gpio));
mcpwm_soft_sync_activate(soft_sync); mcpwm_soft_sync_activate(soft_sync);
@ -941,7 +941,7 @@ TEST_CASE("mcpwm_generator_action_on_timer_sync_trigger_event", "[mcpwm]")
printf("set generator to output high on timer sync trigger\r\n"); printf("set generator to output high on timer sync trigger\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_sync_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_sync_event(gen,
MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, timer_sync, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, timer_sync, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_timer_enable(timer)); TEST_ESP_OK(mcpwm_timer_enable(timer));
@ -1011,7 +1011,7 @@ TEST_CASE("mcpwm_generator_action_on_gpio_sync_trigger_event", "[mcpwm]")
printf("set generator to output high on gpio sync trigger\r\n"); printf("set generator to output high on gpio sync trigger\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_sync_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_sync_event(gen,
MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_sync, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_SYNC_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, gpio_sync, MCPWM_GEN_ACTION_HIGH)));
TEST_ASSERT_EQUAL(0, gpio_get_level(generator_gpio)); TEST_ASSERT_EQUAL(0, gpio_get_level(generator_gpio));
gpio_set_level(gpio_sync_config.gpio_num, 1); gpio_set_level(gpio_sync_config.gpio_num, 1);

View File

@ -146,9 +146,9 @@ TEST_CASE("mcpwm_comparator_iram_safe", "[mcpwm]")
printf("set generator actions on timer and compare events\r\n"); printf("set generator actions on timer and compare events\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gen, TEST_ESP_OK(mcpwm_generator_set_action_on_compare_event(gen,
MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, comparator, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_COMPARE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, comparator, MCPWM_GEN_ACTION_LOW)));
printf("register compare event callback\r\n"); printf("register compare event callback\r\n");
mcpwm_comparator_event_callbacks_t cbs = { mcpwm_comparator_event_callbacks_t cbs = {

View File

@ -193,15 +193,15 @@ TEST_CASE("mcpwm_operator_brake_on_gpio_fault", "[mcpwm]")
printf("set generator actions on timer event\r\n"); printf("set generator actions on timer event\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_a, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_a,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_b, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_b,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW)));
printf("set generator actions on brake event\r\n"); printf("set generator actions on brake event\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_a, TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_a,
MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_CBC, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_CBC, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_b, TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_b,
MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_OST, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_OST, MCPWM_GEN_ACTION_HIGH)));
printf("enable and start timer\r\n"); printf("enable and start timer\r\n");
TEST_ESP_OK(mcpwm_timer_enable(timer)); TEST_ESP_OK(mcpwm_timer_enable(timer));
@ -299,15 +299,15 @@ TEST_CASE("mcpwm_operator_brake_on_soft_fault", "[mcpwm]")
printf("set generator actions on timer event\r\n"); printf("set generator actions on timer event\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_a, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_a,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW)));
TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_b, TEST_ESP_OK(mcpwm_generator_set_action_on_timer_event(gen_b,
MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW))); MCPWM_GEN_TIMER_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_TIMER_EVENT_EMPTY, MCPWM_GEN_ACTION_LOW)));
printf("set generator actions on brake event\r\n"); printf("set generator actions on brake event\r\n");
TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_a, TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_a,
MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_CBC, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_CBC, MCPWM_GEN_ACTION_HIGH)));
TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_b, TEST_ESP_OK(mcpwm_generator_set_action_on_brake_event(gen_b,
MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_OST, MCPWM_GEN_ACTION_HIGH))); MCPWM_GEN_BRAKE_EVENT_ACTION(MCPWM_TIMER_DIRECTION_UP, MCPWM_OPER_BRAKE_MODE_OST, MCPWM_GEN_ACTION_HIGH)));
printf("enable and start timer\r\n"); printf("enable and start timer\r\n");
TEST_ESP_OK(mcpwm_timer_enable(timer)); TEST_ESP_OK(mcpwm_timer_enable(timer));

View File

@ -9,6 +9,5 @@ endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity esp_driver_pcnt spi_flash PRIV_REQUIRES unity esp_driver_pcnt esp_driver_gpio spi_flash
driver # will be replaced by esp_driver_gpio
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@ -16,8 +16,9 @@ components/esp_hw_support/test_apps/etm:
depends_components: depends_components:
- esp_driver_gptimer - esp_driver_gptimer
- esp_driver_gpio - esp_driver_gpio
- esp_driver_mcpwm
- esp_timer - esp_timer
- driver # TODO: replace with esp_driver_mcpwm, esp_driver_ana_cmpr - driver # TODO: replace with esp_driver_ana_cmpr (IDF-8521)
components/esp_hw_support/test_apps/host_test_linux: components/esp_hw_support/test_apps/host_test_linux:
enable: enable:

View File

@ -29,6 +29,6 @@ endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity esp_timer esp_driver_gptimer esp_driver_gpio PRIV_REQUIRES unity esp_timer esp_driver_gptimer esp_driver_gpio esp_driver_mcpwm
driver # TODO: replace with esp_driver_mcpwm (IDF-8379), esp_driver_ana_cmpr driver # TODO: replace with esp_driver_ana_cmpr (IDF-8521)
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@ -92,7 +92,7 @@ typedef union {
Color Conversion Color Conversion
---------------------------------------------------------------*/ ---------------------------------------------------------------*/
/** /**
* @brief LCD color range * @brief Color range
* @note The difference between a full range color and a limited range color is * @note The difference between a full range color and a limited range color is
* the amount of shades of black and white that they can display. * the amount of shades of black and white that they can display.
*/ */

View File

@ -89,15 +89,6 @@ INPUT = \
$(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_tdm.h \ $(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_tdm.h \
$(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_types.h \ $(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_types.h \
$(PROJECT_PATH)/components/driver/ledc/include/driver/ledc.h \ $(PROJECT_PATH)/components/driver/ledc/include/driver/ledc.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_cap.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_cmpr.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_etm.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_fault.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_gen.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_oper.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_sync.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_timer.h \
$(PROJECT_PATH)/components/driver/mcpwm/include/driver/mcpwm_types.h \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_tx.h \ $(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_tx.h \
$(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_types.h \ $(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_types.h \
$(PROJECT_PATH)/components/driver/rmt/include/driver/rmt_common.h \ $(PROJECT_PATH)/components/driver/rmt/include/driver/rmt_common.h \
@ -142,6 +133,15 @@ INPUT = \
$(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer.h \ $(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer.h \
$(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer_etm.h \ $(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer_etm.h \
$(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer_types.h \ $(PROJECT_PATH)/components/esp_driver_gptimer/include/driver/gptimer_types.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_cap.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_cmpr.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_etm.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_fault.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_gen.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_oper.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_sync.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_timer.h \
$(PROJECT_PATH)/components/esp_driver_mcpwm/include/driver/mcpwm_types.h \
$(PROJECT_PATH)/components/esp_driver_pcnt/include/driver/pulse_cnt.h \ $(PROJECT_PATH)/components/esp_driver_pcnt/include/driver/pulse_cnt.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_com.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_com.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \

View File

@ -1044,7 +1044,7 @@ API Reference
.. include-build-file:: inc/mcpwm_sync.inc .. include-build-file:: inc/mcpwm_sync.inc
.. include-build-file:: inc/mcpwm_cap.inc .. include-build-file:: inc/mcpwm_cap.inc
.. include-build-file:: inc/mcpwm_etm.inc .. include-build-file:: inc/mcpwm_etm.inc
.. include-build-file:: inc/components/driver/mcpwm/include/driver/mcpwm_types.inc .. include-build-file:: inc/components/esp_driver_mcpwm/include/driver/mcpwm_types.inc
.. include-build-file:: inc/components/hal/include/hal/mcpwm_types.inc .. include-build-file:: inc/components/hal/include/hal/mcpwm_types.inc

View File

@ -9,6 +9,7 @@ In order to control the dependence of other components on drivers at a smaller g
- `esp_driver_pcnt` - Driver for pulse counter - `esp_driver_pcnt` - Driver for pulse counter
- `esp_driver_gpio` - Driver for GPIO - `esp_driver_gpio` - Driver for GPIO
- `esp_driver_spi` - Driver for GPSPI - `esp_driver_spi` - Driver for GPSPI
- `esp_driver_mcpwm` - Driver for Motor Control PWM
For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on. For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on.

View File

@ -1044,7 +1044,7 @@ API Reference
.. include-build-file:: inc/mcpwm_sync.inc .. include-build-file:: inc/mcpwm_sync.inc
.. include-build-file:: inc/mcpwm_cap.inc .. include-build-file:: inc/mcpwm_cap.inc
.. include-build-file:: inc/mcpwm_etm.inc .. include-build-file:: inc/mcpwm_etm.inc
.. include-build-file:: inc/components/driver/mcpwm/include/driver/mcpwm_types.inc .. include-build-file:: inc/components/esp_driver_mcpwm/include/driver/mcpwm_types.inc
.. include-build-file:: inc/components/hal/include/hal/mcpwm_types.inc .. include-build-file:: inc/components/hal/include/hal/mcpwm_types.inc

View File

@ -9,6 +9,7 @@
- `esp_driver_pcnt` - 脉冲计数器驱动 - `esp_driver_pcnt` - 脉冲计数器驱动
- `esp_driver_gpio` - GPIO 驱动 - `esp_driver_gpio` - GPIO 驱动
- `esp_driver_spi` - 通用 SPI 驱动 - `esp_driver_spi` - 通用 SPI 驱动
- `esp_driver_mcpwm` - 电机控制 PWM 驱动
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。 为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。

View File

@ -151,10 +151,14 @@ examples/peripherals/ledc/ledc_gamma_curve_fade:
examples/peripherals/mcpwm: examples/peripherals/mcpwm:
disable: disable:
- if: SOC_MCPWM_SUPPORTED != 1 - if: SOC_MCPWM_SUPPORTED != 1
depends_components:
- esp_driver_mcpwm
examples/peripherals/mcpwm/mcpwm_bdc_speed_control: examples/peripherals/mcpwm/mcpwm_bdc_speed_control:
disable: disable:
- if: SOC_MCPWM_SUPPORTED != 1 - if: SOC_MCPWM_SUPPORTED != 1
depends_components:
- esp_driver_mcpwm
disable_test: disable_test:
- if: IDF_TARGET != "esp32s3" - if: IDF_TARGET != "esp32s3"
temporary: true temporary: true
@ -163,6 +167,8 @@ examples/peripherals/mcpwm/mcpwm_bdc_speed_control:
examples/peripherals/mcpwm/mcpwm_bldc_hall_control: examples/peripherals/mcpwm/mcpwm_bldc_hall_control:
disable: disable:
- if: SOC_MCPWM_SUPPORTED != 1 - if: SOC_MCPWM_SUPPORTED != 1
depends_components:
- esp_driver_mcpwm
disable_test: disable_test:
- if: IDF_TARGET != "esp32s3" - if: IDF_TARGET != "esp32s3"
temporary: true temporary: true
@ -171,6 +177,8 @@ examples/peripherals/mcpwm/mcpwm_bldc_hall_control:
examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop: examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop:
disable: disable:
- if: SOC_MCPWM_SUPPORTED != 1 - if: SOC_MCPWM_SUPPORTED != 1
depends_components:
- esp_driver_mcpwm
disable_test: disable_test:
- if: IDF_TARGET != "esp32s3" - if: IDF_TARGET != "esp32s3"
temporary: true temporary: true

View File

@ -35,7 +35,7 @@ set(extra_components_which_shouldnt_be_included
cxx cxx
# [refactor-todo]: driver is a dependency of esp_pm, spi_flash, vfs, esp_wifi # [refactor-todo]: driver is a dependency of esp_pm, spi_flash, vfs, esp_wifi
# all of these should be removed from G1 except for spi_flash. # all of these should be removed from G1 except for spi_flash.
driver esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi driver esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
# esp_app_format is dependency of bootloader_support, app_update # esp_app_format is dependency of bootloader_support, app_update
esp_app_format esp_app_format
# esp_bootloader_format is dependency of bootloader_support, app_update # esp_bootloader_format is dependency of bootloader_support, app_update