Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the DAC HAL driver.

Data Structures

struct  dac_converter_config_t
 Defines the type of structure for configuring the DAC converter. More...
 
struct  dac_buffer_config_t
 Defines the type of structure for configuring the DAC buffer. More...
 

Enumerations

enum  dac_status_t {
  kStatus_DAC_Success = 0U,
  kStatus_DAC_InvalidArgument = 1U,
  kStatus_DAC_Failed = 2U
}
 DAC status return codes. More...
 
enum  dac_ref_volt_src_mode_t {
  kDacRefVoltSrcOfVref1 = 0U,
  kDacRefVoltSrcOfVref2 = 1U
}
 Defines the type of selection for DAC module's reference voltage source. More...
 
enum  dac_trigger_mode_t {
  kDacTriggerByHardware = 0U,
  kDacTriggerBySoftware = 1U
}
 Defines the type of selection for DAC module trigger mode. More...
 
enum  dac_buff_watermark_mode_t {
  kDacBuffWatermarkFromUpperAs1Word = 0U,
  kDacBuffWatermarkFromUpperAs2Word = 1U,
  kDacBuffWatermarkFromUpperAs3Word = 2U,
  kDacBuffWatermarkFromUpperAs4Word = 3U
}
 Defines the type of selection for buffer watermark mode. More...
 
enum  dac_buff_work_mode_t { kDacBuffWorkAsNormalMode = 0U }
 Defines the type of selection for buffer work mode. More...
 

Functions

void DAC_HAL_Init (DAC_Type *base)
 Resets all configurable registers to the reset state for DAC. More...
 
void DAC_HAL_ConfigConverter (DAC_Type *base, const dac_converter_config_t *configPtr)
 Configures the converter for DAC. More...
 
void DAC_HAL_ConfigBuffer (DAC_Type *base, const dac_buffer_config_t *configPtr)
 Configures the buffer for DAC. More...
 
void DAC_HAL_SetBuffValue (DAC_Type *base, uint8_t idx, uint16_t value)
 Sets the 12-bit value for the DAC items in the buffer. More...
 
static void DAC_HAL_ClearBuffIdxUpperFlag (DAC_Type *base)
 Clears the flag of the DAC buffer read pointer. More...
 
static bool DAC_HAL_GetBuffIdxUpperFlag (DAC_Type *base)
 Gets the flag of the DAC buffer read pointer when it reaches the bottom position. More...
 
static void DAC_HAL_ClearBuffIdxStartFlag (DAC_Type *base)
 Clears the flag of the DAC buffer read pointer when it reaches the top position. More...
 
static bool DAC_HAL_GetBuffIdxStartFlag (DAC_Type *base)
 Gets the flag of the DAC buffer read pointer when it reaches the top position. More...
 
static void DAC_HAL_Enable (DAC_Type *base)
 Enables the Programmable Reference Generator. More...
 
static void DAC_HAL_Disable (DAC_Type *base)
 Disables the Programmable Reference Generator. More...
 
static void DAC_HAL_SetSoftTriggerCmd (DAC_Type *base)
 Triggers the converter with software. More...
 
static void DAC_HAL_SetBuffCurIdx (DAC_Type *base, uint8_t idx)
 Sets the buffer index for the DAC module. More...
 
static uint8_t DAC_HAL_GetBuffCurIdx (DAC_Type *base)
 Gets the buffer index for the DAC module. More...
 

Data Structure Documentation

struct dac_converter_config_t

Data Fields

dac_ref_volt_src_mode_t dacRefVoltSrc
 Select the reference voltage source.
 
bool lowPowerEnable
 Enable the low power mode.
 
struct dac_buffer_config_t

Data Fields

bool bufferEnable
 Enable the buffer function.
 
dac_trigger_mode_t triggerMode
 Select the trigger mode.
 
bool idxStartIntEnable
 Switcher to enable interrupt when buffer index reaches the start (0).
 
bool idxUpperIntEnable
 Switcher to enable interrupt when buffer index reaches the upper limit.
 
bool dmaEnable
 Switcher to enable DMA request by original interrupts.
 
dac_buff_work_mode_t buffWorkMode
 Selection of buffer's work mode. More...
 
uint8_t upperIdx
 Setting of the buffer's upper limit, 0-15.
 

Field Documentation

dac_buff_work_mode_t dac_buffer_config_t::buffWorkMode

See "dac_buff_work_mode_t".

Enumeration Type Documentation

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.

Function Documentation

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
baseThe DAC peripheral base address.
void DAC_HAL_ConfigConverter ( DAC_Type *  base,
const dac_converter_config_t configPtr 
)

This function configures the converter for DAC. The features it covers are a one-time setting in the application.

Parameters
baseThe DAC peripheral base address.
configPtrThe pointer to configure structure.
void DAC_HAL_ConfigBuffer ( DAC_Type *  base,
const dac_buffer_config_t configPtr 
)

This function configures the converter for DAC. The features it covers are used for the buffer.

Parameters
baseThe DAC peripheral base address.
configPtrThe 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
baseThe DAC peripheral base address.
idxBuffer index.
valueSetting 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
baseThe 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
baseThe 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
baseThe 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
baseThe 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
baseThe 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
baseThe 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
baseThe 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
basethe DAC peripheral base address.
idxSetting buffer index.
static uint8_t DAC_HAL_GetBuffCurIdx ( DAC_Type *  base)
inlinestatic

This function gets the current buffer index for the DAC module.

Parameters
basethe DAC peripheral base address.
Returns
Current index of buffer.