kopia lustrzana https://github.com/espressif/esp-idf
feat(mcpwm): refactor mcpwm driver into a component
rodzic
92c4714128
commit
eb5183f503
|
@ -15,7 +15,6 @@ set(includes "include"
|
|||
"i2c/include"
|
||||
"i2s/include"
|
||||
"ledc/include"
|
||||
"mcpwm/include"
|
||||
"parlio/include"
|
||||
"rmt/include"
|
||||
"sdio_slave/include"
|
||||
|
@ -103,21 +102,9 @@ if(CONFIG_SOC_LEDC_SUPPORTED)
|
|||
list(APPEND ldfragments "ledc/linker.lf")
|
||||
endif()
|
||||
|
||||
# MCPWM related source files
|
||||
# MCPWM legacy driver
|
||||
if(CONFIG_SOC_MCPWM_SUPPORTED)
|
||||
list(APPEND srcs "mcpwm/mcpwm_cap.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")
|
||||
list(APPEND srcs "deprecated/mcpwm_legacy.c")
|
||||
endif()
|
||||
|
||||
# PCNT legacy driver
|
||||
|
@ -211,7 +198,7 @@ else()
|
|||
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
|
||||
# for backward compatibility, the driver component needs to
|
||||
# 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}
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -147,8 +147,6 @@ menu "Driver Configurations"
|
|||
|
||||
orsource "./rmt/Kconfig.rmt"
|
||||
|
||||
orsource "./mcpwm/Kconfig.mcpwm"
|
||||
|
||||
menu "I2S Configuration"
|
||||
depends on SOC_I2S_SUPPORTED
|
||||
config I2S_ISR_IRAM_SAFE
|
||||
|
|
|
@ -74,10 +74,14 @@ components/driver/test_apps/legacy_i2c_driver:
|
|||
components/driver/test_apps/legacy_mcpwm_driver:
|
||||
disable:
|
||||
- if: SOC_MCPWM_SUPPORTED != 1
|
||||
depends_filepatterns:
|
||||
- components/driver/deprecated/**/*mcpwm*
|
||||
|
||||
components/driver/test_apps/legacy_pcnt_driver:
|
||||
disable:
|
||||
- if: SOC_PCNT_SUPPORTED != 1
|
||||
depends_filepatterns:
|
||||
- components/driver/deprecated/**/*pcnt*
|
||||
|
||||
components/driver/test_apps/legacy_rmt_driver:
|
||||
disable:
|
||||
|
@ -98,10 +102,8 @@ components/driver/test_apps/legacy_sigma_delta_driver:
|
|||
components/driver/test_apps/legacy_timer_driver:
|
||||
disable:
|
||||
- if: SOC_GPTIMER_SUPPORTED != 1
|
||||
|
||||
components/driver/test_apps/mcpwm:
|
||||
disable:
|
||||
- if: SOC_MCPWM_SUPPORTED != 1
|
||||
depends_filepatterns:
|
||||
- components/driver/deprecated/**/*timer*
|
||||
|
||||
components/driver/test_apps/parlio:
|
||||
disable:
|
||||
|
|
|
@ -8,5 +8,5 @@ endif()
|
|||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity driver
|
||||
PRIV_REQUIRES unity esp_driver_gptimer
|
||||
WHOLE_ARCHIVE)
|
||||
|
|
|
@ -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"
|
||||
)
|
|
@ -1,4 +1,4 @@
|
|||
menu "MCPWM Configuration"
|
||||
menu "ESP-Driver:MCPWM Configurations"
|
||||
depends on SOC_MCPWM_SUPPORTED
|
||||
config MCPWM_ISR_IRAM_SAFE
|
||||
bool "Place MCPWM ISR function into IRAM"
|
||||
|
@ -30,4 +30,4 @@ menu "MCPWM Configuration"
|
|||
help
|
||||
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.
|
||||
endmenu # MCPWM Configuration
|
||||
endmenu
|
|
@ -1,5 +1,5 @@
|
|||
[mapping:mcpwm_driver]
|
||||
archive: libdriver.a
|
||||
archive: libesp_driver_mcpwm.a
|
||||
entries:
|
||||
if MCPWM_CTRL_FUNC_IN_IRAM = y:
|
||||
mcpwm_cmpr: mcpwm_comparator_set_compare_value (noflash)
|
|
@ -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
|
|
@ -10,7 +10,7 @@ project(mcpwm_test)
|
|||
if(CONFIG_COMPILER_DUMP_RTL_FILES)
|
||||
add_custom_target(check_test_app_sections ALL
|
||||
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
|
||||
find-refs
|
||||
--from-sections=.iram0.text
|
|
@ -16,5 +16,5 @@ endif()
|
|||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity driver
|
||||
PRIV_REQUIRES unity esp_driver_mcpwm esp_driver_gpio
|
||||
WHOLE_ARCHIVE)
|
|
@ -163,7 +163,6 @@ TEST_CASE("mcpwm_group_set_prescale_dynamically", "[mcpwm]")
|
|||
carrier_config.first_pulse_duration_us = 5;
|
||||
TEST_ESP_OK(mcpwm_operator_apply_carrier(oper, &carrier_config));
|
||||
|
||||
|
||||
TEST_ESP_OK(mcpwm_del_generator(generator));
|
||||
TEST_ESP_OK(mcpwm_del_operator(oper));
|
||||
TEST_ESP_OK(mcpwm_del_timer(timer));
|
|
@ -9,6 +9,5 @@ endif()
|
|||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity esp_driver_pcnt spi_flash
|
||||
driver # will be replaced by esp_driver_gpio
|
||||
PRIV_REQUIRES unity esp_driver_pcnt esp_driver_gpio spi_flash
|
||||
WHOLE_ARCHIVE)
|
||||
|
|
|
@ -16,8 +16,9 @@ components/esp_hw_support/test_apps/etm:
|
|||
depends_components:
|
||||
- esp_driver_gptimer
|
||||
- esp_driver_gpio
|
||||
- esp_driver_mcpwm
|
||||
- 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:
|
||||
enable:
|
||||
|
|
|
@ -29,6 +29,6 @@ endif()
|
|||
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
|
||||
# the component can be registered as WHOLE_ARCHIVE
|
||||
idf_component_register(SRCS ${srcs}
|
||||
PRIV_REQUIRES unity esp_timer esp_driver_gptimer esp_driver_gpio
|
||||
driver # TODO: replace with esp_driver_mcpwm (IDF-8379), esp_driver_ana_cmpr
|
||||
PRIV_REQUIRES unity esp_timer esp_driver_gptimer esp_driver_gpio esp_driver_mcpwm
|
||||
driver # TODO: replace with esp_driver_ana_cmpr (IDF-8521)
|
||||
WHOLE_ARCHIVE)
|
||||
|
|
|
@ -92,7 +92,7 @@ typedef union {
|
|||
Color Conversion
|
||||
---------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief LCD color range
|
||||
* @brief Color range
|
||||
* @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.
|
||||
*/
|
||||
|
|
|
@ -89,15 +89,6 @@ INPUT = \
|
|||
$(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_tdm.h \
|
||||
$(PROJECT_PATH)/components/driver/i2s/include/driver/i2s_types.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_types.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_etm.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_eth/include/esp_eth_com.h \
|
||||
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \
|
||||
|
|
|
@ -1044,7 +1044,7 @@ API Reference
|
|||
.. include-build-file:: inc/mcpwm_sync.inc
|
||||
.. include-build-file:: inc/mcpwm_cap.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
|
||||
|
||||
|
||||
|
|
|
@ -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_gpio` - Driver for GPIO
|
||||
- `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.
|
||||
|
||||
|
|
|
@ -1044,7 +1044,7 @@ API Reference
|
|||
.. include-build-file:: inc/mcpwm_sync.inc
|
||||
.. include-build-file:: inc/mcpwm_cap.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
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
- `esp_driver_pcnt` - 脉冲计数器驱动
|
||||
- `esp_driver_gpio` - GPIO 驱动
|
||||
- `esp_driver_spi` - 通用 SPI 驱动
|
||||
- `esp_driver_mcpwm` - 电机控制 PWM 驱动
|
||||
|
||||
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。
|
||||
|
||||
|
|
|
@ -151,10 +151,14 @@ examples/peripherals/ledc/ledc_gamma_curve_fade:
|
|||
examples/peripherals/mcpwm:
|
||||
disable:
|
||||
- if: SOC_MCPWM_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_mcpwm
|
||||
|
||||
examples/peripherals/mcpwm/mcpwm_bdc_speed_control:
|
||||
disable:
|
||||
- if: SOC_MCPWM_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_mcpwm
|
||||
disable_test:
|
||||
- if: IDF_TARGET != "esp32s3"
|
||||
temporary: true
|
||||
|
@ -163,6 +167,8 @@ examples/peripherals/mcpwm/mcpwm_bdc_speed_control:
|
|||
examples/peripherals/mcpwm/mcpwm_bldc_hall_control:
|
||||
disable:
|
||||
- if: SOC_MCPWM_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_mcpwm
|
||||
disable_test:
|
||||
- if: IDF_TARGET != "esp32s3"
|
||||
temporary: true
|
||||
|
@ -171,6 +177,8 @@ examples/peripherals/mcpwm/mcpwm_bldc_hall_control:
|
|||
examples/peripherals/mcpwm/mcpwm_foc_svpwm_open_loop:
|
||||
disable:
|
||||
- if: SOC_MCPWM_SUPPORTED != 1
|
||||
depends_components:
|
||||
- esp_driver_mcpwm
|
||||
disable_test:
|
||||
- if: IDF_TARGET != "esp32s3"
|
||||
temporary: true
|
||||
|
|
|
@ -35,7 +35,7 @@ set(extra_components_which_shouldnt_be_included
|
|||
cxx
|
||||
# [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.
|
||||
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
|
||||
# esp_bootloader_format is dependency of bootloader_support, app_update
|
||||
|
|
Ładowanie…
Reference in New Issue