Skip to content

Branch imxrt1180 nxp evk jason#11475

Open
Jason0204 wants to merge 6 commits into
RT-Thread:masterfrom
Jason0204:Branch_imxrt1180_nxp_evk_jason
Open

Branch imxrt1180 nxp evk jason#11475
Jason0204 wants to merge 6 commits into
RT-Thread:masterfrom
Jason0204:Branch_imxrt1180_nxp_evk_jason

Conversation

@Jason0204

Copy link
Copy Markdown

拉取/合并请求描述:(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)

  1. use MCU_Config software for peripheral initialization as much as possible.
  2. update drv_adc to enable LPADC1 and eDMA4.
  3. update board.c to call BOARD_CommonSetting function and comment Region 11 (OCRAM1).

请提供验证的bsp和config (provide the config and bsp)

  • BSP:bsp\nxp\imx\imxrt\imxrt1180-nxp-evk\cm33 and bsp\nxp\imx\imxrt\imxrt1180-nxp-evk\cm33\packages\nxp-imxrt-sdk-latest\MIMXRT1180\SConscript
  • .config: CONFIG_BSP_LPADC1_USING_DMA=y
  • action: not defined it yet.

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

@Jason0204 Jason0204 requested a review from Rbb666 as a code owner June 12, 2026 14:30
@github-actions

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:Branch_imxrt1180_nxp_evk_jason
  • 设置PR number为 \ Set the PR number to:11475
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 Branch_imxrt1180_nxp_evk_jason 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the Branch_imxrt1180_nxp_evk_jason branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions github-actions Bot added BSP: NXP Code related with NXP BSP labels Jun 12, 2026
@CLAassistant

CLAassistant commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ Jason0204
❌ jasontek
You have signed the CLA already but the status is still pending? Let us recheck it.

int main(void)
{
rt_kprintf("MIMXRT1180_CM33 Hello_World\r\n");
rt_kprintf("MIMXRT1180_CM33 MCUX_Config_26.03\r\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分可以不用PR

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同意

/* 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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边的MPU配置不需要修改

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

调试时更改后忘记恢复

peripherals.c
""")

CPPPATH = [cwd,cwd + '/MCUX_Config',cwd + '/ports']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

推荐还是把 MCUX Config Tool 生成的代码放在 MCUX_Config 目录下,并在该目录下新建一个文件夹,如adc_template。

并且建议 pin_mux.c .h 和clock_config.c .h 先保持不动。

因为这个只是给ADC测试使用,否则这个代码会影响默认配置。

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议。 虽然会导致源码看起来混乱,但如果你用这个软件就会发现它会自动生成一个board目录并产生新的pin_mux.c.h和clock_config.c.h,且没有找到更改输出路径的配置,这必然导致sconscript的更改,还不如将此文件更改到上一级进行源码更新。你打开配置使用下就会发现此问题。这是我给的解决方案,原因是代码框架意图是尽量依靠MCU_Config进行底层配置,那么不应该削弱代码输出更新带来的麻烦。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

手动复制,或者脚本自动复制都可以解决你的问题。并且也不是所有人都去用config tool配置所有的driver。并且即使改了目录。你这样还是破坏原有BSP。

我的核心问题是:你现在生成的文件,把原有的clock 和 pin_mux完全覆盖了。放在哪个路径,看上去是不是混乱,不是我关注的核心问题。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些图片可以放在MCU_config 目录下新建的adc_template下
并且如果方便,可以加一个readme

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为了展示我验证方式和结果。至于放在哪里我没有主意

bool "Enable LPADC1"
default n

config BSP_LPADC1_USING_DMA

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我看这个BSP_LPADC1_USING_DMA,似乎在代码中没有使用?

@Jason0204 Jason0204 Jun 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这是个构想和现实的冲突造成的。 规划的时候目标实现这个宏定义,但是发现底层已经用了 BSP_USING_DMA来加载SDK中的edma和edma_soc,这里因为时间紧迫忘记删除了。

menu "On-chip Peripheral Drivers"

config BSP_USING_DMA
bool "Enable DMA"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个BSP_USING_DMA被删了,但是代码中有使用。请再检查一下

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我恢复下,不做删除了,可能其他模块也需要这个BSP_USING_DMA,移动到上一级MENU更合适,不做LPADC下的DMA开关了。因为网络问题,没有更新主分支,SDK checkout最新后,本地文件重复没有再次验证。

@Rbb666

Rbb666 commented Jun 16, 2026

Copy link
Copy Markdown
Member

需要添加下attach编译看护,参考:https://club.rt-thread.org/ask/article/5edd0f0940a57129.html

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Comment on lines +430 to 433
#define BSP_USING_LPADC
#define BSP_USING_LPADC1
#define BSP_LPADC1_USING_DMA
#define BSP_USING_LPUART
Comment on lines +1469 to 1472
CONFIG_BSP_USING_LPADC=y
CONFIG_BSP_USING_LPADC1=y
# CONFIG_BSP_LPADC1_USING_DMA is not set
CONFIG_BSP_USING_DMA=y
Comment on lines +43 to +45
volatile bool g_Transfer_Done = false;
AT_NONCACHEABLE_SECTION_ALIGN_INIT(uint32_t adc_result[7], sizeof(uint32_t));

Comment on lines 104 to +112
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
Comment on lines +67 to +70
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;
Comment on lines +46 to +48
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 !!!
*/
Comment on lines +71 to +84
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSP: NXP Code related with NXP BSP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants