no-OS
ad9739a.h
Go to the documentation of this file.
1 /***************************************************************************/
42 #ifndef __AD9739A_H__
43 #define __AD9739A_H__
44 
45 /******************************************************************************/
46 /***************************** Include Files **********************************/
47 /******************************************************************************/
48 #include <stdint.h>
49 #include "no_os_spi.h"
50 
51 /******************************************************************************/
52 /***************************** AD9739A ****************************************/
53 /******************************************************************************/
54 
55 #define AD9739A_READ (1 << 7)
56 #define AD9739A_WRITE (0 << 7)
57 
58 /* Registers */
59 #define AD9739A_REG_MODE 0x00
60 #define AD9739A_REG_POWER_DOWN 0x01
61 #define AD9739A_REG_CNT_CLK_DIS 0x02
62 #define AD9739A_REG_IRQ_EN 0x03
63 #define AD9739A_REG_IRQ_REQ 0x04
64 #define AD9739A_REG_FSC_1 0x06
65 #define AD9739A_REG_FSC_2 0x07
66 #define AD9739A_REG_DEC_CNT 0x08
67 #define AD9739A_REG_LVDS_STAT1 0x0C
68 #define AD9739A_REG_LVDS_REC_CNT1 0x10
69 #define AD9739A_REG_LVDS_REC_CNT2 0x11
70 #define AD9739A_REG_LVDS_REC_CNT3 0x12
71 #define AD9739A_REG_LVDS_REC_CNT4 0x13
72 #define AD9739A_REG_LVDS_REC_CNT5 0x14
73 #define AD9739A_REG_LVDS_REC_STAT1 0x19
74 #define AD9739A_REG_LVDS_REC_STAT2 0x1A
75 #define AD9739A_REG_LVDS_REC_STAT3 0x1B
76 #define AD9739A_REG_LVDS_REC_STAT4 0x1C
77 #define AD9739A_REG_LVDS_REC_STAT9 0x21
78 #define AD9739A_REG_CROSS_CNT1 0x22
79 #define AD9739A_REG_CROSS_CNT2 0x23
80 #define AD9739A_REG_PHS_DET 0x24
81 #define AD9739A_REG_MU_DUTY 0x25
82 #define AD9739A_REG_MU_CNT1 0x26
83 #define AD9739A_REG_MU_CNT2 0x27
84 #define AD9739A_REG_MU_CNT3 0x28
85 #define AD9739A_REG_MU_CNT4 0x29
86 #define AD9739A_REG_MU_STAT1 0x2A
87 #define AD9739A_REG_PART_ID 0x35
88 #define AD9739A_CHIP_ID 0x24
89 
90 /* AD9739A_REG_MODE definitions, address 0x00 */
91 #define AD9739A_MODE_SDIO_DIR ((1 << 7) | (1 << 0))
92 #define AD9739A_MODE_LSB ((1 << 6) | (1 << 1))
93 #define AD9739A_MODE_RESET ((1 << 5) | (1 << 2))
94 
95 /* AD9739A_REG_POWER_DOWN definitions, address 0x01 */
96 #define AD9739A_POWER_DOWN_LVDS_DRVR_PD (1 << 5)
97 #define AD9739A_POWER_DOWN_LVDS_RCVR_PD (1 << 4)
98 #define AD9739A_POWER_DOWN_CLK_RCVR_PD (1 << 1)
99 #define AD9739A_POWER_DOWN_DAC_BIAS_PD (1 << 0)
100 
101 /* AD9739A_REG_CNT_CLK_DIS definitions, address 0x02 */
102 #define AD9739A_CNT_CLK_DIS_CLKGEN_PD (1 << 3)
103 #define AD9739A_CNT_CLK_DIS_REC_CNT_CLK (1 << 1)
104 #define AD9739A_CNT_CLK_DIS_MU_CNT_CLK (1 << 0)
105 
106 /* AD9739A_REG_IRQ_EN definitions, address 0x03 */
107 #define AD9739A_IRQ_EN_MU_LST_EN (1 << 3)
108 #define AD9739A_IRQ_EN_MU_LCK_EN (1 << 2)
109 #define AD9739A_IRQ_EN_RCV_LST_EN (1 << 1)
110 #define AD9739A_IRQ_EN_RCV_LCK_EN (1 << 0)
111 
112 /* AD9739A_REG_IRQ_REQ definitions, address 0x04 */
113 #define AD9739A_IRQ_REQ_MU_LST_IRQ (1 << 3)
114 #define AD9739A_IRQ_REQ_MU_LCK_IRQ (1 << 2)
115 #define AD9739A_IRQ_REQ_RCV_LST_IRQ (1 << 1)
116 #define AD9739A_IRQ_REQ_RCV_LCK_IRQ (1 << 0)
117 
118 /* AD9739A_REG_FSC_1 definitions, address 0x06 */
119 #define AD9739A_FSC_1_FSC_1(x) (((x) & 0xFF) << 0)
120 
121 /* AD9739A_REG_FSC_2 definitions, address 0x07 */
122 #define AD9739A_FSC_2_FSC_2(x) (((x) & 0x3) << 0)
123 #define AD9739A_FSC_2_Sleep (1 << 7)
124 
125 /* AD9739A_REG_DEC_CNT definitions, address 0x08 */
126 #define AD9739A_DEC_CNT_DAC_DEC(x) (((x) & 0x3) << 0)
127 /* AD9739A_DEC_CNT_DAC_DEC(x) option. */
128 #define AD9739A_DAC_DEC_NORMAL_BASEBAND 0
129 /* AD9739A_DEC_CNT_DAC_DEC(x) option. */
130 #define AD9739A_DAC_DEC_MIX_MODE 2
131 
132 /* AD9739A_REG_LVDS_STAT1 definitions, address 0x0C */
133 #define AD9739A_LVDS_STAT1_DCI_PRE_PH0 (1 << 2)
134 #define AD9739A_LVDS_STAT1_DCI_PST_PH0 (1 << 0)
135 
136 /* AD9739A_REG_LVDS_REC_CNT1 definitions, address 0x10 */
137 #define AD9739A_LVDS_REC_CNT1_RCVR_FLG_RST (1 << 2)
138 #define AD9739A_LVDS_REC_CNT1_RCVR_LOOP_ON (1 << 1)
139 #define AD9739A_LVDS_REC_CNT1_RCVR_CNT_ENA (1 << 0)
140 
141 /* AD9739A_REG_LVDS_REC_CNT2 definitions, address 0x11 */
142 #define AD9739A_LVDS_REC_CNT2_SMP_DEL(x) (((x) & 0x3) << 6)
143 
144 /* AD9739A_REG_LVDS_REC_CNT3 definitions, address 0x12 */
145 #define AD9739A_LVDS_REC_CNT3_SMP_DEL(x) (((x) & 0xFF) << 0)
146 
147 /* AD9739A_REG_LVDS_REC_CNT4 definitions, address 0x13 */
148 #define AD9739A_LVDS_REC_CNT4_DCI_DEL(x) (((x) & 0xF) << 4)
149 #define AD9739A_LVDS_REC_CNT4_FINE_DEL_SKEW(x) (((x) & 0xF) << 0)
150 
151 /* AD9739A_REG_LVDS_REC_CNT5 definitions, address 0x14 */
152 #define AD9739A_LVDS_REC_CNT5_DCI_DEL(x) (((x) & 0x3F) << 0)
153 
154 /* AD9739A_REG_LVDS_REC_STAT1 definitions, address 0x19 */
155 #define AD9739A_LVDS_REC_STAT1_SMP_DEL(x) (((x) & 0x3) << 6)
156 
157 /* AD9739A_REG_LVDS_REC_STAT2 definitions, address 0x1A */
158 #define AD9739A_LVDS_REC_STAT2_SMP_DEL(x) (((x) & 0xFF) << 0)
159 
160 /* AD9739A_REG_LVDS_REC_STAT3 definitions, address 0x1B */
161 #define AD9739A_LVDS_REC_STAT3_DCI_DEL(x) (((x) & 0x3) << 6)
162 
163 /* AD9739A_REG_LVDS_REC_STAT4 definitions, address 0x1C */
164 #define AD9739A_LVDS_REC_STAT4_DCI_DEL(x) (((x) & 0xFF) << 0)
165 
166 /* AD9739A_REG_LVDS_REC_STAT9 definitions, address 0x21 */
167 #define AD9739A_LVDS_REC_STAT9_RCVR_TRK_ON (1 << 3)
168 #define AD9739A_LVDS_REC_STAT9_RCVR_FE_ON (1 << 2)
169 #define AD9739A_LVDS_REC_STAT9_RCVR_LST (1 << 1)
170 #define AD9739A_LVDS_REC_STAT9_RCVR_LCK (1 << 0)
171 
172 /* AD9739A_REG_CROSS_CNT1 definitions, address 0x22 */
173 #define AD9739A_CROSS_CNT1_DIR_P (1 << 4)
174 #define AD9739A_CROSS_CNT1_CLKP_OFFSET(x) (((x) & 0xF) << 0)
175 
176 /* AD9739A_REG_CROSS_CNT2 definitions, address 0x23 */
177 #define AD9739A_CROSS_CNT2_DIR_N (1 << 4)
178 #define AD9739A_CROSS_CNT2_CLKN_OFFSET(x) (((x) & 0xF) << 0)
179 
180 /* AD9739A_REG_PHS_DET definitions, address 0x24 */
181 #define AD9739A_PHS_DET_CMP_BST (1 << 5)
182 #define AD9739A_PHS_DET_PHS_DET_AUTO_EN (1 << 4)
183 
184 /* AD9739A_REG_MU_DUTY definitions, address 0x25 */
185 #define AD9739A_MU_DUTY_MU_DUTY_AUTO_EN (1 << 7)
186 
187 /* AD9739A_REG_MU_CNT1 definitions, address 0x26 */
188 #define AD9739A_MU_CNT1_SLOPE (1 << 6)
189 #define AD9739A_MU_CNT1_MODE(x) (((x) & 0x3) << 4)
190 #define AD9739A_MU_CNT1_READ (1 << 3)
191 #define AD9739A_MU_CNT1_GAIN(x) (((x) & 0x3) << 1)
192 #define AD9739A_MU_CNT1_ENABLE (1 << 0)
193 
194 /* AD9739A_REG_MU_CNT2 definitions, address 0x27 */
195 #define AD9739A_MU_CNT2_MUDEL (1 << 7)
196 #define AD9739A_MU_CNT2_SRCH_MODE(x) ((((x) & 0x3) << 5))
197 #define AD9739A_MU_CNT2_SET_PHS(x) ((((x) & 0x1F) << 0))
198 
199 /* AD9739A_REG_MU_CNT3 definitions, address 0x28 */
200 #define AD9739A_MU_CNT3_MUDEL(x) ((((x) & 0xFF) << 0))
201 
202 /* AD9739A_REG_MU_CNT4 definitions, address 0x29 */
203 #define AD9739A_MU_CNT4_SEARCH_TOL (1 << 7)
204 #define AD9739A_MU_CNT4_RETRY (1 << 6)
205 #define AD9739A_MU_CNT4_CONTRST (1 << 5)
206 #define AD9739A_MU_CNT4_GUARD(x) ((((x) & 0x1F) << 0))
207 
208 /* AD9739A_REG_MU_STAT1 definitions, address 0x2A */
209 #define AD9739A_MU_STAT1_MU_LST (1 << 1)
210 #define AD9739A_MU_STAT1_MU_LKD (1 << 0)
211 
212 /* AD9739A_REG_PART_ID definitions, address 0x35 */
213 #define AD9739A_PART_ID_PART_ID(x) ((((x) & 0xFF) << 0))
214 
215 /******************************************************************************/
216 /************************ Types Definitions ***********************************/
217 /******************************************************************************/
218 
219 struct ad9739a_dev {
220  /* SPI */
222 };
223 
237 };
238 
239 /******************************************************************************/
240 /************************ Functions Declarations ******************************/
241 /******************************************************************************/
242 
244 int32_t ad9739a_write(struct ad9739a_dev *dev,
245  uint8_t register_address,
246  uint8_t register_value);
248 int32_t ad9739a_read(struct ad9739a_dev *dev,
249  uint8_t register_address,
250  uint8_t *register_value);
252 int32_t ad9739a_reset(struct ad9739a_dev *dev);
254 int32_t ad9739a_power_down(struct ad9739a_dev *dev,
255  uint8_t pwr_config);
257 int32_t ad9739a_operation_mode(struct ad9739a_dev *dev,
258  uint8_t mode);
260 float ad9739a_dac_fs_current(struct ad9739a_dev *dev,
261  float fs_val);
263 int32_t delay_fdata_cycles(uint32_t cycles);
265 int32_t ad9739a_setup(struct ad9739a_dev **device,
268 int32_t ad9739a_remove(struct ad9739a_dev *dev);
269 
270 #endif /* __AD9739A_H__ */
AD9739A_MU_CNT4_SEARCH_TOL
#define AD9739A_MU_CNT4_SEARCH_TOL
Definition: ad9739a.h:203
no_os_alloc.h
AD9739A_REG_MU_CNT3
#define AD9739A_REG_MU_CNT3
Definition: ad9739a.h:84
ad9739a_setup
int32_t ad9739a_setup(struct ad9739a_dev **device, struct ad9739a_init_param init_param)
Initializes the AD9739A.
Definition: ad9739a.c:275
FDATA
#define FDATA
Definition: ad9739a.c:53
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
AD9739A_MU_CNT1_GAIN
#define AD9739A_MU_CNT1_GAIN(x)
Definition: ad9739a.h:191
AD9739A_PHS_DET_PHS_DET_AUTO_EN
#define AD9739A_PHS_DET_PHS_DET_AUTO_EN
Definition: ad9739a.h:182
AD9739A_REG_DEC_CNT
#define AD9739A_REG_DEC_CNT
Definition: ad9739a.h:66
no_os_spi.h
Header file of SPI Interface.
ad9739a_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad9739a.h:221
ad9739a.h
Header file of AD9739A Driver.
no_os_spi_init_param::mode
enum no_os_spi_mode mode
Definition: no_os_spi.h:139
device
Definition: ad9361_util.h:75
ad9739a_read
int32_t ad9739a_read(struct ad9739a_dev *dev, uint8_t register_address, uint8_t *register_value)
Reads the value of the selected register.
Definition: ad9739a.c:88
AD9739A_REG_POWER_DOWN
#define AD9739A_REG_POWER_DOWN
Definition: ad9739a.h:60
AD9739A_LVDS_REC_CNT4_FINE_DEL_SKEW
#define AD9739A_LVDS_REC_CNT4_FINE_DEL_SKEW(x)
Definition: ad9739a.h:149
AD9739A_REG_FSC_2
#define AD9739A_REG_FSC_2
Definition: ad9739a.h:65
AD9739A_REG_MU_DUTY
#define AD9739A_REG_MU_DUTY
Definition: ad9739a.h:81
AD9739A_LVDS_REC_STAT9_RCVR_LCK
#define AD9739A_LVDS_REC_STAT9_RCVR_LCK
Definition: ad9739a.h:170
ad9739a_remove
int32_t ad9739a_remove(struct ad9739a_dev *dev)
Free the resources allocated by ad9739a_setup().
Definition: ad9739a.c:460
AD9739A_MU_CNT2_SRCH_MODE
#define AD9739A_MU_CNT2_SRCH_MODE(x)
Definition: ad9739a.h:196
AD9739A_CROSS_CNT2_CLKN_OFFSET
#define AD9739A_CROSS_CNT2_CLKN_OFFSET(x)
Definition: ad9739a.h:178
AD9739A_MODE_RESET
#define AD9739A_MODE_RESET
Definition: ad9739a.h:93
AD9739A_MU_CNT3_MUDEL
#define AD9739A_MU_CNT3_MUDEL(x)
Definition: ad9739a.h:200
AD9739A_READ
#define AD9739A_READ
Definition: ad9739a.h:55
ad9739a_reset
int32_t ad9739a_reset(struct ad9739a_dev *dev)
Resets the device.
Definition: ad9739a.c:110
ad9739a_write
int32_t ad9739a_write(struct ad9739a_dev *dev, uint8_t register_address, uint8_t register_value)
Writes a value to the selected register.
Definition: ad9739a.c:64
ad9739a_write
int32_t ad9739a_write(struct ad9739a_dev *dev, uint8_t register_address, uint8_t register_value)
Writes a value to the selected register.
Definition: ad9739a.c:64
ad9739a_dac_fs_current
float ad9739a_dac_fs_current(struct ad9739a_dev *dev, float fs_val)
Sets the full-scale output current for the DAC.
Definition: ad9739a.c:196
AD9739A_MU_CNT4_GUARD
#define AD9739A_MU_CNT4_GUARD(x)
Definition: ad9739a.h:206
AD9739A_MU_CNT2_SET_PHS
#define AD9739A_MU_CNT2_SET_PHS(x)
Definition: ad9739a.h:197
ad9739a_dev
Definition: ad9739a.h:219
delay_fdata_cycles
int32_t delay_fdata_cycles(uint32_t cycles)
Delay for a number of fdata clock cycles.
Definition: ad9739a.c:245
AD9739A_LVDS_REC_CNT4_DCI_DEL
#define AD9739A_LVDS_REC_CNT4_DCI_DEL(x)
Definition: ad9739a.h:148
AD9739A_REG_MU_STAT1
#define AD9739A_REG_MU_STAT1
Definition: ad9739a.h:86
AD9739A_MU_DUTY_MU_DUTY_AUTO_EN
#define AD9739A_MU_DUTY_MU_DUTY_AUTO_EN
Definition: ad9739a.h:185
AD9739A_REG_MU_CNT4
#define AD9739A_REG_MU_CNT4
Definition: ad9739a.h:85
AD9739A_FSC_2_Sleep
#define AD9739A_FSC_2_Sleep
Definition: ad9739a.h:123
AD9739A_REG_LVDS_REC_CNT4
#define AD9739A_REG_LVDS_REC_CNT4
Definition: ad9739a.h:71
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
AD9739A_MU_STAT1_MU_LKD
#define AD9739A_MU_STAT1_MU_LKD
Definition: ad9739a.h:210
ad9739a_read
int32_t ad9739a_read(struct ad9739a_dev *dev, uint8_t register_address, uint8_t *register_value)
Reads the value of the selected register.
Definition: ad9739a.c:88
AD9739A_REG_PHS_DET
#define AD9739A_REG_PHS_DET
Definition: ad9739a.h:80
AD9739A_CROSS_CNT1_CLKP_OFFSET
#define AD9739A_CROSS_CNT1_CLKP_OFFSET(x)
Definition: ad9739a.h:174
AD9739A_DEC_CNT_DAC_DEC
#define AD9739A_DEC_CNT_DAC_DEC(x)
Definition: ad9739a.h:126
ad9739a_power_down
int32_t ad9739a_power_down(struct ad9739a_dev *dev, uint8_t pwr_config)
Powers down LVDS interface and TxDAC.
Definition: ad9739a.c:138
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:49
ad9739a_init_param::full_scale_current
float full_scale_current
Definition: ad9739a.h:236
ad9739a_operation_mode
int32_t ad9739a_operation_mode(struct ad9739a_dev *dev, uint8_t mode)
AD9739A_LVDS_REC_CNT1_RCVR_CNT_ENA
#define AD9739A_LVDS_REC_CNT1_RCVR_CNT_ENA
Definition: ad9739a.h:139
ad9739a_power_down
int32_t ad9739a_power_down(struct ad9739a_dev *dev, uint8_t pwr_config)
Powers down LVDS interface and TxDAC.
Definition: ad9739a.c:138
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
ad9739a_reset
int32_t ad9739a_reset(struct ad9739a_dev *dev)
Resets the device.
Definition: ad9739a.c:110
ad9739a_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: ad9739a.h:230
AD9739A_MU_CNT4_RETRY
#define AD9739A_MU_CNT4_RETRY
Definition: ad9739a.h:204
ad9739a_init_param
Driver Initialization parameters.
Definition: ad9739a.h:228
AD9739A_DAC_DEC_NORMAL_BASEBAND
#define AD9739A_DAC_DEC_NORMAL_BASEBAND
Definition: ad9739a.h:128
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
AD9739A_WRITE
#define AD9739A_WRITE
Definition: ad9739a.h:56
AD9739A_PHS_DET_CMP_BST
#define AD9739A_PHS_DET_CMP_BST
Definition: ad9739a.h:181
delay_fdata_cycles
int32_t delay_fdata_cycles(uint32_t cycles)
Delay for a number of fdata clock cycles.
Definition: ad9739a.c:245
AD9739A_REG_PART_ID
#define AD9739A_REG_PART_ID
Definition: ad9739a.h:87
AD9739A_REG_CROSS_CNT1
#define AD9739A_REG_CROSS_CNT1
Definition: ad9739a.h:78
AD9739A_REG_MU_CNT2
#define AD9739A_REG_MU_CNT2
Definition: ad9739a.h:83
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
AD9739A_REG_LVDS_REC_CNT1
#define AD9739A_REG_LVDS_REC_CNT1
Definition: ad9739a.h:68
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
AD9739A_REG_FSC_1
#define AD9739A_REG_FSC_1
Definition: ad9739a.h:64
AD9739A_REG_LVDS_REC_STAT9
#define AD9739A_REG_LVDS_REC_STAT9
Definition: ad9739a.h:77
AD9739A_REG_MODE
#define AD9739A_REG_MODE
Definition: ad9739a.h:59
AD9739A_REG_MU_CNT1
#define AD9739A_REG_MU_CNT1
Definition: ad9739a.h:82
AD9739A_LVDS_REC_CNT1_RCVR_LOOP_ON
#define AD9739A_LVDS_REC_CNT1_RCVR_LOOP_ON
Definition: ad9739a.h:138
ad_serdes_clk
int32_t ad_serdes_clk(struct ad9739a_dev *dev, uint8_t mode)
Sets the normal baseband mode or mix-mode.
Definition: ad9739a.c:168
ad9739a_init_param::common_mode_voltage_dacclk_n
uint8_t common_mode_voltage_dacclk_n
Definition: ad9739a.h:234
ad9739a_init_param::common_mode_voltage_dacclk_p
uint8_t common_mode_voltage_dacclk_p
Definition: ad9739a.h:232
ad9739a_setup
int32_t ad9739a_setup(struct ad9739a_dev **device, struct ad9739a_init_param init_param)
Initializes the AD9739A.
Definition: ad9739a.c:275
ad9739a_dac_fs_current
float ad9739a_dac_fs_current(struct ad9739a_dev *dev, float fs_val)
Sets the full-scale output current for the DAC.
Definition: ad9739a.c:196
AD9739A_MU_CNT1_ENABLE
#define AD9739A_MU_CNT1_ENABLE
Definition: ad9739a.h:192
AD9739A_CHIP_ID
#define AD9739A_CHIP_ID
Definition: ad9739a.h:88
AD9739A_LVDS_REC_STAT9_RCVR_TRK_ON
#define AD9739A_LVDS_REC_STAT9_RCVR_TRK_ON
Definition: ad9739a.h:167
AD9739A_DAC_DEC_MIX_MODE
#define AD9739A_DAC_DEC_MIX_MODE
Definition: ad9739a.h:130
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
AD9739A_REG_CROSS_CNT2
#define AD9739A_REG_CROSS_CNT2
Definition: ad9739a.h:79
ad9739a_remove
int32_t ad9739a_remove(struct ad9739a_dev *dev)
Free the resources allocated by ad9739a_setup().
Definition: ad9739a.c:460