fixing volume control for vs1053

This commit is contained in:
Joel Bodenmann 2014-06-28 06:33:47 +02:00
parent 490bd82dd2
commit dad27f76ba

View File

@ -278,11 +278,19 @@ bool_t gaudio_play_lld_init(uint16_t channel, uint32_t frequency, ArrayDataForma
}
bool_t gaudio_play_lld_set_volume(uint8_t vol) {
uint16_t tmp;
// Volume is 0xFE -> 0x00. Adjust vol to match
vol = ~vol;
if (vol == 0xFF) vol = 0xFE;
if (vol > 0xFE)
vol = 0xFE;
tmp = 0;
tmp |= (( vol << VOL_LEFT_SHIFT ) & VOL_LEFT_MASK );
tmp |= (( vol << VOL_RIGHT_SHIFT ) & VOL_RIGHT_MASK );
cmd_write(SCI_VOL, tmp);
cmd_write(SCI_VOL, ((uint16_t)vol) << 8 | vol);
return TRUE;
}