You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/01/13 07:32:20 UTC
[nuttx] branch master updated: sim/posix/sim_linuxspi.c: fix select not work and incorrect behaviour
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new bcb0abc05d sim/posix/sim_linuxspi.c: fix select not work and incorrect behaviour
bcb0abc05d is described below
commit bcb0abc05df358204a6e3b5d463e393f42d77353
Author: W-Mai <13...@qq.com>
AuthorDate: Wed Jan 11 16:19:47 2023 +0800
sim/posix/sim_linuxspi.c: fix select not work and incorrect behaviour
Fixed missing `SPI_SELECT` method and incorrect sending behavior in sim_linuxspi
Signed-off-by: xinbingnan <xi...@xiaomi.com>
---
arch/sim/src/sim/posix/sim_linuxspi.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/arch/sim/src/sim/posix/sim_linuxspi.c b/arch/sim/src/sim/posix/sim_linuxspi.c
index 79c3de53d2..466ab40ce2 100644
--- a/arch/sim/src/sim/posix/sim_linuxspi.c
+++ b/arch/sim/src/sim/posix/sim_linuxspi.c
@@ -191,6 +191,26 @@ static int linux_spi_lock(struct spi_dev_s *dev, bool lock)
static void linux_spi_select(struct spi_dev_s *dev, uint32_t devid,
bool selected)
{
+ if (!selected)
+ {
+ struct linux_spi_dev_s *priv = (struct linux_spi_dev_s *)dev;
+
+ /* Some members of struct spi_ioc_transfer transfer_data is default 0:
+ * @speed_hz = 0, thus it's ignored, MAX_SEPPD_HZ will be used.
+ * @bits_per_word = 0, thus it's ignored, BITS_PER_WORD will be used.
+ * @delay_usecs = 0, thus thers's no delay before next transfer.
+ */
+
+ struct spi_ioc_transfer transfer_data =
+ {
+ .tx_buf = (unsigned long)NULL,
+ .rx_buf = (unsigned long)NULL,
+ .len = 0,
+ .cs_change = false,
+ };
+
+ ioctl(priv->file, SPI_IOC_MESSAGE(1), &transfer_data);
+ }
}
/****************************************************************************
@@ -641,7 +661,7 @@ static int linux_spi_transfer(struct spi_dev_s *dev, const void *txbuffer,
.tx_buf = (unsigned long)txbuffer, /* Transmit buffer. */
.rx_buf = (unsigned long)rxbuffer, /* Receive buffer. */
.len = (uint32_t)nwords, /* Number of words. */
- .cs_change = false, /* In normal, CS remains selected. */
+ .cs_change = true, /* In normal, CS remains selected. */
};
#ifdef CONFIG_SPI_HWFEATURES