Skip to content

Commit c5fa9af

Browse files
hongquan-progmmahadevan108
authored andcommitted
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 <[email protected]>
1 parent a2e920c commit c5fa9af

File tree

1 file changed

+7
-1
lines changed
  • drivers/wifi/nrfwifi/src/qspi/src

1 file changed

+7
-1
lines changed

drivers/wifi/nrfwifi/src/qspi/src/spi_if.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static int spim_xfer_rx(unsigned int addr, void *data, unsigned int len, unsigne
5858
addr & 0xFF,
5959
0 /* dummy byte */
6060
};
61+
uint8_t discard[sizeof(hdr) + 2 * 4];
6162

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

6970
const struct spi_buf rx_buf[] = {
70-
{.buf = NULL, .len = sizeof(hdr) + discard_bytes},
71+
{.buf = discard, .len = sizeof(hdr) + discard_bytes},
7172
{.buf = data, .len = len },
7273
};
7374

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

77+
if (rx_buf[0].len > sizeof(discard)) {
78+
LOG_ERR("Discard bytes too large, please adjust buf size");
79+
return -EINVAL;
80+
}
81+
7682
return spi_transceive_dt(&spi_spec, &tx, &rx);
7783
}
7884

0 commit comments

Comments
 (0)