The MCUXpresso SDK provides a peripheral driver for the Digital-to-Analog Converter (DAC32) module of MCUXpresso SDK devices.
The DAC32 driver includes a basic DAC32 module (converter) and DAC32 buffer.
The basic DAC32 module supports operations unique to the DAC converter in each DAC32 instance. The APIs in this part are used in the initialization phase, which is necessary for enabling the DAC32 module in the application. The APIs enable/disable the clock, enable/disable the module, and configure the converter. Call the initial APIs to prepare the DAC32 module for the application.
The DAC32 buffer operates the DAC32 hardware buffer. The DAC32 module supports a hardware buffer to keep a group of DAC values to be converted. This feature supports updating the DAC output value automatically by triggering the buffer read pointer to move in the buffer. Use the APIs to configure the hardware buffer's trigger mode, watermark, work mode, and use size. Additionally, the APIs operate the DMA, interrupts, flags, the pointer (index of buffer), item values, and so on.
The DAC32 buffer plays a major part when using the DAC module, as the most functional features are designed for the DAC32 hardware buffer.
Function groups
Initialization and deinitialization
This function group implements APIs for the basic DAC module (converter).
Buffer
This function group implements APIs for the DAC buffer.
Typical use case
Working as a basic DAC without the hardware buffer feature.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/dac32
Working with the hardware buffer.
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/dac32
|
enum | _dac32_buffer_status_flags {
kDAC32_BufferWatermarkFlag = DAC_STATCTRL_DACBFWMF_MASK,
kDAC32_BufferReadPointerTopPositionFlag,
kDAC32_BufferReadPointerBottomPositionFlag = DAC_STATCTRL_DACBFRPBF_MASK
} |
| DAC32 buffer flags. More...
|
|
enum | _dac32_buffer_interrupt_enable {
kDAC32_BufferWatermarkInterruptEnable = DAC_STATCTRL_DACBWIEN_MASK,
kDAC32_BufferReadPointerTopInterruptEnable = DAC_STATCTRL_DACBTIEN_MASK,
kDAC32_BufferReadPointerBottomInterruptEnable = DAC_STATCTRL_DACBBIEN_MASK
} |
| DAC32 buffer interrupts. More...
|
|
enum | dac32_reference_voltage_source_t {
kDAC32_ReferenceVoltageSourceVref1 = 0U,
kDAC32_ReferenceVoltageSourceVref2 = 1U
} |
| DAC32 reference voltage source. More...
|
|
enum | dac32_buffer_trigger_mode_t {
kDAC32_BufferTriggerByHardwareMode = 0U,
kDAC32_BufferTriggerBySoftwareMode = 1U
} |
| DAC32 buffer trigger mode. More...
|
|
enum | dac32_buffer_watermark_t {
kDAC32_BufferWatermark1Word = 0U,
kDAC32_BufferWatermark2Word = 1U,
kDAC32_BufferWatermark3Word = 2U,
kDAC32_BufferWatermark4Word = 3U
} |
| DAC32 buffer watermark. More...
|
|
enum | dac32_buffer_work_mode_t {
kDAC32_BufferWorkAsNormalMode = 0U,
kDAC32_BufferWorkAsSwingMode = 1U,
kDAC32_BufferWorkAsOneTimeScanMode = 2U,
kDAC32_BufferWorkAsFIFOMode = 3U
} |
| DAC32 buffer work mode. More...
|
|
|
static void | DAC32_EnableBuffer (DAC_Type *base, bool enable) |
| Enables the DAC32 buffer. More...
|
|
void | DAC32_SetBufferConfig (DAC_Type *base, const dac32_buffer_config_t *config) |
| Configures the DAC32 buffer. More...
|
|
void | DAC32_GetDefaultBufferConfig (dac32_buffer_config_t *config) |
| Initializes the DAC32 buffer configuration structure. More...
|
|
static void | DAC32_EnableBufferDMA (DAC_Type *base, bool enable) |
| Enables the DMA for DAC32 buffer. More...
|
|
void | DAC32_SetBufferValue (DAC_Type *base, uint32_t index, uint32_t value) |
| Sets the value for items in the buffer. More...
|
|
static void | DAC32_DoSoftwareTriggerBuffer (DAC_Type *base) |
| Triggers the buffer by software and updates the read pointer of the DAC32 buffer. More...
|
|
static uint32_t | DAC32_GetBufferReadPointer (DAC_Type *base) |
| Gets the current read pointer of the DAC32 buffer. More...
|
|
static void | DAC32_SetBufferReadPointer (DAC_Type *base, uint32_t index) |
| Sets the current read pointer of the DAC32 buffer. More...
|
|
static void | DAC32_EnableBufferInterrupts (DAC_Type *base, uint32_t mask) |
| Enables interrupts for the DAC32 buffer. More...
|
|
static void | DAC32_DisableBufferInterrupts (DAC_Type *base, uint32_t mask) |
| Disables interrupts for the DAC32 buffer. More...
|
|
static uint32_t | DAC32_GetBufferStatusFlags (DAC_Type *base) |
| Gets the flags of events for the DAC32 buffer. More...
|
|
static void | DAC32_ClearBufferStatusFlags (DAC_Type *base, uint32_t mask) |
| Clears the flags of events for the DAC32 buffer. More...
|
|
static void | DAC32_EnableBufferOutput (DAC_Type *base, bool enable) |
| Enable the buffer output. More...
|
|
static void | DAC32_EnableTestOutput (DAC_Type *base, bool enable) |
| Enable the test output. More...
|
|
bool dac32_config_t::enableLowPowerMode |
struct dac32_buffer_config_t |
uint32_t dac32_buffer_config_t::upperLimit |
Normally, 0-15 is available for buffer with 16 item.
Enumerator |
---|
kDAC32_BufferWatermarkFlag |
DAC32 Buffer Watermark Flag.
|
kDAC32_BufferReadPointerTopPositionFlag |
DAC32 Buffer Read Pointer Top Position Flag.
|
kDAC32_BufferReadPointerBottomPositionFlag |
DAC32 Buffer Read Pointer Bottom Position Flag.
|
Enumerator |
---|
kDAC32_BufferWatermarkInterruptEnable |
DAC32 Buffer Watermark Interrupt Enable.
|
kDAC32_BufferReadPointerTopInterruptEnable |
DAC32 Buffer Read Pointer Top Flag Interrupt Enable.
|
kDAC32_BufferReadPointerBottomInterruptEnable |
DAC32 Buffer Read Pointer Bottom Flag Interrupt Enable.
|
Enumerator |
---|
kDAC32_ReferenceVoltageSourceVref1 |
The DAC32 selects DACREF_1 as the reference voltage.
|
kDAC32_ReferenceVoltageSourceVref2 |
The DAC32 selects DACREF_2 as the reference voltage.
|
Enumerator |
---|
kDAC32_BufferTriggerByHardwareMode |
The DAC32 hardware trigger is selected.
|
kDAC32_BufferTriggerBySoftwareMode |
The DAC32 software trigger is selected.
|
Enumerator |
---|
kDAC32_BufferWatermark1Word |
1 word away from the upper limit.
|
kDAC32_BufferWatermark2Word |
2 words away from the upper limit.
|
kDAC32_BufferWatermark3Word |
3 words away from the upper limit.
|
kDAC32_BufferWatermark4Word |
4 words away from the upper limit.
|
Enumerator |
---|
kDAC32_BufferWorkAsNormalMode |
Normal mode.
|
kDAC32_BufferWorkAsSwingMode |
Swing mode.
|
kDAC32_BufferWorkAsOneTimeScanMode |
One-Time Scan mode.
|
kDAC32_BufferWorkAsFIFOMode |
FIFO mode.
|
This function initializes the DAC32 module, including:
- Enabling the clock for DAC32 module.
- Configuring the DAC32 converter with a user configuration.
- Enabling the DAC32 module.
- Parameters
-
base | DAC32 peripheral base address. |
config | Pointer to the configuration structure. See "dac32_config_t". |
void DAC32_Deinit |
( |
DAC_Type * |
base | ) |
|
This function de-initializes the DAC32 module, including:
- Disabling the DAC32 module.
- Disabling the clock for the DAC32 module.
- Parameters
-
base | DAC32 peripheral base address. |
This function initializes the user configuration structure to a default value. The default values are:
* config->enableLowPowerMode = false;
*
- Parameters
-
config | Pointer to the configuration structure. See "dac32_config_t". |
static void DAC32_Enable |
( |
DAC_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
enable | Enables the feature or not. |
static void DAC32_EnableBuffer |
( |
DAC_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
enable | Enables the feature or not. |
- Parameters
-
base | DAC32 peripheral base address. |
config | Pointer to the configuration structure. See "dac32_buffer_config_t". |
This function initializes the DAC32 buffer configuration structure to a default value. The default values are:
* config->upperLimit = DAC_DAT_COUNT * 2U - 1U;
*
- Parameters
-
config | Pointer to the configuration structure. See "dac32_buffer_config_t". |
static void DAC32_EnableBufferDMA |
( |
DAC_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
enable | Enables the feature or not. |
void DAC32_SetBufferValue |
( |
DAC_Type * |
base, |
|
|
uint32_t |
index, |
|
|
uint32_t |
value |
|
) |
| |
- Parameters
-
base | DAC32 peripheral base address. |
index | Setting index for items in the buffer. The available index should not exceed the size of the DAC32 buffer. |
value | Setting value for items in the buffer. 12-bits are available. |
static void DAC32_DoSoftwareTriggerBuffer |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function triggers the function by software. The read pointer of the DAC32 buffer is updated with one step after this function is called. Changing the read pointer depends on the buffer's work mode.
- Parameters
-
base | DAC32 peripheral base address. |
static uint32_t DAC32_GetBufferReadPointer |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
This function gets the current read pointer of the DAC32 buffer. The current output value depends on the item indexed by the read pointer. It is updated by software trigger or hardware trigger.
- Parameters
-
base | DAC32 peripheral base address. |
- Returns
- Current read pointer of DAC32 buffer.
static void DAC32_SetBufferReadPointer |
( |
DAC_Type * |
base, |
|
|
uint32_t |
index |
|
) |
| |
|
inlinestatic |
This function sets the current read pointer of the DAC32 buffer. The current output value depends on the item indexed by the read pointer. It is updated by software trigger or hardware trigger. After the read pointer changes, the DAC32 output value also changes.
- Parameters
-
base | DAC32 peripheral base address. |
index | Setting index value for the pointer. |
static void DAC32_EnableBufferInterrupts |
( |
DAC_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
mask | Mask value for interrupts. See "_dac32_buffer_interrupt_enable". |
static void DAC32_DisableBufferInterrupts |
( |
DAC_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
mask | Mask value for interrupts. See "_dac32_buffer_interrupt_enable". |
static uint32_t DAC32_GetBufferStatusFlags |
( |
DAC_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
- Returns
- Mask value for the asserted flags. See "_dac32_buffer_status_flags".
static void DAC32_ClearBufferStatusFlags |
( |
DAC_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
mask | Mask value for flags. See "_dac32_buffer_status_flags_t". |
static void DAC32_EnableBufferOutput |
( |
DAC_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
enable | Enable the buffer output or not. |
static void DAC32_EnableTestOutput |
( |
DAC_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | DAC32 peripheral base address. |
enable | Enable the test output or not. |