no-OS
ad9680.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef AD9680_H_
40 #define AD9680_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include "no_os_delay.h"
47 #include "no_os_spi.h"
48 #include "jesd204.h"
49 #include "no_os_util.h"
50 
51 /******************************************************************************/
52 /********************** Macros and Constants Definitions **********************/
53 /******************************************************************************/
54 #define AD9680_REG_INTERFACE_CONF_A 0x000
55 #define AD9680_REG_INTERFACE_CONF_B 0x001
56 #define AD9680_REG_CHIP_ID_LOW 0x004
57 #define AD9680_REG_CHIP_ID_HIGH 0x005
58 #define AD9680_REG_DEVICE_INDEX 0x008
59 #define AD9680_REG_CHIP_DEC_RATIO 0x201
60 #define AD9680_REG_ADC_TEST_MODE 0x550
61 #define AD9680_REG_OUTPUT_MODE 0x561
62 #define AD9680_REG_LINK_CONTROL 0x571
63 #define AD9680_REG_JESD204B_LANE_RATE_CTRL 0x56e
64 #define AD9680_REG_JESD204B_PLL_LOCK_STATUS 0x56f
65 #define AD9680_REG_JESD204B_QUICK_CONFIG 0x570
66 #define AD9680_REG_JESD_LINK_CTRL1_REG 0x571
67 #define AD9680_REG_JESD204B_MF_CTRL 0x58d
68 #define AD9680_REG_JESD204B_CSN_CONFIG 0x58f
69 #define AD9680_REG_JESD204B_SUBCLASS_CONFIG 0x590
70 #define AD9680_REG_JESD204B_LANE_SERD_OUT0_ASSIGN 0x5b2
71 #define AD9680_REG_JESD204B_LANE_SERD_OUT1_ASSIGN 0x5b3
72 #define AD9680_REG_JESD204B_LANE_SERD_OUT2_ASSIGN 0x5b5
73 #define AD9680_REG_JESD204B_LANE_SERD_OUT3_ASSIGN 0x5b6
74 
75 #define AD9680_CHIP_ID 0x0C5
76 #define AD9680_TEST_OFF 0x000
77 #define AD9680_TEST_PN9 0x006
78 #define AD9680_TEST_PN23 0x005
79 #define AD9680_TEST_RAMP 0x00f
80 #define AD9680_FORMAT_2S_COMPLEMENT 0x001
81 #define AD9680_FORMAT_OFFSET_BINARY 0x000
82 #define AD9680_JESD_LINK_PDN NO_OS_BIT(0)
83 
84 #define AD9680_SYSREF_NONE 0 /* No SYSREF Support */
85 #define AD9680_SYSREF_ONESHOT 2 /* ONE-SHOT SYSREF */
86 #define AD9680_SYSREF_CONT 1 /* Continuous Sysref Synchronisation */
87 #define AD9680_SYSREF_MON 3 /* SYSREF monitor Mode */
88 
89 /******************************************************************************/
90 /*************************** Types Declarations *******************************/
91 /******************************************************************************/
92 struct ad9680_dev {
93  /* SPI */
95 
96  struct jesd204_dev *jdev;
98 
99  unsigned long long sampling_frequency_hz;
100  unsigned long dcm;
101 
102  unsigned long sysref_mode;
103 };
104 
106  /* SPI */
108  /* Device Settings */
109  uint32_t lane_rate_kbps;
110 
112  unsigned long long sampling_frequency_hz;
113  unsigned long dcm;
114  unsigned long sysref_mode;
115 };
116 
117 /******************************************************************************/
118 /************************ Functions Declarations ******************************/
119 /******************************************************************************/
120 
121 int32_t ad9680_spi_read(struct ad9680_dev *dev,
122  uint16_t reg_addr,
123  uint8_t *reg_data);
124 
125 int32_t ad9680_spi_write(struct ad9680_dev *dev,
126  uint16_t reg_addr,
127  uint8_t reg_data);
128 
129 int32_t ad9680_setup(struct ad9680_dev **device,
130  const struct ad9680_init_param *init_param);
131 
132 /* Initialize ad9680_dev, JESD FSM ON */
133 int32_t ad9680_setup_jesd_fsm(struct ad9680_dev **device,
134  const struct ad9680_init_param *init_param);
135 
136 int32_t ad9680_remove(struct ad9680_dev *dev);
137 
138 int32_t ad9680_test(struct ad9680_dev *dev,
139  uint32_t test_mode);
140 
141 #endif
AD9680_REG_JESD204B_QUICK_CONFIG
#define AD9680_REG_JESD204B_QUICK_CONFIG
Definition: ad9680.h:65
ad9680_setup_jesd_fsm
int32_t ad9680_setup_jesd_fsm(struct ad9680_dev **device, const struct ad9680_init_param *init_param)
Definition: ad9680.c:300
no_os_alloc.h
ad9680_init_param::lane_rate_kbps
uint32_t lane_rate_kbps
Definition: ad9680.h:109
ad9680_jesd204_priv
Definition: ad9680.c:50
ad9680_spi_read
int32_t ad9680_spi_read(struct ad9680_dev *dev, uint16_t reg_addr, uint8_t *reg_data)
ad9680_spi_read
Definition: ad9680.c:57
jesd204_dev_data::state_ops
struct jesd204_state_op state_ops[__JESD204_MAX_OPS]
Definition: jesd204.h:232
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
JESD204_STATE_OP_REASON_INIT
@ JESD204_STATE_OP_REASON_INIT
Definition: jesd204.h:148
AD9680_CHIP_ID
#define AD9680_CHIP_ID
Definition: ad9680.h:75
no_os_spi.h
Header file of SPI Interface.
ad9680_init_param::dcm
unsigned long dcm
Definition: ad9680.h:113
AD9680_REG_JESD204B_PLL_LOCK_STATUS
#define AD9680_REG_JESD204B_PLL_LOCK_STATUS
Definition: ad9680.h:64
jesd204_copy_link_params
void jesd204_copy_link_params(struct jesd204_link *dst, const struct jesd204_link *src)
pr_err
#define pr_err(fmt, args...)
Definition: no_os_print_log.h:94
ad9680_dev
Definition: ad9680.h:92
ad9680.h
Header file of AD9680 Driver.
ad9680_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad9680.h:94
AD9680_REG_JESD204B_CSN_CONFIG
#define AD9680_REG_JESD204B_CSN_CONFIG
Definition: ad9680.h:68
no_os_delay.h
Header file of Delay functions.
JESD204_ENCODER_8B10B
@ JESD204_ENCODER_8B10B
Definition: jesd204.h:30
jesd204_sysref::mode
enum jesd204_sysref_mode mode
Definition: jesd204.h:61
jesd204_state_op_reason
jesd204_state_op_reason
Definition: jesd204.h:147
device
Definition: ad9361_util.h:75
no_os_print_log.h
Print messages helpers.
ad9680_setup_jesd_fsm
int32_t ad9680_setup_jesd_fsm(struct ad9680_dev **device, const struct ad9680_init_param *init_param)
Definition: ad9680.c:300
ad9680_jesd_enable_link
int ad9680_jesd_enable_link(struct ad9680_dev *dev, uint8_t en)
Definition: ad9680.c:153
AD9680_REG_LINK_CONTROL
#define AD9680_REG_LINK_CONTROL
Definition: ad9680.h:62
jesd204_dev_priv
void * jesd204_dev_priv(struct jesd204_dev *jdev)
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:132
AD9680_REG_JESD204B_SUBCLASS_CONFIG
#define AD9680_REG_JESD204B_SUBCLASS_CONFIG
Definition: ad9680.h:69
AD9680_REG_INTERFACE_CONF_A
#define AD9680_REG_INTERFACE_CONF_A
Definition: ad9680.h:54
JESD204_OP_CLOCKS_ENABLE
@ JESD204_OP_CLOCKS_ENABLE
Definition: jesd204.h:210
no_os_error.h
Error codes definition.
pr_debug
#define pr_debug(fmt, args...)
Definition: no_os_print_log.h:135
AD9680_FORMAT_OFFSET_BINARY
#define AD9680_FORMAT_OFFSET_BINARY
Definition: ad9680.h:81
ad9680_spi_write
int32_t ad9680_spi_write(struct ad9680_dev *dev, uint16_t reg_addr, uint8_t reg_data)
ad9680_spi_write
Definition: ad9680.c:80
JESD204_OP_LINK_INIT
@ JESD204_OP_LINK_INIT
Definition: jesd204.h:198
AD9680_SYSREF_CONT
#define AD9680_SYSREF_CONT
Definition: ad9680.h:86
JESD204_SYSREF_ONESHOT
@ JESD204_SYSREF_ONESHOT
Definition: jesd204.h:40
jesd204.h
ad9680_dev::jesd204_link
struct jesd204_link jesd204_link
Definition: ad9680.h:97
ad9680_dev::jdev
struct jesd204_dev * jdev
Definition: ad9680.h:96
ad9680_spi_write
int32_t ad9680_spi_write(struct ad9680_dev *dev, uint16_t reg_addr, uint8_t reg_data)
ad9680_spi_write
Definition: ad9680.c:80
ad9680_remove
int32_t ad9680_remove(struct ad9680_dev *dev)
Free the resources allocated by ad9680_setup().
Definition: ad9680.c:390
ad9680_init_param::sampling_frequency_hz
unsigned long long sampling_frequency_hz
Definition: ad9680.h:112
JESD204_OP_LINK_ENABLE
@ JESD204_OP_LINK_ENABLE
Definition: jesd204.h:211
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
ad9680_dev::sampling_frequency_hz
unsigned long long sampling_frequency_hz
Definition: ad9680.h:99
ad9680_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: ad9680.h:107
ad9680_dev::sysref_mode
unsigned long sysref_mode
Definition: ad9680.h:102
AD9680_REG_JESD204B_MF_CTRL
#define AD9680_REG_JESD204B_MF_CTRL
Definition: ad9680.h:67
AD9680_TEST_OFF
#define AD9680_TEST_OFF
Definition: ad9680.h:76
AD9680_REG_JESD204B_LANE_RATE_CTRL
#define AD9680_REG_JESD204B_LANE_RATE_CTRL
Definition: ad9680.h:63
AD9680_FORMAT_2S_COMPLEMENT
#define AD9680_FORMAT_2S_COMPLEMENT
Definition: ad9680.h:80
AD9680_REG_OUTPUT_MODE
#define AD9680_REG_OUTPUT_MODE
Definition: ad9680.h:61
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:49
ad9680_dev::dcm
unsigned long dcm
Definition: ad9680.h:100
ad9680_spi_read
int32_t ad9680_spi_read(struct ad9680_dev *dev, uint16_t reg_addr, uint8_t *reg_data)
ad9680_spi_read
Definition: ad9680.c:57
ad9680_remove
int32_t ad9680_remove(struct ad9680_dev *dev)
Free the resources allocated by ad9680_setup().
Definition: ad9680.c:390
AD9680_SYSREF_ONESHOT
#define AD9680_SYSREF_ONESHOT
Definition: ad9680.h:85
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
jesd204_dev_register
int jesd204_dev_register(struct jesd204_dev **jdev, const struct jesd204_dev_data *dev_data)
NULL
#define NULL
Definition: wrapper.h:64
ad9680_init_param
Definition: ad9680.h:105
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
AD9680_REG_JESD_LINK_CTRL1_REG
#define AD9680_REG_JESD_LINK_CTRL1_REG
Definition: ad9680.h:66
AD9680_JESD_LINK_PDN
#define AD9680_JESD_LINK_PDN
Definition: ad9680.h:82
JESD204_STATE_CHANGE_DONE
@ JESD204_STATE_CHANGE_DONE
Definition: jesd204.h:46
JESD204_SYSREF_CONTINUOUS
@ JESD204_SYSREF_CONTINUOUS
Definition: jesd204.h:39
ad9680_setup
int32_t ad9680_setup(struct ad9680_dev **device, const struct ad9680_init_param *init_param)
ad9680_setup
Definition: ad9680.c:226
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
jesd204_state_op::per_link
jesd204_link_cb per_link
Definition: jesd204.h:192
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
ad9680_test
int32_t ad9680_test(struct ad9680_dev *dev, uint32_t test_mode)
Definition: ad9680.c:102
no_os_util.h
Header file of utility functions.
ad9680_test
int32_t ad9680_test(struct ad9680_dev *dev, uint32_t test_mode)
Definition: ad9680.c:102
AD9680_REG_ADC_TEST_MODE
#define AD9680_REG_ADC_TEST_MODE
Definition: ad9680.h:60
ad9680_setup
int32_t ad9680_setup(struct ad9680_dev **device, const struct ad9680_init_param *init_param)
ad9680_setup
Definition: ad9680.c:226
jesd204_dev_data
JESD204 device initialization data.
Definition: jesd204.h:227
ad9680_jesd204_priv::dev
struct ad9680_dev * dev
Definition: ad9680.c:51
AD9680_REG_CHIP_ID_LOW
#define AD9680_REG_CHIP_ID_LOW
Definition: ad9680.h:56
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
ad9680_init_param::sysref_mode
unsigned long sysref_mode
Definition: ad9680.h:114