用户工具

站点工具


标准:bus:spi:start

这是本文档旧的修订版!


SPI(Serial Peripheral interface)

串行外围设备接口。

常用标准

SPI为De-facto standard,即没有特定的组织来管理定义其规范,这也导致其有很多不同的版本。

对于Basic SPI,Freescale发布了一个标准版本: SPI Block Guide V04.01

版本差异

三个版本,Basic SPI、Dual SPI(DSPI)、Quad SPI(QSPI)。

DSPI和QSPI和Basic SPI的差异为数据线为双向,但其是半双工,即同一时间只能单向传输数据,不能像千兆网口一样,同时双向传输数据。

Basic SPI

Basic SPI的管脚定义如下表:

Name Function
nCS Chip select, a.k.a. slave select (nSS). This is driven low (hence the n) by the master to select a slave. There is a separate chip select line going from the master to each slave.
SCLK Clock. Driven by the master, this provides the clock signal to the slaves to clock data in and out with. The exact polarity and edges that are used depend on the values of CPOL and CPHA.
MOSI Master out, slave in. A.k.a. main out, subnode in. The master drives the line and provides data to the slaves. Only the slave with nCS asserted (low) listens to the data.
MISO Master in, slave out. A.k.a. main in, subnode out. The selected slave can drive this line to send data to the master.

Dual SPI

Dual SPI(DSPI)把Basic SPI两根单向的数据线,变为双向的两根数据线,传输速率翻倍。

Quad SPI

Quad SPI(QSPI)则是四根双向数据线,传输速率为再翻倍。

Transmission Formats

Basic SPI有四种模式,按空闲时时钟电平,以及采样的时钟边缘分。

空闲时时钟电平为0对应CPOL = 0,1对应CPOL = 1。

第一个时间边缘采样对应CPHA = 0,第二个则对应CPHA = 1。

不是每个芯片都支持这四种模式,一般均支持0和3,Master和Slave设备需要设定成同一个模式。

另Master设备可以在一个总线上和不同模式的slave设备通讯,只需要保证通讯时其他slave设备是inactive状态。

列表和示意图如下:

SPI Mode Clock Polarity (CPOL) Clock Phase (CPHA) Which Clock Edge Is Used To Sample/Shift?
0 0 0 Data sampled on rising edge and shifted out on falling edge.
1 0 1 Data sampled on falling edge and shifted out on rising edge.
2 1 0 Data sampled on falling edge and shifted out on rising edge.
3 1 1 Data sampled on rising edge and shifted out on falling edge.

参考文献

评论

请输入您的评论. 可以使用维基语法:
J G M W᠎ I
 
标准/bus/spi/start.1742027072.txt.gz · 最后更改: 2025/03/15 16:24 由 hwwiki