MT2523 API Reference  LinkIt SDK v4
DAC

This section describes the programming interfaces of the Digital-to-Analog Converter(DAC) HAL driver. More...

Overview

This section describes the programming interfaces of the Digital-to-Analog Converter(DAC) HAL driver.

Terms and acronyms

The following provides descriptions to the terms commonly used in the DAC driver and how to use the various functions.

Terms Details
DAC DAC is a Digital-to-Analog Converter that converts digital data (usually binary) into an analog signal (current, voltage, or electric charge).

Supported features

The general purpose DAC acts similar to a waveform generator. Resolution of the DAC is 10 bits. Features supported by this module are listed below:

How to use this driver

Functions

hal_dac_status_t hal_dac_init (void)
 DAC initialization function. More...
 
hal_dac_status_t hal_dac_deinit (void)
 DAC deinitialization function. More...
 
hal_dac_status_t hal_dac_start_output (void)
 Start the DAC data conversion, data written into the internal RAM is transmitted as an analog waveform. More...
 
hal_dac_status_t hal_dac_stop_output (void)
 Call this function to stop the DAC data conversion. More...
 
hal_dac_status_t hal_dac_write_data (uint32_t start_address, const uint32_t *data, uint32_t length)
 Write data into the internal RAM, prepared to be converted as analog waveform. More...
 
hal_dac_status_t hal_dac_configure_output (hal_dac_mode_t mode, uint32_t start_address, uint32_t end_address)
 This function configures the output mode of the DAC as well as the data range that will be outputted. More...
 

Modules

 Enum
 

Function Documentation

hal_dac_status_t hal_dac_configure_output ( hal_dac_mode_t  mode,
uint32_t  start_address,
uint32_t  end_address 
)

This function configures the output mode of the DAC as well as the data range that will be outputted.

Parameters
[in]modeis the output mode of DAC, it is either repeat mode or no repeat mode, the parameter should be of type hal_dac_mode_t.
[in]start_addressis the base address of the internal RAM that contains the data will be converted.
[in]end_addressis the end address of data in the internal RAM.
Returns
HAL_DAC_STATUS_INVALID_PARAMETER, the start_address or end_address is invalid.
HAL_DAC_STATUS_ERROR, the mode is not HAL_DAC_REPEAT_MODE.
HAL_DAC_STATUS_OK, the DAC output is successfully configured.
Note
User should make sure that both the start_address and end_address are no more than 127.
hal_dac_status_t hal_dac_deinit ( void  )

DAC deinitialization function.

This function resets the DAC peripheral registers to their default values.

Returns
HAL_DAC_STATUS_OK, the DAC is successfully deinitialized.
HAL_DAC_STATUS_ERROR, DAC clock disable failed.
hal_dac_status_t hal_dac_init ( void  )

DAC initialization function.

Returns
HAL_DAC_STATUS_OK, the DAC is successfully initialized.
HAL_DAC_STATUS_ERROR_BUSY, the DAC is busy.
HAL_DAC_STATUS_ERROR, DAC clock enable failed.
hal_dac_status_t hal_dac_start_output ( void  )

Start the DAC data conversion, data written into the internal RAM is transmitted as an analog waveform.

Returns
HAL_DAC_STATUS_OK, the DAC output is successfully started.
hal_dac_status_t hal_dac_stop_output ( void  )

Call this function to stop the DAC data conversion.

Returns
HAL_DAC_STATUS_OK, the DAC output is successfully stopped.
hal_dac_status_t hal_dac_write_data ( uint32_t  start_address,
const uint32_t *  data,
uint32_t  length 
)

Write data into the internal RAM, prepared to be converted as analog waveform.

Parameters
[in]start_addressis the address for the data to be saved, should be 0~127.
[in]datais the base address of the data that will be written into the internal RAM.
[in]lengthis the length of the data that will be written.
Returns
HAL_DAC_STATUS_INVALID_PARAMETER, indicates that the combination of parameters start_address and length is out of range of the internal RAM, or the data is NULL.
HAL_DAC_STATUS_ERROR, writing data to the internal RAM failed.
HAL_DAC_STATUS_OK, writing data to the internal RAM is successful.