SP接口的全双工首发接口整合
作者:互联网
unsigned char bits = 8; unsigned int speed = 50000; unsigned short delay;
static spi_transfer_data(unsigned char *cmd, int len, unsigned char *data) { int ret; struct spi_ioc_transfer spi_rtx = { .tx_buf = (unsigned long)cmd, .rx_buf = (unsigned long)data, .len = len, .delay_usecs = delay, .speed_hz = speed, .bits_per_word = bits, }; ret = ioctl(spi,SPI_IOC_MESSAGE(1),&spi_rtx); if (1 == ret) perror("It can not do spi well\n"); }
以上代码为spi在收发(全双工)时刻的操作,该接口的问题在于slen是cmd和data的长度。
P.S. 可以了解到.len = len 是先把len长度tx数据放在SPI总线上,再获取len长度数据塞到rx数组。
[后续加入全双工的独立长度读取SPI数据的接口和测试结果]
标签:cmd,int,SP,unsigned,len,spi,接口,全双工,data 来源: https://www.cnblogs.com/real-watson/p/14337201.html