Skip to content

Commit 450ebf9

Browse files
committed
NUCLEO_F429ZI: Fix SPI ref impl - add null check in spi_transfer()
1 parent 2a58aa3 commit 450ebf9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

targets/TARGET_STM/stm_spi_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ uint32_t spi_transfer(spi_t *obj, const void *tx_buffer, uint32_t tx_length,
525525
out = *(uint8_t *)write_fill;
526526
}
527527
in = spi_write(obj, out);
528-
if (i < rx_length) {
528+
if (rx_buffer && i < rx_length) {
529529
((uint8_t*)rx_buffer)[i] = (uint8_t)in;
530530
}
531531
break;
@@ -536,7 +536,7 @@ uint32_t spi_transfer(spi_t *obj, const void *tx_buffer, uint32_t tx_length,
536536
out = *(uint16_t *)write_fill;
537537
}
538538
in = spi_write(obj, out);
539-
if (i < rx_length) {
539+
if (rx_buffer && i < rx_length) {
540540
((uint16_t*)rx_buffer)[i] = (uint16_t)in;
541541
}
542542
break;

0 commit comments

Comments
 (0)