libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Defined Constants and Types for the STM32G0xx Digital-to-Analog Converter More...
Modules | |
DAC register base addresses | |
DAC Registers | |
DAC_CR values | |
DAC_SWTRIGR Values | |
DAC_DHRxxx Values | |
DAC_DORx Values | |
DAC_SR Values | |
DAC Channel Identifier | |
Enumerations | |
enum | dac_align { DAC_ALIGN_RIGHT8 , DAC_ALIGN_RIGHT12 , DAC_ALIGN_LEFT12 } |
DAC data size (8/12 bits), alignment (right/left) More... | |
enum | dac_wave { DAC_WAVE_DISABLE = 0 , DAC_WAVE_NOISE = 1 , DAC_WAVE_TRIANGLE = 2 , DAC_WAVE_SAWTOOTH = 3 } |
DAC waveform generation options. More... | |
Functions | |
void | dac_enable (uint32_t dac, int channel) |
DAC Channel Enable. More... | |
void | dac_disable (uint32_t dac, int channel) |
DAC Channel Disable. More... | |
void | dac_buffer_enable (uint32_t dac, int channel) |
DAC Channel Output Buffer Enable. More... | |
void | dac_buffer_disable (uint32_t dac, int channel) |
DAC Channel Output Buffer Disable. More... | |
void | dac_dma_enable (uint32_t dac, int channel) |
DAC Channel DMA Enable. More... | |
void | dac_dma_disable (uint32_t dac, int channel) |
DAC Channel DMA Disable. More... | |
void | dac_trigger_enable (uint32_t dac, int channel) |
DAC Channel Trigger Enable. More... | |
void | dac_trigger_disable (uint32_t dac, int channel) |
DAC Channel Trigger Disable. More... | |
void | dac_set_trigger_source (uint32_t dac, uint32_t source) |
Set DAC Channel Trigger Source. More... | |
void | dac_set_waveform_generation (uint32_t dac, int channel, enum dac_wave wave) |
Set DAC Channel Waveform Generation mode for one or both channels. More... | |
void | dac_disable_waveform_generation (uint32_t dac, int channel) |
Disable DAC Channel Waveform Generation. More... | |
void | dac_set_waveform_characteristics (uint32_t dac, int channel, int mamp) |
Set DAC Channel LFSR Mask or Triangle Wave Amplitude. More... | |
void | dac_load_data_buffer_single (uint32_t dac, uint16_t data, enum dac_align align, int channel) |
Load DAC Data Register. More... | |
void | dac_load_data_buffer_dual (uint32_t dac, uint16_t data1, uint16_t data2, enum dac_align align) |
Load DAC Dual Data Register. More... | |
void | dac_software_trigger (uint32_t dac, int channel) |
Trigger the DAC by a Software Trigger. More... | |
Defined Constants and Types for the STM32G0xx Digital-to-Analog Converter
LGPL License Terms libopencm3 License
enum dac_align |
DAC data size (8/12 bits), alignment (right/left)
Enumerator | |
---|---|
DAC_ALIGN_RIGHT8 | |
DAC_ALIGN_RIGHT12 | |
DAC_ALIGN_LEFT12 |
Definition at line 237 of file dac_common_all.h.
enum dac_wave |
DAC waveform generation options.
Not all wave shapes are available on all parts.
Enumerator | |
---|---|
DAC_WAVE_DISABLE | |
DAC_WAVE_NOISE | |
DAC_WAVE_TRIANGLE | |
DAC_WAVE_SAWTOOTH |
Definition at line 246 of file dac_common_all.h.
void dac_buffer_disable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel Output Buffer Disable.
Disable a digital to analog converter channel output drive buffer. Disabling this will reduce power consumption slightly and will increase the output impedance of the DAC. The buffers are enabled by default after a reset.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 66 of file dac_common_v1.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_BOFF1, and DAC_CR_BOFF2.
void dac_buffer_enable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel Output Buffer Enable.
Enable a digital to analog converter channel output drive buffer. This is an optional amplifying buffer that provides additional drive for the output signal. The buffer is enabled by default after a reset and needs to be explicitly disabled if required.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 42 of file dac_common_v1.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_BOFF1, and DAC_CR_BOFF2.
void dac_disable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel Disable.
Disable a digital to analog converter channel.
[in] | dac | the base address of the DAC DAC register base addresses |
[in] | channel | with DAC mask DAC Channel Identifier |
Definition at line 159 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_EN1, and DAC_CR_EN2.
void dac_disable_waveform_generation | ( | uint32_t | dac, |
int | channel | ||
) |
Disable DAC Channel Waveform Generation.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 332 of file dac_common_all.c.
References dac_set_waveform_generation(), and DAC_WAVE_DISABLE.
void dac_dma_disable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel DMA Disable.
Disable a digital to analog converter channel DMA mode.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 209 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_DMAEN1, and DAC_CR_DMAEN2.
void dac_dma_enable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel DMA Enable.
Enable a digital to analog converter channel DMA mode (connected to DMA2 channel 3 for DAC channel 1 and DMA2 channel 4 for DAC channel 2). A DMA request is generated following an external trigger.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 185 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_DMAEN1, and DAC_CR_DMAEN2.
void dac_enable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel Enable.
Enable a digital to analog converter channel. After setting this enable, the DAC requires a twakeup time typically around 10 microseconds before it actually wakes up.
[in] | dac | the base address of the DAC DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 137 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_EN1, and DAC_CR_EN2.
void dac_load_data_buffer_dual | ( | uint32_t | dac, |
uint16_t | data1, | ||
uint16_t | data2, | ||
enum dac_align | align | ||
) |
Load DAC Dual Data Register.
Loads the appropriate digital to analog converter dual data register with 12 or 8 bit data to be converted for both channels. This allows high bandwidth simultaneous or independent analog output. The data in both channels are aligned identically.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | data1 | uint16_t for channel 1 with appropriate alignment. |
[in] | data2 | uint16_t for channel 2 with appropriate alignment. |
[in] | align | enum dac_align. Right or left aligned, and 8 or 12 bit. |
Definition at line 441 of file dac_common_all.c.
References DAC_ALIGN_LEFT12, DAC_ALIGN_RIGHT12, DAC_ALIGN_RIGHT8, DAC_DHR12LD, DAC_DHR12RD, and DAC_DHR8RD.
void dac_load_data_buffer_single | ( | uint32_t | dac, |
uint16_t | data, | ||
enum dac_align | align, | ||
int | channel | ||
) |
Load DAC Data Register.
Loads the appropriate digital to analog converter data register with 12 or 8 bit data to be converted on a channel. The data can be aligned as follows:
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | data | uint16_t with appropriate alignment. |
[in] | align | enum dac_align. Alignment and size. |
[in] | channel | uint8_t with DAC mask. |
Definition at line 393 of file dac_common_all.c.
References DAC_ALIGN_LEFT12, DAC_ALIGN_RIGHT12, DAC_ALIGN_RIGHT8, DAC_CHANNEL1, DAC_CHANNEL2, DAC_DHR12L1, DAC_DHR12L2, DAC_DHR12R1, DAC_DHR12R2, DAC_DHR8R1, and DAC_DHR8R2.
void dac_set_trigger_source | ( | uint32_t | dac, |
uint32_t | source | ||
) |
Set DAC Channel Trigger Source.
Sets the digital to analog converter trigger source, which can be taken from various timers, an external trigger or a software trigger.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | source | Taken from DAC Channel 2 Trigger Source Selection or DAC Channel 1 Trigger Source Selection or a logical OR of one of each of these to set both channels simultaneously. |
Definition at line 287 of file dac_common_all.c.
References DAC_CR.
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.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | one or both, select from DAC Channel Identifier |
[in] | mamp | amplitude of mixed waveform, bit width DAC_CR_MAMPx_MASK |
Definition at line 356 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_MAMP1_SHIFT, DAC_CR_MAMP2_SHIFT, and DAC_CR_MAMPx_MASK.
void dac_set_waveform_generation | ( | uint32_t | dac, |
int | channel, | ||
enum dac_wave | wave | ||
) |
Set DAC Channel Waveform Generation mode for one or both channels.
These signals are superimposed on existing output values in the DAC output registers. Waveform can be disabled, noise, triangular, or sawtooth, depending on family.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | one or both, DAC Channel Identifier |
[in] | wave | enum dac_wave. mode for channel |
Definition at line 302 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_WAVE1_SHIFT, DAC_CR_WAVE2_SHIFT, and DAC_CR_WAVEx_MASK.
Referenced by dac_disable_waveform_generation().
void dac_software_trigger | ( | uint32_t | dac, |
int | channel | ||
) |
Trigger the DAC by a Software Trigger.
If the trigger source is set to be a software trigger, cause a trigger to occur. The trigger is cleared by hardware after conversion.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 470 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_SWTRIGR, DAC_SWTRIGR_SWTRIG1, and DAC_SWTRIGR_SWTRIG2.
void dac_trigger_disable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel Trigger Disable.
Disable a digital to analog converter channel external trigger.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 260 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_TEN1, and DAC_CR_TEN2.
void dac_trigger_enable | ( | uint32_t | dac, |
int | channel | ||
) |
DAC Channel Trigger Enable.
Enable a digital to analog converter channel external trigger mode. This allows an external trigger to initiate register transfers from the buffer register to the DAC output register, followed by a DMA transfer to the buffer register if DMA is enabled. The trigger source must also be selected.
[in] | dac | the base address of the DAC. DAC register base addresses |
[in] | channel | with DAC mask. DAC Channel Identifier |
Definition at line 236 of file dac_common_all.c.
References DAC_CHANNEL1, DAC_CHANNEL2, DAC_CHANNEL_BOTH, DAC_CR, DAC_CR_TEN1, and DAC_CR_TEN2.