Branch imxrt1180 nxp evk jason#11475
Conversation
…test(no DMA and ISR).
… on MCU Config software.
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
|
|
| int main(void) | ||
| { | ||
| rt_kprintf("MIMXRT1180_CM33 Hello_World\r\n"); | ||
| rt_kprintf("MIMXRT1180_CM33 MCUX_Config_26.03\r\n"); |
| /* Region 4 (CM7 I/D TCM): [0x303C0000, 0x3043FFFF, 512K] */ | ||
| /* non-shareable, read/write in privilege and non-privilege, execute-never. Attr 1 (non cacheable). */ | ||
| ARM_MPU_SetRegion(4U, ARM_MPU_RBAR(0x303C0000, ARM_MPU_SH_NON, 0U, 1U, 1U), ARM_MPU_RLAR(0x3043FFFF, 1U)); | ||
| ARM_MPU_SetRegion(4U, ARM_MPU_RBAR(0x303C0000, ARM_MPU_SH_OUTER, 0U, 1U, 1U), ARM_MPU_RLAR(0x3043FFFF, 1U)); |
| peripherals.c | ||
| """) | ||
|
|
||
| CPPPATH = [cwd,cwd + '/MCUX_Config',cwd + '/ports'] |
There was a problem hiding this comment.
推荐还是把 MCUX Config Tool 生成的代码放在 MCUX_Config 目录下,并在该目录下新建一个文件夹,如adc_template。
并且建议 pin_mux.c .h 和clock_config.c .h 先保持不动。
因为这个只是给ADC测试使用,否则这个代码会影响默认配置。
There was a problem hiding this comment.
不建议。 虽然会导致源码看起来混乱,但如果你用这个软件就会发现它会自动生成一个board目录并产生新的pin_mux.c.h和clock_config.c.h,且没有找到更改输出路径的配置,这必然导致sconscript的更改,还不如将此文件更改到上一级进行源码更新。你打开配置使用下就会发现此问题。这是我给的解决方案,原因是代码框架意图是尽量依靠MCU_Config进行底层配置,那么不应该削弱代码输出更新带来的麻烦。
There was a problem hiding this comment.
手动复制,或者脚本自动复制都可以解决你的问题。并且也不是所有人都去用config tool配置所有的driver。并且即使改了目录。你这样还是破坏原有BSP。
我的核心问题是:你现在生成的文件,把原有的clock 和 pin_mux完全覆盖了。放在哪个路径,看上去是不是混乱,不是我关注的核心问题。
There was a problem hiding this comment.
这些图片可以放在MCU_config 目录下新建的adc_template下
并且如果方便,可以加一个readme
| bool "Enable LPADC1" | ||
| default n | ||
|
|
||
| config BSP_LPADC1_USING_DMA |
There was a problem hiding this comment.
我看这个BSP_LPADC1_USING_DMA,似乎在代码中没有使用?
There was a problem hiding this comment.
这是个构想和现实的冲突造成的。 规划的时候目标实现这个宏定义,但是发现底层已经用了 BSP_USING_DMA来加载SDK中的edma和edma_soc,这里因为时间紧迫忘记删除了。
| menu "On-chip Peripheral Drivers" | ||
|
|
||
| config BSP_USING_DMA | ||
| bool "Enable DMA" |
There was a problem hiding this comment.
这个BSP_USING_DMA被删了,但是代码中有使用。请再检查一下
There was a problem hiding this comment.
我恢复下,不做删除了,可能其他模块也需要这个BSP_USING_DMA,移动到上一级MENU更合适,不做LPADC下的DMA开关了。因为网络问题,没有更新主分支,SDK checkout最新后,本地文件重复没有再次验证。
|
需要添加下attach编译看护,参考:https://club.rt-thread.org/ask/article/5edd0f0940a57129.html |
There was a problem hiding this comment.
Pull request overview
This PR updates the i.MXRT1180 NXP EVK (CM33) BSP to support LPADC1 multi-channel sampling, optionally using eDMA4, and integrates MCUXpresso Config Tools generated clock/pin/peripheral initialization into the BSP boot flow.
本 PR 更新 i.MXRT1180 NXP EVK(CM33)BSP,支持 LPADC1 多通道采样(可选 eDMA4),并将 MCUXpresso Config Tools 生成的时钟/引脚/外设初始化整合进 BSP 启动流程。
Changes:
- Add MCUXpresso-generated
clock_config.*,pin_mux.*,peripherals.*and wire them into board init and build scripts.
新增 MCUXpresso 生成的clock_config.*、pin_mux.*、peripherals.*并接入板级初始化与编译脚本。 - Update the common IMXRT LPADC driver to support the new sampling flow and add DMA-based conversion path.
更新 IMXRT 通用 LPADC 驱动以适配新的采样流程,并增加 DMA 转换路径。 - Update BSP configuration/Kconfig and enable RT-Thread ADC framework for this BSP.
更新 BSP 配置/Kconfig,并启用 RT-Thread ADC 框架。
Reviewed changes
Copilot reviewed 17 out of 29 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| bsp/nxp/imx/imxrt/libraries/drivers/drv_lpadc.h | Adds board/channel notes and a comment about future channel encoding changes. |
| bsp/nxp/imx/imxrt/libraries/drivers/drv_lpadc.c | Refactors LPADC ops, adds DMA conversion path and multi-sample sequencing logic. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/rtconfig.h | Enables ADC-related macros and LPADC options for this BSP. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/SConscript | Switches to new generated config sources (clock_config.c, pin_mux.c, peripherals.c). |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/pin_mux.h | New MCUXpresso-generated pin mux header. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/pin_mux.c | Updates pin routing (UART, LED GPIO, ADC-related pins) based on MCUXpresso config. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/peripherals.h | New MCUXpresso-generated peripheral init header (ADC/LPUART/DMA declarations). |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/peripherals.c | New MCUXpresso-generated peripheral init implementation (ADC1, LPUART1, DMA4). |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/MCUX_Config/pin_mux.h | Removes older generated header under MCUX_Config/. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/MCUX_Config/clock_config.h | Removes older generated header under MCUX_Config/. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/Kconfig | Introduces LPADC/LPADC1/DMA options under on-chip drivers menu. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/clock_config.h | New MCUXpresso-generated clock config header. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/clock_config.c | Updates generated clock configuration metadata and includes. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/board.h | Includes peripherals.h for generated init entry points. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/board/board.c | Updates MPU setup and board init sequence to call generated init functions. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/applications/main.c | Updates boot banner string. |
| bsp/nxp/imx/imxrt/imxrt1180-nxp-evk/cm33/.config | Enables RT_USING_ADC and adds LPADC-related BSP config entries. |
|
|
||
| config BSP_USING_DMA | ||
| bool "Enable DMA" | ||
| menuconfig BSP_USING_LPADC |
| #define BSP_USING_LPADC | ||
| #define BSP_USING_LPADC1 | ||
| #define BSP_LPADC1_USING_DMA | ||
| #define BSP_USING_LPUART |
| CONFIG_BSP_USING_LPADC=y | ||
| CONFIG_BSP_USING_LPADC1=y | ||
| # CONFIG_BSP_LPADC1_USING_DMA is not set | ||
| CONFIG_BSP_USING_DMA=y |
| volatile bool g_Transfer_Done = false; | ||
| AT_NONCACHEABLE_SECTION_ALIGN_INIT(uint32_t adc_result[7], sizeof(uint32_t)); | ||
|
|
| LPADC_DoSoftwareTrigger(base, 1U); | ||
|
|
||
| #if defined(BSP_USING_DMA) | ||
| data_mask = 0xffff; | ||
| EDMA_StartTransfer(&DMA4_CH0_Handle); | ||
| /* Wait for EDMA transfer finish */ | ||
| while (g_Transfer_Done != true) | ||
| { | ||
| } | ||
| #else |
| extern edma_config_t DMA4_config; | ||
| /* Destination address extern definition */ | ||
| AT_NONCACHEABLE_SECTION_ALIGN_INIT(extern uint32_t adc_result[], sizeof(uint32_t)); | ||
| extern edma_handle_t DMA4_CH0_Handle; |
| IMPORTANT!! | ||
| Propose to change rt_adc_ops structure from rt_int8_t to rt_int16_t to enable side A and side B simultineously in same ADC !!! | ||
| */ |
| static rt_err_t imxrt_lp_adc_enabled(struct rt_adc_device *device, rt_int8_t channel, rt_bool_t enabled) | ||
| { | ||
| ADC_Type *base; | ||
| /* channel check*/ | ||
|
|
||
| if(channel < 4) return -RT_ERROR; | ||
|
|
||
|
|
||
| base = (ADC_Type *)(device->parent.user_data); | ||
| if( RT_TRUE == enabled ) { | ||
| LPADC_Enable(base, true); | ||
| } else { | ||
| LPADC_Enable(base, false); | ||
| } |
| break; | ||
| case 7: *value = adc_result[3] & data_mask; | ||
| break; | ||
| default: *value = 0xdeadbeef; return -RT_ERROR; |
| ADC_Type *base; | ||
| /* channel check*/ | ||
|
|
||
| if(channel < 4) return -RT_ERROR; |
拉取/合并请求描述:(PR description)
[
these channels A1_4, A1_6, A1_7, B1_5, B1_6, B1_7 are routed to LPADC1 peripheral based on CM33 core from XIP boot-up, and multi-channel sampling is enabled with DMA. They are configured to VDDA_ADC_1P8 as VREFH source, full scale input(max 1.8V), you can check CM33/board/MIMXRT1180-CM33-ADC.mex and cm33/figures for more details.
all the configured channels are verified in msh, but drv_adc can only support A1_4, B1_5, A1_6 and A1_7, this is a limitation of driver.
为什么提交这份PR (why to submit this PR)
submit BSP development task for imxrt1180-nxp-bsp
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up