no-OS
|
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"
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_RATECNTRL 0x4C |
#define | AXI_DAC_RATE(x) (((x) & 0xFF) << 0) |
#define | AXI_DAC_TO_RATE(x) (((x) >> 0) & 0xFF) |
#define | AXI_DAC_REG_CLK_FREQ 0x54 |
#define | AXI_DAC_CLK_FREQ(x) (((x) & 0xFFFFFFFF) << 0) |
#define | AXI_DAC_TO_CLK_FREQ(x) (((x) >> 0) & 0xFFFFFFFF) |
#define | AXI_DAC_REG_CLK_RATIO 0x58 |
#define | AXI_DAC_CLK_RATIO(x) (((x) & 0xFFFFFFFF) << 0) |
#define | AXI_DAC_TO_CLK_RATIO(x) (((x) >> 0) & 0xFFFFFFFF) |
#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_REG_DDS_SCALE(x) (0x400 + ((x) >> 1) * 0x40 + ((x) & 1) * 0x8) |
#define | AXI_DAC_DDS_SCALE(x) (((x) & 0xFFFF) << 0) |
#define | AXI_DAC_TO_DDS_SCALE(x) (((x) >> 0) & 0xFFFF) |
#define | AXI_DAC_REG_DDS_INIT_INCR(x) (0x404 + ((x) >> 1) * 0x40 + ((x) & 1) * 0x8) |
#define | AXI_DAC_DDS_INIT(x) (((x) & 0xFFFFU) << 16) |
#define | AXI_DAC_TO_DDS_INIT(x) (((x) >> 16) & 0xFFFF) |
#define | AXI_DAC_DDS_INCR(x) (((x) & 0xFFFF) << 0) |
#define | AXI_DAC_TO_DDS_INCR(x) (((x) >> 0) & 0xFFFF) |
#define | DAC_REG_DATA_PATTERN(c) (0x0410 + (c) * 0x40) |
#define | AXI_DAC_REG_DATA_SELECT(c) (0x0418 + (c) * 0x40) |
#define | AXI_DAC_DATA_SELECT(x) (((x) & 0xF) << 0) |
#define | AXI_DAC_TO_DATA_SELECT(x) (((x) >> 0) & 0xF) |
#define | AXI_DAC_REG_CHAN_CNTRL_6(c) (0x0414 + (c) * 0x40) |
#define | AXI_DAC_IQCOR_ENB (1 << 2) |
#define | AXI_DAC_REG_CHAN_CNTRL_7(c) (0x0418 + (c) * 0x40) |
#define | AXI_DAC_DAC_DDS_SEL(x) (((x) & 0xF) << 0) |
#define | AXI_DAC_TO_DAC_DDS_SEL(x) (((x) >> 0) & 0xF) |
#define | AXI_DAC_REG_CHAN_CNTRL_8(c) (0x041C + (c) * 0x40) |
#define | AXI_DAC_IQCOR_COEFF_1(x) (((x) & 0xFFFFU) << 16) |
#define | AXI_DAC_TO_IQCOR_COEFF_1(x) (((x) >> 16) & 0xFFFF) |
#define | AXI_DAC_IQCOR_COEFF_2(x) (((x) & 0xFFFF) << 0) |
#define | AXI_DAC_TO_IQCOR_COEFF_2(x) (((x) >> 0) & 0xFFFF) |
Functions | |
int32_t | axi_dac_read (struct axi_dac *dac, uint32_t reg_addr, uint32_t *reg_data) |
AXI DAC Data Read. More... | |
int32_t | axi_dac_write (struct axi_dac *dac, uint32_t reg_addr, uint32_t reg_data) |
AXI DAC Data Write. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
uint32_t | axi_dac_dds_to_signed_mag_fmt (int32_t val, int32_t val2) |
AXI DAC Convert to signed magnitude format. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
uint32_t | axi_dac_set_sine_lut (struct axi_dac *dac, uint32_t address) |
AXI DAC Set data based on a Sine Lookup Table. More... | |
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. More... | |
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. More... | |
int32_t | axi_dac_init_begin (struct axi_dac **dac_core, const struct axi_dac_init *init) |
Begin AXI DAC Initialization. More... | |
int32_t | axi_dac_init_finish (struct axi_dac *dac) |
Begin AXI DAC Initialization. More... | |
int32_t | axi_dac_init (struct axi_dac **dac_core, const struct axi_dac_init *init) |
AXI DAC Main Initialization. More... | |
int32_t | axi_dac_data_setup (struct axi_dac *dac) |
AXI DAC Data Setup. More... | |
int32_t | axi_dac_remove (struct axi_dac *dac) |
AXI DAC Resources deallocation. More... | |
Variables | |
const uint16_t | sine_lut [128] |
const uint32_t | sine_lut_iq [1024] |
Driver for the Analog Devices AXI-DAC-CORE module.
Copyright 2018(c) Analog Devices, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AXI_DAC_CLK_FREQ | ( | x | ) | (((x) & 0xFFFFFFFF) << 0) |
#define AXI_DAC_CLK_RATIO | ( | x | ) | (((x) & 0xFFFFFFFF) << 0) |
#define AXI_DAC_DAC_DDS_SEL | ( | x | ) | (((x) & 0xF) << 0) |
#define AXI_DAC_DATA_SELECT | ( | x | ) | (((x) & 0xF) << 0) |
#define AXI_DAC_DDS_INCR | ( | x | ) | (((x) & 0xFFFF) << 0) |
#define AXI_DAC_DDS_INIT | ( | x | ) | (((x) & 0xFFFFU) << 16) |
#define AXI_DAC_DDS_SCALE | ( | x | ) | (((x) & 0xFFFF) << 0) |
#define AXI_DAC_IQCOR_COEFF_1 | ( | x | ) | (((x) & 0xFFFFU) << 16) |
#define AXI_DAC_IQCOR_COEFF_2 | ( | x | ) | (((x) & 0xFFFF) << 0) |
#define AXI_DAC_IQCOR_ENB (1 << 2) |
#define AXI_DAC_MMCM_RSTN NO_OS_BIT(1) |
#define AXI_DAC_MUX_OVER_RANGE NO_OS_BIT(1) |
#define AXI_DAC_MUX_PN_ERR NO_OS_BIT(3) |
#define AXI_DAC_MUX_PN_OOS NO_OS_BIT(2) |
#define AXI_DAC_RATE | ( | x | ) | (((x) & 0xFF) << 0) |
#define AXI_DAC_REG_CHAN_CNTRL_6 | ( | c | ) | (0x0414 + (c) * 0x40) |
#define AXI_DAC_REG_CHAN_CNTRL_7 | ( | c | ) | (0x0418 + (c) * 0x40) |
#define AXI_DAC_REG_CHAN_CNTRL_8 | ( | c | ) | (0x041C + (c) * 0x40) |
#define AXI_DAC_REG_CLK_FREQ 0x54 |
#define AXI_DAC_REG_CLK_RATIO 0x58 |
#define AXI_DAC_REG_DATA_SELECT | ( | c | ) | (0x0418 + (c) * 0x40) |
#define AXI_DAC_REG_DDS_INIT_INCR | ( | x | ) | (0x404 + ((x) >> 1) * 0x40 + ((x) & 1) * 0x8) |
#define AXI_DAC_REG_DDS_SCALE | ( | x | ) | (0x400 + ((x) >> 1) * 0x40 + ((x) & 1) * 0x8) |
#define AXI_DAC_REG_RATECNTRL 0x4C |
#define AXI_DAC_REG_RSTN 0x40 |
#define AXI_DAC_REG_STATUS 0x005C |
#define AXI_DAC_REG_SYNC_CONTROL 0x44 |
#define AXI_DAC_RSTN NO_OS_BIT(0) |
#define AXI_DAC_STATUS NO_OS_BIT(0) |
#define AXI_DAC_SYNC NO_OS_BIT(0) |
#define AXI_DAC_TO_CLK_FREQ | ( | x | ) | (((x) >> 0) & 0xFFFFFFFF) |
#define AXI_DAC_TO_CLK_RATIO | ( | x | ) | (((x) >> 0) & 0xFFFFFFFF) |
#define AXI_DAC_TO_DAC_DDS_SEL | ( | x | ) | (((x) >> 0) & 0xF) |
#define AXI_DAC_TO_DATA_SELECT | ( | x | ) | (((x) >> 0) & 0xF) |
#define AXI_DAC_TO_DDS_INCR | ( | x | ) | (((x) >> 0) & 0xFFFF) |
#define AXI_DAC_TO_DDS_INIT | ( | x | ) | (((x) >> 16) & 0xFFFF) |
#define AXI_DAC_TO_DDS_SCALE | ( | x | ) | (((x) >> 0) & 0xFFFF) |
#define AXI_DAC_TO_IQCOR_COEFF_1 | ( | x | ) | (((x) >> 16) & 0xFFFF) |
#define AXI_DAC_TO_IQCOR_COEFF_2 | ( | x | ) | (((x) >> 0) & 0xFFFF) |
#define AXI_DAC_TO_RATE | ( | x | ) | (((x) >> 0) & 0xFF) |
#define DAC_REG_DATA_PATTERN | ( | c | ) | (0x0410 + (c) * 0x40) |
int32_t axi_dac_data_setup | ( | struct axi_dac * | dac | ) |
AXI DAC Data Setup.
dac | - The device structure. |
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.
val | - input value |
r_val | - integer part |
r_val2 | - fractional part |
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.
dac | - The device structure. |
chan | - The DAC channel. |
val | - the integer part. |
val2 | - the fractional part. |
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.
dac | - The device structure. |
phase | - Phase value. |
chan | - The DAC channel. |
val | - the integer part. |
val2 | - the fractional part. |
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.
dac | - The device structure. |
chan | - The DAC channel. |
val | - the integer part. |
val2 | - the fractional part. |
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.
dac | - The device structure. |
chan | - The DAC channel. |
freq | - The frequency read in Hz. |
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.
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)) |
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.
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) |
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.
dac | - The device structure. |
chan | - The DAC channel. |
val | - the integer part. |
val2 | - the fractional part. |
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.
dac | - The device structure. |
phase | - Phase value. |
chan | - The DAC channel. |
val | - the integer part. |
val2 | - the fractional part. |
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.
dac | - The device structure. |
chan | - The DAC channel. |
val | - the integer part. |
val2 | - the fractional part. |
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.
dac | - The device structure. |
chan | - The DAC channel. |
freq_hz | - The frequency to be set in Hz. |
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.
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)) |
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.
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) |
uint32_t axi_dac_dds_to_signed_mag_fmt | ( | int32_t | val, |
int32_t | val2 | ||
) |
AXI DAC Convert to signed magnitude format.
val | - integer part |
val2 | - fractional part |
int32_t axi_dac_init | ( | struct axi_dac ** | dac_core, |
const struct axi_dac_init * | init | ||
) |
AXI DAC Main Initialization.
dac_core | - The device structure. |
init | - Initialization parameters. |
int32_t axi_dac_init_begin | ( | struct axi_dac ** | dac_core, |
const struct axi_dac_init * | init | ||
) |
Begin AXI DAC Initialization.
dac_core | - The device structure. |
init | - Initialization parameters. |
int32_t axi_dac_init_finish | ( | struct axi_dac * | dac | ) |
Begin AXI DAC Initialization.
dac | - The device structure. |
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.
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. |
int32_t axi_dac_read | ( | struct axi_dac * | dac, |
uint32_t | reg_addr, | ||
uint32_t * | reg_data | ||
) |
AXI DAC Data Read.
dac | - The device structure. |
reg_addr | - The register address. |
reg_data | - Data value to be written. |
int32_t axi_dac_remove | ( | struct axi_dac * | dac | ) |
AXI DAC Resources deallocation.
dac | - The device structure. |
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.
dac | - The device structure. |
address | - Base Address. |
buff | - The buffer to be set. |
buff_size | - The buffer size. |
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.
dac | - The device structure. |
chan | - The DAC channel. |
sel | - Data type. |
uint32_t axi_dac_set_sine_lut | ( | struct axi_dac * | dac, |
uint32_t | address | ||
) |
AXI DAC Set data based on a Sine Lookup Table.
dac | - The device structure. |
address | - Address of the sine lut. |
int32_t axi_dac_write | ( | struct axi_dac * | dac, |
uint32_t | reg_addr, | ||
uint32_t | reg_data | ||
) |
AXI DAC Data Write.
dac | - The device structure. |
reg_addr | - The register address. |
reg_data | - Data value to be written. |
const uint16_t sine_lut[128] |
const uint32_t sine_lut_iq[1024] |