Air001 如何开启 SPI2 的 DMA 功能? #103
Unanswered
Walkline80
asked this question in
Q&A
Replies: 1 comment
-
所以目前来说是不能使用 DMA 方式发送数据的 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
因为不会使用 HAL 库初始化 SPI2,所以选择了以下方法来获取 SPI_Handle
然后在代码中自定义了一个 HAL_SPI_MspInit() 函数,用于配置和绑定 DMA
还定义了一个 reinit_spi() 用于重置 SPI 设置,之后就是按照正常流程进行 setup 和 loop,在 loop 中发送 SPI 数据
使用 HAL_SPI_Transmit() 函数可以发送数据不会卡死
但是使用 HAL_SPI_Transmit_DMA() 只能成功发送一次数据,之后就会卡死
以下是完整代码
Beta Was this translation helpful? Give feedback.
All reactions