Commit c5fa9af2 authored by Hongquan Li's avatar Hongquan Li Committed by Mahesh Mahadevan
Browse files

drivers/wifi/nrfwifi: Add buffer for discard bytes



Some spi drivers do not allow the send buffer
and receive buffer to be empty at the same time,
if this happens it will cause the spi to be unable
to communicate with the nrf7002, so add the receive
buffer for the discard byte in the spim_xfer_rx.

Fix #80686

Signed-off-by: default avatarHongquan Li <hongquan.prog@gmail.com>
parent a2e920cf
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ static int spim_xfer_rx(unsigned int addr, void *data, unsigned int len, unsigne
		addr & 0xFF,
		0 /* dummy byte */
	};
	uint8_t discard[sizeof(hdr) + 2 * 4];

	const struct spi_buf tx_buf[] = {
		{.buf = hdr,  .len = sizeof(hdr) },
@@ -67,12 +68,17 @@ static int spim_xfer_rx(unsigned int addr, void *data, unsigned int len, unsigne
	const struct spi_buf_set tx = { .buffers = tx_buf, .count = 2 };

	const struct spi_buf rx_buf[] = {
		{.buf = NULL,  .len = sizeof(hdr) + discard_bytes},
		{.buf = discard,  .len = sizeof(hdr) + discard_bytes},
		{.buf = data, .len = len },
	};

	const struct spi_buf_set rx = { .buffers = rx_buf, .count = 2 };

	if (rx_buf[0].len > sizeof(discard)) {
		LOG_ERR("Discard bytes too large, please adjust buf size");
		return -EINVAL;
	}

	return spi_transceive_dt(&spi_spec, &tx, &rx);
}