no-OS
ad9208.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef __AD9208_H__
40 #define __AD9208_H__
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdbool.h>
46 #include <stddef.h>
47 #include <string.h>
48 #include "ad9208_api.h"
49 #include "ad9208_reg.h"
50 #include "no_os_gpio.h"
51 #include "no_os_spi.h"
52 #include "no_os_delay.h"
53 
54 /******************************************************************************/
55 /********************** Macros and Constants Definitions **********************/
56 /******************************************************************************/
57 #define AD9208_FULL_BANDWIDTH_MODE 0
58 #define AD9208_1_DDC_MODE 1
59 #define AD9208_2_DDC_MODE 2
60 #define AD9208_4_DDC_MODE 4
61 
62 #define AD9208_SYSREF_NONE 0 /* No SYSREF Support */
63 #define AD9208_SYSREF_ONESHOT 1 /* ONE-SHOT SYSREF */
64 #define AD9208_SYSREF_CONT 2 /* Continuous Sysref Synchronisation */
65 #define AD9208_SYSREF_MON 3 /* SYSREF monitor Mode */
66 
67 #define AD9208_NCO_MODE_VIF 0 /* Variable IF Mode */
68 #define AD9208_NCO_MODE_ZIF 1 /* Zero IF Mode */
69 #define AD9208_NCO_MODE_TEST 3 /* Test Mode*/
70 
71 #define AD9208_BUFF_CURR_400_UA 0x4 /* Buffer Current set to 400 uA */
72 #define AD9208_BUFF_CURR_500_UA 0x9 /* Buffer Current set to 500 uA */
73 #define AD9208_BUFF_CURR_600_UA 0x1E /* Buffer Current set to 600 uA */
74 #define AD9208_BUFF_CURR_700_UA 0x23 /* Buffer Current set to 700 uA */
75 #define AD9208_BUFF_CURR_800_UA 0x28 /* Buffer Current set to 800 uA */
76 #define AD9208_BUFF_CURR_1000_UA 0x32 /* Buffer Current set to 1000 uA */
77 
78 #define AD9208_CHIP_TYPE 0x03
79 #define AD9208_CHIP_ID 0xDF
80 
81 /******************************************************************************/
82 /*************************** Types Declarations *******************************/
83 /******************************************************************************/
84 struct ad9208_ddc {
85  uint32_t decimation;
86  uint32_t nco_mode;
87  uint64_t carrier_freq_hz;
88  uint64_t po;
89  bool gain_db;
90 };
91 
92 typedef struct ad9208_dev {
93  /* SPI */
95  /* GPIO */
97  struct ad9208_state *st;
98 } ad9208_dev;
99 
100 struct ad9208_state {
103  uint32_t input_div; /* input clock divider ratio */
105  uint32_t powerdown_mode;
107  uint8_t current_scale;
110  uint32_t buff_curr_n;
111  uint32_t buff_curr_p;
112  uint8_t fc_ch;
113  struct ad9208_ddc ddc[4];
114  uint32_t ddc_cnt;
117  uint32_t test_mode_ch0;
118  uint32_t test_mode_ch1;
119 
125  uint32_t sysref_mode;
126  uint32_t sysref_count;
127 
129  uint32_t jesd_subclass;
130 };
131 
132 typedef struct ad9208_init_param {
133  /* SPI */
135  /* GPIO */
138  uint32_t input_div; /* input clock divider ratio */
140  uint32_t powerdown_mode;
142  uint8_t current_scale;
145  uint32_t buff_curr_n;
146  uint32_t buff_curr_p;
147  uint8_t fc_ch;
148  struct ad9208_ddc *ddc;
149  uint32_t ddc_cnt;
152  uint32_t test_mode_ch0;
153  uint32_t test_mode_ch1;
154 
160  uint32_t sysref_mode;
161  uint32_t sysref_count;
162 
164  uint32_t jesd_subclass;
166 
167 /******************************************************************************/
168 /************************ Functions Declarations ******************************/
169 /******************************************************************************/
170 /* Initialize the device. */
172 /* Remove the device. */
174 
175 #endif // __AD9208_H__
ad9208_adc_set_channel_select
int ad9208_adc_set_channel_select(ad9208_handle_t *h, uint8_t ch)
Set AD9208 ADC Channel Select.
Definition: ad9208_api.c:162
AD9208_DATA_FRMT_REAL
@ AD9208_DATA_FRMT_REAL
Definition: ad9208_api.h:25
ad9208_state::sampling_frequency_hz
uint64_t sampling_frequency_hz
Definition: ad9208.h:102
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.
Definition: ad9208_adc_api.c:453
ad9208_init_param::sysref_pos_window_skew
uint32_t sysref_pos_window_skew
Definition: ad9208.h:159
ad9208_state::sysref_edge_sel
bool sysref_edge_sel
Definition: ad9208.h:121
ad9208_init_param::sysref_mode
uint32_t sysref_mode
Definition: ad9208.h:160
timeout
uint32_t timeout
Definition: ad413x.c:55
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:85
ad9208_jesd_syref_lmfc_offset_set
int ad9208_jesd_syref_lmfc_offset_set(ad9208_handle_t *h, uint8_t offset)
Set JESD LMFC Offset.
Definition: ad9208_jesd_api.c:648
ad9208_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad9208.h:94
no_os_min_t
#define no_os_min_t(type, x, y)
Definition: no_os_util.h:65
ad9208_state::powerdown_mode
uint32_t powerdown_mode
Definition: ad9208.h:105
ad9208_remove
int32_t ad9208_remove(ad9208_dev *device)
Definition: ad9208.c:503
ad9208_state::buff_curr_n
uint32_t buff_curr_n
Definition: ad9208.h:110
ad9208_ddc::po
uint64_t po
Definition: ad9208.h:88
ad9208_initialize
int32_t ad9208_initialize(ad9208_dev **device, ad9208_init_param *init_param)
Definition: ad9208.c:380
ad9208_init_param::sysref_neg_window_skew
uint32_t sysref_neg_window_skew
Definition: ad9208.h:158
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:165
AD9208_CHIP_TYPE
#define AD9208_CHIP_TYPE
Definition: ad9208.h:78
ad9208_init_param::fc_ch
uint8_t fc_ch
Definition: ad9208.h:147
ad9208_init_param::gpio_powerdown
struct no_os_gpio_init_param gpio_powerdown
Definition: ad9208.h:136
ad9208_init_param::sysref_clk_edge_sel
bool sysref_clk_edge_sel
Definition: ad9208.h:157
no_os_spi.h
Header file of SPI Interface.
ad9208_ddc::nco_mode
uint32_t nco_mode
Definition: ad9208.h:86
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.
Definition: ad9208_adc_api.c:556
ad9208_state::sysref_neg_window_skew
uint32_t sysref_neg_window_skew
Definition: ad9208.h:123
ad9208_handle_t
Definition: ad9208_api.h:79
COUPLING_DC
@ COUPLING_DC
Definition: api_def.h:203
ad9208_handle_t::user_data
void * user_data
Definition: ad9208_api.h:80
ad9208_get_chip_id
int ad9208_get_chip_id(ad9208_handle_t *h, adi_chip_id_t *chip_id)
Get Chip Identification Data.
Definition: ad9208_api.c:88
no_os_delay.h
Header file of Delay functions.
ad9208_remove
int32_t ad9208_remove(ad9208_dev *device)
Definition: ad9208.c:503
ad9208_init_param
struct ad9208_init_param ad9208_init_param
ad9208_ddc::gain_db
bool gain_db
Definition: ad9208.h:89
ad9208_init
int ad9208_init(ad9208_handle_t *h)
Initialize AD9208 Device This API must be called first before any other API calls....
Definition: ad9208_api.c:46
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.
Definition: ad9208_adc_api.c:334
AD9208_FULL_BANDWIDTH_MODE
#define AD9208_FULL_BANDWIDTH_MODE
Definition: ad9208.h:57
ad9208_deinit
int ad9208_deinit(ad9208_handle_t *h)
De-initialize the AD9208 Device.
Definition: ad9208_api.c:74
device
Definition: ad9361_util.h:75
ad9208_state::buff_curr_p
uint32_t buff_curr_p
Definition: ad9208.h:111
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.
Definition: ad9208_adc_api.c:282
ad9208_init_param::ddc_input_format_real_en
bool ddc_input_format_real_en
Definition: ad9208.h:151
ad9208_jesd_get_pll_status
int ad9208_jesd_get_pll_status(ad9208_handle_t *h, uint8_t *pll_status)
Get SERDES PLL Status Flags.
Definition: ad9208_jesd_api.c:418
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:60
ad9208_init_param::buff_curr_n
uint32_t buff_curr_n
Definition: ad9208.h:145
ad9208_init_param::sysref_count
uint32_t sysref_count
Definition: ad9208.h:161
ad9208_state::input_div
uint32_t input_div
Definition: ad9208.h:103
ad9208_jesd_set_if_config
int ad9208_jesd_set_if_config(ad9208_handle_t *h, jesd_param_t jesd_param, uint64_t *lane_rate_kbps)
Configure the JESD Interface for AD9208.
Definition: ad9208_jesd_api.c:163
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:121
ad9208_init_param::jesd_param
jesd_param_t * jesd_param
Definition: ad9208.h:163
ad9208_state::sysref_count
uint32_t sysref_count
Definition: ad9208.h:126
ad9208_handle_t::dev_xfer
spi_xfer_t dev_xfer
Definition: ad9208_api.h:81
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
ad9208_init_param
Definition: ad9208.h:132
ad9208_ddc::decimation
uint32_t decimation
Definition: ad9208.h:85
ad9208_state::jesd_subclass
uint32_t jesd_subclass
Definition: ad9208.h:129
ad9208_init_param::input_div
uint32_t input_div
Definition: ad9208.h:138
AD9208_BUFF_CURR_600_UA
#define AD9208_BUFF_CURR_600_UA
Definition: ad9208.h:73
ad9208_state::sysref_pos_window_skew
uint32_t sysref_pos_window_skew
Definition: ad9208.h:124
jesd_param_t
Definition: api_def.h:231
ad9208_state::analog_input_mode
bool analog_input_mode
Definition: ad9208.h:108
ad9208_jesd_subclass_set
int ad9208_jesd_subclass_set(ad9208_handle_t *h, uint8_t subclass)
Set JESD SYNCHRONIZATION Mode.
Definition: ad9208_jesd_api.c:436
ad9208_init_param::ddc_cnt
uint32_t ddc_cnt
Definition: ad9208.h:149
ad9208_init_param::test_mode_ch1
uint32_t test_mode_ch1
Definition: ad9208.h:153
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.
Definition: ad9208_adc_api.c:780
ad9208_init_param::current_scale
uint8_t current_scale
Definition: ad9208.h:142
AD9208_ADC_CH_ALL
@ AD9208_ADC_CH_ALL
Definition: ad9208_api.h:34
ad9208_init_param::analog_input_mode
bool analog_input_mode
Definition: ad9208.h:143
ad9208_reset
int ad9208_reset(ad9208_handle_t *h, uint8_t hw_reset)
Reset the AD9208.
Definition: ad9208_api.c:122
ad9208_init_param::ddc
struct ad9208_ddc * ddc
Definition: ad9208.h:148
ad9208_init_param::ddc_output_format_real_en
bool ddc_output_format_real_en
Definition: ad9208.h:150
ad9208_init_param::ext_vref_en
bool ext_vref_en
Definition: ad9208.h:144
ad9208_jesd_syref_config_set
int ad9208_jesd_syref_config_set(ad9208_handle_t *h, uint8_t sysref_edge_sel, uint8_t clk_edge_sel, uint8_t neg_window_skew, uint8_t pos_window_skew)
Set SYSREF Signal Capture settings.
Definition: ad9208_jesd_api.c:512
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:110
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
AD9208_DATA_FRMT_COMPLEX
@ AD9208_DATA_FRMT_COMPLEX
Definition: ad9208_api.h:26
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.
Definition: ad9208_adc_api.c:742
ad9208_ddc::carrier_freq_hz
uint64_t carrier_freq_hz
Definition: ad9208.h:87
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:102
ad9208_state::ddc_output_format_real_en
bool ddc_output_format_real_en
Definition: ad9208.h:115
ad9208_state::powerdown_pin_en
bool powerdown_pin_en
Definition: ad9208.h:104
AD9208_JESD_PLL_LOCK_STAT
#define AD9208_JESD_PLL_LOCK_STAT
Definition: ad9208_reg.h:202
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.
Definition: ad9208_adc_api.c:599
ad9208_init_param::sysref_edge_sel
bool sysref_edge_sel
Definition: ad9208.h:156
ad9208_state::ddc_cnt
uint32_t ddc_cnt
Definition: ad9208.h:114
ad9208_state::ext_vref_en
bool ext_vref_en
Definition: ad9208.h:109
ad9208_set_input_clk_cfg
int ad9208_set_input_clk_cfg(ad9208_handle_t *h, uint64_t clk_freq_hz, uint8_t div)
Set AD9208 Input Sample Clock Configuration.
Definition: ad9208_api.c:263
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.
Definition: ad9208_adc_api.c:624
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.
Definition: ad9208_adc_api.c:399
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:55
ad9208_state::ddc_input_format_real_en
bool ddc_input_format_real_en
Definition: ad9208.h:116
ad9208_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: ad9208.h:134
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:49
ad9208.h
Header file of AD9208 Driver.
ad9208_init_param::powerdown_pin_en
bool powerdown_pin_en
Definition: ad9208.h:139
ad9208_initialize
int32_t ad9208_initialize(ad9208_dev **device, ad9208_init_param *init_param)
Definition: ad9208.c:380
ad9208_reg.h
AD9208 SPI Register Definition Header File.
ad9208_handle_t::delay_us
delay_us_t delay_us
Definition: ad9208_api.h:84
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.
Definition: ad9208_adc_api.c:427
ad9208_init_param::test_mode_ch0
uint32_t test_mode_ch0
Definition: ad9208.h:152
ad9208_api.h
ad9208_set_input_clk_duty_cycle_stabilizer
int ad9208_set_input_clk_duty_cycle_stabilizer(ad9208_handle_t *h, uint8_t en)
Set AD9208 Input Sample Clock Duty Cycle Enablers.
Definition: ad9208_api.c:308
ad9208_set_pdn_pin_mode
int ad9208_set_pdn_pin_mode(ad9208_handle_t *h, uint8_t pin_enable, ad9208_pdn_mode_t pin_mode)
Sets the operation of the Power Down pin the AD9208.
Definition: ad9208_api.c:197
ad9208_dev
struct ad9208_dev ad9208_dev
ad9208_state::ddc
struct ad9208_ddc ddc[4]
Definition: ad9208.h:113
ad9208_state::adc_h
ad9208_handle_t * adc_h
Definition: ad9208.h:101
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:51
ad9208_jesd_syref_mode_set
int ad9208_jesd_syref_mode_set(ad9208_handle_t *h, jesd_sysref_mode_t mode, uint8_t sysref_count)
Set JESD SYNCHRONIZATION Mode.
Definition: ad9208_jesd_api.c:457
ad9208_jesd_enable_scrambler
int ad9208_jesd_enable_scrambler(ad9208_handle_t *h, uint8_t en)
Enable the scrambler for the JESD Link.
Definition: ad9208_jesd_api.c:311
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:75
AD9208_REG_TEST_MODE
#define AD9208_REG_TEST_MODE
Definition: ad9208_reg.h:172
ad9208_init_param::powerdown_mode
uint32_t powerdown_mode
Definition: ad9208.h:140
ad9208_ddc
Definition: ad9208.h:84
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:120
COUPLING_AC
@ COUPLING_AC
Definition: api_def.h:202
ad9208_dev::gpio_powerdown
struct no_os_gpio_desc * gpio_powerdown
Definition: ad9208.h:96
no_os_gpio_set_value
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:203
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
adi_chip_id_t
Definition: api_def.h:164
no_os_spi_remove
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:122
ad9208_state::sysref_clk_edge_sel
bool sysref_clk_edge_sel
Definition: ad9208.h:122
ad9208_state::test_mode_ch1
uint32_t test_mode_ch1
Definition: ad9208.h:118
no_os_gpio.h
Header file of GPIO Interface.
AD9208_CHIP_ID
#define AD9208_CHIP_ID
Definition: ad9208.h:79
ad9208_init_param::sampling_frequency_hz
uint64_t sampling_frequency_hz
Definition: ad9208.h:137
no_os_spi_init
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:58
ad9208_state::sysref_mode
uint32_t sysref_mode
Definition: ad9208.h:125
spi
struct no_os_spi_desc * spi
Definition: main.c:78
ad9208_state::jesd_param
jesd_param_t * jesd_param
Definition: ad9208.h:128
ad9208_init_param::sysref_lmfc_offset
uint32_t sysref_lmfc_offset
Definition: ad9208.h:155
ad9208_init_param::jesd_subclass
uint32_t jesd_subclass
Definition: ad9208.h:164
ad9208_dev::st
struct ad9208_state * st
Definition: ad9208.h:97
no_os_spi_desc::mode
enum no_os_spi_mode mode
Definition: no_os_spi.h:187
ad9208_state::duty_cycle_stabilizer_en
bool duty_cycle_stabilizer_en
Definition: ad9208.h:106
ad9208_state
Definition: ad9208.h:100
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:153
ad9208_state::sysref_lmfc_offset
uint32_t sysref_lmfc_offset
Definition: ad9208.h:120
ad9208_adc_data_frmt_t
ad9208_adc_data_frmt_t
Definition: ad9208_api.h:24
ad9208_state::fc_ch
uint8_t fc_ch
Definition: ad9208.h:112
ad9208_init_param::duty_cycle_stabilizer_en
bool duty_cycle_stabilizer_en
Definition: ad9208.h:141
errno.h
Error macro definition for ARM Compiler.
ad9208_init_param::buff_curr_p
uint32_t buff_curr_p
Definition: ad9208.h:146
ad9208_dev
Definition: ad9208.h:92
ad9208_jesd_enable_link
int ad9208_jesd_enable_link(ad9208_handle_t *h, uint8_t en)
Enable JESD Link.
Definition: ad9208_jesd_api.c:132
ad9208_state::current_scale
uint8_t current_scale
Definition: ad9208.h:107
chip_id
chip_id
Definition: ad9172.h:57
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131
ad9208_state::test_mode_ch0
uint32_t test_mode_ch0
Definition: ad9208.h:117
ad9208_register_write
int ad9208_register_write(ad9208_handle_t *h, const uint16_t address, const uint8_t data)
Perform SPI register write access to AD9208 Device.
Definition: ad9208_reg.c:21