|
linux下spi读写的时间开销问题。求助!!!
[复制链接]
板子跑的linux,我在调spi的时候遇到一个问题就是读写外设的寄存器的时间开销太大。
static void
transfer (int fd)
{
int ret;
uint8_t tx[] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xAD,
0xF0, 0x0D,
};
uint8_t rx[ARRAY_SIZE (tx)] = { 0, };
struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long) tx,
.rx_buf = (unsigned long) rx,
.len = ARRAY_SIZE (tx),
.delay_usecs = delay,
.speed_hz = speed,
.bits_per_word = bits,
};
ret = ioctl (fd, SPI_IOC_MESSAGE (1), &tr);
上面是spi_write函数的大概内容,其中ioctrl的时间开销就很大,读一次spi(一个字节)需要大约50us的时间(spi配置为3Mbps)。
是有点长,有什么方法可以提高spi读写的效率?
谢谢!
|
|