先转网上的一篇文章:
| 如果你需要使用spi驱动的接口,不是去修改驱动的实现代码,因为它只负责完成spi的硬件交互功能。
在这个驱动中,你只需要用spi_register_driver向系统进行注册,就可以让系统用你指定的与 .name 相匹配的硬件交互代码 |
It's easy to be confused here, and the vendor documentation you'll
find isn't necessarily helpful. The four modes combine two mode bits:
- CPOL indicates the initial clock polarity. CPOL=0 means the
clock starts low, so the first (leading) edge is rising, and
the second (trailing) edge is falling. CPOL=1 means the clock
starts high, so the first (leading) edge is falling.
- CPHA indicates the clock phase used to sample data; CPHA=0 says
sample on the leading edge, CPHA=1 means the trailing edge.
Since the signal needs to stablize before it's sampled, CPHA=0
implies that its data is written half a clock before the first
clock edge. The chipselect may have made it become available.
Chip specs won't always say "uses SPI mode X" in as many words,
but their timing diagrams will make the CPOL and CPHA modes clear.
In the SPI mode number, CPOL is the high order bit and CPHA is the
low order bit. So when a chip's timing diagram shows the clock
starting low (CPOL=0) and data stabilized for sampling during the
trailing clock edge (CPHA=1), that's SPI mode 1.

本文介绍在Linux 2.6内核环境下SPI驱动的编写方法,包括spi.h中的接口使用及spi设备读写操作示例。此外,还概述了SPI四种工作模式及如何从时序图中确定CPOL和CPHA。
4395

被折叠的 条评论
为什么被折叠?



