From a9008884c93946f26fd26448aeb716d005693d6c Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 5 Sep 2023 16:01:05 +1000 Subject: [PATCH] Improve dac startup sequencing to reduce the clicky poppy --- src/drivers/i2s_dac.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/drivers/i2s_dac.cpp b/src/drivers/i2s_dac.cpp index bedf7ebf..2fdd826f 100644 --- a/src/drivers/i2s_dac.cpp +++ b/src/drivers/i2s_dac.cpp @@ -93,22 +93,21 @@ I2SDac::I2SDac(IGpios& gpio, i2s_chan_handle_t i2s_handle) wm8523::WriteRegister(wm8523::Register::kReset, 1); vTaskDelay(pdMS_TO_TICKS(10)); wm8523::WriteRegister(wm8523::Register::kPsCtrl, 0b0); + + gpio_.WriteSync(IGpios::Pin::kAmplifierEnable, true); } I2SDac::~I2SDac() { Stop(); i2s_del_channel(i2s_handle_); + + gpio_.WriteSync(IGpios::Pin::kAmplifierEnable, false); } auto I2SDac::Start() -> void { std::lock_guard lock(configure_mutex_); gpio_.WriteSync(IGpios::Pin::kAmplifierUnmute, false); - // Ramp up the amplifier power supply. - gpio_.WriteSync(IGpios::Pin::kAmplifierEnable, true); - - // Wait for voltage to stabilise - vTaskDelay(pdMS_TO_TICKS(5)); // Ensure the DAC powers up to a muted state. wm8523::WriteRegister(wm8523::Register::kPsCtrl, 0b10); @@ -118,12 +117,7 @@ auto I2SDac::Start() -> void { i2s_channel_enable(i2s_handle_); i2s_active_ = true; - // Wait for DAC output lines to stabilise - vTaskDelay(pdMS_TO_TICKS(5)); - wm8523::WriteRegister(wm8523::Register::kPsCtrl, 0b11); - - vTaskDelay(pdMS_TO_TICKS(5)); gpio_.WriteSync(IGpios::Pin::kAmplifierUnmute, true); }