From 8a1a5c236d1fc07596a1f23f73e26f24c0e5b540 Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Tue, 4 Aug 2015 23:36:01 -0700 Subject: [PATCH] stmhal: Fix hardfault when configured as a SPI slave --- stmhal/spi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stmhal/spi.c b/stmhal/spi.c index 311f176b3..b1aacfd0b 100644 --- a/stmhal/spi.c +++ b/stmhal/spi.c @@ -546,7 +546,9 @@ STATIC mp_obj_t pyb_spi_recv(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_ if (status == HAL_OK) { status = spi_wait_dma_finished(self->spi, args[1].u_int); } - dma_deinit(&tx_dma); + if (self->spi->hdmatx != NULL) { + dma_deinit(&tx_dma); + } dma_deinit(&rx_dma); }