优化代码

main
Matthew 1 year ago
parent 7da3cd752f
commit 2db9e020d7

@ -154,7 +154,7 @@ void NrsecPort::RcvData(uint8_t*txbuf, uint8_t*buf, int len)
for (i = 0; i < len; i++)
{
retval = spi_transfer(txbuf, buf + i, 1);
__android_log_print(ANDROID_LOG_INFO, TAG_SPI, "RcvData data[%d]=%x", i, *(buf + i));
// __android_log_print(ANDROID_LOG_INFO, TAG_SPI, "RcvData data[%d]=%x", i, *(buf + i));
}
}

@ -40,18 +40,27 @@ void SpiPort::Close()
int SpiPort::spi_transfer(unsigned char *txbuf, unsigned char *rxbuf, int bytes)
{
struct spi_ioc_transfer xfer[2];
int status;
#if 0
struct spi_ioc_transfer xfer[2];
memset(xfer, 0, sizeof(xfer));
xfer[0].tx_buf = (__u64)txbuf;
xfer[0].rx_buf = (__u64)rxbuf;
xfer[0].len = bytes;
xfer[0].delay_usecs = 2;
status = ioctl(m_fd, SPI_IOC_MESSAGE(1), xfer);
#else
struct spi_ioc_transfer xfer;
memset(&xfer, 0, sizeof(xfer));
xfer.tx_buf = (__u64)txbuf;
xfer.rx_buf = (__u64)rxbuf;
xfer.len = bytes;
xfer.delay_usecs = 2;
status = ioctl(m_fd, SPI_IOC_MESSAGE(1), &xfer);
#endif
if (status < 0)
{
perror("SPI_IOC_MESSAGE");

Loading…
Cancel
Save