初级会员

- 积分
- 56
- 金钱
- 56
- 注册时间
- 2019-11-30
- 在线时间
- 13 小时
|

楼主 |
发表于 2020-11-4 09:16:04
|
显示全部楼层
目前未找到直接增大缓存的方法
抛砖引玉,在不过于考虑执行效率的情况下,本人使用以下的函数来传输32K以下的数据的接收。
int spi_transceive_32k (int fd, uint8_t* tx_dat, uint8_t* rx_dat, uint16_t len)
{
struct spi_ioc_transfer spi_l = {0};
int res_l;
uint16_t ofs_l = 0;
while (len > 4096)
{
memset (&spi_l, 0, sizeof (spi_l)) ;
memset (&rx_dat[ofs_l], 0, 4096);
spi_l.tx_buf = (unsigned long)(&tx_dat[ofs_l]);
spi_l.rx_buf = (unsigned long)(&rx_dat[ofs_l]);
spi_l.len = 4096 ;
spi_l.delay_usecs = 0;
spi_l.speed_hz = 10000000 ;
spi_l.bits_per_word = 8 ;
res_l = ioctl (fd, SPI_IOC_MESSAGE(1), &spi_l) ;
ofs_l = ofs_l + 4096;
len = len - 4096;
}
spi_l.tx_buf = (unsigned long)(&tx_dat[ofs_l]);
spi_l.rx_buf = (unsigned long)(&rx_dat[ofs_l]);
spi_l.len = len ;
spi_l.delay_usecs = 0;
spi_l.speed_hz =10000000 ;
spi_l.bits_per_word = 8 ;
res_l = ioctl (fd, SPI_IOC_MESSAGE(1), &spi_l) ;
return res_l;
} |
|