Skip to content

Commit 20fe361

Browse files
committed
wm8960 configuration
1 parent 9205725 commit 20fe361

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/Driver.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -678,25 +678,40 @@ class AudioDriverWM8960Class : public AudioDriver {
678678
mtb_wm8960_free();
679679
return true;
680680
}
681+
681682
bool setMute(bool enable) { return setVolume(enable ? 0 : volume_out); }
683+
682684
/// Defines the Volume (in %) if volume is 0, mute is enabled,range is 0-100.
683685
bool setVolume(int volume) {
684686
setOutputVolume(volume);
685687
return true;
686688
};
687689
int getVolume() { return volume_out; }
690+
688691
bool setInputVolume(int volume) {
689692
adjustInputVolume(volume);
690693
return true;
691694
}
692695
bool isVolumeSupported() { return true; }
696+
693697
bool isInputVolumeSupported() { return true; }
694698

699+
/// Configuration: define retry count (default : 0)
700+
void setI2CRetryCount(int cnt) { i2c_retry_count = cnt; }
701+
702+
/// Configuration: enable/diable PLL (active by default)
703+
void setEnablePLL(bool active) { vs1053_enable_pll = active; }
704+
705+
/// Configuration: define master clock frequency (default: 0)
706+
void setMclkHz(uint32_t hz ){
707+
vs1053_mclk_hz = hz;
708+
}
709+
695710
protected:
696-
int volume_in;
697-
int volume_out;
698-
int i2c_retry_count = 5;
699-
int vs1053_mclk_hz = 0;
711+
int volume_in = 100;
712+
int volume_out = 100;
713+
int i2c_retry_count = 0;
714+
uint32_t vs1053_mclk_hz = 0;
700715
bool vs1053_enable_pll = true;
701716

702717
void adjustInputVolume(int vol) {
@@ -751,7 +766,8 @@ class AudioDriverWM8960Class : public AudioDriver {
751766
vs1053_mclk_hz = 512 * codec_cfg.getRateNumeric();
752767
}
753768
if (!mtb_wm8960_configure_clocking(
754-
vs1053_mclk_hz, vs1053_enable_pll, sampleRate(codec_cfg.getRateNumeric()),
769+
vs1053_mclk_hz, vs1053_enable_pll,
770+
sampleRate(codec_cfg.getRateNumeric()),
755771
wordLength(codec_cfg.getBitsNumeric()),
756772
modeMasterSlave(codec_cfg.i2s.mode == MODE_MASTER))) {
757773
AD_LOGE("mtb_wm8960_configure_clocking");

src/Driver/wm8960/mtb_wm8960.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ typedef enum
550550
WM8960_MODE_SLAVE = WM8960_AUDIO_INTF0_MS_SLAVE /**< Slave mode */
551551
} mtb_wm8960_mode_t;
552552

553-
#ifdef ARDUINO
554553

555554
/**
556555
* @brief Provide an alternative initialized Wire object. If this is not called we
@@ -561,9 +560,8 @@ typedef enum
561560
* @return true
562561
* @return false
563562
*/
564-
bool mtb_wm8960_set_wire(TwoWire* i2c_inst);
563+
bool mtb_wm8960_set_wire(void* i2c_inst);
565564

566-
#endif
567565

568566
/**
569567
* @brief Defines the number of times we retry to update a register value via I2C.

0 commit comments

Comments
 (0)