no-OS
ad9680.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef AD9680_H_
34 #define AD9680_H_
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 #include "no_os_delay.h"
41 #include "no_os_spi.h"
42 #include "jesd204.h"
43 #include "no_os_util.h"
44 
45 /******************************************************************************/
46 /********************** Macros and Constants Definitions **********************/
47 /******************************************************************************/
48 #define AD9680_REG_INTERFACE_CONF_A 0x000
49 #define AD9680_REG_INTERFACE_CONF_B 0x001
50 #define AD9680_REG_CHIP_ID_LOW 0x004
51 #define AD9680_REG_CHIP_ID_HIGH 0x005
52 #define AD9680_REG_DEVICE_INDEX 0x008
53 #define AD9680_REG_CHIP_DEC_RATIO 0x201
54 #define AD9680_REG_ADC_TEST_MODE 0x550
55 #define AD9680_REG_OUTPUT_MODE 0x561
56 #define AD9680_REG_LINK_CONTROL 0x571
57 #define AD9680_REG_JESD204B_LANE_RATE_CTRL 0x56e
58 #define AD9680_REG_JESD204B_PLL_LOCK_STATUS 0x56f
59 #define AD9680_REG_JESD204B_QUICK_CONFIG 0x570
60 #define AD9680_REG_JESD_LINK_CTRL1_REG 0x571
61 #define AD9680_REG_JESD204B_MF_CTRL 0x58d
62 #define AD9680_REG_JESD204B_CSN_CONFIG 0x58f
63 #define AD9680_REG_JESD204B_SUBCLASS_CONFIG 0x590
64 #define AD9680_REG_JESD204B_LANE_SERD_OUT0_ASSIGN 0x5b2
65 #define AD9680_REG_JESD204B_LANE_SERD_OUT1_ASSIGN 0x5b3
66 #define AD9680_REG_JESD204B_LANE_SERD_OUT2_ASSIGN 0x5b5
67 #define AD9680_REG_JESD204B_LANE_SERD_OUT3_ASSIGN 0x5b6
68 
69 #define AD9680_CHIP_ID 0x0C5
70 #define AD9680_TEST_OFF 0x000
71 #define AD9680_TEST_PN9 0x006
72 #define AD9680_TEST_PN23 0x005
73 #define AD9680_TEST_RAMP 0x00f
74 #define AD9680_FORMAT_2S_COMPLEMENT 0x001
75 #define AD9680_FORMAT_OFFSET_BINARY 0x000
76 #define AD9680_JESD_LINK_PDN NO_OS_BIT(0)
77 
78 #define AD9680_SYSREF_NONE 0 /* No SYSREF Support */
79 #define AD9680_SYSREF_ONESHOT 2 /* ONE-SHOT SYSREF */
80 #define AD9680_SYSREF_CONT 1 /* Continuous Sysref Synchronisation */
81 #define AD9680_SYSREF_MON 3 /* SYSREF monitor Mode */
82 
83 /******************************************************************************/
84 /*************************** Types Declarations *******************************/
85 /******************************************************************************/
86 struct ad9680_dev {
87  /* SPI */
89 
90  struct jesd204_dev *jdev;
92 
93  unsigned long long sampling_frequency_hz;
94  unsigned long dcm;
95 
96  unsigned long sysref_mode;
97 };
98 
100  /* SPI */
102  /* Device Settings */
103  uint32_t lane_rate_kbps;
104 
106  unsigned long long sampling_frequency_hz;
107  unsigned long dcm;
108  unsigned long sysref_mode;
109 };
110 
111 /******************************************************************************/
112 /************************ Functions Declarations ******************************/
113 /******************************************************************************/
114 
115 int32_t ad9680_spi_read(struct ad9680_dev *dev,
116  uint16_t reg_addr,
117  uint8_t *reg_data);
118 
119 int32_t ad9680_spi_write(struct ad9680_dev *dev,
120  uint16_t reg_addr,
121  uint8_t reg_data);
122 
123 int32_t ad9680_setup(struct ad9680_dev **device,
124  const struct ad9680_init_param *init_param);
125 
126 /* Initialize ad9680_dev, JESD FSM ON */
127 int32_t ad9680_setup_jesd_fsm(struct ad9680_dev **device,
128  const struct ad9680_init_param *init_param);
129 
130 int32_t ad9680_remove(struct ad9680_dev *dev);
131 
132 int32_t ad9680_test(struct ad9680_dev *dev,
133  uint32_t test_mode);
134 
135 #endif
AD9680_REG_JESD204B_QUICK_CONFIG
#define AD9680_REG_JESD204B_QUICK_CONFIG
Definition: ad9680.h:59
ad9680_setup_jesd_fsm
int32_t ad9680_setup_jesd_fsm(struct ad9680_dev **device, const struct ad9680_init_param *init_param)
Definition: ad9680.c:294
no_os_alloc.h
ad9680_init_param::lane_rate_kbps
uint32_t lane_rate_kbps
Definition: ad9680.h:103
ad9680_jesd204_priv
Definition: ad9680.c:44
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:51
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:159
JESD204_STATE_OP_REASON_INIT
@ JESD204_STATE_OP_REASON_INIT
Definition: jesd204.h:148
AD9680_CHIP_ID
#define AD9680_CHIP_ID
Definition: ad9680.h:69
no_os_spi.h
Header file of SPI Interface.
ad9680_init_param::dcm
unsigned long dcm
Definition: ad9680.h:107
AD9680_REG_JESD204B_PLL_LOCK_STATUS
#define AD9680_REG_JESD204B_PLL_LOCK_STATUS
Definition: ad9680.h:58
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:88
ad9680_dev
Definition: ad9680.h:86
ad9680.h
Header file of AD9680 Driver.
ad9680_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad9680.h:88
AD9680_REG_JESD204B_CSN_CONFIG
#define AD9680_REG_JESD204B_CSN_CONFIG
Definition: ad9680.h:62
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:69
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:294
ad9680_jesd_enable_link
int ad9680_jesd_enable_link(struct ad9680_dev *dev, uint8_t en)
Definition: ad9680.c:147
AD9680_REG_LINK_CONTROL
#define AD9680_REG_LINK_CONTROL
Definition: ad9680.h:56
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:126
AD9680_REG_JESD204B_SUBCLASS_CONFIG
#define AD9680_REG_JESD204B_SUBCLASS_CONFIG
Definition: ad9680.h:63
AD9680_REG_INTERFACE_CONF_A
#define AD9680_REG_INTERFACE_CONF_A
Definition: ad9680.h:48
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:129
AD9680_FORMAT_OFFSET_BINARY
#define AD9680_FORMAT_OFFSET_BINARY
Definition: ad9680.h:75
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:74
JESD204_OP_LINK_INIT
@ JESD204_OP_LINK_INIT
Definition: jesd204.h:198
AD9680_SYSREF_CONT
#define AD9680_SYSREF_CONT
Definition: ad9680.h:80
JESD204_SYSREF_ONESHOT
@ JESD204_SYSREF_ONESHOT
Definition: jesd204.h:40
jesd204.h
ad9680_dev::jesd204_link
struct jesd204_link jesd204_link
Definition: ad9680.h:91
ad9680_dev::jdev
struct jesd204_dev * jdev
Definition: ad9680.h:90
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:74
ad9680_remove
int32_t ad9680_remove(struct ad9680_dev *dev)
Free the resources allocated by ad9680_setup().
Definition: ad9680.c:384
ad9680_init_param::sampling_frequency_hz
unsigned long long sampling_frequency_hz
Definition: ad9680.h:106
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:192
ad9680_dev::sampling_frequency_hz
unsigned long long sampling_frequency_hz
Definition: ad9680.h:93
ad9680_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: ad9680.h:101
ad9680_dev::sysref_mode
unsigned long sysref_mode
Definition: ad9680.h:96
AD9680_REG_JESD204B_MF_CTRL
#define AD9680_REG_JESD204B_MF_CTRL
Definition: ad9680.h:61
AD9680_TEST_OFF
#define AD9680_TEST_OFF
Definition: ad9680.h:70
AD9680_REG_JESD204B_LANE_RATE_CTRL
#define AD9680_REG_JESD204B_LANE_RATE_CTRL
Definition: ad9680.h:57
AD9680_FORMAT_2S_COMPLEMENT
#define AD9680_FORMAT_2S_COMPLEMENT
Definition: ad9680.h:74
AD9680_REG_OUTPUT_MODE
#define AD9680_REG_OUTPUT_MODE
Definition: ad9680.h:55
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
ad9680_dev::dcm
unsigned long dcm
Definition: ad9680.h:94
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:51
ad9680_remove
int32_t ad9680_remove(struct ad9680_dev *dev)
Free the resources allocated by ad9680_setup().
Definition: ad9680.c:384
AD9680_SYSREF_ONESHOT
#define AD9680_SYSREF_ONESHOT
Definition: ad9680.h:79
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
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:99
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
AD9680_REG_JESD_LINK_CTRL1_REG
#define AD9680_REG_JESD_LINK_CTRL1_REG
Definition: ad9680.h:60
AD9680_JESD_LINK_PDN
#define AD9680_JESD_LINK_PDN
Definition: ad9680.h:76
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:220
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
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:52
ad9680_test
int32_t ad9680_test(struct ad9680_dev *dev, uint32_t test_mode)
Definition: ad9680.c:96
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:96
AD9680_REG_ADC_TEST_MODE
#define AD9680_REG_ADC_TEST_MODE
Definition: ad9680.h:54
ad9680_setup
int32_t ad9680_setup(struct ad9680_dev **device, const struct ad9680_init_param *init_param)
ad9680_setup
Definition: ad9680.c:220
jesd204_dev_data
JESD204 device initialization data.
Definition: jesd204.h:227
ad9680_jesd204_priv::dev
struct ad9680_dev * dev
Definition: ad9680.c:45
AD9680_REG_CHIP_ID_LOW
#define AD9680_REG_CHIP_ID_LOW
Definition: ad9680.h:50
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
ad9680_init_param::sysref_mode
unsigned long sysref_mode
Definition: ad9680.h:108