This section describes the programming interface of the DAC HAL driver.
struct dac_converter_config_t |
struct dac_buffer_config_t |
See "dac_buff_work_mode_t".
Enumerator |
---|
kStatus_DAC_Success |
Success.
|
kStatus_DAC_InvalidArgument |
Invalid argument.
|
kStatus_DAC_Failed |
Execution failed.
|
See the appropriate SoC Reference Manual for actual connections.
Enumerator |
---|
kDacRefVoltSrcOfVref1 |
Select DACREF_1 as the reference voltage.
|
kDacRefVoltSrcOfVref2 |
Select DACREF_2 as the reference voltage.
|
Enumerator |
---|
kDacTriggerByHardware |
Select hardware trigger.
|
kDacTriggerBySoftware |
Select software trigger.
|
If the buffer feature for DAC module is enabled, a watermark event occurs when the buffer index reaches the watermark.
Enumerator |
---|
kDacBuffWatermarkFromUpperAs1Word |
Select 1 word away from the upper limit of buffer.
|
kDacBuffWatermarkFromUpperAs2Word |
Select 2 word away from the upper limit of buffer.
|
kDacBuffWatermarkFromUpperAs3Word |
Select 3 word away from the upper limit of buffer.
|
kDacBuffWatermarkFromUpperAs4Word |
Select 4 word away from the upper limit of buffer.
|
These are the work modes when the DAC buffer is enabled.
- Normal mode - When the buffer index reaches the upper level, it starts (0) on the next trigger.
- Swing mode - When the buffer index reaches the upper level, it goes backward to the start and is reduced one-by-one on the next trigger. When the buffer index reaches the start, it goes backward to the upper level and increases one-by-one on the next trigger.
- One-Time-Scan mode - The buffer index can only be increased on the next trigger. When the buffer index reaches the upper level, it is not updated by the trigger.
- FIFO mode - In FIFO mode, the buffer is organized as a FIFO. For a valid write to any item, the data is put into the FIFO. The written index in buffer should be an even number; otherwise, the write is ignored.
Enumerator |
---|
kDacBuffWorkAsNormalMode |
Buffer works normally.
|
void DAC_HAL_Init |
( |
DAC_Type * |
base | ) |
|
This function resets all configurable registers to the reset state for DAC. It should be called before configuring the DAC module.
- Parameters
-
base | The DAC peripheral base address. |
This function configures the converter for DAC. The features it covers are a one-time setting in the application.
- Parameters
-
base | The DAC peripheral base address. |
configPtr | The pointer to configure structure. |
This function configures the converter for DAC. The features it covers are used for the buffer.
- Parameters
-
base | The DAC peripheral base address. |
configPtr | The pointer to configure structure. |
void DAC_HAL_SetBuffValue |
( |
DAC_Type * |
base, |
|
|
uint8_t |
idx, |
|
|
uint16_t |
value |
|
) |
| |
This function sets the value assembled by the low 8 bits and high 4 bits of 12-bit DAC item in the buffer.
- Parameters
-
base | The DAC peripheral base address. |
idx | Buffer index. |
value | Setting value. |
static void DAC_HAL_ClearBuffIdxUpperFlag |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function clears the flag of the DAC buffer read pointer when it reaches the bottom position.
- Parameters
-
base | The DAC peripheral base address. |
static bool DAC_HAL_GetBuffIdxUpperFlag |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function gets the flag of DAC buffer read pointer when it reaches the bottom position.
- Parameters
-
base | The DAC peripheral base address. |
- Returns
- Assertion of indicated event.
static void DAC_HAL_ClearBuffIdxStartFlag |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function clears the flag of the DAC buffer read pointer when it reaches the top position.
- Parameters
-
base | The DAC peripheral base address. |
static bool DAC_HAL_GetBuffIdxStartFlag |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function gets the flag of the DAC buffer read pointer when it reaches the top position.
- Parameters
-
base | The DAC peripheral base address. |
- Returns
- Assertion of indicated event.
static void DAC_HAL_Enable |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function enables the Programmable Reference Generator. Then, the DAC system is enabled.
- Parameters
-
base | The DAC peripheral base address. |
static void DAC_HAL_Disable |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function disables the Programmable Reference Generator. Then, the DAC system is disabled.
- Parameters
-
base | The DAC peripheral base address. |
static void DAC_HAL_SetSoftTriggerCmd |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function triggers the converter with software. If the DAC software trigger is selected and buffer enabled, calling this API advances the buffer read pointer once.
- Parameters
-
base | The DAC peripheral base address. |
static void DAC_HAL_SetBuffCurIdx |
( |
DAC_Type * |
base, |
|
|
uint8_t |
idx |
|
) |
| |
|
inlinestatic |
This function sets the current buffer index for the DAC module.
- Parameters
-
base | the DAC peripheral base address. |
idx | Setting buffer index. |
static uint8_t DAC_HAL_GetBuffCurIdx |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function gets the current buffer index for the DAC module.
- Parameters
-
base | the DAC peripheral base address. |
- Returns
- Current index of buffer.