Missing CS42448 control functions written

Status
Not open for further replies.

palmerr

Well-known member
Hi Paul,

I was testing some CS42448 functions and found that some of the functions for .output() and .input() were blank!

Here is the missing code:

Code:
// Output channels defined as [1..8]
bool AudioControlCS42448::volumeInteger(int channel, uint32_t n)
{
	write(CS42448_DAC_Channel_Mute, 0); 			     // unmute all channels
	return write(CS42448_DAC_Channel_Mute + channel -1, n); // set this channel
}

// Input channels defined as [1..6] - no volume control on EXT inputs 7/8
bool AudioControlCS42448::inputLevelInteger(int32_t n)
{
	uint8_t data[6];
	for (int i = 0; i < 6; i++) 
          data[i] = n;
	return	write(CS42448_AIN1_Volume_Control, data, 6); // set all channels (not 7 & 8)
}

bool AudioControlCS42448::inputLevelInteger(int channel, int32_t n)
{
	return write(CS42448_AIN1_Volume_Control + channel -1, n); // set just this channel
}
 
Last edited:
And a correction to a definition in the .h file.

The function's max return value should be 255, rather than 128, for a gain of -127.5dB.

Code:
// convert level to volume byte, section 6.9.1, page 50
uint32_t volumebyte(float level) {
  if (level >= 1.0) return 0;
  if (level <= 0.0000003981) return 255;
  return roundf(log10f(level) * -40.0);
}
 
Correcting my own post!

I set the wrong base for the register bank.

Code:
// Output channels defined as [1..8]
bool AudioControlCS42448::volumeInteger(int channel, uint32_t n)
{
	write(CS42448_DAC_Channel_Mute, 0); 			     // unmute all channels
	return write(CS42448_AOUT1_Volume_Control + channel -1, n); // set this channel
 
Status
Not open for further replies.
Back
Top