Skip to content

Commit 7b7b976

Browse files
esp32s3_spi: fix tx/rx bounds and pad 0xEB dummy bytes
1 parent cbb15d7 commit 7b7b976

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

hw/ssi/esp32s3_spi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ static void esp32s3_spi_txrx_buffer(ESP32S3SpiState *s,
150150
int bytes = MAX(tx_bytes, rx_bytes);
151151
for (int i = 0; i < bytes; ++i) {
152152
uint8_t byte = 0;
153-
if (byte < tx_bytes) {
153+
if (i < tx_bytes) {
154154
memcpy(&byte, tx + i, 1);
155155
}
156156
uint32_t res = ssi_transfer(s->spi, byte);
157-
if (byte < rx_bytes) {
157+
if (i < rx_bytes) {
158158
memcpy(rx + i, &res, 1);
159159
}
160160
}
@@ -272,6 +272,10 @@ static void esp32s3_spi_begin_transaction(ESP32S3SpiState *s)
272272
}
273273
}
274274

275+
if (t.cmd == 0xeb && t.dummy_bytes < 2) {
276+
t.dummy_bytes = 2;
277+
}
278+
275279
esp32s3_spi_perform_transaction(s, &t);
276280
}
277281

0 commit comments

Comments
 (0)