SPI

【SPI】你真的会使用SPI接口吗?

发布于 2019-12-23 10:42:24
探讨::lol

1. 以下3种发送方式有区别吗?
sendBuff[4]= {0x01, 0x02, 0x03, 0x04}
rt_spi_send_then_send(spi20,&sendBuff[0],2, &sendBuff[2],2)
rt_spi_send(spi20,&sendBuff[0],2) + rt_spi_send(spi20,&sendBuff[2],2)
rt_spi_transfer(spi20,sendBuff,RT_NULL, 4)


2. 以下3种发送接收的方式有区别吗?
sendBuff[2]= {0x01, 0x02}
recvBuff[2]= {0xFF, 0xFE}
rt_spi_send_then_recv(spi20,&sendBuff[0],2, &recvBuff[0],2)
rt_spi_send(spi20,&sendBuff[0],2) + rt_spi_recv(spi20,&recvBuff[0],2)
rt_spi_transfer(spi20,sendBuff,recvBuff,2)




查看更多

关注者
0
被浏览
1k
5 个回答
liu2guang
liu2guang 认证专家 2020-01-09
sendBuff[4]= {0x01, 0x02, 0x03, 0x04}
rt_spi_send_then_send(spi20,&sendBuff[0],2, &sendBuff[2],2)
rt_spi_send(spi20,&sendBuff[0],2) + rt_spi_send(spi20,&sendBuff[2],2)
rt_spi_transfer(spi20,sendBuff,RT_NULL, 4)

rt_spi_send_then_send(spi20, &sendBuff[0], 2, &sendBuff[2], 2)
图片1.png

rt_spi_send(spi20, &sendBuff[0], 2) +
rt_spi_send(spi20, &sendBuff[2], 2)
2.png

rt_spi_transfer(spi20, sendBuff, RT_NULL, 4)
3.png
liu2guang
liu2guang 认证专家 2020-01-09
sendBuff[2]= {0x01, 0x02}
recvBuff[2]= {0xFF, 0xFE}
rt_spi_send_then_recv(spi20,&sendBuff[0],2, &recvBuff[0],2)
rt_spi_send(spi20,&sendBuff[0],2) + rt_spi_recv(spi20,&recvBuff[0],2)
rt_spi_transfer(spi20,sendBuff,recvBuff,2)
rt_spi_send_then_recv(spi20,&sendBuff[0],2, &recvBuff[0],2)
4.png

rt_spi_send(spi20,&sendBuff[0],2) + rt_spi_recv(spi20,&recvBuff[0],2)
5.png

rt_spi_transfer(spi20,sendBuff,recvBuff,2)
6.png
alficfte
alficfte 2020-01-09
攒 一目了然 曾今也卡过这个问题
freedom195
freedom195 2020-02-11
你这个用的是三线SPI么?三线SPI 不支持transfer全双工吧
james_s
james_s 2021-04-14

spi是一种数据交换协议, 发送和接收是同时的. 两个send中间有cs电平变化不知道会不会影响到外设的状态机.

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览