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 <xinbingnan@xiaomi.com>
This commit is contained in:
W-Mai 2023-01-11 16:19:47 +08:00 committed by Xiang Xiao
parent 40c9e627d6
commit bcb0abc05d

View file

@ -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