12 bit Peaks with MCP4822

Hello everyone,

I think this is the best place to post this, as people here are most familiar with Mutable Instruments firmware. If not feel free to delete.

I’m thinking about doing a similar 12 bit conversion project as sound-force.nl did on Braids for Peaks, as it’s another discontinued module, it uses the same “Blue Pill processor”, and a very similar DAC (same model just dual channel).
To use the MCP4822, sound-force only had to modify the dac.h file of the Braids firmware (see how on his site). Because of the similar hardware, Peaks has similar firmware, and so I tried to apply a similar modification. Could anyone here give some feedback on this, if you think it is worth pursuing? Or if it’s going to be much more complicated.

This is at line 56 of the Peaks dac.h file:

if (wrote_both_channels_) {
		/* delete old DAC channel 1 write code
      SPI2->DR = 0x2400 | (data_[0] >> 8);
      wrote_both_channels_ = false;
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      SPI2->DR = data_[0] << 8;
	  */
	  
	  // new DAC channel 1 code
	  //step 1 convert 16 bits data to 12 bits
	  data_[0] = data_[0] >> 4;
	  //step 2 add the configuration bit_mask (see MCP4822 documentation for how to configure)
	  data_[0] &= 0x0FFF;
	  data_[0] |= 0x3000;
	  SPI2->DR = data_[0];
	  
    } else {
		/* delete old DAC channel 2 write code
      SPI2->DR = 0x1000 | (data_[1] >> 8);
      wrote_both_channels_ = true;
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      __asm__("nop");
      SPI2->DR = data_[1] << 8;
	  */
	  
	  // new DAC channel 2 code
	  //step 1 convert 16 bits data to 12 bits
	  data_[1] = data_[1] >> 4;
	  //step 2 add the configuration bit_mask, this time for second channel
	  data_[1] &= 0x0FFF;
	  data_[1] |= 0xB000;
	  SPI2->DR = data_[01;
    }
    return wrote_both_channels_;