dac.h

Digital to Analog Conversion (DAC) support.

Types

struct dac_dev

DAC device type.

Public Members
dac_reg_map * regs

Register map.

Warning

doxygenstruct: Cannot find struct “dac_reg_map” in doxygen xml output for project “project0” from directory: /home/mbolivar/leaf/libmaple/doxygen/xml

Devices

Warning

doxygenvariable: Cannot find variable “DAC” in doxygen xml output for project “project0” from directory: /home/mbolivar/leaf/libmaple/doxygen/xml

Functions

void dac_init(const dac_dev * dev, uint32 flags)

Initialize the digital to analog converter.

Parameters:
  • dev -

    DAC device

  • flags -

    Flags: DAC_CH1: Enable channel 1 DAC_CH2: Enable channel 2

Side Effects::

May set PA4 or PA5 to INPUT_ANALOG

void dac_write_channel(const dac_dev * dev, uint8 channel, uint16 val)

Write a 12-bit value to the DAC to output.

Parameters:
  • dev -

    DAC device

  • channel -

    channel to select (1 or 2)

  • val -

    value to write

void dac_enable_channel(const dac_dev * dev, uint8 channel)

Enable a DAC channel.

Parameters:
  • dev -

    DAC device

  • channel -

    channel to enable, either 1 or 2

Side Effects::

May change pin mode of PA4 or PA5

void dac_disable_channel(const dac_dev * dev, uint8 channel)

Disable a DAC channel.

Parameters:
  • dev -

    DAC device

  • channel -

    channel to disable, either 1 or 2

Register Bit Definitions

Control register

Channel 1:

DAC_CR_EN1

DAC_CR_BOFF1

DAC_CR_TEN1

DAC_CR_TSEL1

DAC_CR_WAVE1

DAC_CR_MAMP1

DAC_CR_DMAEN1

Channel 2:

DAC_CR_EN2

DAC_CR_BOFF2

DAC_CR_TEN2

DAC_CR_TSEL2

DAC_CR_WAVE2

DAC_CR_MAMP2

DAC_CR_DMAEN2

Software trigger register

DAC_SWTRIGR_SWTRIG1

DAC_SWTRIGR_SWTRIG2

Dual DAC 12-bit right-aligned data holding register

DAC_DHR12RD_DACC1DHR

DAC_DHR12RD_DACC2DHR

Dual DAC 12-bit left-aligned data holding register

DAC_DHR12LD_DACC1DHR

DAC_DHR12LD_DACC2DHR

Dual DAC 8-bit left-aligned data holding register

DAC_DHR8RD_DACC1DHR

DAC_DHR8RD_DACC2DHR