Fix Codec initialization (add initial reset)
This commit is contained in:
parent
cc183e6509
commit
961a42a1d1
File diff suppressed because one or more lines are too long
|
@ -14,20 +14,21 @@ void codec_wait() {
|
|||
}
|
||||
|
||||
void init_codec() {
|
||||
*CODEC = 0x1A00; // R13 - Turn On Headphones
|
||||
codec_wait();
|
||||
*CODEC = 0x2A1F; // R21 - Enable All the Analog In
|
||||
codec_wait();
|
||||
*CODEC = 0x2301; // R17
|
||||
codec_wait();
|
||||
*CODEC = 0x2C07; // R22 - Enable all output sources
|
||||
codec_wait();
|
||||
*CODEC = 0x1402; // R10
|
||||
codec_wait();
|
||||
*CODEC = 0x1602; // R11
|
||||
codec_wait();
|
||||
*CODEC = 0x1845; // R12
|
||||
codec_wait();
|
||||
const uint16_t codec_init_data[] = {
|
||||
0x2e00, // Master reset
|
||||
0x1a00, // R13 - Turn On Headphones
|
||||
0x2a1f, // R21 - Enable All the Analog In
|
||||
0x2301, // R17 - Auto-level control: WM8776_R17_ADC_ANALOG_AUTO_LEVEL_CONTROL | LCEN_ENABLED | HLD_MASK,
|
||||
0x2c07, // R22 - Enable all output sources
|
||||
0x1402, // R10 - DAC interface control
|
||||
0x1602, // R11 - ADC inteface control
|
||||
0x1845 // R12 - ADC rate 768, DAC rate 512
|
||||
};
|
||||
|
||||
for (int i = 0; i<sizeof(codec_init_data)/sizeof(uint16_t); i++) {
|
||||
codec_wait();
|
||||
*CODEC = codec_init_data[i];
|
||||
}
|
||||
|
||||
codec_set_volume(0xff);
|
||||
}
|
||||
|
@ -41,11 +42,11 @@ void init_codec() {
|
|||
void codec_set_volume(unsigned char vol) {
|
||||
volume = vol;
|
||||
|
||||
*CODEC = 0x0A00 | (0xFF - vol);
|
||||
codec_wait();
|
||||
*CODEC = 0x0A00 | (0xFF - vol);
|
||||
|
||||
codec_wait();
|
||||
*CODEC = 0x0400 | (vol >> 1);
|
||||
codec_wait();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue