HAL DAC Types

Enumerations

group DAC_Exported_Types_Group1

Enums

enum hal_dac_t

HAL DAC instance.

Values:

enumerator HAL_DAC1

DAC1

enum hal_dac_channel_t

HAL DAC channels.

Values:

enumerator HAL_DAC_CHANNEL_1

DAC channel 1

enum hal_dac_state_t

HAL DAC state definition.

Values:

enumerator HAL_DAC_STATE_RESET

DAC not yet initialized or is de-initialized

enumerator HAL_DAC_STATE_SEPARATE_CHANNEL_CONFIGURED

DAC is initialized and a global configuration has been applied, the channels are used separately

enum hal_dac_channel_state_t

HAL DAC channel state definition.

Values:

enumerator HAL_DAC_CHANNEL_STATE_RESET

DAC CHANNEL not yet initialized or disabled

enumerator HAL_DAC_CHANNEL_STATE_IDLE

DAC CHANNEL is initialized and a channel configuration has been applied

enumerator HAL_DAC_CHANNEL_STATE_ACTIVE

DAC CHANNEL is active, conversion is running

enumerator HAL_DAC_CHANNEL_STATE_ACTIVE_SILENT

DAC CHANNEL is active, conversion is running, using DMA in silent mode

enum hal_dac_trigger_t

HAL DAC channel trigger.

Values:

enumerator HAL_DAC_TRIGGER_NONE

Conversion is automatic once the DAC_DHRxxxx register

enumerator HAL_DAC_TRIGGER_SOFTWARE

conversion started by software trigger for DAC channel

enumerator HAL_DAC_TRIGGER_TIM1_TRGO

TIM1 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_TIM2_TRGO

TIM2 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_TIM5_TRGO

TIM5 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_TIM6_TRGO

TIM6 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_TIM7_TRGO

TIM7 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_TIM8_TRGO

TIM8 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_TIM12_TRGO

TIM12 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_TIM15_TRGO

TIM15 TRGO selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_LPTIM1_OC1

LPTIM1 CH1 selected as external conversion trigger for DAC channel.

enumerator HAL_DAC_TRIGGER_EXTI9

EXTI Line9 event selected as external conversion trigger for DAC channel.

enum hal_dac_output_buffer_status_t

DAC channel output buffer mode.

Values:

enumerator HAL_DAC_OUTPUT_BUFFER_ENABLED

The output is buffered: higher drive current capability, but also higher current consumption

enumerator HAL_DAC_OUTPUT_BUFFER_DISABLED

The output is not buffered: lower drive current capability, but also lower current consumption

enum hal_dac_data_alignment_t

DAC channel data alignment.

Values:

enumerator HAL_DAC_DATA_ALIGN_12_BITS_RIGHT

Data must be written in 12-bit right alignment

enumerator HAL_DAC_DATA_ALIGN_12_BITS_LEFT

Data must be written in 12-bit left alignment

enumerator HAL_DAC_DATA_ALIGN_8_BITS_RIGHT

Data must be written in 8-bit right alignment

enum hal_dac_output_connection_t

DAC channel output connection.

Note

With some configuration of mode and buffer, there are both internal and external connections. This applies regardless of this hal_dac_output_connection_t value.

Values:

enumerator HAL_DAC_OUTPUT_CONNECTION_EXTERNAL

DAC channel output is connected to external pin. Note: Depending on other parameters (mode normal or sample and hold, output buffer state), output can also be connected to on-chip peripherals, refer to ref manual.

enumerator HAL_DAC_OUTPUT_CONNECTION_INTERNAL

DAC channel output is connected to on-chip peripherals (via internal paths). Note: Depending on other parameters (mode normal or sample and hold, output buffer state), output can also be connected to external pin, refer to ref manual.

enum hal_dac_sample_and_hold_status_t

DAC channel sample and hold mode.

Values:

enumerator HAL_DAC_SAMPLE_AND_HOLD_DISABLED

The output is in normal mode

enumerator HAL_DAC_SAMPLE_AND_HOLD_ENABLED

The output is in sample-and-hold mode. Note: the sample-and-hold mode requires an external capacitor

enum hal_dac_high_freq_mode_t

DAC high frequency interface mode.

Values:

enumerator HAL_DAC_HIGH_FREQ_MODE_DISABLED

High frequency interface mode disabled

enumerator HAL_DAC_HIGH_FREQ_MODE_ABOVE_80MHZ

High frequency interface mode compatible to AHB>80MHz enabled

enumerator HAL_DAC_HIGH_FREQ_MODE_ABOVE_160MHZ

High frequency interface mode compatible to AHB>160MHz enabled

enum hal_dac_sign_format_t

DAC channel signed or unsigned data format.

Values:

enumerator HAL_DAC_SIGN_FORMAT_UNSIGNED

The data format is not signed

enumerator HAL_DAC_SIGN_FORMAT_SIGNED

The data format is signed

enum hal_dac_dma_double_data_mode_status_t

DAC channel DMA double data mode.

Values:

enumerator HAL_DAC_DMA_DOUBLE_DATA_MODE_DISABLED

The DMA data mode is the single data mode

enumerator HAL_DAC_DMA_DOUBLE_DATA_MODE_ENABLED

The DMA data mode is the double data mode

enum hal_dac_wave_amplitude_t

HAL DAC channel triangle wave and pseudo noise amplitude.

Values:

enumerator HAL_DAC_WAVE_AMPLITUDE_1

Noise/triangle amplitude equal to 1

enumerator HAL_DAC_WAVE_AMPLITUDE_3

Noise/triangle amplitude equal to 3

enumerator HAL_DAC_WAVE_AMPLITUDE_7

Noise/triangle amplitude equal to 7

enumerator HAL_DAC_WAVE_AMPLITUDE_15

Noise/triangle amplitude equal to 15

enumerator HAL_DAC_WAVE_AMPLITUDE_31

Noise/triangle amplitude equal to 31

enumerator HAL_DAC_WAVE_AMPLITUDE_63

Noise/triangle amplitude equal to 63

enumerator HAL_DAC_WAVE_AMPLITUDE_127

Noise/triangle amplitude equal to 127

enumerator HAL_DAC_WAVE_AMPLITUDE_255

Noise/triangle amplitude equal to 255

enumerator HAL_DAC_WAVE_AMPLITUDE_511

Noise/triangle amplitude equal to 511

enumerator HAL_DAC_WAVE_AMPLITUDE_1023

Noise/triangle amplitude equal to 1023

enumerator HAL_DAC_WAVE_AMPLITUDE_2047

Noise/triangle amplitude equal to 2047

enumerator HAL_DAC_WAVE_AMPLITUDE_4095

Noise/triangle amplitude equal to 4095

HAL DAC Constants

group DAC_Exported_Constants

Defines

HAL_DAC_ERROR_NONE (0UL)

HAL DAC error code, declared and used has bit fields in HAL_DAC_GetLastErrorCodes()

No error

HAL_DAC_ERROR_DMA_UNDERRUN_CH1 (1UL << 0U)

DMA underrun error on channel 1

HAL_DAC_ERROR_DMA_CH1 (1UL << 1U)

DMA transfer error on channel 1

HAL_DAC_OPT_DMA_IT_NONE HAL_DMA_OPT_IT_NONE

HAL DAC optional interrupts.

All optional interrupts are disabled

HAL_DAC_OPT_DMA_IT_HT HAL_DMA_OPT_IT_HT

Enable optional IT half completed transfer

HAL_DAC_OPT_DMA_IT_DEFAULT HAL_DMA_OPT_IT_DEFAULT

Enable all optional IT

HAL_DAC_OPT_DMA_IT_SILENT HAL_DMA_OPT_IT_SILENT

DMA in silent mode

Handle Structure

group DAC_Exported_Types_Group2

Typedefs

typedef struct hal_dac_handle_s hal_dac_handle_t

DAC Handle structure Definition.

< DAC handle structure definition DAC handle type definition

struct hal_dac_handle_s
#include <stm32c5xx_hal_dac.h>

DAC handle structure definition, contains: DAC instance, states, callbacks, DMA handles linked with DAC channels.

Public Members

hal_dac_t instance

Peripheral instance

volatile hal_dac_state_t global_state

DAC global state

volatile hal_dac_channel_state_t channel_state [ ( 1U ) ]

State for channels subinstances, they can be active in parallel

volatile uint32_t * channel_dhr_address [ ( 1U ) ]

DHR (data holding register) address according to the alignment

volatile uint16_t last_error_codes [ ( 1U ) ]

DAC channel errors codes array of uint16_t to avoid race condition between the channels

hal_dma_handle_t * dma_ch [ ( 1U ) ]

Pointer to a DMA handle (used by DAC channels or by dual channels)

hal_dac_channel_t dual_channel_dma_requester

Dual mode DMA channel requester

hal_dac_cb_t p_conv_cplt_cb

Converter completed callback

hal_dac_cb_t p_conv_half_cplt_cb

Converter half completed callback

hal_dac_cb_t p_stop_cplt_cb

Stop completed callback

hal_dac_error_cb_t p_error_cb

Converter error callback

const void * p_user_data

User Data Pointer

callback prototype

group DAC_Exported_Types_Group_Callback

Typedefs

typedef void ( * hal_dac_cb_t ) ( hal_dac_handle_t * hdac , hal_dac_channel_t channel )

Callback prototype for converter completed

typedef void ( * hal_dac_error_cb_t ) ( hal_dac_handle_t * hdac )

Callback prototype for error callback

Configuration Structure

group DAC_Exported_Types_Group4
struct hal_dac_channel_sample_and_hold_config_t
#include <stm32c5xx_hal_dac.h>

DAC configuration “sample and hold” structure definition.

Public Members

uint32_t sample_time_cycle

The sample time for the channel, unit is in number of clock period. This parameter must be a number the range [0, 1023]. The sample_time_cycle is applied when the sample_and_hold mode is HAL_DAC_SAMPLE_AND_HOLD_ENABLED

uint32_t hold_time_cycle

The hold time for the channel, unit is in number of clock period. This parameter must be a number the range [0, 1023]. The hold_time is applied when the sample_and_hold mode is HAL_DAC_SAMPLE_AND_HOLD_ENABLED

uint32_t refresh_time_cycle

The refresh time for the channel, unit is in number of clock period. This parameter must be a number the range [0, 255]. The refresh_time is applied when the sample_and_hold mode is HAL_DAC_SAMPLE_AND_HOLD_ENABLED

struct hal_dac_config_t
#include <stm32c5xx_hal_dac.h>

DAC configuration structure definition.

Public Members

hal_dac_high_freq_mode_t high_frequency_mode

The frequency interface mode Note: HAL_DAC_GetOptimumFrequencyMode() API allows to select and update the high frequency mode afterwards

struct hal_dac_channel_config_t
#include <stm32c5xx_hal_dac.h>

DAC channel configuration structure definition.

Public Members

hal_dac_sign_format_t data_sign_format

The data format: signed data or unsigned data

hal_dac_trigger_t trigger

The external trigger for the channel

hal_dac_output_buffer_status_t output_buffer

The DAC channel output buffer: enabled or disabled

hal_dac_output_connection_t output_connection

The DAC channel output connection: to external pin or to on chip peripheral

hal_dac_data_alignment_t alignment

Default alignment and width, for both channel: 12bit right or left align, 8bit right align