当前位置: 技术问答>linux和unix
spi用户空间驱动问题咨询
来源: 互联网 发布时间:2017-05-02
本文导语: 本人想用spi用户空间驱动往spi从设备发消息,现在驱动加载正常,可以在dev下生成dev1.0设备节点,用wirte和read函数操作从设备正常,但是write和read是半双工的方式不符合要求,本人需要用全双工的方式去读取spi从设备...
本人想用spi用户空间驱动往spi从设备发消息,现在驱动加载正常,可以在dev下生成dev1.0设备节点,用wirte和read函数操作从设备正常,但是write和read是半双工的方式不符合要求,本人需要用全双工的方式去读取spi从设备的数据,请各位大侠帮忙给点思路,这个问题困扰我好久了,谢谢
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static void do_msg(int fd)
{
unsigned char tx[6] = {0x08, 0xff, 0x12, 0, 0, 0,};
unsigned char rx[6];
unsigned char *bp, *av;
int status;
int len, len_rx;
len = sizeof tx;
len_rx = len;
struct spi_ioc_transfer xfer = {
.tx_buf = (unsigned long long)tx,
.rx_buf = (unsigned long long)tx,
.len = 6,
.delay_usecs = 0,
.bits_per_word = 8,
};
status = ioctl(fd, SPI_IOC_MESSAGE(1), &xfer);
if (status
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
static void do_msg(int fd)
{
unsigned char tx[6] = {0x08, 0xff, 0x12, 0, 0, 0,};
unsigned char rx[6];
unsigned char *bp, *av;
int status;
int len, len_rx;
len = sizeof tx;
len_rx = len;
struct spi_ioc_transfer xfer = {
.tx_buf = (unsigned long long)tx,
.rx_buf = (unsigned long long)tx,
.len = 6,
.delay_usecs = 0,
.bits_per_word = 8,
};
status = ioctl(fd, SPI_IOC_MESSAGE(1), &xfer);
if (status