添加 PWM & ADC 驱动 & 整理工程 - #192
Conversation
b504f02 to
8bd9089
Compare
There was a problem hiding this comment.
Pull request overview
该 PR 主要针对 Infineon edge-e83 双核(CM33/CM55)工程做结构整理,并补充/接入 PWM、ADC 等驱动与测试代码,同时调整构建脚本与部分生成配置文件。
Changes:
- 将 m33/m55 下分散的驱动/公共代码收敛到
target/infineon/edge-e83/drivers/,并调整两核的board.c/SConstruct来适配新结构 - 新增/接入 ADC、PWM(含测试用例),并增强 console 设备名可配置(支持
RT_CONSOLE_DEVICE_NAME) - 更新 ModusToolbox 生成配置及部分库构建脚本依赖选择
Reviewed changes
Copilot reviewed 133 out of 133 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| target/infineon/edge-e83/m55/fmtconfig.h | 为 M55 增加 RT_CONSOLE_DEVICE_NAME 配置 |
| target/infineon/edge-e83/m55/drivers/uart_config.h | 删除(驱动配置收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m55/drivers/drv_uart.h | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m55/drivers/drv_eth.h | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m55/drivers/drv_common.h | 删除(BSP 初始化逻辑迁移到 board.c) |
| target/infineon/edge-e83/m55/drivers/drv_common.c | 删除(BSP 初始化逻辑迁移到 board.c) |
| target/infineon/edge-e83/m55/drivers/SConscript | 删除(改用 edge-e83/drivers/SConscript) |
| target/infineon/edge-e83/m55/config/task.py | 注释掉部分 task 编译项 |
| target/infineon/edge-e83/m55/board/bsp_header.h | 更新版权年份 |
| target/infineon/edge-e83/m55/board/board_device.h | 更新版权年份 |
| target/infineon/edge-e83/m55/board/board.h | 头部版权切换为 Firmament 版权并移除 drv_common 依赖 |
| target/infineon/edge-e83/m55/board/board.c | 承担 BSP 初始化入口(原 drv_common.c)并加入 PWM/ADC 头文件引用 |
| target/infineon/edge-e83/m55/applications/usb_test.c | 代码风格微调 |
| target/infineon/edge-e83/m55/applications/pin_test.c | include/格式整理 |
| target/infineon/edge-e83/m55/applications/ipc_test.c | IPC demo include/风格整理并改用新头文件路径 |
| target/infineon/edge-e83/m55/applications/i2c_test.c | I2C 示例风格整理(含导出命令描述文本变化) |
| target/infineon/edge-e83/m55/SConstruct | 构建目录从 common 调整为 drivers |
| target/infineon/edge-e83/m33/fmtconfig.h | 新增 M33 的 fmtconfig(含 console 设备名配置) |
| target/infineon/edge-e83/m33/drivers/uart_config.h | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_wdt.h | 删除(清理/收敛) |
| target/infineon/edge-e83/m33/drivers/drv_wdt.c | 删除(清理/收敛) |
| target/infineon/edge-e83/m33/drivers/drv_uart.h | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_uart.c | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_spi.h | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_spi.c | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_soft_i2c.h | 删除(清理/收敛) |
| target/infineon/edge-e83/m33/drivers/drv_soft_i2c.c | 删除(清理/收敛) |
| target/infineon/edge-e83/m33/drivers/drv_rtc.c | 删除(清理/收敛) |
| target/infineon/edge-e83/m33/drivers/drv_pwm.h | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_pwm.c | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_pdm.h | 删除(清理音频相关) |
| target/infineon/edge-e83/m33/drivers/drv_log.h | 删除(清理/替换日志封装) |
| target/infineon/edge-e83/m33/drivers/drv_i2s.h | 删除(清理音频相关) |
| target/infineon/edge-e83/m33/drivers/drv_i2c.c | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_hwtimer.h | 删除(清理/收敛) |
| target/infineon/edge-e83/m33/drivers/drv_hwtimer.c | 删除(清理/收敛) |
| target/infineon/edge-e83/m33/drivers/drv_gpio.h | 删除(收敛到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/drv_common.h | 删除(BSP 初始化逻辑迁移到 board.c) |
| target/infineon/edge-e83/m33/drivers/drv_common.c | 删除(BSP 初始化逻辑迁移到 board.c) |
| target/infineon/edge-e83/m33/drivers/drv_adc.c | 删除(ADC 迁移到 edge-e83/drivers) |
| target/infineon/edge-e83/m33/drivers/SConscript | 删除(改用 edge-e83/drivers/SConscript) |
| target/infineon/edge-e83/m33/config/task.py | 新增(M33 侧 task 编译列表) |
| target/infineon/edge-e83/m33/config/protocol.py | 新增(M33 侧协议编译列表) |
| target/infineon/edge-e83/m33/config/module.py | 新增(M33 侧模块编译列表) |
| target/infineon/edge-e83/m33/config/model.py | 新增(按 vehicle/sim 选择模型) |
| target/infineon/edge-e83/m33/config/library.py | 新增(库选择,如 cm_backtrace) |
| target/infineon/edge-e83/m33/config/hal.py | 新增(HAL 选择列表) |
| target/infineon/edge-e83/m33/config/driver.py | 新增(外设驱动选择列表) |
| target/infineon/edge-e83/m33/board/ports/filesystem/mnt.c | 删除(工程整理/裁剪) |
| target/infineon/edge-e83/m33/board/ports/fal/fal_flash_port.c | 删除(工程整理/裁剪) |
| target/infineon/edge-e83/m33/board/ports/fal/fal_cfg.h | 删除(工程整理/裁剪) |
| target/infineon/edge-e83/m33/board/ports/drv_hyperam.c | 删除(工程整理/裁剪) |
| target/infineon/edge-e83/m33/board/ports/SConscript | 删除(工程整理/裁剪) |
| target/infineon/edge-e83/m33/board/linker_scripts/link.ld | 调整链接段:将 init/finsh/utest/task/mlog 等 section 放入 NVM 段 |
| target/infineon/edge-e83/m33/board/bsp_header.h | 新增 BSP 头文件占位 |
| target/infineon/edge-e83/m33/board/board_device.h | 新增设备名宏(如 FMTIO_DEVICE_NAME) |
| target/infineon/edge-e83/m33/board/board.h | Firmament 版权头、include 顺序调整、增加 TARGET_NAME |
| target/infineon/edge-e83/m33/board/board.c | 承担 BSP 初始化与启动流程,初始化 PWM/ADC 等 |
| target/infineon/edge-e83/m33/applications/pwm_test.c | 将 PWM 测试改为通过 actuator(main_out) 输出 |
| target/infineon/edge-e83/m33/applications/main.c | 删除(不再使用该简单示例 main) |
| target/infineon/edge-e83/m33/applications/ipc_test.c | IPC demo include/风格整理并改用新头文件路径 |
| target/infineon/edge-e83/m33/applications/adc_test.c | 重写 ADC 测试:单次读取 + 可启动/停止的采样线程 |
| target/infineon/edge-e83/m33/SConstruct | 增加 vehicle/airframe/sim 选项并重构构建加载逻辑(遍历 FMU_ROOT SConscript;drivers 组单独编译) |
| target/infineon/edge-e83/m33/BuildLists.py | 新增:集中导入各 config 列表 |
| target/infineon/edge-e83/m33/.gitignore | 增加忽略 *.asm |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/design.modus | 更新 ModusToolbox 配置版本与部分参数(含 GPIO 中断、分频) |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/qspi_config.cfg | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_system.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_system.c | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_routing.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_routing.c | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_qspi_memslot.timestamp | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_qspi_memslot.h | 更新生成器版本号与 CY_SMIF_CFG_TOOL_VERSION |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_qspi_memslot.c | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_protection.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_protection.c | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_pins.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_pins.c | 更新生成器版本号并变更 WiFi host wake 中断配置 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_peripherals.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_peripherals.c | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_peripheral_clocks.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_peripheral_clocks.c | 更新 PWM 分频设置(从 4999 -> 9) |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_notices.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_memory.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_dmas.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_dmas.c | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_connectivity_wifi.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_connectivity_bt.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_clocks.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg_clocks.c | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg.h | 更新生成器版本号 |
| target/infineon/edge-e83/libs/TARGET_APP_KIT_PSE84_EVAL_EPC2/config/GeneratedSource/cycfg.c | 更新生成器版本号 |
| target/infineon/edge-e83/libraries/mtb-device-support-pse8xxgp/pdl/SConscript | 按 BSP_USING_* 依赖选择性加入 UART/SPI/I2C/PWM/ADC/ETH/SD 等 PDL 源文件 |
| target/infineon/edge-e83/libraries/Infineon_cmsis-latest/SConscript | 仅在 BSP_USING_CMSIS_DSP 时编译 CMSIS-DSP 源码 |
| target/infineon/edge-e83/drivers/uart_config.h | 新增:统一 UART 配置宏与中断配置 |
| target/infineon/edge-e83/drivers/ipc_common.h | 新增:统一 IPC 帧格式与校验逻辑 |
| target/infineon/edge-e83/drivers/drv_usbd_cdc.h | 更新版权年份 |
| target/infineon/edge-e83/drivers/drv_usbd_cdc.c | include 顺序整理并更新版权年份 |
| target/infineon/edge-e83/drivers/drv_uart.h | 新增:统一 UART 驱动头(serial v1) |
| target/infineon/edge-e83/drivers/drv_uart.c | 迁移/整理 UART 驱动实现 |
| target/infineon/edge-e83/drivers/drv_systick.h | 更新版权年份 |
| target/infineon/edge-e83/drivers/drv_systick.c | include 顺序整理并更新版权年份 |
| target/infineon/edge-e83/drivers/drv_spi.h | 更新版权年份 |
| target/infineon/edge-e83/drivers/drv_spi.c | 更新版权年份 |
| target/infineon/edge-e83/drivers/drv_sdio.h | 更新版权年份与尾部空格修正 |
| target/infineon/edge-e83/drivers/drv_sdio.c | 更新版权年份 |
| target/infineon/edge-e83/drivers/drv_pwm.h | 新增:PWM 驱动接口声明 |
| target/infineon/edge-e83/drivers/drv_ipc.h | 新增:IPC 设备接口声明 |
| target/infineon/edge-e83/drivers/drv_i2c.h | 更新版权年份与小幅格式整理 |
| target/infineon/edge-e83/drivers/drv_i2c.c | 迁移/整理 I2C 驱动实现 |
| target/infineon/edge-e83/drivers/drv_gpio.h | include 顺序调整并更新版权年份 |
| target/infineon/edge-e83/drivers/drv_gpio.c | 迁移/整理 GPIO/pin HAL 驱动实现 |
| target/infineon/edge-e83/drivers/drv_eth.h | 新增:以 Firmament 版权头替换旧头 |
| target/infineon/edge-e83/drivers/drv_adc.h | API 名称改为 drv_adc_init 并更新版权年份 |
| target/infineon/edge-e83/drivers/drv_adc.c | 新增:基于 hal/adc 的 ADC 驱动实现 |
| target/infineon/edge-e83/drivers/adc_config.h | ADC0 配置重命名/整理(BSP_USING_ADC0) |
| target/infineon/edge-e83/drivers/SConscript | 新增:统一 drivers 组构建入口 |
| target/infineon/edge-e83/common/edge_ipc_device.h | 删除(IPC 头迁移到 drivers) |
| target/infineon/edge-e83/common/edge_ipc_common.h | 删除(IPC 头迁移到 drivers) |
| target/infineon/edge-e83/common/SConscript | 删除(common 组被 drivers 组替代) |
| src/module/console/console.c | 支持通过 RT_CONSOLE_DEVICE_NAME 配置 console 串口设备名 |
Comments suppressed due to low confidence (1)
target/infineon/edge-e83/m55/applications/i2c_test.c:94
- Same spacing issue in the exported command description:
"I2C single - byte ..."looks like a typo. Consider"I2C single-byte read test"(or"single byte").
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| #include <rtthread.h> | ||
| #include "drv_common.h" | ||
| #include "drv_gpio.h" | ||
| #include <rtthread.h> | ||
|
|
||
| #include "cy_result.h" | ||
| #include "cybsp.h" |
There was a problem hiding this comment.
board.h no longer declares bsp_early_initialize/bsp_initialize/bsp_post_initialize (it previously got them via drv_common.h). src/startup.c includes <board.h> and calls bsp_initialize()/bsp_post_initialize(), so this will cause missing-prototype/implicit-declaration build failures on modern C compilers. Add the BSP init function prototypes to this board.h (consistent with other targets’ board headers).
| #ifndef __BOARD_H__ | ||
| #define __BOARD_H__ | ||
|
|
||
| #include <rtthread.h> | ||
| #include "drv_common.h" | ||
| #include "drv_gpio.h" | ||
|
|
||
| #include "cy_result.h" |
There was a problem hiding this comment.
board.h removed the drv_common.h include but does not declare bsp_early_initialize/bsp_initialize/bsp_post_initialize. Since src/startup.c includes <board.h> and calls these symbols, this introduces missing-prototype/implicit-declaration build errors. Please add the BSP init function prototypes to this header (as done in other targets’ board.h).
| cfg->channel); | ||
|
|
||
| mv = Cy_AutAnalog_SAR_CountsTo_mVolts( | ||
| cfg->sar_idx, | ||
| cfg->low_power, | ||
| cfg->sequencer, | ||
| cfg->input, | ||
| cfg->channel, |
There was a problem hiding this comment.
ifx_adc_measure() ignores the channel argument and always reads cfg->channel/cfg->input from the static config. This makes rt_device_read(dev, pos=channel, ...) return the same physical ADC channel regardless of pos, breaking the HAL’s channel semantics. Use the channel parameter to select the SAR channel (or provide a per-channel config table and index it by channel).
| cfg->channel); | |
| mv = Cy_AutAnalog_SAR_CountsTo_mVolts( | |
| cfg->sar_idx, | |
| cfg->low_power, | |
| cfg->sequencer, | |
| cfg->input, | |
| cfg->channel, | |
| channel); | |
| mv = Cy_AutAnalog_SAR_CountsTo_mVolts( | |
| cfg->sar_idx, | |
| cfg->low_power, | |
| cfg->sequencer, | |
| cfg->input, | |
| channel, |
| static void ifx_autonomous_analog_init_once(void) | ||
| { | ||
| if (autonomous_initialized) | ||
| return; | ||
|
|
||
| if (Cy_AutAnalog_Init(&autonomous_analog_init) != CY_AUTANALOG_SUCCESS) { | ||
| rt_kprintf("Autonomous Analog init failed"); | ||
| return; | ||
| } | ||
|
|
||
| Cy_AutAnalog_SetInterruptMask(CY_AUTANALOG_INT_SAR0_RESULT); | ||
| Cy_AutAnalog_StartAutonomousControl(); | ||
|
|
||
| autonomous_initialized = RT_TRUE; | ||
| } |
There was a problem hiding this comment.
ifx_autonomous_analog_init_once() prints an error and returns when Cy_AutAnalog_Init() fails, but drv_adc_init() still proceeds to register the ADC device. That can leave a registered device that can never successfully measure. Please propagate init failure back to drv_adc_init() (return an error) and avoid registering the device when the Autonomous Analog block isn't initialized.
| void adc_test_stop(void) | ||
| { | ||
| if (!adc_test_running) { | ||
| rt_kprintf("ADC test thread is not running!\n"); | ||
| return; | ||
| } | ||
|
|
||
| rt_adc_device_t adc_dev; | ||
| rt_uint32_t value, mv, v, mv_frac; | ||
| rt_kprintf("Stopping ADC test thread...\n"); | ||
| adc_test_running = RT_FALSE; | ||
|
|
||
| static rt_thread_t adc_test_tid = RT_NULL; | ||
| if (adc_test_thread != RT_NULL) { | ||
| rt_thread_delete(adc_test_thread); | ||
| adc_test_thread = RT_NULL; | ||
| } |
There was a problem hiding this comment.
adc_test_stop() calls rt_thread_delete(adc_test_thread) immediately after setting adc_test_running = RT_FALSE. This can terminate the thread before it runs its cleanup path (notably rt_device_close(dev)), potentially leaking the open ref_count and leaving the ADC enabled. Prefer letting the thread exit naturally (signal via the flag, then have the thread clear adc_test_thread/adc_test_running after closing the device), or use a synchronization primitive to wait for clean shutdown before deleting.
| MSH_CMD_EXPORT(i2c_write_sample, I2C single - byte write test); | ||
|
|
There was a problem hiding this comment.
The exported command descriptions introduce awkward spacing: "I2C single - byte ..." reads like a typo. Consider changing to "I2C single-byte ..." (or "single byte") for consistency and readability.
19e1347 to
5590a5c
Compare
添加 PWM & ADC 驱动 & 整理工程