DAC

概述

数模转换器(digital-to-analog converter,通常称为DAC)是一种数字与模拟转换器,,FIFO深度为1,支持2路DAC调制输出。 可用于音频播放,常规的模拟信号调制。

注解

dac更多资料请参考 BL602参考手册

应用实例

DAC实例: customer_app/peripheral/demo_dac

API参考

Header File

  • components/platform/hosal/include/hosal_dac.h

Functions

int hosal_dac_init(hosal_dac_dev_t *dac)

Initialises an dac interface.

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • dac: the interface which should be initialised

int hosal_dac_finalize(hosal_dac_dev_t *dac)

De-initialises an dac interface, Turns off an dac hardware interface.

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • dac: the interface which should be de-initialised

int hosal_dac_start(hosal_dac_dev_t *dac)

Start output dac (no DMA mode)

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • dac: the interface which should be started

int hosal_dac_stop(hosal_dac_dev_t *dac)

Stop output dac.

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • dac: the interface which should be stopped

int hosal_dac_set_value(hosal_dac_dev_t *dac, uint32_t data)

Output a value to an dac interface.

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • dac: the interface to set value
  • data: the value to output, output unit: μV

int hosal_dac_get_value(hosal_dac_dev_t *dac)

Returns the last data output value of the selected dac channel.

Return
dac output value, output unit: μV
Parameters
  • dac: the interface to get value

int hosal_dac_dma_cb_reg(hosal_dac_dev_t *dac, hosal_dac_cb_t callback, void *arg)

DAC cb register.

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • dac: the DAC interface
  • callback: callback handler
  • arg: callback arg

int hosal_dac_dma_start(hosal_dac_dev_t *dac, uint32_t *data, uint32_t size)

DAC use DMA mode.

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • adc: the DAC interface
  • data: dac data buffer
  • size: data buffer size

int hosal_dac_dma_stop(hosal_dac_dev_t *dac)

Stop output dac.

Return
  • 0 on success
  • EIO if an error occurred with any step
Parameters
  • dac: the interface which should be stopped

Structures

struct hosal_dac_config_t

This struct define dac config args.

Public Members

uint8_t dma_enable

1: use dma, 0: no dma

uint32_t pin

dac pin

uint32_t freq

dac freq

struct hosal_dac_dev_t

This struct define dac device type.

Public Members

uint8_t port

dac id

hosal_dac_config_t config

dac config

hosal_dac_cb_t cb

dma callback

hosal_dma_chan_t dma_chan

dac dma channel

void *arg

arg data

void *priv

priv data

Type Definitions

typedef void (*hosal_dac_cb_t)(void *arg)

hosal dac callback

Parameters
  • arg: Set the custom parameters specified when the callback function is set