no-OS
ad9208.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef __AD9208_H__
34 #define __AD9208_H__
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdbool.h>
40 #include <stddef.h>
41 #include <string.h>
42 #include "ad9208_api.h"
43 #include "ad9208_reg.h"
44 #include "no_os_gpio.h"
45 #include "no_os_spi.h"
46 #include "no_os_delay.h"
47 
48 /******************************************************************************/
49 /********************** Macros and Constants Definitions **********************/
50 /******************************************************************************/
51 #define AD9208_FULL_BANDWIDTH_MODE 0
52 #define AD9208_1_DDC_MODE 1
53 #define AD9208_2_DDC_MODE 2
54 #define AD9208_4_DDC_MODE 4
55 
56 #define AD9208_SYSREF_NONE 0 /* No SYSREF Support */
57 #define AD9208_SYSREF_ONESHOT 1 /* ONE-SHOT SYSREF */
58 #define AD9208_SYSREF_CONT 2 /* Continuous Sysref Synchronisation */
59 #define AD9208_SYSREF_MON 3 /* SYSREF monitor Mode */
60 
61 #define AD9208_NCO_MODE_VIF 0 /* Variable IF Mode */
62 #define AD9208_NCO_MODE_ZIF 1 /* Zero IF Mode */
63 #define AD9208_NCO_MODE_TEST 3 /* Test Mode*/
64 
65 #define AD9208_BUFF_CURR_400_UA 0x4 /* Buffer Current set to 400 uA */
66 #define AD9208_BUFF_CURR_500_UA 0x9 /* Buffer Current set to 500 uA */
67 #define AD9208_BUFF_CURR_600_UA 0x1E /* Buffer Current set to 600 uA */
68 #define AD9208_BUFF_CURR_700_UA 0x23 /* Buffer Current set to 700 uA */
69 #define AD9208_BUFF_CURR_800_UA 0x28 /* Buffer Current set to 800 uA */
70 #define AD9208_BUFF_CURR_1000_UA 0x32 /* Buffer Current set to 1000 uA */
71 
72 #define AD9208_CHIP_TYPE 0x03
73 #define AD9208_CHIP_ID 0xDF
74 
75 /******************************************************************************/
76 /*************************** Types Declarations *******************************/
77 /******************************************************************************/
78 struct ad9208_ddc {
79  uint32_t decimation;
80  uint32_t nco_mode;
81  uint64_t carrier_freq_hz;
82  uint64_t po;
83  bool gain_db;
84 };
85 
86 typedef struct ad9208_dev {
87  /* SPI */
89  /* GPIO */
91  struct ad9208_state *st;
92 } ad9208_dev;
93 
94 struct ad9208_state {
97  uint32_t input_div; /* input clock divider ratio */
99  uint32_t powerdown_mode;
101  uint8_t current_scale;
104  uint32_t buff_curr_n;
105  uint32_t buff_curr_p;
106  uint8_t fc_ch;
107  struct ad9208_ddc ddc[4];
108  uint32_t ddc_cnt;
111  uint32_t test_mode_ch0;
112  uint32_t test_mode_ch1;
113 
119  uint32_t sysref_mode;
120  uint32_t sysref_count;
121 
123  uint32_t jesd_subclass;
124 };
125 
126 typedef struct ad9208_init_param {
127  /* SPI */
129  /* GPIO */
132  uint32_t input_div; /* input clock divider ratio */
134  uint32_t powerdown_mode;
136  uint8_t current_scale;
139  uint32_t buff_curr_n;
140  uint32_t buff_curr_p;
141  uint8_t fc_ch;
142  struct ad9208_ddc *ddc;
143  uint32_t ddc_cnt;
146  uint32_t test_mode_ch0;
147  uint32_t test_mode_ch1;
148 
154  uint32_t sysref_mode;
155  uint32_t sysref_count;
156 
158  uint32_t jesd_subclass;
160 
161 /******************************************************************************/
162 /************************ Functions Declarations ******************************/
163 /******************************************************************************/
164 /* Initialize the device. */
166 /* Remove the device. */
168 
169 #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:161
AD9208_DATA_FRMT_REAL
@ AD9208_DATA_FRMT_REAL
Definition: ad9208_api.h:24
ad9208_state::sampling_frequency_hz
uint64_t sampling_frequency_hz
Definition: ad9208.h:96
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:452
ad9208_init_param::sysref_pos_window_skew
uint32_t sysref_pos_window_skew
Definition: ad9208.h:153
ad9208_state::sysref_edge_sel
bool sysref_edge_sel
Definition: ad9208.h:115
ad9208_init_param::sysref_mode
uint32_t sysref_mode
Definition: ad9208.h:154
timeout
uint32_t timeout
Definition: ad413x.c:49
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
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:647
ad9208_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad9208.h:88
no_os_min_t
#define no_os_min_t(type, x, y)
Definition: no_os_util.h:61
ad9208_state::powerdown_mode
uint32_t powerdown_mode
Definition: ad9208.h:99
ad9208_remove
int32_t ad9208_remove(ad9208_dev *device)
Definition: ad9208.c:497
ad9208_state::buff_curr_n
uint32_t buff_curr_n
Definition: ad9208.h:104
ad9208_ddc::po
uint64_t po
Definition: ad9208.h:82
ad9208_initialize
int32_t ad9208_initialize(ad9208_dev **device, ad9208_init_param *init_param)
Definition: ad9208.c:374
ad9208_init_param::sysref_neg_window_skew
uint32_t sysref_neg_window_skew
Definition: ad9208.h:152
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:159
AD9208_CHIP_TYPE
#define AD9208_CHIP_TYPE
Definition: ad9208.h:72
ad9208_init_param::fc_ch
uint8_t fc_ch
Definition: ad9208.h:141
ad9208_init_param::gpio_powerdown
struct no_os_gpio_init_param gpio_powerdown
Definition: ad9208.h:130
ad9208_init_param::sysref_clk_edge_sel
bool sysref_clk_edge_sel
Definition: ad9208.h:151
no_os_spi.h
Header file of SPI Interface.
ad9208_ddc::nco_mode
uint32_t nco_mode
Definition: ad9208.h:80
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:555
ad9208_state::sysref_neg_window_skew
uint32_t sysref_neg_window_skew
Definition: ad9208.h:117
ad9208_handle_t
Definition: ad9208_api.h:78
COUPLING_DC
@ COUPLING_DC
Definition: api_def.h:202
ad9208_handle_t::user_data
void * user_data
Definition: ad9208_api.h:79
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:87
no_os_delay.h
Header file of Delay functions.
ad9208_remove
int32_t ad9208_remove(ad9208_dev *device)
Definition: ad9208.c:497
ad9208_init_param
struct ad9208_init_param ad9208_init_param
ad9208_ddc::gain_db
bool gain_db
Definition: ad9208.h:83
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:45
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:333
AD9208_FULL_BANDWIDTH_MODE
#define AD9208_FULL_BANDWIDTH_MODE
Definition: ad9208.h:51
ad9208_deinit
int ad9208_deinit(ad9208_handle_t *h)
De-initialize the AD9208 Device.
Definition: ad9208_api.c:73
device
Definition: ad9361_util.h:69
ad9208_state::buff_curr_p
uint32_t buff_curr_p
Definition: ad9208.h:105
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:281
ad9208_init_param::ddc_input_format_real_en
bool ddc_input_format_real_en
Definition: ad9208.h:145
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:417
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:54
ad9208_init_param::buff_curr_n
uint32_t buff_curr_n
Definition: ad9208.h:139
ad9208_init_param::sysref_count
uint32_t sysref_count
Definition: ad9208.h:155
ad9208_state::input_div
uint32_t input_div
Definition: ad9208.h:97
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:162
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
ad9208_init_param::jesd_param
jesd_param_t * jesd_param
Definition: ad9208.h:157
ad9208_state::sysref_count
uint32_t sysref_count
Definition: ad9208.h:120
ad9208_handle_t::dev_xfer
spi_xfer_t dev_xfer
Definition: ad9208_api.h:80
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
ad9208_init_param
Definition: ad9208.h:126
ad9208_ddc::decimation
uint32_t decimation
Definition: ad9208.h:79
ad9208_state::jesd_subclass
uint32_t jesd_subclass
Definition: ad9208.h:123
ad9208_init_param::input_div
uint32_t input_div
Definition: ad9208.h:132
AD9208_BUFF_CURR_600_UA
#define AD9208_BUFF_CURR_600_UA
Definition: ad9208.h:67
ad9208_state::sysref_pos_window_skew
uint32_t sysref_pos_window_skew
Definition: ad9208.h:118
jesd_param_t
Definition: api_def.h:230
ad9208_state::analog_input_mode
bool analog_input_mode
Definition: ad9208.h:102
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:435
ad9208_init_param::ddc_cnt
uint32_t ddc_cnt
Definition: ad9208.h:143
ad9208_init_param::test_mode_ch1
uint32_t test_mode_ch1
Definition: ad9208.h:147
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:779
ad9208_init_param::current_scale
uint8_t current_scale
Definition: ad9208.h:136
AD9208_ADC_CH_ALL
@ AD9208_ADC_CH_ALL
Definition: ad9208_api.h:33
ad9208_init_param::analog_input_mode
bool analog_input_mode
Definition: ad9208.h:137
ad9208_reset
int ad9208_reset(ad9208_handle_t *h, uint8_t hw_reset)
Reset the AD9208.
Definition: ad9208_api.c:121
ad9208_init_param::ddc
struct ad9208_ddc * ddc
Definition: ad9208.h:142
ad9208_init_param::ddc_output_format_real_en
bool ddc_output_format_real_en
Definition: ad9208.h:144
ad9208_init_param::ext_vref_en
bool ext_vref_en
Definition: ad9208.h:138
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:511
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:104
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
AD9208_DATA_FRMT_COMPLEX
@ AD9208_DATA_FRMT_COMPLEX
Definition: ad9208_api.h:25
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:741
ad9208_ddc::carrier_freq_hz
uint64_t carrier_freq_hz
Definition: ad9208.h:81
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ad9208_state::ddc_output_format_real_en
bool ddc_output_format_real_en
Definition: ad9208.h:109
ad9208_state::powerdown_pin_en
bool powerdown_pin_en
Definition: ad9208.h:98
AD9208_JESD_PLL_LOCK_STAT
#define AD9208_JESD_PLL_LOCK_STAT
Definition: ad9208_reg.h:201
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:598
ad9208_init_param::sysref_edge_sel
bool sysref_edge_sel
Definition: ad9208.h:150
ad9208_state::ddc_cnt
uint32_t ddc_cnt
Definition: ad9208.h:108
ad9208_state::ext_vref_en
bool ext_vref_en
Definition: ad9208.h:103
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:262
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:623
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:398
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:49
ad9208_state::ddc_input_format_real_en
bool ddc_input_format_real_en
Definition: ad9208.h:110
ad9208_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: ad9208.h:128
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
ad9208.h
Header file of AD9208 Driver.
ad9208_init_param::powerdown_pin_en
bool powerdown_pin_en
Definition: ad9208.h:133
ad9208_initialize
int32_t ad9208_initialize(ad9208_dev **device, ad9208_init_param *init_param)
Definition: ad9208.c:374
ad9208_reg.h
AD9208 SPI Register Definition Header File.
ad9208_handle_t::delay_us
delay_us_t delay_us
Definition: ad9208_api.h:83
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:426
ad9208_init_param::test_mode_ch0
uint32_t test_mode_ch0
Definition: ad9208.h:146
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:307
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:196
ad9208_dev
struct ad9208_dev ad9208_dev
ad9208_state::ddc
struct ad9208_ddc ddc[4]
Definition: ad9208.h:107
ad9208_state::adc_h
ad9208_handle_t * adc_h
Definition: ad9208.h:95
NO_OS_BIT
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
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:456
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:310
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:69
AD9208_REG_TEST_MODE
#define AD9208_REG_TEST_MODE
Definition: ad9208_reg.h:171
ad9208_init_param::powerdown_mode
uint32_t powerdown_mode
Definition: ad9208.h:134
ad9208_ddc
Definition: ad9208.h:78
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
COUPLING_AC
@ COUPLING_AC
Definition: api_def.h:201
ad9208_dev::gpio_powerdown
struct no_os_gpio_desc * gpio_powerdown
Definition: ad9208.h:90
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:197
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
adi_chip_id_t
Definition: api_def.h:163
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:116
ad9208_state::sysref_clk_edge_sel
bool sysref_clk_edge_sel
Definition: ad9208.h:116
ad9208_state::test_mode_ch1
uint32_t test_mode_ch1
Definition: ad9208.h:112
no_os_gpio.h
Header file of GPIO Interface.
AD9208_CHIP_ID
#define AD9208_CHIP_ID
Definition: ad9208.h:73
ad9208_init_param::sampling_frequency_hz
uint64_t sampling_frequency_hz
Definition: ad9208.h:131
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:52
ad9208_state::sysref_mode
uint32_t sysref_mode
Definition: ad9208.h:119
spi
struct no_os_spi_desc * spi
Definition: main.c:72
ad9208_state::jesd_param
jesd_param_t * jesd_param
Definition: ad9208.h:122
ad9208_init_param::sysref_lmfc_offset
uint32_t sysref_lmfc_offset
Definition: ad9208.h:149
ad9208_init_param::jesd_subclass
uint32_t jesd_subclass
Definition: ad9208.h:158
ad9208_dev::st
struct ad9208_state * st
Definition: ad9208.h:91
no_os_spi_desc::mode
enum no_os_spi_mode mode
Definition: no_os_spi.h:202
ad9208_state::duty_cycle_stabilizer_en
bool duty_cycle_stabilizer_en
Definition: ad9208.h:100
ad9208_state
Definition: ad9208.h:94
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:147
ad9208_state::sysref_lmfc_offset
uint32_t sysref_lmfc_offset
Definition: ad9208.h:114
ad9208_adc_data_frmt_t
ad9208_adc_data_frmt_t
Definition: ad9208_api.h:23
ad9208_state::fc_ch
uint8_t fc_ch
Definition: ad9208.h:106
ad9208_init_param::duty_cycle_stabilizer_en
bool duty_cycle_stabilizer_en
Definition: ad9208.h:135
errno.h
Error macro definition for ARM Compiler.
ad9208_init_param::buff_curr_p
uint32_t buff_curr_p
Definition: ad9208.h:140
ad9208_dev
Definition: ad9208.h:86
ad9208_jesd_enable_link
int ad9208_jesd_enable_link(ad9208_handle_t *h, uint8_t en)
Enable JESD Link.
Definition: ad9208_jesd_api.c:131
ad9208_state::current_scale
uint8_t current_scale
Definition: ad9208.h:101
chip_id
chip_id
Definition: ad9172.h:51
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
ad9208_state::test_mode_ch0
uint32_t test_mode_ch0
Definition: ad9208.h:111
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:20