Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Missing CS42448 control functions written

  1. #1
    Senior Member
    Join Date
    Aug 2016
    Location
    Australia
    Posts
    204

    Missing CS42448 control functions written

    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 by palmerr; 05-24-2021 at 03:08 AM.

  2. #2
    Senior Member
    Join Date
    Aug 2016
    Location
    Australia
    Posts
    204
    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);
    }

  3. #3
    Senior Member
    Join Date
    Aug 2016
    Location
    Australia
    Posts
    204
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •