-
Notifications
You must be signed in to change notification settings - Fork 5.2k
bsp/nrf5x: nrf52840添加spim驱动 #10576
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
bsp/nrf5x: nrf52840添加spim驱动 #10576
Conversation
📌 Code Review Assignment🏷️ Tag: bsp_nrf5xReviewers: ReviewSun Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2025-08-03 13:59 CST)
📝 Review Instructions
|
尊敬的审查者,您好! 修复了代码格式问题:tab转为空格; 调整了头文件的包含路径:删除了不必要的头文件; 重新编译一边,并完成了相关功能的测试。 |
请在bsp/nrf5x/nrf52840/.ci/attachconfig/ci.attachconfig.yml 中添加测试的配置 |
CI 问题也要处理一下 |
描述规范请修改 |
|
102行-110行:
} |
CI如果确定不是问题,可以不用修改 |
There was a problem hiding this comment.
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 adds SPIM (SPI Master with EasyDMA) driver support for the nRF52840 BSP, providing DMA functionality for SPI transfers to handle large data volumes efficiently.
- Adds complete SPIM driver implementation with DMA support for nRF52840
- Corrects pin range configurations from 31/64 to 47/48 for nRF52840 compatibility
- Updates copyright years across multiple driver files
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
File | Description |
---|---|
bsp/nrf5x/nrf52840/board/Kconfig | Adds SPIM configuration options and corrects pin ranges |
bsp/nrf5x/libraries/drivers/nrfx_spim.h | New SPIM driver header with API definitions |
bsp/nrf5x/libraries/drivers/nrfx_spim.c | Complete SPIM driver implementation with DMA support |
bsp/nrf5x/libraries/drivers/drv_spim.h | RT-Thread SPIM driver wrapper header |
bsp/nrf5x/libraries/drivers/drv_spim.c | RT-Thread SPIM driver wrapper implementation |
Various driver files | Copyright year updates and minor formatting fixes |
Comments suppressed due to low confidence (2)
bsp/nrf5x/nrf52840/board/Kconfig:356
- Missing 'endif' statement for the SPIM3 configuration block. The SPIM3 section is opened but not properly closed.
config BSP_USING_SPIM3
bsp/nrf5x/libraries/drivers/drv_spim.c:14
- The USING_SPI_DMA macro should be defined in a header file or configuration file rather than hardcoded in the source file, to allow for better configurability.
#ifdef BSP_USING_SPIM
range 0 47 | ||
default 31 | ||
endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] There is an extra blank line after 'endif' that should be removed for consistency with the rest of the configuration structure.
Copilot uses AI. Check for mistakes.
* - SS pin active low | ||
* - over-run character set to 0xFF | ||
* - clock frequency: 4 MHz | ||
* - mode: 0 (SCK active high, sample on leading edge of the clock signa;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in comment: 'signa;)' should be 'signal)'.
* - mode: 0 (SCK active high, sample on leading edge of the clock signa;) | |
* - mode: 0 (SCK active high, sample on leading edge of the clock signal) |
Copilot uses AI. Check for mistakes.
static void finish_transfer(spim_control_block_t * p_cb) | ||
{ | ||
|
||
#if USING_SPI_DMA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macro USING_SPI_DMA is used but not defined in this file. It should be defined or included from a header file to avoid compilation issues.
Copilot uses AI. Check for mistakes.
struct rt_spi_message * message, | ||
struct rt_spi_device * dev) | ||
{ | ||
#define DMA_TRANS_MIN_LEN (20) /* only buffer length >= DMA_TRANS_MIN_LEN will use DMA mode */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number 20 for DMA_TRANS_MIN_LEN should be moved to a header file or made configurable, as it's a critical threshold for DMA usage decision.
Copilot uses AI. Check for mistakes.
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
在我的一个项目中,需要nrf52840的spi接口写入大量的数据,需要用到DMA,但是目前的bsp中只有spi的驱动。
你的解决方案是什么 (what is your solution)
我自己根据rtt的spi风格,自行编写了spim的驱动。
请提供验证的bsp和config (provide the config and bsp)
.config:需要添加
menuconfig BSP_USING_SPIM
bool "Enable SPIM"
select RT_USING_SPIM
default n
]
当前拉取/合并请求的状态 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