小弟就不明白了,由于(2)测试成功,说明spi总线加上了,硬件层的配置也没问题了,而使用probe中传入的spi_device设备在内核进行spi_read,spi_write操作却没有成功?难道是那个地方没有设置的原因?作者: acrazyworld 时间: 2012-03-28 15:43
引用文档spidev
Normal open() and close() operations on /dev/spidevB.D files work as you
would expect.
Standard read() and write() operations are obviously only half-duplex, and
the chipselect is deactivated between those operations. Full-duplex access,
and composite operation without chipselect de-activation, is available using
the SPI_IOC_MESSAGE(N) request.
Several ioctl() requests let your driver read or override the device's current
settings for data transfer parameters:
SPI_IOC_RD_MODE, SPI_IOC_WR_MODE ... pass a pointer to a byte which will
return (RD) or assign (WR) the SPI transfer mode. Use the constants
SPI_MODE_0..SPI_MODE_3; or if you prefer you can combine SPI_CPOL
(clock polarity, idle high iff this is set) or SPI_CPHA (clock phase,
sample on trailing edge iff this is set) flags.
SPI_IOC_RD_LSB_FIRST, SPI_IOC_WR_LSB_FIRST ... pass a pointer to a byte
which will return (RD) or assign (WR) the bit justification used to
transfer SPI words. Zero indicates MSB-first; other values indicate
the less common LSB-first encoding. In both cases the specified value
is right-justified in each word, so that unused (TX) or undefined (RX)
bits are in the MSBs.
SPI_IOC_RD_BITS_PER_WORD, SPI_IOC_WR_BITS_PER_WORD ... pass a pointer to
a byte which will return (RD) or assign (WR) the number of bits in
each SPI transfer word. The value zero signifies eight bits.
SPI_IOC_RD_MAX_SPEED_HZ, SPI_IOC_WR_MAX_SPEED_HZ ... pass a pointer to a
u32 which will return (RD) or assign (WR) the maximum SPI transfer
speed, in Hz. The controller can't necessarily assign that specific
clock speed.
NOTES:
- At this time there is no async I/O support; everything is purely
synchronous.都是同步的?
- There's currently no way to report the actual bit rate used to
shift data to/from a given device.
- From userspace, you can't currently change the chip select polarity;
that could corrupt transfers to other devices sharing the SPI bus.
Each SPI device is deselected when it's not in active use, allowing
other drivers to talk to other devices.
- There's a limit on the number of bytes each I/O request can transfer
to the SPI device. It defaults to one page, but that can be changed
using a module parameter.
- Because SPI has no low-level transfer acknowledgement, you usually
won't see any I/O errors when talking to a non-existent device.