Add function to recalibrate codec HPF

pull/13/head
Steve Lascos 4 years ago
parent 56bbb1b339
commit 6575400fbc
  1. 2
      examples/Tests/MeasureNoise/MeasureNoise.ino
  2. 6
      src/BAAudioControlWM8731.h
  3. 20
      src/peripherals/BAAudioControlWM8731.cpp

@ -69,6 +69,8 @@ void setup() {
rmsModule.enable();
rmsModule.bypass(false);
codecControl.recalibrateDcOffset();
}

@ -110,6 +110,12 @@ public:
/// @details This will cause the codec to reset its internal registers to default values.
void resetCodec(void);
/// Recalibrate the DC offset removal
/// @details This function will temporarily mute the inputs, enable the CODEC's
/// HPF in order to calculate the DC offset (which is subtracted out). Then the filter
/// is disabled.
void recalibrateDcOffset(void);
/// Write a custom command to the codec via I2C control interface.
/// @details See WM8731 datasheet for register map details.
/// @param addr The register address you wish to write to, range 0 to 15.

@ -361,6 +361,26 @@ void BAAudioControlWM8731::resetCodec(void)
resetInternalReg();
}
void BAAudioControlWM8731::recalibrateDcOffset(void)
{
// mute the inputs
setLeftInMute(true);
setRightInMute(true);
// enable the HPF and DC offset store
setHPFDisable(false);
regArray[WM8731_HPF_STORE_OFFSET_ADDR] |= WM8731_HPF_STORE_OFFSET_MASK;
write(WM8731_REG_DIGITAL, regArray[WM8731_REG_DIGITAL]);
delay(1000); // wait for the DC offset to be calculated over 1 second
setHPFDisable(true); // disable the dynamic HPF calculation
delay(500);
// unmute the inputs
setLeftInMute(false);
setRightInMute(false);
}
// Direct write control to the codec
bool BAAudioControlWM8731::writeI2C(unsigned int addr, unsigned int val)
{

Loading…
Cancel
Save