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.
This commit is contained in:
iabdalkader 2022-01-23 03:33:43 +02:00 committed by Damien George
parent c1841c2d45
commit a00e1e5735
3 changed files with 12 additions and 0 deletions

View File

@ -131,6 +131,13 @@ STATIC void dac_deinit(uint32_t dac_channel) {
#endif #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) { STATIC void dac_config_channel(uint32_t dac_channel, uint32_t trig, uint32_t outbuf) {
DAC->CR &= ~(DAC_CR_EN1 << dac_channel); 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; uint32_t cr_off = DAC_CR_DMAEN1 | DAC_CR_MAMP1 | DAC_CR_WAVE1 | DAC_CR_TSEL1 | DAC_CR_TEN1;

View File

@ -28,4 +28,6 @@
extern const mp_obj_type_t pyb_dac_type; extern const mp_obj_type_t pyb_dac_type;
void dac_deinit_all(void);
#endif // MICROPY_INCLUDED_STM32_DAC_H #endif // MICROPY_INCLUDED_STM32_DAC_H

View File

@ -654,6 +654,9 @@ soft_reset_exit:
#if MICROPY_HW_ENABLE_CAN #if MICROPY_HW_ENABLE_CAN
can_deinit_all(); can_deinit_all();
#endif #endif
#if MICROPY_HW_ENABLE_DAC
dac_deinit_all();
#endif
machine_deinit(); machine_deinit();
#if MICROPY_PY_THREAD #if MICROPY_PY_THREAD