no-OS
Loading...
Searching...
No Matches
axi_dac_core.c File Reference

Driver for the Analog Devices AXI-DAC-CORE module. More...

#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
#include "no_os_error.h"
#include "no_os_delay.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
#include "axi_dac_core.h"
#include "no_os_axi_io.h"
Include dependency graph for axi_dac_core.c:

Macros

#define AXI_DAC_REG_RSTN   0x40
 
#define AXI_DAC_MMCM_RSTN   NO_OS_BIT(1)
 
#define AXI_DAC_RSTN   NO_OS_BIT(0)
 
#define AXI_DAC_REG_SYNC_CONTROL   0x44
 
#define AXI_DAC_SYNC   NO_OS_BIT(0)
 
#define AXI_DAC_REG_CNTRL_2   0x48
 
#define AXI_DAC_SDR_DDR_N   NO_OS_BIT(16)
 
#define AXI_DAC_SYMB_8B   NO_OS_BIT(14)
 
#define AXI_DAC_REG_RATECNTRL   0x4C
 
#define AXI_DAC_RATE(x)
 
#define AXI_DAC_TO_RATE(x)
 
#define AXI_DAC_REG_CLK_FREQ   0x54
 
#define AXI_DAC_CLK_FREQ(x)
 
#define AXI_DAC_TO_CLK_FREQ(x)
 
#define AXI_DAC_REG_CLK_RATIO   0x58
 
#define AXI_DAC_CLK_RATIO(x)
 
#define AXI_DAC_TO_CLK_RATIO(x)
 
#define AXI_DAC_REG_STATUS   0x005C
 
#define AXI_DAC_MUX_PN_ERR   NO_OS_BIT(3)
 
#define AXI_DAC_MUX_PN_OOS   NO_OS_BIT(2)
 
#define AXI_DAC_MUX_OVER_RANGE   NO_OS_BIT(1)
 
#define AXI_DAC_STATUS   NO_OS_BIT(0)
 
#define AXI_DAC_CNTRL_DATA_RD   0x80
 
#define AXI_DAC_CNTRL_DATA_WR   0x84
 
#define AXI_DAC_DATA_WR_16(x)
 
#define AXI_DAC_DATA_WR_8(x)
 
#define AXI_DAC_REG_CUSTOM_CTRL   0x8c
 
#define AXI_DAC_ADDRESS(x)
 
#define AXI_DAC_STREAM   NO_OS_BIT(1)
 
#define AXI_DAC_TRANSFER_DATA   NO_OS_BIT(0)
 
#define AXI_DAC_IO_MODE(x)
 
#define AXI_DAC_STREAM_ENABLE
 
#define AXI_DAC_UI_STATUS   0x88
 
#define AXI_DAC_BUSY   NO_OS_BIT(4)
 
#define AXI_DAC_REG_DDS_SCALE(x)
 
#define AXI_DAC_DDS_SCALE(x)
 
#define AXI_DAC_TO_DDS_SCALE(x)
 
#define AXI_DAC_REG_DDS_INIT_INCR(x)
 
#define AXI_DAC_DDS_INIT(x)
 
#define AXI_DAC_TO_DDS_INIT(x)
 
#define AXI_DAC_DDS_INCR(x)
 
#define AXI_DAC_TO_DDS_INCR(x)
 
#define DAC_REG_DATA_PATTERN(c)
 
#define AXI_DAC_REG_DATA_SELECT(c)
 
#define AXI_DAC_DATA_SELECT(x)
 
#define AXI_DAC_TO_DATA_SELECT(x)
 
#define AXI_DAC_REG_CHAN_CNTRL_6(c)
 
#define AXI_DAC_IQCOR_ENB   (1 << 2)
 
#define AXI_DAC_REG_CHAN_CNTRL_7(c)
 
#define AXI_DAC_DAC_DDS_SEL(x)
 
#define AXI_DAC_TO_DAC_DDS_SEL(x)
 
#define AXI_DAC_REG_CHAN_CNTRL_8(c)
 
#define AXI_DAC_IQCOR_COEFF_1(x)
 
#define AXI_DAC_TO_IQCOR_COEFF_1(x)
 
#define AXI_DAC_IQCOR_COEFF_2(x)
 
#define AXI_DAC_TO_IQCOR_COEFF_2(x)
 
#define AXI_DAC_RD_ADDR(x)
 

Functions

int32_t axi_dac_read (struct axi_dac *dac, uint32_t reg_addr, uint32_t *reg_data)
 AXI DAC Data Read.
 
int32_t axi_dac_write (struct axi_dac *dac, uint32_t reg_addr, uint32_t reg_data)
 AXI DAC Data Write.
 
void axi_dac_update_bits (struct axi_dac *dac, uint32_t reg_addr, uint32_t reg_mask, uint32_t reg_data)
 AXI DAC Update Data bits.
 
int32_t axi_dac_read_poll_timeout (struct axi_dac *dac, uint32_t reg_addr, uint32_t mask, uint32_t value, uint32_t sleep_us, uint32_t timeout_us)
 AXI DAC Read Data until condition is met.
 
int32_t axi_dac_bus_write (struct axi_dac *dac, uint32_t reg_addr, uint32_t reg_data, uint8_t data_size)
 AXI DAC Bus Data Write.
 
int32_t axi_dac_bus_read (struct axi_dac *dac, uint32_t reg_addr, uint32_t *reg_data, uint8_t data_size)
 AXI DAC Bus Data Read.
 
int32_t axi_dac_set_ddr (struct axi_dac *dac, bool enable)
 AXI DAC Set DDR (bus double-data-rate) mode.
 
int32_t axi_dac_set_io_mode (struct axi_dac *dac, enum axi_io_mode mode)
 AXI DAC Set IO mode.
 
int32_t axi_dac_set_data_stream (struct axi_dac *dac, bool enable)
 AXI DAC Set data stream mode.
 
int32_t axi_dac_data_transfer_addr (struct axi_dac *dac, uint32_t address)
 AXI DAC Set starting dma data trasfer address.
 
int32_t axi_dac_data_format_set (struct axi_dac *dac, int format)
 AXI DAC data format.
 
int32_t axi_dac_set_datasel (struct axi_dac *dac, int32_t chan, enum axi_dac_data_sel sel)
 AXI DAC Set Data type for specific channel.
 
int32_t axi_dac_dds_set_frequency (struct axi_dac *dac, uint32_t chan, uint32_t freq_hz)
 AXI DAC Set DDS frequency for specific channel.
 
int32_t axi_dac_dds_get_frequency (struct axi_dac *dac, uint32_t chan, uint32_t *freq)
 AXI DAC Get DDS frequency for specific channel.
 
int32_t axi_dac_dds_set_phase (struct axi_dac *dac, uint32_t chan, uint32_t phase)
 AXI DAC Set DDS phase for specific channel.
 
int32_t axi_dac_dds_get_phase (struct axi_dac *dac, uint32_t chan, uint32_t *phase)
 AXI DAC Get DDS phase for specific channel.
 
int32_t axi_dac_dds_set_scale (struct axi_dac *dac, uint32_t chan, int32_t scale_micro_units)
 AXI DAC Set DDS scale for specific channel.
 
int32_t axi_dac_dds_get_scale (struct axi_dac *dac, uint32_t chan, int32_t *scale_micro_units)
 AXI DAC Get DDS scale for specific channel.
 
uint32_t axi_dac_dds_to_signed_mag_fmt (int32_t val, int32_t val2)
 AXI DAC Convert to signed magnitude format.
 
void axi_dac_dds_from_signed_mag_fmt (uint32_t val, int32_t *r_val, int32_t *r_val2)
 AXI DAC Convert from signed magnitude format.
 
int32_t axi_dac_dds_set_calib_phase_scale (struct axi_dac *dac, uint32_t phase, uint32_t chan, int32_t val, int32_t val2)
 Calibrate phase scale for specific AXI DAC channel.
 
int32_t axi_dac_dds_get_calib_phase_scale (struct axi_dac *dac, uint32_t phase, uint32_t chan, int32_t *val, int32_t *val2)
 Get the phase scale calibration values for AXI DAC channel.
 
int32_t axi_dac_dds_set_calib_scale (struct axi_dac *dac, uint32_t chan, int32_t val, int32_t val2)
 Calibrate scale for specific AXI DAC channel.
 
int32_t axi_dac_dds_get_calib_scale (struct axi_dac *dac, uint32_t chan, int32_t *val, int32_t *val2)
 Get the scale calibration values for AXI DAC channel.
 
int32_t axi_dac_dds_set_calib_phase (struct axi_dac *dac, uint32_t chan, int32_t val, int32_t val2)
 Calibrate phase for specific AXI DAC channel.
 
int32_t axi_dac_dds_get_calib_phase (struct axi_dac *dac, uint32_t chan, int32_t *val, int32_t *val2)
 Get the phase calibration values for AXI DAC channel.
 
uint32_t axi_dac_set_sine_lut (struct axi_dac *dac, uint32_t address)
 AXI DAC Set data based on a Sine Lookup Table.
 
int32_t axi_dac_set_buff (struct axi_dac *dac, uint32_t address, uint16_t *buff, uint32_t buff_size)
 AXI DAC Set data buffer.
 
int32_t axi_dac_load_custom_data (struct axi_dac *dac, const uint32_t *custom_data_iq, uint32_t custom_tx_count, uint32_t address)
 AXI DAC Load custom data.
 
int32_t axi_dac_init_begin (struct axi_dac **dac_core, const struct axi_dac_init *init)
 Begin AXI DAC Initialization.
 
int32_t axi_dac_init_finish (struct axi_dac *dac)
 Begin AXI DAC Initialization.
 
int32_t axi_dac_init (struct axi_dac **dac_core, const struct axi_dac_init *init)
 AXI DAC Main Initialization.
 
int32_t axi_dac_data_setup (struct axi_dac *dac)
 AXI DAC Data Setup.
 
int32_t axi_dac_remove (struct axi_dac *dac)
 AXI DAC Resources deallocation.
 

Variables

const uint16_t sine_lut [128]
 
const uint32_t sine_lut_iq [1024]
 

Detailed Description

Driver for the Analog Devices AXI-DAC-CORE module.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2018(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ AXI_DAC_ADDRESS

#define AXI_DAC_ADDRESS ( x)
Value:
((x << 24) & 0xff000000)

◆ AXI_DAC_BUSY

#define AXI_DAC_BUSY   NO_OS_BIT(4)

◆ AXI_DAC_CLK_FREQ

#define AXI_DAC_CLK_FREQ ( x)
Value:
(((x) & 0xFFFFFFFF) << 0)

◆ AXI_DAC_CLK_RATIO

#define AXI_DAC_CLK_RATIO ( x)
Value:
(((x) & 0xFFFFFFFF) << 0)

◆ AXI_DAC_CNTRL_DATA_RD

#define AXI_DAC_CNTRL_DATA_RD   0x80

◆ AXI_DAC_CNTRL_DATA_WR

#define AXI_DAC_CNTRL_DATA_WR   0x84

◆ AXI_DAC_DAC_DDS_SEL

#define AXI_DAC_DAC_DDS_SEL ( x)
Value:
(((x) & 0xF) << 0)

◆ AXI_DAC_DATA_SELECT

#define AXI_DAC_DATA_SELECT ( x)
Value:
(((x) & 0xF) << 0)

◆ AXI_DAC_DATA_WR_16

#define AXI_DAC_DATA_WR_16 ( x)
Value:
((x << 8) & 0x00ffff00)

◆ AXI_DAC_DATA_WR_8

#define AXI_DAC_DATA_WR_8 ( x)
Value:
((x << 16) & 0x00ff0000)

◆ AXI_DAC_DDS_INCR

#define AXI_DAC_DDS_INCR ( x)
Value:
(((x) & 0xFFFF) << 0)

◆ AXI_DAC_DDS_INIT

#define AXI_DAC_DDS_INIT ( x)
Value:
(((x) & 0xFFFFU) << 16)

◆ AXI_DAC_DDS_SCALE

#define AXI_DAC_DDS_SCALE ( x)
Value:
(((x) & 0xFFFF) << 0)

◆ AXI_DAC_IO_MODE

#define AXI_DAC_IO_MODE ( x)
Value:
((x << 2) & 0x0000000c)

◆ AXI_DAC_IQCOR_COEFF_1

#define AXI_DAC_IQCOR_COEFF_1 ( x)
Value:
(((x) & 0xFFFFU) << 16)

◆ AXI_DAC_IQCOR_COEFF_2

#define AXI_DAC_IQCOR_COEFF_2 ( x)
Value:
(((x) & 0xFFFF) << 0)

◆ AXI_DAC_IQCOR_ENB

#define AXI_DAC_IQCOR_ENB   (1 << 2)

◆ AXI_DAC_MMCM_RSTN

#define AXI_DAC_MMCM_RSTN   NO_OS_BIT(1)

◆ AXI_DAC_MUX_OVER_RANGE

#define AXI_DAC_MUX_OVER_RANGE   NO_OS_BIT(1)

◆ AXI_DAC_MUX_PN_ERR

#define AXI_DAC_MUX_PN_ERR   NO_OS_BIT(3)

◆ AXI_DAC_MUX_PN_OOS

#define AXI_DAC_MUX_PN_OOS   NO_OS_BIT(2)

◆ AXI_DAC_RATE

#define AXI_DAC_RATE ( x)
Value:
(((x) & 0xFF) << 0)

◆ AXI_DAC_RD_ADDR

#define AXI_DAC_RD_ADDR ( x)
Value:
(NO_OS_BIT(7) | x)
#define NO_OS_BIT(x)
Definition no_os_util.h:23

◆ AXI_DAC_REG_CHAN_CNTRL_6

#define AXI_DAC_REG_CHAN_CNTRL_6 ( c)
Value:
(0x0414 + (c) * 0x40)

◆ AXI_DAC_REG_CHAN_CNTRL_7

#define AXI_DAC_REG_CHAN_CNTRL_7 ( c)
Value:
(0x0418 + (c) * 0x40)

◆ AXI_DAC_REG_CHAN_CNTRL_8

#define AXI_DAC_REG_CHAN_CNTRL_8 ( c)
Value:
(0x041C + (c) * 0x40)

◆ AXI_DAC_REG_CLK_FREQ

#define AXI_DAC_REG_CLK_FREQ   0x54

◆ AXI_DAC_REG_CLK_RATIO

#define AXI_DAC_REG_CLK_RATIO   0x58

◆ AXI_DAC_REG_CNTRL_2

#define AXI_DAC_REG_CNTRL_2   0x48

◆ AXI_DAC_REG_CUSTOM_CTRL

#define AXI_DAC_REG_CUSTOM_CTRL   0x8c

◆ AXI_DAC_REG_DATA_SELECT

#define AXI_DAC_REG_DATA_SELECT ( c)
Value:
(0x0418 + (c) * 0x40)

◆ AXI_DAC_REG_DDS_INIT_INCR

#define AXI_DAC_REG_DDS_INIT_INCR ( x)
Value:
(0x404 + ((x) >> 1) * 0x40 + ((x) & 1) * 0x8)

◆ AXI_DAC_REG_DDS_SCALE

#define AXI_DAC_REG_DDS_SCALE ( x)
Value:
(0x400 + ((x) >> 1) * 0x40 + ((x) & 1) * 0x8)

◆ AXI_DAC_REG_RATECNTRL

#define AXI_DAC_REG_RATECNTRL   0x4C

◆ AXI_DAC_REG_RSTN

#define AXI_DAC_REG_RSTN   0x40

◆ AXI_DAC_REG_STATUS

#define AXI_DAC_REG_STATUS   0x005C

◆ AXI_DAC_REG_SYNC_CONTROL

#define AXI_DAC_REG_SYNC_CONTROL   0x44

◆ AXI_DAC_RSTN

#define AXI_DAC_RSTN   NO_OS_BIT(0)

◆ AXI_DAC_SDR_DDR_N

#define AXI_DAC_SDR_DDR_N   NO_OS_BIT(16)

◆ AXI_DAC_STATUS

#define AXI_DAC_STATUS   NO_OS_BIT(0)

◆ AXI_DAC_STREAM

#define AXI_DAC_STREAM   NO_OS_BIT(1)

◆ AXI_DAC_STREAM_ENABLE

#define AXI_DAC_STREAM_ENABLE
Value:
#define AXI_DAC_TRANSFER_DATA
Definition axi_dac_core.c:59
#define AXI_DAC_STREAM
Definition axi_dac_core.c:58

◆ AXI_DAC_SYMB_8B

#define AXI_DAC_SYMB_8B   NO_OS_BIT(14)

◆ AXI_DAC_SYNC

#define AXI_DAC_SYNC   NO_OS_BIT(0)

◆ AXI_DAC_TO_CLK_FREQ

#define AXI_DAC_TO_CLK_FREQ ( x)
Value:
(((x) >> 0) & 0xFFFFFFFF)

◆ AXI_DAC_TO_CLK_RATIO

#define AXI_DAC_TO_CLK_RATIO ( x)
Value:
(((x) >> 0) & 0xFFFFFFFF)

◆ AXI_DAC_TO_DAC_DDS_SEL

#define AXI_DAC_TO_DAC_DDS_SEL ( x)
Value:
(((x) >> 0) & 0xF)

◆ AXI_DAC_TO_DATA_SELECT

#define AXI_DAC_TO_DATA_SELECT ( x)
Value:
(((x) >> 0) & 0xF)

◆ AXI_DAC_TO_DDS_INCR

#define AXI_DAC_TO_DDS_INCR ( x)
Value:
(((x) >> 0) & 0xFFFF)

◆ AXI_DAC_TO_DDS_INIT

#define AXI_DAC_TO_DDS_INIT ( x)
Value:
(((x) >> 16) & 0xFFFF)

◆ AXI_DAC_TO_DDS_SCALE

#define AXI_DAC_TO_DDS_SCALE ( x)
Value:
(((x) >> 0) & 0xFFFF)

◆ AXI_DAC_TO_IQCOR_COEFF_1

#define AXI_DAC_TO_IQCOR_COEFF_1 ( x)
Value:
(((x) >> 16) & 0xFFFF)

◆ AXI_DAC_TO_IQCOR_COEFF_2

#define AXI_DAC_TO_IQCOR_COEFF_2 ( x)
Value:
(((x) >> 0) & 0xFFFF)

◆ AXI_DAC_TO_RATE

#define AXI_DAC_TO_RATE ( x)
Value:
(((x) >> 0) & 0xFF)

◆ AXI_DAC_TRANSFER_DATA

#define AXI_DAC_TRANSFER_DATA   NO_OS_BIT(0)

◆ AXI_DAC_UI_STATUS

#define AXI_DAC_UI_STATUS   0x88

◆ DAC_REG_DATA_PATTERN

#define DAC_REG_DATA_PATTERN ( c)
Value:
(0x0410 + (c) * 0x40)

Function Documentation

◆ axi_dac_bus_read()

int32_t axi_dac_bus_read ( struct axi_dac * dac,
uint32_t reg_addr,
uint32_t * reg_data,
uint8_t data_size )

AXI DAC Bus Data Read.

Parameters
dac- The device structure.
reg_addr- The register address.
reg_data- Pointer to data value to be read.
data_size- Data size in bytes.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_bus_write()

int32_t axi_dac_bus_write ( struct axi_dac * dac,
uint32_t reg_addr,
uint32_t reg_data,
uint8_t data_size )

AXI DAC Bus Data Write.

Parameters
dac- The device structure.
reg_addr- The register address.
reg_data- Data value to be written.
data_size- Data size in bytes.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_data_format_set()

int32_t axi_dac_data_format_set ( struct axi_dac * dac,
int format )

AXI DAC data format.

Parameters
dac- The device structure.
format- bit width of the samples sent over dma, can be 8 or 16.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_data_setup()

int32_t axi_dac_data_setup ( struct axi_dac * dac)

AXI DAC Data Setup.

Parameters
dac- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_data_transfer_addr()

int32_t axi_dac_data_transfer_addr ( struct axi_dac * dac,
uint32_t address )

AXI DAC Set starting dma data trasfer address.

Parameters
dac- The device structure.
address- the 8-bit target register address for dma data streaming operations.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_from_signed_mag_fmt()

void axi_dac_dds_from_signed_mag_fmt ( uint32_t val,
int32_t * r_val,
int32_t * r_val2 )

AXI DAC Convert from signed magnitude format.

Parameters
val- input value
r_val- integer part
r_val2- fractional part

◆ axi_dac_dds_get_calib_phase()

int32_t axi_dac_dds_get_calib_phase ( struct axi_dac * dac,
uint32_t chan,
int32_t * val,
int32_t * val2 )

Get the phase calibration values for AXI DAC channel.

Parameters
dac- The device structure.
chan- The DAC channel.
val- the integer part.
val2- the fractional part.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_get_calib_phase_scale()

int32_t axi_dac_dds_get_calib_phase_scale ( struct axi_dac * dac,
uint32_t phase,
uint32_t chan,
int32_t * val,
int32_t * val2 )

Get the phase scale calibration values for AXI DAC channel.

Parameters
dac- The device structure.
phase- Phase value.
chan- The DAC channel.
val- the integer part.
val2- the fractional part.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_get_calib_scale()

int32_t axi_dac_dds_get_calib_scale ( struct axi_dac * dac,
uint32_t chan,
int32_t * val,
int32_t * val2 )

Get the scale calibration values for AXI DAC channel.

Parameters
dac- The device structure.
chan- The DAC channel.
val- the integer part.
val2- the fractional part.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_get_frequency()

int32_t axi_dac_dds_get_frequency ( struct axi_dac * dac,
uint32_t chan,
uint32_t * freq )

AXI DAC Get DDS frequency for specific channel.

Parameters
dac- The device structure.
chan- The DAC channel.
freq- The frequency read in Hz.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_get_phase()

int32_t axi_dac_dds_get_phase ( struct axi_dac * dac,
uint32_t chan,
uint32_t * phase )

AXI DAC Get DDS phase for specific channel.

Parameters
dac- The device structure.
chan- The DAC channel.
phase- The phase read. Phase is in milli angles scaled to 1000 (i.e. 90*1000 is 90 degrees (pi/2))
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_get_scale()

int32_t axi_dac_dds_get_scale ( struct axi_dac * dac,
uint32_t chan,
int32_t * scale_micro_units )

AXI DAC Get DDS scale for specific channel.

Parameters
dac- The device structure.
chan- The DAC channel.
scale_micro_units- The scale read. Scale is in micro units (i.e. 1*1000*1000 is 1.0)
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_set_calib_phase()

int32_t axi_dac_dds_set_calib_phase ( struct axi_dac * dac,
uint32_t chan,
int32_t val,
int32_t val2 )

Calibrate phase for specific AXI DAC channel.

Parameters
dac- The device structure.
chan- The DAC channel.
val- the integer part.
val2- the fractional part.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_set_calib_phase_scale()

int32_t axi_dac_dds_set_calib_phase_scale ( struct axi_dac * dac,
uint32_t phase,
uint32_t chan,
int32_t val,
int32_t val2 )

Calibrate phase scale for specific AXI DAC channel.

Parameters
dac- The device structure.
phase- Phase value.
chan- The DAC channel.
val- the integer part.
val2- the fractional part.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_set_calib_scale()

int32_t axi_dac_dds_set_calib_scale ( struct axi_dac * dac,
uint32_t chan,
int32_t val,
int32_t val2 )

Calibrate scale for specific AXI DAC channel.

Parameters
dac- The device structure.
chan- The DAC channel.
val- the integer part.
val2- the fractional part.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_set_frequency()

int32_t axi_dac_dds_set_frequency ( struct axi_dac * dac,
uint32_t chan,
uint32_t freq_hz )

AXI DAC Set DDS frequency for specific channel.

Parameters
dac- The device structure.
chan- The DAC channel.
freq_hz- The frequency to be set in Hz.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_set_phase()

int32_t axi_dac_dds_set_phase ( struct axi_dac * dac,
uint32_t chan,
uint32_t phase )

AXI DAC Set DDS phase for specific channel.

Parameters
dac- The device structure.
chan- The DAC channel.
phase- The phase to be set. Phase is in milli angles scaled to 1000 (i.e. 90*1000 is 90 degrees (pi/2))
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_set_scale()

int32_t axi_dac_dds_set_scale ( struct axi_dac * dac,
uint32_t chan,
int32_t scale_micro_units )

AXI DAC Set DDS scale for specific channel.

Parameters
dac- The device structure.
chan- The DAC channel.
scale_micro_units- The scale to be set. Scale is in micro units (i.e. 1*1000*1000 is 1.0)
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_dds_to_signed_mag_fmt()

uint32_t axi_dac_dds_to_signed_mag_fmt ( int32_t val,
int32_t val2 )

AXI DAC Convert to signed magnitude format.

Parameters
val- integer part
val2- fractional part
Returns
Returns converted value in case of success or negative error code otherwise.

◆ axi_dac_init()

int32_t axi_dac_init ( struct axi_dac ** dac_core,
const struct axi_dac_init * init )

AXI DAC Main Initialization.

Parameters
dac_core- The device structure.
init- Initialization parameters.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_init_begin()

int32_t axi_dac_init_begin ( struct axi_dac ** dac_core,
const struct axi_dac_init * init )

Begin AXI DAC Initialization.

Parameters
dac_core- The device structure.
init- Initialization parameters.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_init_finish()

int32_t axi_dac_init_finish ( struct axi_dac * dac)

Begin AXI DAC Initialization.

Parameters
dac- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_load_custom_data()

int32_t axi_dac_load_custom_data ( struct axi_dac * dac,
const uint32_t * custom_data_iq,
uint32_t custom_tx_count,
uint32_t address )

AXI DAC Load custom data.

Parameters
dac- The device structure.
custom_data_iq- The custom data array in I/Q format.
custom_tx_count- The custom data array size.
address- The address where the data is loaded.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_read()

int32_t axi_dac_read ( struct axi_dac * dac,
uint32_t reg_addr,
uint32_t * reg_data )

AXI DAC Data Read.

Parameters
dac- The device structure.
reg_addr- The register address.
reg_data- Data value to be written.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_read_poll_timeout()

int32_t axi_dac_read_poll_timeout ( struct axi_dac * dac,
uint32_t reg_addr,
uint32_t mask,
uint32_t value,
uint32_t sleep_us,
uint32_t timeout_us )

AXI DAC Read Data until condition is met.

Parameters
dac- The device structure.
reg_addr- The register address.
mask- The data mask to apply.
value- The data value to check.
sleep_us- Poll interval.
timeout_us- Poll timepout.

◆ axi_dac_remove()

int32_t axi_dac_remove ( struct axi_dac * dac)

AXI DAC Resources deallocation.

Parameters
dac- The device structure.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_set_buff()

int32_t axi_dac_set_buff ( struct axi_dac * dac,
uint32_t address,
uint16_t * buff,
uint32_t buff_size )

AXI DAC Set data buffer.

Parameters
dac- The device structure.
address- Base Address.
buff- The buffer to be set.
buff_size- The buffer size.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_set_data_stream()

int32_t axi_dac_set_data_stream ( struct axi_dac * dac,
bool enable )

AXI DAC Set data stream mode.

Parameters
dac- The device structure.
enable- enable or disable data stream over the bus interface, where any is available.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_set_datasel()

int32_t axi_dac_set_datasel ( struct axi_dac * dac,
int32_t chan,
enum axi_dac_data_sel sel )

AXI DAC Set Data type for specific channel.

Parameters
dac- The device structure.
chan- The DAC channel.
sel- Data type.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_set_ddr()

int32_t axi_dac_set_ddr ( struct axi_dac * dac,
bool enable )

AXI DAC Set DDR (bus double-data-rate) mode.

Parameters
dac- The device structure.
enable- enable or disable DDR mode.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_set_io_mode()

int32_t axi_dac_set_io_mode ( struct axi_dac * dac,
enum axi_io_mode mode )

AXI DAC Set IO mode.

Parameters
dac- The device structure.
mode- enum axi_io_mode.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_set_sine_lut()

uint32_t axi_dac_set_sine_lut ( struct axi_dac * dac,
uint32_t address )

AXI DAC Set data based on a Sine Lookup Table.

Parameters
dac- The device structure.
address- Address of the sine lut.
Returns
Returns 0 in case of success or negative error code otherwise.

◆ axi_dac_update_bits()

void axi_dac_update_bits ( struct axi_dac * dac,
uint32_t reg_addr,
uint32_t reg_mask,
uint32_t reg_data )

AXI DAC Update Data bits.

Parameters
dac- The device structure.
reg_addr- The register address.
reg_mask- The data mask.
reg_data- The data value.

◆ axi_dac_write()

int32_t axi_dac_write ( struct axi_dac * dac,
uint32_t reg_addr,
uint32_t reg_data )

AXI DAC Data Write.

Parameters
dac- The device structure.
reg_addr- The register address.
reg_data- Data value to be written.
Returns
Returns 0 in case of success or negative error code otherwise.

Variable Documentation

◆ sine_lut

const uint16_t sine_lut[128]
Initial value:
= {
0x000, 0x064, 0x0C8, 0x12C, 0x18F, 0x1F1, 0x252, 0x2B1,
0x30F, 0x36B, 0x3C5, 0x41C, 0x471, 0x4C3, 0x512, 0x55F,
0x5A7, 0x5ED, 0x62E, 0x66C, 0x6A6, 0x6DC, 0x70D, 0x73A,
0x763, 0x787, 0x7A7, 0x7C2, 0x7D8, 0x7E9, 0x7F5, 0x7FD,
0x7FF, 0x7FD, 0x7F5, 0x7E9, 0x7D8, 0x7C2, 0x7A7, 0x787,
0x763, 0x73A, 0x70D, 0x6DC, 0x6A6, 0x66C, 0x62E, 0x5ED,
0x5A7, 0x55F, 0x512, 0x4C3, 0x471, 0x41C, 0x3C5, 0x36B,
0x30F, 0x2B1, 0x252, 0x1F1, 0x18F, 0x12C, 0xC8, 0x64,
0x000, 0xF9B, 0xF37, 0xED3, 0xE70, 0xE0E, 0xDAD, 0xD4E,
0xCF0, 0xC94, 0xC3A, 0xBE3, 0xB8E, 0xB3C, 0xAED, 0xAA0,
0xA58, 0xA12, 0x9D1, 0x993, 0x959, 0x923, 0x8F2, 0x8C5,
0x89C, 0x878, 0x858, 0x83D, 0x827, 0x816, 0x80A, 0x802,
0x800, 0x802, 0x80A, 0x816, 0x827, 0x83D, 0x858, 0x878,
0x89C, 0x8C5, 0x8F2, 0x923, 0x959, 0x993, 0x9D1, 0xA12,
0xA58, 0xAA0, 0xAED, 0xB3C, 0xB8E, 0xBE3, 0xC3A, 0xC94,
0xCF0, 0xD4E, 0xDAD, 0xE0E, 0xE70, 0xED3, 0xF37, 0xF9B
}

◆ sine_lut_iq

const uint32_t sine_lut_iq[1024]