Skip to content

Commit a00e1e5

Browse files
iabdalkaderdpgeorge
authored andcommitted
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.
1 parent c1841c2 commit a00e1e5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

ports/stm32/dac.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ STATIC void dac_deinit(uint32_t dac_channel) {
131131
#endif
132132
}
133133

134+
void dac_deinit_all(void) {
135+
dac_deinit(DAC_CHANNEL_1);
136+
#if !defined(STM32L452xx)
137+
dac_deinit(DAC_CHANNEL_2);
138+
#endif
139+
}
140+
134141
STATIC void dac_config_channel(uint32_t dac_channel, uint32_t trig, uint32_t outbuf) {
135142
DAC->CR &= ~(DAC_CR_EN1 << dac_channel);
136143
uint32_t cr_off = DAC_CR_DMAEN1 | DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1;

ports/stm32/dac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@
2828

2929
extern const mp_obj_type_t pyb_dac_type;
3030

31+
void dac_deinit_all(void);
32+
3133
#endif // MICROPY_INCLUDED_STM32_DAC_H

ports/stm32/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,9 @@ void stm32_main(uint32_t reset_mode) {
654654
#if MICROPY_HW_ENABLE_CAN
655655
can_deinit_all();
656656
#endif
657+
#if MICROPY_HW_ENABLE_DAC
658+
dac_deinit_all();
659+
#endif
657660
machine_deinit();
658661

659662
#if MICROPY_PY_THREAD

0 commit comments

Comments
 (0)