Skip to content

Commit

Permalink
[nrf fromlist] drivers/wifi/nrfwifi: Add buffer for discard bytes
Browse files Browse the repository at this point in the history
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 zephyrproject-rtos#80686

Upstream PR #: 80787

Signed-off-by: Hongquan Li <[email protected]>
  • Loading branch information
hongquan-prog authored and rlubos committed Nov 5, 2024
1 parent f2efee5 commit e26e2a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/wifi/nrfwifi/src/qspi/src/spi_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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);
}

Expand Down

0 comments on commit e26e2a2

Please sign in to comment.