diff options
| author | Peter Hinch <peter@hinch.me.uk> | 2016-06-13 08:54:57 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2016-09-05 15:07:23 +1000 |
| commit | ef47a67cf42246bbcf3c81e5f89e0e25db9dff74 (patch) | |
| tree | ee42680249e6c7ab439a1fd4cd690dbb3c22de81 | |
| parent | 9526e24234bba06fcbf42c590743087bc8527319 (diff) | |
stmhal/dac: Fix DAC (re-)initialisation by resetting DMA.
Fixes issue #2176.
| -rw-r--r-- | stmhal/dac.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/stmhal/dac.c b/stmhal/dac.c index 7493bb59a..a9b1b9eca 100644 --- a/stmhal/dac.c +++ b/stmhal/dac.c @@ -171,6 +171,14 @@ STATIC mp_obj_t pyb_dac_init_helper(pyb_dac_obj_t *self, mp_uint_t n_args, const #endif // stop anything already going on + __DMA1_CLK_ENABLE(); + DMA_HandleTypeDef DMA_Handle; + /* Get currently configured dma */ + dma_init_handle(&DMA_Handle, self->tx_dma_descr, (void*)NULL); + // Need to deinit DMA first + DMA_Handle.State = HAL_DMA_STATE_READY; + HAL_DMA_DeInit(&DMA_Handle); + HAL_DAC_Stop(&DAC_Handle, self->dac_channel); if ((self->dac_channel == DAC_CHANNEL_1 && DAC_Handle.DMA_Handle1 != NULL) || (self->dac_channel == DAC_CHANNEL_2 && DAC_Handle.DMA_Handle2 != NULL)) { |
