/* Set DAC Channel LFSR Mask or Triangle Wave Amplitude. 
Sets the digital to analog converter superimposed waveform generation characteristics.  */
void dac_set_waveform_characteristics(uint32_t dac, int channel, int mamp)
/* Set DAC Channel LFSR Mask or Triangle Wave Amplitude. 
Sets the digital to analog converter superimposed waveform generation characteristics.  */
void dac_set_waveform_characteristics(uint32_t dac, int channel, int mamp)
{
	uint32_t reg = DAC_CR(dac);
	switch(channel) {
	case DAC_CHANNEL1:
		reg &= ~(DAC_CR_MAMPx_MASK << DAC_CR_MAMP1_SHIFT);
		reg |= mamp << DAC_CR_MAMP1_SHIFT;
		break;
	case DAC_CHANNEL2:
		reg &= ~(DAC_CR_MAMPx_MASK << DAC_CR_MAMP2_SHIFT);
		reg |= mamp << DAC_CR_MAMP2_SHIFT;
		break;
	case DAC_CHANNEL_BOTH:
		reg &= ~(DAC_CR_MAMPx_MASK << DAC_CR_MAMP1_SHIFT)
			| ~(DAC_CR_MAMPx_MASK << DAC_CR_MAMP2_SHIFT);
		reg |= mamp << DAC_CR_MAMP1_SHIFT;
		reg |= mamp << DAC_CR_MAMP2_SHIFT;
		break;
	default:
		break;
	}
	DAC_CR(dac) = reg;
}