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() {
|
void init_codec() {
|
||||||
*CODEC = 0x1A00; // R13 - Turn On Headphones
|
const uint16_t codec_init_data[] = {
|
||||||
codec_wait();
|
0x2e00, // Master reset
|
||||||
*CODEC = 0x2A1F; // R21 - Enable All the Analog In
|
0x1a00, // R13 - Turn On Headphones
|
||||||
codec_wait();
|
0x2a1f, // R21 - Enable All the Analog In
|
||||||
*CODEC = 0x2301; // R17
|
0x2301, // R17 - Auto-level control: WM8776_R17_ADC_ANALOG_AUTO_LEVEL_CONTROL | LCEN_ENABLED | HLD_MASK,
|
||||||
codec_wait();
|
0x2c07, // R22 - Enable all output sources
|
||||||
*CODEC = 0x2C07; // R22 - Enable all output sources
|
0x1402, // R10 - DAC interface control
|
||||||
codec_wait();
|
0x1602, // R11 - ADC inteface control
|
||||||
*CODEC = 0x1402; // R10
|
0x1845 // R12 - ADC rate 768, DAC rate 512
|
||||||
codec_wait();
|
};
|
||||||
*CODEC = 0x1602; // R11
|
|
||||||
codec_wait();
|
for (int i = 0; i<sizeof(codec_init_data)/sizeof(uint16_t); i++) {
|
||||||
*CODEC = 0x1845; // R12
|
codec_wait();
|
||||||
codec_wait();
|
*CODEC = codec_init_data[i];
|
||||||
|
}
|
||||||
|
|
||||||
codec_set_volume(0xff);
|
codec_set_volume(0xff);
|
||||||
}
|
}
|
||||||
|
@ -41,11 +42,11 @@ void init_codec() {
|
||||||
void codec_set_volume(unsigned char vol) {
|
void codec_set_volume(unsigned char vol) {
|
||||||
volume = vol;
|
volume = vol;
|
||||||
|
|
||||||
*CODEC = 0x0A00 | (0xFF - vol);
|
|
||||||
codec_wait();
|
codec_wait();
|
||||||
|
*CODEC = 0x0A00 | (0xFF - vol);
|
||||||
|
|
||||||
|
codec_wait();
|
||||||
*CODEC = 0x0400 | (vol >> 1);
|
*CODEC = 0x0400 | (vol >> 1);
|
||||||
codec_wait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue