Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void DAC_Init( dac_channels_conf_e channel_conf, uint8_t conv_trig_sel, bool output_buffer_used)
- {
- // Set the DAC out pins as analog pins
- GPIO_Analog_Configure(GPIOA, PIN_4 | PIN_5);
- switch(channel_conf)
- {
- case dac_dual_channel_simultanous:
- {
- DAC->CR &= (uint32_t)0;
- // Set the conversion trigger source and enable it
- DAC->CR |= ((conv_trig_sel << 3) | DAC_CR_TEN1) | (conv_trig_sel << 19) | DAC_CR_TEN2 ;
- // Enable the output buffer (if required) to decrease the output impedance
- if(output_buffer_used)
- {
- DAC->CR |= DAC_CR_BOFF1 | DAC_CR_BOFF2;
- }
- // Enable the peripheral
- DAC->CR |= DAC_CR_EN1 | DAC_CR_EN2;
- break;
- }
- default:
- {
- DAC->CR &= (uint32_t)(0 << channel_conf);
- // Set the conversion trigger source and enable it
- DAC->CR |= ((conv_trig_sel << 3) | DAC_CR_TEN1) << channel_conf ;
- // Enable the output buffer (if required) to decrease the output impedance
- if(output_buffer_used)
- {
- DAC->CR |= DAC_CR_BOFF1 << channel_conf;
- }
- // Enable the peripheral
- DAC->CR |= DAC_CR_EN1 << channel_conf;
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement