no-OS
axi_dac_core.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef AXI_DAC_CORE_H_
40 #define AXI_DAC_CORE_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 
47 /******************************************************************************/
48 /*************************** Types Declarations *******************************/
49 /******************************************************************************/
54 struct axi_dac {
56  const char *name;
58  uint32_t base;
60  uint8_t num_channels;
62  uint64_t clock_hz;
65 };
66 
67 struct axi_dac_init {
69  const char *name;
71  uint32_t base;
73  uint8_t num_channels;
76 };
77 
89 };
90 
92  uint32_t dds_frequency_0; // in hz (1000*1000 for MHz)
93  uint32_t dds_phase_0; // in milli(?) angles (90*1000 for 90 degrees = pi/2)
94  int32_t dds_scale_0; // in micro units (1.0*1000*1000 is 1.0)
95  uint32_t dds_frequency_1; // in hz (1000*1000 for MHz)
96  uint32_t dds_phase_1; // in milli(?) angles (90*1000 for 90 degrees = pi/2)
97  int32_t dds_scale_1; // in micro units (1.0*1000*1000 is 1.0)
98  uint32_t dds_dual_tone; // if using single tone for this channel, set to 0x0
99  uint32_t pat_data; // if using SED/debug that sort of thing
100  enum axi_dac_data_sel sel; // set to one of the enumerated type above.
101 };
102 
103 extern const uint16_t sine_lut[128];
104 
105 extern const uint32_t sine_lut_iq[1024];
106 
107 /******************************************************************************/
108 /************************ Functions Declarations ******************************/
109 /******************************************************************************/
111 int32_t axi_dac_init_begin(struct axi_dac **dac_core,
112  const struct axi_dac_init *init);
114 int32_t axi_dac_init_finish(struct axi_dac *dac);
116 int32_t axi_dac_init(struct axi_dac **dac_core,
117  const struct axi_dac_init *init);
119 int32_t axi_dac_remove(struct axi_dac *dac);
121 int32_t axi_dac_set_datasel(struct axi_dac *dac,
122  int32_t chan,
123  enum axi_dac_data_sel sel);
125 int32_t axi_dac_dds_set_frequency(struct axi_dac *dac,
126  uint32_t chan, uint32_t freq_hz);
128 int32_t axi_dac_dds_get_frequency(struct axi_dac *dac,
129  uint32_t chan, uint32_t *freq);
131 int32_t axi_dac_dds_set_phase(struct axi_dac *dac,
132  uint32_t chan, uint32_t phase);
134 int32_t axi_dac_dds_get_phase(struct axi_dac *dac,
135  uint32_t chan, uint32_t *phase);
137 int32_t axi_dac_dds_set_scale(struct axi_dac *dac,
138  uint32_t chan,
139  int32_t scale_micro_units);
141 int32_t axi_dac_dds_get_scale(struct axi_dac *dac,
142  uint32_t chan,
143  int32_t *scale_micro_units);
145 int32_t axi_dac_set_buff(struct axi_dac *dac,
146  uint32_t address,
147  uint16_t *buff,
148  uint32_t buff_size);
150 uint32_t axi_dac_set_sine_lut(struct axi_dac *dac,
151  uint32_t address);
153 int32_t axi_dac_dds_get_calib_scale(struct axi_dac *dac,
154  uint32_t chan,
155  int32_t *val,
156  int32_t *val2);
158 int32_t axi_dac_dds_get_calib_phase(struct axi_dac *dac,
159  uint32_t chan,
160  int32_t *val,
161  int32_t *val2);
163 int32_t axi_dac_dds_set_calib_scale(struct axi_dac *dac,
164  uint32_t chan,
165  int32_t val,
166  int32_t val2);
168 int32_t axi_dac_dds_set_calib_phase(struct axi_dac *dac,
169  uint32_t chan,
170  int32_t val,
171  int32_t val2);
173 int32_t axi_dac_load_custom_data(struct axi_dac *dac,
174  const uint32_t *custom_data_iq,
175  uint32_t custom_tx_count,
176  uint32_t address);
178 int32_t axi_dac_data_setup(struct axi_dac *dac);
179 
180 #endif
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.
Definition: axi_dac_core.c:697
axi_dac_data_setup
int32_t axi_dac_data_setup(struct axi_dac *dac)
AXI DAC Data Setup.
Definition: axi_dac_core.c:977
AXI_DAC_DATA_SEL_ZERO
@ AXI_DAC_DATA_SEL_ZERO
Definition: axi_dac_core.h:82
axi_dac::name
const char * name
Definition: axi_dac_core.h:56
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.
Definition: axi_dac_core.c:378
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.
Definition: axi_dac_core.c:502
axi_dac_read
int32_t axi_dac_read(struct axi_dac *dac, uint32_t reg_addr, uint32_t *reg_data)
AXI DAC Data Read.
Definition: axi_dac_core.c:346
AXI_DAC_IQCOR_COEFF_1
#define AXI_DAC_IQCOR_COEFF_1(x)
Definition: axi_dac_core.c:104
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.
Definition: axi_dac_core.c:886
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.
Definition: axi_dac_core.c:533
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.
Definition: axi_dac_core.c:713
axi_dac::clock_hz
uint64_t clock_hz
Definition: axi_dac_core.h:62
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.
Definition: axi_dac_core.c:759
axi_dac_init::base
uint32_t base
Definition: axi_dac_core.h:71
axi_dac_channel::pat_data
uint32_t pat_data
Definition: axi_dac_core.h:99
AXI_DAC_REG_CLK_RATIO
#define AXI_DAC_REG_CLK_RATIO
Definition: axi_dac_core.c:70
axi_dac_init_finish
int32_t axi_dac_init_finish(struct axi_dac *dac)
Begin AXI DAC Initialization.
Definition: axi_dac_core.c:910
AXI_DAC_DATA_SEL_DDS
@ AXI_DAC_DATA_SEL_DDS
Definition: axi_dac_core.h:79
sine_lut
const uint16_t sine_lut[128]
Definition: axi_dac_core.c:109
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.
Definition: axi_dac_core.c:476
no_os_delay.h
Header file of Delay functions.
DAC_REG_DATA_PATTERN
#define DAC_REG_DATA_PATTERN(c)
Definition: axi_dac_core.c:90
axi_dac_channel::dds_frequency_1
uint32_t dds_frequency_1
Definition: axi_dac_core.h:95
axi_dac_channel::dds_phase_1
uint32_t dds_phase_1
Definition: axi_dac_core.h:96
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.
Definition: axi_dac_core.c:824
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.
Definition: axi_dac_core.c:596
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.
Definition: axi_dac_core.c:426
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.
Definition: axi_dac_core.c:451
AXI_DAC_SYNC
#define AXI_DAC_SYNC
Definition: axi_dac_core.c:60
AXI_DAC_IQCOR_COEFF_2
#define AXI_DAC_IQCOR_COEFF_2(x)
Definition: axi_dac_core.c:106
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.
Definition: axi_dac_core.c:402
axi_dac_init::channels
struct axi_dac_channel * channels
Definition: axi_dac_core.h:75
AXI_DAC_TO_DDS_INIT
#define AXI_DAC_TO_DDS_INIT(x)
Definition: axi_dac_core.c:86
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.
Definition: axi_dac_core.c:502
AXI_DAC_REG_SYNC_CONTROL
#define AXI_DAC_REG_SYNC_CONTROL
Definition: axi_dac_core.c:59
axi_dac_core.h
Driver for the Analog Devices AXI-DAC-CORE module.
no_os_axi_io.h
Header file of AXI IO.
AXI_DAC_DATA_SEL_PN15
@ AXI_DAC_DATA_SEL_PN15
Definition: axi_dac_core.h:84
AXI_DAC_REG_STATUS
#define AXI_DAC_REG_STATUS
Definition: axi_dac_core.c:74
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.
Definition: axi_dac_core.c:759
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.
Definition: axi_dac_core.c:729
AXI_DAC_REG_RSTN
#define AXI_DAC_REG_RSTN
Definition: axi_dac_core.c:55
AXI_DAC_REG_DATA_SELECT
#define AXI_DAC_REG_DATA_SELECT(c)
Definition: axi_dac_core.c:92
AXI_DAC_DDS_INCR
#define AXI_DAC_DDS_INCR(x)
Definition: axi_dac_core.c:87
AXI_DAC_REG_CLK_FREQ
#define AXI_DAC_REG_CLK_FREQ
Definition: axi_dac_core.c:66
AXI_DAC_RATE
#define AXI_DAC_RATE(x)
Definition: axi_dac_core.c:63
no_os_do_div
uint64_t no_os_do_div(uint64_t *n, uint64_t base)
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
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.
Definition: axi_dac_core.c:745
no_os_error.h
Error codes definition.
axi_dac_write
int32_t axi_dac_write(struct axi_dac *dac, uint32_t reg_addr, uint32_t reg_data)
AXI DAC Data Write.
Definition: axi_dac_core.c:362
axi_dac_channel
Definition: axi_dac_core.h:91
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.
Definition: axi_dac_core.c:378
axi_dac_init::name
const char * name
Definition: axi_dac_core.h:69
axi_dac::base
uint32_t base
Definition: axi_dac_core.h:58
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.
Definition: axi_dac_core.c:713
AXI_DAC_DDS_SCALE
#define AXI_DAC_DDS_SCALE(x)
Definition: axi_dac_core.c:81
sine_lut_iq
const uint32_t sine_lut_iq[1024]
Definition: axi_dac_core.c:128
axi_dac_channel::dds_frequency_0
uint32_t dds_frequency_0
Definition: axi_dac_core.h:92
AXI_DAC_REG_RATECNTRL
#define AXI_DAC_REG_RATECNTRL
Definition: axi_dac_core.c:62
AXI_DAC_TO_IQCOR_COEFF_1
#define AXI_DAC_TO_IQCOR_COEFF_1(x)
Definition: axi_dac_core.c:105
axi_dac_init
Definition: axi_dac_core.h:67
axi_dac_channel::dds_scale_0
int32_t dds_scale_0
Definition: axi_dac_core.h:94
axi_dac_init::num_channels
uint8_t num_channels
Definition: axi_dac_core.h:73
no_os_axi_io_read
int32_t no_os_axi_io_read(uint32_t base, uint32_t offset, uint32_t *data)
AXI IO Altera specific read function.
Definition: altera_axi_io.c:59
axi_dac
AXI DAC Device Descriptor.
Definition: axi_dac_core.h:54
AXI_DAC_DATA_SEL_PN23
@ AXI_DAC_DATA_SEL_PN23
Definition: axi_dac_core.h:85
axi_dac::num_channels
uint8_t num_channels
Definition: axi_dac_core.h:60
sine_lut
const uint16_t sine_lut[128]
Definition: adc_demo.c:52
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.
Definition: axi_dac_core.c:697
axi_dac::channels
struct axi_dac_channel * channels
Definition: axi_dac_core.h:64
axi_dac_remove
int32_t axi_dac_remove(struct axi_dac *dac)
AXI DAC Resources deallocation.
Definition: axi_dac_core.c:1022
AXI_DAC_REG_DDS_SCALE
#define AXI_DAC_REG_DDS_SCALE(x)
Definition: axi_dac_core.c:80
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.
Definition: axi_dac_core.c:451
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.
Definition: axi_dac_core.c:851
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.
Definition: axi_dac_core.c:402
axi_dac_init
int32_t axi_dac_init(struct axi_dac **dac_core, const struct axi_dac_init *init)
AXI DAC Main Initialization.
Definition: axi_dac_core.c:939
AXI_DAC_REG_CHAN_CNTRL_8
#define AXI_DAC_REG_CHAN_CNTRL_8(c)
Definition: axi_dac_core.c:103
axi_dac_channel::dds_phase_0
uint32_t dds_phase_0
Definition: axi_dac_core.h:93
sine_lut_iq
const uint32_t sine_lut_iq[1024]
Definition: axi_dac_core.c:128
AXI_DAC_DATA_SEL_SED
@ AXI_DAC_DATA_SEL_SED
Definition: axi_dac_core.h:80
AXI_DAC_REG_DDS_INIT_INCR
#define AXI_DAC_REG_DDS_INIT_INCR(x)
Definition: axi_dac_core.c:84
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.
Definition: axi_dac_core.c:745
axi_dac_data_setup
int32_t axi_dac_data_setup(struct axi_dac *dac)
AXI DAC Data Setup.
Definition: axi_dac_core.c:977
AXI_DAC_REG_CHAN_CNTRL_6
#define AXI_DAC_REG_CHAN_CNTRL_6(c)
Definition: axi_dac_core.c:96
no_os_axi_io_write
int32_t no_os_axi_io_write(uint32_t base, uint32_t offset, uint32_t data)
AXI IO Altera specific write function.
Definition: altera_axi_io.c:73
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.
Definition: axi_dac_core.c:886
axi_dac_remove
int32_t axi_dac_remove(struct axi_dac *dac)
AXI DAC Resources deallocation.
Definition: axi_dac_core.c:1022
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.
Definition: axi_dac_core.c:560
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.
Definition: axi_dac_core.c:533
AXI_DAC_IQCOR_ENB
#define AXI_DAC_IQCOR_ENB
Definition: axi_dac_core.c:97
axi_dac_channel::sel
enum axi_dac_data_sel sel
Definition: axi_dac_core.h:100
AXI_DAC_MMCM_RSTN
#define AXI_DAC_MMCM_RSTN
Definition: axi_dac_core.c:56
AXI_DAC_DATA_SEL_PN31
@ AXI_DAC_DATA_SEL_PN31
Definition: axi_dac_core.h:86
axi_dac_channel::dds_dual_tone
uint32_t dds_dual_tone
Definition: axi_dac_core.h:98
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.
Definition: axi_dac_core.c:851
AXI_DAC_TO_IQCOR_COEFF_2
#define AXI_DAC_TO_IQCOR_COEFF_2(x)
Definition: axi_dac_core.c:107
AXI_DAC_DATA_SEL_DMA
@ AXI_DAC_DATA_SEL_DMA
Definition: axi_dac_core.h:81
AXI_DAC_REG_CHAN_CNTRL_7
#define AXI_DAC_REG_CHAN_CNTRL_7(c)
Definition: axi_dac_core.c:99
AXI_DAC_DDS_INIT
#define AXI_DAC_DDS_INIT(x)
Definition: axi_dac_core.c:85
no_os_util.h
Header file of utility functions.
axi_dac_channel::dds_scale_1
int32_t dds_scale_1
Definition: axi_dac_core.h:97
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.
Definition: axi_dac_core.c:729
axi_dac_init_finish
int32_t axi_dac_init_finish(struct axi_dac *dac)
Begin AXI DAC Initialization.
Definition: axi_dac_core.c:910
AXI_DAC_TO_DDS_SCALE
#define AXI_DAC_TO_DDS_SCALE(x)
Definition: axi_dac_core.c:82
axi_dac_init
int32_t axi_dac_init(struct axi_dac **dac_core, const struct axi_dac_init *init)
AXI DAC Main Initialization.
Definition: axi_dac_core.c:939
axi_dac_data_sel
axi_dac_data_sel
Definition: axi_dac_core.h:78
AXI_DAC_DATA_SEL_LB
@ AXI_DAC_DATA_SEL_LB
Definition: axi_dac_core.h:87
AXI_DAC_DATA_SEL_PN7
@ AXI_DAC_DATA_SEL_PN7
Definition: axi_dac_core.h:83
AXI_DAC_RSTN
#define AXI_DAC_RSTN
Definition: axi_dac_core.c:57
AXI_DAC_DATA_SEL_PNXX
@ AXI_DAC_DATA_SEL_PNXX
Definition: axi_dac_core.h:88
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.
Definition: axi_dac_core.c:668
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.
Definition: axi_dac_core.c:476
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.
Definition: axi_dac_core.c:633
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.
Definition: axi_dac_core.c:824
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.
Definition: axi_dac_core.c:426