summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2022-01-23 03:33:43 +0200
committerDamien George <damien@micropython.org>2022-01-27 17:10:39 +1100
commita00e1e57355f850bce928a770851bc0dc01484c2 (patch)
tree19fe71fe9d63179279b19eebdf1ad39e77a8854c
parentc1841c2d455a99f4184487da658e88267785ebd5 (diff)
stm32/dac: Deinit all DACs on soft reset.
DAC timed functions continue to run after a soft reset cycle, using collected memory in the case of write_timed.
-rw-r--r--ports/stm32/dac.c7
-rw-r--r--ports/stm32/dac.h2
-rw-r--r--ports/stm32/main.c3
3 files changed, 12 insertions, 0 deletions
diff --git a/ports/stm32/dac.c b/ports/stm32/dac.c
index fe3aecdde..d51312aeb 100644
--- a/ports/stm32/dac.c
+++ b/ports/stm32/dac.c
@@ -131,6 +131,13 @@ STATIC void dac_deinit(uint32_t dac_channel) {
#endif
}
+void dac_deinit_all(void) {
+ dac_deinit(DAC_CHANNEL_1);
+ #if !defined(STM32L452xx)
+ dac_deinit(DAC_CHANNEL_2);
+ #endif
+}
+
STATIC void dac_config_channel(uint32_t dac_channel, uint32_t trig, uint32_t outbuf) {
DAC->CR &= ~(DAC_CR_EN1 << dac_channel);
uint32_t cr_off = DAC_CR_DMAEN1 | DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1;
diff --git a/ports/stm32/dac.h b/ports/stm32/dac.h
index fca36e019..d5686725a 100644
--- a/ports/stm32/dac.h
+++ b/ports/stm32/dac.h
@@ -28,4 +28,6 @@
extern const mp_obj_type_t pyb_dac_type;
+void dac_deinit_all(void);
+
#endif // MICROPY_INCLUDED_STM32_DAC_H
diff --git a/ports/stm32/main.c b/ports/stm32/main.c
index 431fa20de..3291a8018 100644
--- a/ports/stm32/main.c
+++ b/ports/stm32/main.c
@@ -654,6 +654,9 @@ soft_reset_exit:
#if MICROPY_HW_ENABLE_CAN
can_deinit_all();
#endif
+ #if MICROPY_HW_ENABLE_DAC
+ dac_deinit_all();
+ #endif
machine_deinit();
#if MICROPY_PY_THREAD