From 2db9e020d742f4e275775f231bd77adf4f0aa2a8 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 6 Apr 2024 09:25:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/NrsecPort.cpp | 2 +- app/src/main/cpp/SpiPort.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/NrsecPort.cpp b/app/src/main/cpp/NrsecPort.cpp index 4187768..a290915 100644 --- a/app/src/main/cpp/NrsecPort.cpp +++ b/app/src/main/cpp/NrsecPort.cpp @@ -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)); } } diff --git a/app/src/main/cpp/SpiPort.cpp b/app/src/main/cpp/SpiPort.cpp index 00593d6..fdb2293 100644 --- a/app/src/main/cpp/SpiPort.cpp +++ b/app/src/main/cpp/SpiPort.cpp @@ -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");