bringup r8 muting

custom
jacqueline 1 year ago
parent 0db85f5e9e
commit 09eacb71f0
  1. 6
      src/drivers/gpios.cpp
  2. 18
      src/drivers/i2s_dac.cpp
  3. 5
      src/drivers/include/gpios.hpp

@ -37,13 +37,13 @@ static const uint8_t kPortADefault = 0b00111110;
// 0 - 3.5mm jack detect (active low) // 0 - 3.5mm jack detect (active low)
// 1 - headphone amp power enable // 1 - headphone amp power enable
// 2 - sd card detect // 2 - sd card detect
// 3 - NC // 3 - amplifier unmute (revisions < r8)
// 4 - NC // 4 - amplifier mute (revisions >= r8)
// 5 - NC // 5 - NC
// 6 - NC // 6 - NC
// 7 - NC // 7 - NC
// Default inputs high, amp off. // Default inputs high, amp off.
static const uint8_t kPortBDefault = 0b00000101; static const uint8_t kPortBDefault = 0b00001101;
/* /*
* Convenience mehod for packing the port a and b bytes into a single 16 bit * Convenience mehod for packing the port a and b bytes into a single 16 bit

@ -88,13 +88,21 @@ I2SDac::I2SDac(IGpios& gpio, i2s_chan_handle_t i2s_handle)
I2S_SLOT_MODE_STEREO)) { I2S_SLOT_MODE_STEREO)) {
clock_config_.clk_src = I2S_CLK_SRC_APLL; clock_config_.clk_src = I2S_CLK_SRC_APLL;
// The amplifier's power rails ramp unevenly, with the negative rail coming
// up ~5ms after the positive rail. Ensure that headphone output is muted
// during this to avoid a loud pop during power up.
gpio_.WriteSync(IGpios::Pin::kAmplifierMute, true);
vTaskDelay(pdMS_TO_TICKS(1));
gpio_.WriteSync(IGpios::Pin::kAmplifierEnable, true); gpio_.WriteSync(IGpios::Pin::kAmplifierEnable, true);
// Reset all registers back to their default values. // Reset all registers back to their default values.
wm8523::WriteRegister(wm8523::Register::kReset, 1); wm8523::WriteRegister(wm8523::Register::kReset, 1);
// Wait for DAC reset + analog rails ramp.
vTaskDelay(pdMS_TO_TICKS(10)); vTaskDelay(pdMS_TO_TICKS(10));
wm8523::WriteRegister(wm8523::Register::kPsCtrl, 0b0);
wm8523::WriteRegister(wm8523::Register::kPsCtrl, 0b0);
// Use zero-cross detection for volume changes. // Use zero-cross detection for volume changes.
wm8523::WriteRegister(wm8523::Register::kDacCtrl, 0b10000); wm8523::WriteRegister(wm8523::Register::kDacCtrl, 0b10000);
} }
@ -103,6 +111,8 @@ I2SDac::~I2SDac() {
Stop(); Stop();
i2s_del_channel(i2s_handle_); i2s_del_channel(i2s_handle_);
gpio_.WriteSync(IGpios::Pin::kAmplifierMute, true);
vTaskDelay(pdMS_TO_TICKS(1));
gpio_.WriteSync(IGpios::Pin::kAmplifierEnable, false); gpio_.WriteSync(IGpios::Pin::kAmplifierEnable, false);
} }
@ -119,11 +129,13 @@ auto I2SDac::Stop() -> void {
auto I2SDac::SetPaused(bool paused) -> void { auto I2SDac::SetPaused(bool paused) -> void {
if (paused) { if (paused) {
gpio_.WriteSync(IGpios::Pin::kAmplifierUnmute, false); gpio_.WriteSync(IGpios::Pin::kAmplifierUnmuteLegacy, false);
gpio_.WriteSync(IGpios::Pin::kAmplifierMute, true);
set_channel(false); set_channel(false);
} else { } else {
set_channel(true); set_channel(true);
gpio_.WriteSync(IGpios::Pin::kAmplifierUnmute, true); gpio_.WriteSync(IGpios::Pin::kAmplifierUnmuteLegacy, true);
gpio_.WriteSync(IGpios::Pin::kAmplifierMute, false);
} }
} }

@ -55,8 +55,9 @@ class IGpios {
kPhoneDetect = 8, kPhoneDetect = 8,
kAmplifierEnable = 9, kAmplifierEnable = 9,
kSdCardDetect = 10, kSdCardDetect = 10,
kAmplifierUnmute = 11, kAmplifierUnmuteLegacy = 11,
// 12 through 15 are unused kAmplifierMute = 12,
// 13 through 15 are unused
}; };
/* Nicer value names for use with kSdMuxSwitch. */ /* Nicer value names for use with kSdMuxSwitch. */

Loading…
Cancel
Save