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: Hongquan Li <hongquan.prog@gmail.com>
This commit is contained in:
Hongquan Li 2024-11-03 14:23:25 +08:00 committed by Mahesh Mahadevan
parent a2e920cf96
commit c5fa9af235
1 changed files with 7 additions and 1 deletions

View File

@ -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);
}