no-OS
Classes | Macros | Typedefs | Functions
ad9208_adc_api.c File Reference

Contains AD9208 APIs for ADC, DDC, NCO configuration and control. More...

#include "ad9208_api.h"
#include "ad9208_reg.h"
#include "api_errors.h"
#include <stddef.h>
Include dependency graph for ad9208_adc_api.c:

Classes

struct  adi_dec_filt_data
 
struct  chip_decimation_ratio_cfg
 

Macros

#define AD9208_NOF_FC_MAX   4
 
#define AD9208_ADC_DCM_NONE   1
 
#define AD9208_ADC_DCM_MIN   1
 
#define AD9208_ADC_DCM_MAX   48
 
#define NCO_RESET_PERIOD_US   0
 
#define LOWER_16(A)   ((A) & 0xFFFF)
 
#define UPPER_16(A)   (((A) >> 16) & 0xFFFF)
 
#define LOWER_32(A)   ((A) & (uint32_t) 0xFFFFFFFF)
 
#define MHZ_TO_HZ(x)   (((uint64_t)x)*1000*1000)
 
#define MS_TO_US(x)   ((x)*1000)
 
#define U64MSB   0x8000000000000000ull
 

Typedefs

typedef struct adi_dec_filt_data adi_dec_filt_data
 

Functions

int ad9208_get_decimation (ad9208_handle_t *h, uint8_t *dcm)
 
int ad9208_adc_set_input_scale (ad9208_handle_t *h, ad9208_adc_scale_range_t full_scale_range)
 
int ad9208_adc_set_input_cfg (ad9208_handle_t *h, signal_coupling_t analog_input_mode, uint8_t ext_vref, ad9208_adc_scale_range_t full_scale_range)
 Set AD9208 ADC Input Configuration. More...
 
int ad9208_adc_set_input_buffer_cfg (ad9208_handle_t *h, ad9208_adc_buff_curr_t buff_curr_n, ad9208_adc_buff_curr_t buff_curr_p, ad9208_adc_buff_curr_t vcm_buff)
 Set AD9208 Input Buffer Configuration. More...
 
int ad9208_adc_set_dc_offset_filt_en (ad9208_handle_t *h, uint8_t en)
 Enable AD9208 ADC DC Offset Calibaration. More...
 
int ad9208_adc_set_fc_ch_mode (ad9208_handle_t *h, uint8_t fc_ch)
 Set AD9208 ADC Operational Mode-Number of Channels. More...
 
int ad9208_adc_set_dcm_mode (ad9208_handle_t *h, uint8_t dcm)
 Set AD9208 ADC Operational Mode-decimation rate. More...
 
int ad9208_adc_set_data_format (ad9208_handle_t *h, ad9208_adc_data_frmt_t ip_data_frmt, ad9208_adc_data_frmt_t op_data_frmt)
 Set AD9208 ADC Data Format. More...
 
int ad9208_adc_set_sync_update_mode_enable (ad9208_handle_t *h, uint8_t en)
 Set AD9208 ADC Synchronized Update mode Mode. More...
 
int ad9208_adc_set_ddc_ip_mux (ad9208_handle_t *h, uint8_t ddc_ch, ad9208_adc_ch_t i_data_src, ad9208_adc_ch_t q_data_src)
 Select ADC Source for each DDC Channel. More...
 
int ad9208_adc_set_ddc_dcm (ad9208_handle_t *h, uint8_t ddc_ch, uint8_t dcm)
 Set AD9208 Decimation Filters. More...
 
int ad9208_adc_set_ddc_gain (ad9208_handle_t *h, uint8_t ddc_ch, uint8_t gain_db)
 Set AD9208 DDC Gain Stage. More...
 
int ad9208_adc_set_ddc_nco_mode (ad9208_handle_t *h, uint8_t ddc_ch, ad9208_adc_nco_mode_t mode)
 API to set DDC Frequency Translation Mode. More...
 
int ad9208_adc_set_ddc_nco_ftw (ad9208_handle_t *h, uint8_t ddc_ch, uint64_t ftw, uint64_t mod_a, uint64_t mod_b)
 API to directly set the NCO Parameters. More...
 
int ad9208_adc_set_ddc_nco_phase (ad9208_handle_t *h, uint8_t ddc_ch, uint64_t po)
 Set AD9208 NCO Phase Offset. More...
 
int ad9208_adc_set_ddc_nco (ad9208_handle_t *h, uint8_t ddc_ch, const int64_t carrier_freq_hz)
 Set AD9208 NCO based on the Channel Carrier Frequency. More...
 
int ad9208_adc_set_ddc_nco_reset (ad9208_handle_t *h)
 API to trigger a DDC Soft Reset. More...
 
int ad9208_adc_set_clk_phase (ad9208_handle_t *h, uint8_t phase_adj)
 Set AD9208 ADC Clock Phase Adjust. More...
 
int ad9208_adc_temp_sensor_set_enable (ad9208_handle_t *h, uint8_t en)
 Enable Temp Sensor. More...
 

Detailed Description

Contains AD9208 APIs for ADC, DDC, NCO configuration and control.

Release 1.0.x

Copyright(c) 2017 Analog Devices, Inc. All Rights Reserved. This software is proprietary to Analog Devices, Inc. and its licensors. By using this software you agree to the terms of the associated Analog Devices Software License Agreement.

Macro Definition Documentation

◆ AD9208_ADC_DCM_MAX

#define AD9208_ADC_DCM_MAX   48

◆ AD9208_ADC_DCM_MIN

#define AD9208_ADC_DCM_MIN   1

◆ AD9208_ADC_DCM_NONE

#define AD9208_ADC_DCM_NONE   1

◆ AD9208_NOF_FC_MAX

#define AD9208_NOF_FC_MAX   4

◆ LOWER_16

#define LOWER_16 (   A)    ((A) & 0xFFFF)

◆ LOWER_32

#define LOWER_32 (   A)    ((A) & (uint32_t) 0xFFFFFFFF)

◆ MHZ_TO_HZ

#define MHZ_TO_HZ (   x)    (((uint64_t)x)*1000*1000)

◆ MS_TO_US

#define MS_TO_US (   x)    ((x)*1000)

◆ NCO_RESET_PERIOD_US

#define NCO_RESET_PERIOD_US   0

◆ U64MSB

#define U64MSB   0x8000000000000000ull

◆ UPPER_16

#define UPPER_16 (   A)    (((A) >> 16) & 0xFFFF)

Typedef Documentation

◆ adi_dec_filt_data

Function Documentation

◆ ad9208_adc_set_clk_phase()

int ad9208_adc_set_clk_phase ( ad9208_handle_t h,
uint8_t  phase_adj 
)

Set AD9208 ADC Clock Phase Adjust.

Note Phase can be applied independantly to each ADC. Use ad9208_adc_select_ch prior to selecting ADC Note 1: This API should be used in conjunction with ad9208_adc_set_channel_select To set the target channel.

Parameters
hPointer to the AD9208 device reference handle.
phase_adjNumber of 1/2 cycle delays to apply. Range 0-15 0 = No Delay 1 = 1/2 Input clock Cycle delay (Invert Clock) 2 = 1 input clock cycle delay .... 15 = 7.5 Input clock Cyle delay
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_data_format()

int ad9208_adc_set_data_format ( ad9208_handle_t h,
ad9208_adc_data_frmt_t  ip_data_frmt,
ad9208_adc_data_frmt_t  op_data_frmt 
)

Set AD9208 ADC Data Format.

Parameters
hPointer to the AD9208 device reference handle.
ip_data_frmtInput data format Real or Complex
op_data_frmtOutput data format Real or Complex
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_dc_offset_filt_en()

int ad9208_adc_set_dc_offset_filt_en ( ad9208_handle_t h,
uint8_t  en 
)

Enable AD9208 ADC DC Offset Calibaration.

The AD9208 contains a digital filter to remove the dc offset from the output of the ADC. This API enables or disables this optional digital Filter

Parameters
hPointer to the AD9208 device reference handle.
enDesired enable setting for the DC Offset Calibration 0 - Disable DC Offset Calibration 1 - Disable DC Offset Calibration
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_dcm_mode()

int ad9208_adc_set_dcm_mode ( ad9208_handle_t h,
uint8_t  dcm 
)

Set AD9208 ADC Operational Mode-decimation rate.

The AD9208 contains a configurable ADC signal path to support a wide range of applications. This API configures the ADC decimation mode based desired requred ADC sampling rate (Fs) and the desired output sample rate (Fout). Fs/Fout

NOTE: The ADC DCM rate shall be set to the lowest Channel DCM value.

Parameters
hPointer to the AD9208 device reference handle.
dcmSet ADC Decimation Ratio Range 1-48 TODO: Verify All this modes are really Valid
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_ddc_dcm()

int ad9208_adc_set_ddc_dcm ( ad9208_handle_t h,
uint8_t  ddc_ch,
uint8_t  dcm 
)

Set AD9208 Decimation Filters.

Each DDC Channel supports a range of Decimation filters This API enables the appropriate Decimation filters per Channel based on the desired decimation.

Parameters
hPointer to the AD9208 device reference handle.
ddc_chDDC Channel on which to set Decimation Filters. Valid Range 0 to 3
dcmDDC Channel Decimation. Valid Range 1 - 48
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_ddc_gain()

int ad9208_adc_set_ddc_gain ( ad9208_handle_t h,
uint8_t  ddc_ch,
uint8_t  gain_db 
)

Set AD9208 DDC Gain Stage.

Each DDC Channel contains an independently controlled gain stage. For the AD9208 a 0dB or 6dB gain can be applied. This API sets the gain for a particular DDC.

Parameters
hPointer to the AD9208 device reference handle.
ddc_chDDC Channel on which to set the Gain Stage. Range 0 to 3
gain_dbDesired gain setting. 0dB or 6dB
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_ddc_ip_mux()

int ad9208_adc_set_ddc_ip_mux ( ad9208_handle_t h,
uint8_t  ddc_ch,
ad9208_adc_ch_t  i_data_src,
ad9208_adc_ch_t  q_data_src 
)

Select ADC Source for each DDC Channel.

Parameters
hPointer to the AD9208 device reference handle.
ddc_chDDC Channel on which to set Decimation Filters Valid Range 0-3
i_data_srcADC data source for DDC I data channel. AD9208_ADC_CH_A - ADC Channel A AD9208_ADC_CH_B - ADC Channel B
q_data_srcADC data source for DDC Q data channel. AD9208_ADC_CH_A - ADC Channel A AD9208_ADC_CH_B - ADC Channel B
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_ddc_nco()

int ad9208_adc_set_ddc_nco ( ad9208_handle_t h,
uint8_t  ddc_ch,
const int64_t  carrier_freq_hz 
)

Set AD9208 NCO based on the Channel Carrier Frequency.

Each DDC Channel support an NCO for frequency translation This API configures NCO based on the Channel Carrier Frequency and the adc_clk_freq_hz.

Parameters
hPointer to the AD9208 device reference handle.
ddc_chDDC Channel on which to set NCO Frequency Translation. Range 0 to 3
carrier_freq_hzDesired Channel Carrier Frequency in Hz
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_ddc_nco_ftw()

int ad9208_adc_set_ddc_nco_ftw ( ad9208_handle_t h,
uint8_t  ddc_ch,
uint64_t  ftw,
uint64_t  mod_a,
uint64_t  mod_b 
)

API to directly set the NCO Parameters.

Each DDC Channel supports an NCO for frequency translation This API configures NCO parameters for the desired frequency Translation. Alternatively the NCO may be configured based on the carrier Frequency. Refer to ad9208_adc_set_ddc_nco

Parameters
hPointer to the AD9208 device reference handle.
ddc_chDDDC Channel on which to set NCO Frequency Translation. Range 0 to 3
ftwDesired 48-bit FTW value for the NCO on the Target DDC Channel
mod_aDesired 48-bit MAW value for the NCO on the Target DDC Channel
mod_bDesired 48-bit MBW value for the NCO on the Target DDC Channel
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter
Here is the caller graph for this function:

◆ ad9208_adc_set_ddc_nco_mode()

int ad9208_adc_set_ddc_nco_mode ( ad9208_handle_t h,
uint8_t  ddc_ch,
ad9208_adc_nco_mode_t  mode 
)

API to set DDC Frequency Translation Mode.

Each DDC Channel supports an NCO for frequency translation. This API enables or disables the NCO to achieve Variable IF mode( NCO enabled) or Zero IF Mode (NCO disabled). Alternatively there a test mode may be enabled where the NCO directly injects a ramp into the signal path.

Parameters
hPointer to the AD9208 device reference handle.
ddc_chDDC Channel on which to enable the NCO. Range 0-3.
modeDesired NCO mode for target DDC Channel.
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_ddc_nco_phase()

int ad9208_adc_set_ddc_nco_phase ( ad9208_handle_t h,
uint8_t  ddc_ch,
uint64_t  po 
)

Set AD9208 NCO Phase Offset.

Each DDC Channel support an NCO for frequency translation This API configures NCO parameters for the desired frequency Translation.

Parameters
hPointer to the AD9208 device reference handle.
ddc_chDDC Channel on which to enable the NCO, Range 0-3
poDesired 48-bit NCO Phase offset
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_ddc_nco_reset()

int ad9208_adc_set_ddc_nco_reset ( ad9208_handle_t h)

API to trigger a DDC Soft Reset.

Following an update NCOs may be synchronized via DDC software Reset This may be required as alternative to SYSREF signal Synchronization. All NCO will be synchronized.

Parameters
hPointer to the AD9208 device reference handle.
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_INVALID_PARAMInvalid Parameter
API_ERROR_INIT_SEQ_FAILInit sequence failed
API_ERROR_SPI_SDOInvalid SPI configuration

◆ ad9208_adc_set_fc_ch_mode()

int ad9208_adc_set_fc_ch_mode ( ad9208_handle_t h,
uint8_t  fc_ch 
)

Set AD9208 ADC Operational Mode-Number of Channels.

The AD9208 contains a configurable ADC signal path to support a wide range of applications. This API configures the ADC operational mode based on the Carrier Frequency (Fc) Channels on input signal.

Parameters
hPointer to the AD9208 device reference handle.
fc_chNumber of Carrier Frequencies. Valid Values 0 - Full Bandwidth 1 - One Channel 2 - Two Channel 4 - Four Channel
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_input_buffer_cfg()

int ad9208_adc_set_input_buffer_cfg ( ad9208_handle_t h,
ad9208_adc_buff_curr_t  buff_curr_n,
ad9208_adc_buff_curr_t  buff_curr_p,
ad9208_adc_buff_curr_t  vcm_buff 
)

Set AD9208 Input Buffer Configuration.

The AD9208 analog inputs are internally biased to the comon mode voltage. For DC coupled applications the internal common mode buffer may be disabled. And its recommended to export the internal common mode voltage to the input buffer via the Vref pin. The buffer currents may be adjusted to optimize of SFDR over various input frequencies and bandwidth.

Parameters
hPointer to the AD9208 device reference handle.
buff_curr_nN-Input buffer current. Valid values defined by ad9208_adc_buff_curr_t enumeration
buff_curr_pP-Input buffer current. Valid values defined by ad9208_adc_buff_curr_t enumeration
vcm_buffVCM buffer current. Valid values defined by ad9208_adc_buff_curr_t enumeration
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_input_cfg()

int ad9208_adc_set_input_cfg ( ad9208_handle_t h,
signal_coupling_t  analog_input_mode,
uint8_t  ext_vref,
ad9208_adc_scale_range_t  full_scale_range 
)

Set AD9208 ADC Input Configuration.

The AD9208 analog inputs are internally biased to the comon mode voltage. For AC coupled applications an external Vref may be used. For DC coupled applications the internal common mode buffer may be disabled. And its recommended to export the internal common mode voltage reference to the input buffer via the Vref pin. Refer to the Datasheet for more details. Finally the internal voltage reference may be adjusted to modify the full-scale voltage. Refer to the Datasheet for full details.

Parameters
hPointer to the AD9208 device reference handle.
analog_input_modeADC Analog Input mode. Enumerated by signal_coupling_t COUPLING_AC - AC Coupled Mode COUPLING_DC- DC Coupled Mode
ext_vrefExternal Voltage Reference mode of AC Coupled Applications. This parameter shall be ignored in DC Coupled Applications 0 - AC Coupled Mode 1- DC Coupled Mode
full_scale_rangeFull Scale Voltage settings. Valid options are defined by ad9208_adc_scale_range_t
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_set_input_scale()

int ad9208_adc_set_input_scale ( ad9208_handle_t h,
ad9208_adc_scale_range_t  full_scale_range 
)

◆ ad9208_adc_set_sync_update_mode_enable()

int ad9208_adc_set_sync_update_mode_enable ( ad9208_handle_t h,
uint8_t  en 
)

Set AD9208 ADC Synchronized Update mode Mode.

DDC NCO Parameters and Programable Filter Registers may be updated either instantaneously or in a synchronized update. In Synchronized Mode update may be trigger by a SPI bit trigger or alternatively a GPIO pin may be configured to trigger synchronized update. This api enables or disables the synchronized update mode. This affects updates to FTW, POW, MAW & MBW and programmable filter configuration.

Parameters
hPointer to the AD9208 device reference handle.
enEnable Synchronized update 0- Synchronized Update Mode Disabled. Instantaneous update 1- Synchronized Update Mode Enabled.
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_adc_temp_sensor_set_enable()

int ad9208_adc_temp_sensor_set_enable ( ad9208_handle_t h,
uint8_t  en 
)

Enable Temp Sensor.

AD9208 Contains diode-based temperature sensors. And the diode output voltages may be output to the VREF Pin.

Note 1: the VREF pin may be used for the ADC reference voltage DC coupled applications and External VREF for the ADC in AC coupled modes. If VREF pin is used for the ADC Analog Input, VREF cannot be used for Temperature Sensor. Refer to the Datasheet and the ad9208_adc_set_input_cfg API

Note 2: This API should be used in conjunction with ad9208_adc_set_channel_select To set the target channel.

Parameters
hPointer to the AD9208 device reference handle.
enEnable the Temp Sensor Diodes.
Return values
API_ERROR_OKAPI Completed Successfully
API_ERROR_INVALID_HANDLE_PTRInvalid reference handle.
API_ERROR_INVALID_XFER_PTRSPI Access Failed
API_ERROR_SPI_XFERSPI XFER Function Failed
API_ERROR_INVALID_PARAMInvalid Parameter

◆ ad9208_get_decimation()

int ad9208_get_decimation ( ad9208_handle_t h,
uint8_t *  dcm 
)