This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.
|
enum | _dac_fifo_status_flags {
kDAC_FIFOFullStatusFlag = DAC_STATUS_FULL_MASK,
kDAC_FIFOEmptyStatusFlag = DAC_STATUS_EMPTY_MASK
} |
| The enumeration of DAC status flags, including FIFO full status flag and FIFO empty status flag. More...
|
|
enum | dac_operation_mode_t {
kDAC_NormalOperationMode = 0U,
kDAC_AutomaticOperationMode = 1U
} |
| The enumeration of DAC operation mode, including normal operation mode and automatic operation mode. More...
|
|
enum | dac_sync_signal_selection_t {
kDAC_InternalClockSignal = 0U,
kDAC_ExternalSyncInSignal = 1U
} |
| The enumeration of DAC sync signal mode, including internal clock signal and external SYNC_IN signal. More...
|
|
enum | dac_waveform_type_t {
kDAC_RepeatSawtoothWaveform0 = 0U,
kDAC_RepeatSawtoothWaveform1 = 1U,
kDAC_RepeatTriangleWaveform0 = 2U,
kDAC_RepeatTriangleWaveform1 = 3U,
kDAC_OneShotSawtoothWaveform0 = 4U,
kDAC_OneShotSawtoothWaveform1 = 5U
} |
| The enumeration of waveform type, such as square waveform, triangle waveform, etc. More...
|
|
enum | dac_sync_input_edge_t {
kDAC_NoActiveEdge = 0U,
kDAC_FallingEdge = 1U,
kDAC_RisingEdge = 2U,
kDAC_BothEdges = 3U
} |
| The enumeration of sync input edge that used for updates buffered registers, such as Falling edge, etc. More...
|
|
enum | dac_speed_mode_t {
kDAC_HighSpeedMode = 0U,
kDAC_LowSpeedMode = 1U
} |
| The enumeration of DAC speed mode, including high speed mode and low speed mode. More...
|
|
enum | dac_watermark_level_t {
kDAC_WatermarkValue0 = 0U,
kDAC_WatermarkValue2 = 1U,
kDAC_WatermarkValue4 = 2U,
kDAC_WatermarkValue6 = 3U
} |
| The enumeration of FIFO watermark level. More...
|
|
enum | dac_data_format_t {
kDAC_DataWordRightJustified = 0U,
kDAC_DataWordLeftJustified = 1U
} |
| The enumeration of DAC data format, inclding right right-justified and left-justified. More...
|
|
|
void | DAC_Init (DAC_Type *base, const dac_config_t *psConfig) |
| Initializes the DAC resource, including data format, sync signal, operation mode, etc. More...
|
|
void | DAC_Deinit (DAC_Type *base) |
| De-initializes the DAC resource, the clock and power will be gated off. More...
|
|
void | DAC_GetDefaultConfig (dac_config_t *psConfig) |
| Gets the default DAC configs, such as operation mode, watermark level, sync signal, etc. More...
|
|
|
static void | DAC_SetSyncEdge (DAC_Type *base, dac_sync_input_edge_t eSyncEdge) |
| Selects which SYNC input edge is used for updates, available selections are "no active edge", "falling edge", "rising edge", "both edge". More...
|
|
static void | DAC_SetLDOK (DAC_Type *base) |
| Updates the buffered value of stepSize, minValue ,and maxValue at the active edge of the SYNC_IN signal. More...
|
|
static bool | DAC_GetLDOKValue (DAC_Type *base) |
| Gets the value of load Okay bit field. More...
|
|
|
static void | DAC_EnableOneShot (DAC_Type *base, bool bEnable) |
| Enables/Disables Oneshot feature, oneshot feature used to determines whether automatic waveform generation creates one waveform or a repeated waveform within the period defined by the active SYNC edges. More...
|
|
static void | DAC_WriteDataFIFO (DAC_Type *base, uint16_t u16Data) |
| Writes DAC buffered data value based on the data format when the DAC is in normal operation mode. More...
|
|
static void | DAC_WriteStepSize (DAC_Type *base, uint16_t u16StepSize) |
| Writes Step size based on the data format when the DAC is in automatic operation mode. More...
|
|
static void | DAC_WriteMinValue (DAC_Type *base, uint16_t u16MinValue) |
| Writes the minium value based on the data format when the DAC is in automatic operation mode. More...
|
|
static void | DAC_WriteMaxValue (DAC_Type *base, uint16_t u16MaxValue) |
| Writes the maximum value based on the data format when the DAC is in automatic operation mode. More...
|
|
static void | DAC_ConfigRefreshFrequency (DAC_Type *base, uint16_t u16CompareValue) |
| Sets refresh frequency that used to decide when the automatically generated waveform value is updated. More...
|
|
|
static void | DAC_EnableGlitchFilter (DAC_Type *base, bool bEnable) |
| Enables/Disables Glitch filter. More...
|
|
static void | DAC_SetGlitchFilterCount (DAC_Type *base, uint8_t u8FilterCount) |
| Sets glitch filter count value(ranges from 0 to 63) that represents the number of clock cycles for which the DAC output is held unchanged after new data is presented to the analog DAC's inputs. More...
|
|
struct dac_normal_mode_config_t |
Data Fields |
bool | bEnableDMA |
| Enable/Disable DMA support. More...
|
|
uint16_t | u16DataFIFO |
| The FIFO watermark level, if the level of FIFO is less than or equal to the watermark level field, a DMA request should be sent. More...
|
|
bool dac_normal_mode_config_t::bEnableDMA |
- true Enable DMA support.
- false Disable DMA support.
uint16_t dac_normal_mode_config_t::u16DataFIFO |
The DAC data to be converted to analog. If the data format is set as kDAC_DataWordRightJustified then u16DataFIFO should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16DataFIFO should range from 16 to 65520, which means the lower 4 bits is useless.
struct dac_automatic_mode_config_t |
uint16_t dac_automatic_mode_config_t::u16MinValue |
If the data format is set as kDAC_DataWordRightJustified then u16StepSize should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16StepSize should range from 16 to 65520, which means the lower 4 bits is useless. The minimum value is the lower range limit during automatic waveform generation. If the data format is set as kDAC_DataWordRightJustified then u16MinValue should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16MinValue should range from 16 to 65520, which means the lower 4 bits is useless.
uint16_t dac_automatic_mode_config_t::u16MaxValue |
If the data format is set as kDAC_DataWordRightJustified then u16MaxValue should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16MaxValue should range from 16 to 65520, which means the lower 4 bits is useless.
uint16_t dac_automatic_mode_config_t::u16StartValue |
uint16_t dac_automatic_mode_config_t::u16CompareValue |
The available range is 0 ~ 65535.
- u16CompareValue=0 The REFRESH signal's frequency is equal to the clock's frequency so that the generated waveform will be updated every clock cycle.
- u16CompareValue=N(N!=0) The REFRESH signal's frequency is equal to clock's frequency divided N+1 so that the generated waveform will be updated every N+1 clock cycles
union dac_operation_config_u |
This structure is used to config the DAC module, to initialize the DAC module, user must set the member of this structure. This structure will cost 20 Byte memory space.
The buffered value will be updated at the selected active edge of SYNC_IN signal.
bool dac_config_t::bEnableGlitchFilter |
- true Enable glitch filter.
- false Disable glitch filter.
uint8_t dac_config_t::u8GlitchFilterCount |
bool dac_config_t::bEnableAnalogPortion |
- true Power up the analog portion of the DAC, and the DAC will output the value currently presented to its inputs.
- false Power down the analog portion of the DAC, and its output will be pulled down.
Enumerator |
---|
kDAC_FIFOFullStatusFlag |
Indicate the FIFO is full.
|
kDAC_FIFOEmptyStatusFlag |
Indicate the FIFO is empty.
|
Enumerator |
---|
kDAC_NormalOperationMode |
Normal Mode to generate an analog representation of digital words.
|
kDAC_AutomaticOperationMode |
Automatic Mode to generate waveform without requiring CPU or core assistance.
|
Enumerator |
---|
kDAC_InternalClockSignal |
Internal Clock signal is selected as SYNC signal, data written to the buffered registers is used on the next clock cycle.
|
kDAC_ExternalSyncInSignal |
Peripheral external signal is selected as SYNC signal, the update occurs on the active edge of SYNC_IN signal.
|
Enumerator |
---|
kDAC_RepeatSawtoothWaveform0 |
DAC generates repeated sawtooth waveform0.
The automatic waveform generation logic will create a repeated sawtooth waveform0 upon receiving an active SYNC edge, and the waveform repeats when it reaches its minimum and maximum value. The waveform increases from starting value to max value firstly. Like this following shown:
/| /| /| /|
/ | / | / | / |
| / | / | / |
|/ |/ |/ | |
kDAC_RepeatSawtoothWaveform1 |
DAC generates sawtooth waveform1.
The automatic waveform generation logic will create a repeated sawtooth waveform1 upon receiving an active SYNC edge, and the waveform repeats when it reaches its minimum and maximum value. The waveform decreases from starting value to min value firstly. Like this following shown:
|\ |\ |\ |\
| \ | \ | \ | \
\ | \ | \ | \ | \
\| \| \| \| \ |
kDAC_RepeatTriangleWaveform0 |
The automatic waveform generation logic will create a repeated sawtooth waveform1 upon receiving an active SYNC edge, and the waveform repeats when it reaches its minimum and maximum value.
In this type the generated triangle waveform rises from the starting value. Like this following shown:
/\ /\ /\
/ \ / \ / \ /
/ \ / \ / \ /
\/ \/ \/ |
kDAC_RepeatTriangleWaveform1 |
The automatic waveform generation logic will create a repeated sawtooth waveform1 upon receiving an active SYNC edge, and the waveform repeats when it reaches its minimum and maximum value.
In this type the generated triangle waveform drops from the starting value. Like this following shown:
/\ /\ /\
\ / \ / \ / \
\ / \ / \ /
\/ \/ \/ |
kDAC_OneShotSawtoothWaveform0 |
Automatic waveform generation logic will create a single pattern and stop at the final value.
It will remain at the finial value until a new active edge occurs on the SYNC input, and then the waveform will be repeated. Like this following shown:
/| /|
/ | / |
/ | / |
____/ |____/ |___ |
kDAC_OneShotSawtoothWaveform1 |
Automatic waveform generation logic will create a single pattern and stop at the final value.
It will remain at the finial value until a new active edge occurs on the SYNC input, and then the waveform will be repeated. Like this following shown:
:
|\ |\
| \ | \
| \ | \
____| \___| \__ |
Enumerator |
---|
kDAC_NoActiveEdge |
No active edge is selected, it means the SYNC input is ignored.
|
kDAC_FallingEdge |
Updates occur on the falling edge of the SYNC input.
|
kDAC_RisingEdge |
Updates occur on the rising edge of the SYNC input.
|
kDAC_BothEdges |
Updates occur on both edges of the SYNC input.
|
Enumerator |
---|
kDAC_HighSpeedMode |
In High Speed Mode, the setting time of the DAC module is 1us, but the DAC module uses more power.
|
kDAC_LowSpeedMode |
In Low Speed Mode, the DAC module uses less power but takes more time to settle.
|
Enumerator |
---|
kDAC_WatermarkValue0 |
Watermark value is 0.
|
kDAC_WatermarkValue2 |
Watermark value is 2.
|
kDAC_WatermarkValue4 |
Watermark value is 4.
|
kDAC_WatermarkValue6 |
Watermark value is 6.
|
Enumerator |
---|
kDAC_DataWordRightJustified |
The 12 bits data is right-justified.
|
kDAC_DataWordLeftJustified |
The 12 bits data iss left-justified.
|
void DAC_Init |
( |
DAC_Type * |
base, |
|
|
const dac_config_t * |
psConfig |
|
) |
| |
- Parameters
-
base | DAC peripheral base address. |
psConfig | The pointer to dac_config_t. |
void DAC_Deinit |
( |
DAC_Type * |
base | ) |
|
Invoking this function to power down the analog portion of DAC and disable the DAC clock.
- Parameters
-
base | DAC peripheral base address. |
psConfig->uOperationConfig.sNormalModeConfig.u16DataFIFO = 0U;
psConfig->bEnableDMA = false;
psConfig->bEnableAnalogPortion = false;
psConfig->bEnableGlitchFilter = true;
psConfig->u8GlitchFilterCount = 29U;
- Parameters
-
- Parameters
-
base | DAC peripheral base address. |
eSyncEdge | The input edge to be set, please refer to dac_sync_input_edge_t for details. |
static void DAC_SetLDOK |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
- Note
- Allows new values of minimum, maximum, and step value to be updated by active edge of SYNC_IN. This function should be invoked once new values of these buffered registers have been written by software. The LDOK bit will be cleared by an active edge of SYNC_IN.
-
This function is only useful when the operation mode is selected as Automatic operation mode.
- Parameters
-
base | DAC peripheral base address. |
static bool DAC_GetLDOKValue |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
- Note
- When the SYNC signal is selected as external SYNC_IN signal, the load okay bit will be cleared by an active edge of the SYNC_IN signal. This function can be used to check whether the active edge of the SYNC_IN signal has reached.
-
This function is only useful when the operation mode is selected as Automatic operation mode.
- Parameters
-
base | DAC peripheral base address. |
- Returns
- true The active edge of SYNC_IN signal has not reached when the SYNC signal is selected as external SYNC_IN signal.
- false The active edge of SYNC_IN signal has reached when the SYNC signal is selected as external SYNC_IN signal
static void DAC_EnableOneShot |
( |
DAC_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Note
- This function only useful when the operation mode is selected as automatic operation mode.
- Parameters
-
base | DAC peripheral base address. |
bEnable | Enable/Disable oneshot feature.
- true Automatic waveform generation logic will create a single pattern and stop at the final value.
- false Automatic waveform generation logic will create a repeated (continuous) waveform upon receiving an active SYNC edge.
|
static void DAC_WriteDataFIFO |
( |
DAC_Type * |
base, |
|
|
uint16_t |
u16Data |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC peripheral base address. |
u16Data | The DAC data to be converted to analog. If the data format is set as kDAC_DataWordRightJustified then u16Data should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16Data should range from 16 to 65520, which means the lower 4 bits is useless. |
static void DAC_WriteStepSize |
( |
DAC_Type * |
base, |
|
|
uint16_t |
u16StepSize |
|
) |
| |
|
inlinestatic |
- Note
- This function only useful when the operation mode is selected as automatic operation mode.
- Parameters
-
base | DAC peripheral base address. |
u16StepSize | The step value to be added to or subtracted from the current value. If the data format is set as kDAC_DataWordRightJustified then u16StepSize should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16StepSize should range from 16 to 65520, which means the lower 4 bits is useless. |
static void DAC_WriteMinValue |
( |
DAC_Type * |
base, |
|
|
uint16_t |
u16MinValue |
|
) |
| |
|
inlinestatic |
- Note
- This function only useful when the operation mode is selected as automatic operation mode. If DAC input data is less than the minium value, output is limited to the minium value during automatic waveform generation.
- Parameters
-
base | DAC peripheral base address. |
u16MinValue | The lower range limit during automatic waveform generation. If the data format is set as kDAC_DataWordRightJustified then u16MinValue should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16MinValue should range from 16 to 65520, which means the lower 4 bits is useless. |
static void DAC_WriteMaxValue |
( |
DAC_Type * |
base, |
|
|
uint16_t |
u16MaxValue |
|
) |
| |
|
inlinestatic |
- Note
- This function only useful when the operation mode is selected as automatic operation mode. If DAC input data is greater than maximum value, output is limited to maximum value during automatic waveform generation.
- Parameters
-
base | DAC peripheral base address. |
u16MaxValue | The upper range limit during automatic waveform generation. If the data format is set as kDAC_DataWordRightJustified then u16MaxValue should range from 0 to 4095, which means the higher 4 bits is useless. If the data format is set as kDAC_DataWordLeftJustified, then the u16MaxValue should range from 16 to 65520, which means the lower 4 bits is useless. |
static void DAC_ConfigRefreshFrequency |
( |
DAC_Type * |
base, |
|
|
uint16_t |
u16CompareValue |
|
) |
| |
|
inlinestatic |
- Note
- This function only useful when the operation mode is selected as automatic operation mode.
- Parameters
-
base | DAC peripheral base address. |
u16CompareValue | The compare value(0~65535).
- u16CompareValue=0 The generated waveform will be updated every clock cycle.
- u16CompareValue=N(N!=0) The generated waveform will be updated every N+1 clock cycles.
|
static void DAC_EnableDMA |
( |
DAC_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Note
- This function is only useful when the operation mode is selected as Normal mode.
- Parameters
-
base | DAC peripheral base address. |
bEnable | Enable/Disable DMA support.
- true Enable DMA support.
- false Disable DMA support.
|
- Note
- When the level of FIFO is less than or equal to the Watermark level, a DMA request will be sent. This function is only useful when the operation mode is selected as Normal mode.
- Parameters
-
base | DAC peripheral base address. |
eWatermarkLevel | The watermark level of FIFO, please refer to dac_watermark_level_t for details. |
static void DAC_EnableGlitchFilter |
( |
DAC_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC peripheral base address. |
bEnable | Enable/Disable Glitch filter.
- true Enable glitch filter.
- false Disable glitch filter.
|
static void DAC_SetGlitchFilterCount |
( |
DAC_Type * |
base, |
|
|
uint8_t |
u8FilterCount |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC peripheral base address. |
u8FilterCount | The count of glitch filter. This count represents the number of clock cycles for which the DAC output is held unchanged after new data is presented to the analog DAC's inputs. |
- Parameters
-
base | DAC peripheral base address. |
eSpeedMode | The speedMode to be set, please refer to dac_speed_mode_t for details. |
static void DAC_EnableAnalogPortion |
( |
DAC_Type * |
base, |
|
|
bool |
bEnable |
|
) |
| |
|
inlinestatic |
The function controls the power-up of the analog portion of the DAC. If powered up the analog portion, the DAC module will output the value currently presented to the Data register. The analog portion should be powered up when the DAC is in use. If power down the analog portion, the output of the DAC module will be pulled low. The analog portion should be powered down when the DAC is not in use.
- Parameters
-
base | DAC peripheral base address. |
bEnable | Power up/down the analog portion of the DAC.
- true Power up the analog portion of the DAC, and the DAC will output the value currently presented to its inputs.
- false Power down the analog portion of the DAC, and its output will be pulled down.
|
static uint16_t DAC_GetFIFOStatusFlags |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | DAC peripheral base address. |
- Returns
- The status flags of DAC module, should be the OR'ed value of _dac_fifo_status_flags.