no-OS
adgs1408.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef ADGS1408_H_
40 #define ADGS1408_H_
41 
42 /******************************************************************************/
43 /***************************** Include Files **********************************/
44 /******************************************************************************/
45 #include <stdint.h>
46 #include "no_os_spi.h"
47 
48 /******************************************************************************/
49 /********************** Macros and Constants Definitions **********************/
50 /******************************************************************************/
51 #define ADGS1408_REG_SW_DATA 0x01
52 #define ADGS1408_REG_ERR_CONFIG 0x02
53 #define ADGS1408_REG_ERR_FLAGS 0x03
54 #define ADGS1408_REG_BURST_EN 0x05
55 #define ADGS1408_REG_ROUND_ROBIN_EN 0x06
56 #define ADGS1408_REG_RROBIN_CHANNEL_CONFIG 0x07
57 #define ADGS1408_REG_CNV_EDGE_SEL 0x09
58 #define ADGS1408_REG_SOFT_RESETB 0x0B
59 
60 /* ADGS1408_REG_SW_DATA for ADGS1408 */
61 #define ADGS1408_SW1_EN 0x01
62 #define ADGS1408_SW2_EN 0x03
63 #define ADGS1408_SW3_EN 0x05
64 #define ADGS1408_SW4_EN 0x07
65 #define ADGS1408_SW5_EN 0x09
66 #define ADGS1408_SW6_EN 0x0B
67 #define ADGS1408_SW7_EN 0x0D
68 #define ADGS1408_SW8_EN 0x0F
69 
70 /* ADGS1408_REG_SW_DATA for ADGS1409 */
71 #define ADGS1409_SW1_EN 0x01
72 #define ADGS1409_SW2_EN 0x03
73 #define ADGS1409_SW3_EN 0x05
74 #define ADGS1409_SW4_EN 0x07
75 
76 /* ADGS1408_REG_ERR_CONFIG */
77 #define ADGS1408_RW_ERR_EN (1 << 2)
78 #define ADGS1408_SCLK_ERR_EN (1 << 1)
79 #define ADGS1408_CRC_ERR_EN (1 << 0)
80 
81 /* ADGS1408_REG_ERR_FLAGS */
82 #define ADGS1408_RW_ERR_FLAG (1 << 2)
83 #define ADGS1408_SCLK_ERR_FLAG (1 << 1)
84 #define ADGS1408_CRC_ERR_FLAG (1 << 0)
85 #define ADGS1408_CLR_1 0x6C
86 #define ADGS1408_CLR_2 0xA9
87 
88 /* ADGS1408_REG_BURST_EN */
89 #define ADGS1408_BURST_MODE_EN (1 << 0)
90 
91 /* ADGS1408_REG_ROUND_ROBIN_EN */
92 #define ADGS1408_ROUND_ROBIN_EN (1 << 0)
93 
94 /* ADGS1408_REG_RROBIN_CHANNEL_CONFIG for ADGS1408 */
95 #define ADGS1408_RROBIN_SW1(x) (((x) & 0x1) << 0)
96 #define ADGS1408_RROBIN_SW2(x) (((x) & 0x1) << 1)
97 #define ADGS1408_RROBIN_SW3(x) (((x) & 0x1) << 2)
98 #define ADGS1408_RROBIN_SW4(x) (((x) & 0x1) << 3)
99 #define ADGS1408_RROBIN_SW5(x) (((x) & 0x1) << 4)
100 #define ADGS1408_RROBIN_SW6(x) (((x) & 0x1) << 5)
101 #define ADGS1408_RROBIN_SW7(x) (((x) & 0x1) << 6)
102 #define ADGS1408_RROBIN_SW8(x) (((x) & 0x1) << 7)
103 
104 /* ADGS1408_REG_RROBIN_CHANNEL_CONFIG for ADGS1409 */
105 #define ADGS1408_RROBIN_SW1(x) (((x) & 0x1) << 0)
106 #define ADGS1408_RROBIN_SW2(x) (((x) & 0x1) << 1)
107 #define ADGS1408_RROBIN_SW3(x) (((x) & 0x1) << 2)
108 #define ADGS1408_RROBIN_SW4(x) (((x) & 0x1) << 3)
109 
110 /* ADGS1408_REG_CNV_EDGE_SEL */
111 #define ADGS1408_CNV_EDGE_RISING (1 << 0)
112 
113 /* ADGS1408_REG_SOFT_RESETB */
114 #define ADGS1408_SOFT_RESETB(x) (((x) & 0xFF) << 0)
115 #define ADGS1408_RESET_1 0xA3
116 #define ADGS1408_RESET_2 0x05
117 
118 #define ADGS1408_DAISY_CHAIN_1 0x25
119 #define ADGS1408_DAISY_CHAIN_2 0x00
120 
121 /* ADGS1408 exit Round Robin*/
122 #define ADGS1408_RROBIN_EXIT_1 0xA3
123 #define ADGS1408_RROBIN_EXIT_2 0x18
124 #define ADGS1408_RROBIN_EXIT_3 0xE3
125 #define ADGS1408_RROBIN_EXIT_4 0xB4
126 
127 #define ADGS1408_ALIGNMENT 0x25
128 
129 #define ADGS1408_CRC8_POLY 0x07
130 
131 /******************************************************************************/
132 /*************************** Types Declarations *******************************/
133 /******************************************************************************/
137 };
138 
142 };
143 
153 };
154 
155 struct adgs1408_dev {
156  /* SPI */
158  /* Device Settings */
165 };
166 
168  /* SPI */
170  /* Device Settings */
177 };
178 
179 /******************************************************************************/
180 /************************ Functions Declarations ******************************/
181 /******************************************************************************/
182 /* Compute CRC8 checksum. */
183 uint8_t adgs1408_compute_crc8(uint8_t *data,
184  uint8_t data_size);
185 /* SPI register read from device. */
186 int32_t adgs1408_spi_reg_read(struct adgs1408_dev *dev,
187  uint8_t reg_addr,
188  uint8_t *reg_data);
189 /* SPI register write to device. */
190 int32_t adgs1408_spi_reg_write(struct adgs1408_dev *dev,
191  uint8_t reg_addr,
192  uint8_t reg_data);
193 /* SPI register read from device using a mask. */
194 int32_t adgs1408_spi_reg_read_mask(struct adgs1408_dev *dev,
195  uint8_t reg_addr,
196  uint8_t mask,
197  uint8_t *data);
198 /* SPI internal register write to device using a mask. */
199 int32_t adgs1408_spi_reg_write_mask(struct adgs1408_dev *dev,
200  uint8_t reg_addr,
201  uint8_t mask,
202  uint8_t data);
203 /* Do a software reset. */
204 int32_t adgs1408_do_soft_reset(struct adgs1408_dev *dev);
205 /* Clear the Error Flags Register. */
206 int32_t adgs1408_clear_err_flags(struct adgs1408_dev *dev);
207 /* Enter Daisy-Chain Mode. */
208 int32_t adgs1408_enter_daisy_chain(struct adgs1408_dev *dev);
209 /* Send Daisy-Chain commands. */
210 int32_t adgs1408_send_daisy_chain_cmds(struct adgs1408_dev *dev,
211  uint8_t *cmds,
212  uint8_t cmds_size);
213 /* Enter round robin mode. */
214 int32_t adgs1408_enter_round_robin(struct adgs1408_dev *dev);
215 /* Configure Round Robin Mode. */
216 int32_t adgs1408_configure_round_robin(struct adgs1408_dev *dev,
217  uint8_t cnv_polarity);
218 /* Exit Round Robin Mode. */
219 int32_t adgs1408_exit_round_robin(struct adgs1408_dev *dev);
220 /* Initialize the device. */
221 int32_t adgs1408_init(struct adgs1408_dev **device,
223 /* Free the resources allocated by adgs1408_init(). */
224 int32_t adgs1408_remove(struct adgs1408_dev *dev);
225 #endif // ADGS1408_H_
ADGS1408_REG_ROUND_ROBIN_EN
#define ADGS1408_REG_ROUND_ROBIN_EN
Definition: adgs1408.h:55
adgs1408_dev::burst_mode_en
enum adgs1408_state burst_mode_en
Definition: adgs1408.h:160
adgs1408_configure_round_robin
int32_t adgs1408_configure_round_robin(struct adgs1408_dev *dev, uint8_t cnv_polarity)
Definition: adgs1408.c:325
adgs1408_clear_err_flags
int32_t adgs1408_clear_err_flags(struct adgs1408_dev *dev)
Definition: adgs1408.c:231
adgs1408_remove
int32_t adgs1408_remove(struct adgs1408_dev *dev)
Free the resources allocated by adgs1408_init().
Definition: adgs1408.c:453
adgs1408_dev::rrobin_sw_config
struct adgs1408_rrobin_config rrobin_sw_config
Definition: adgs1408.h:163
adgs1408_spi_reg_write_mask
int32_t adgs1408_spi_reg_write_mask(struct adgs1408_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
Definition: adgs1408.c:177
ADGS1408_RESET_2
#define ADGS1408_RESET_2
Definition: adgs1408.h:116
ADGS1408_BURST_MODE_EN
#define ADGS1408_BURST_MODE_EN
Definition: adgs1408.h:89
adgs1408_compute_crc8
uint8_t adgs1408_compute_crc8(uint8_t *data, uint8_t data_size)
Definition: adgs1408.c:58
ADGS1408_DAISY_CHAIN_2
#define ADGS1408_DAISY_CHAIN_2
Definition: adgs1408.h:119
adgs1408_do_soft_reset
int32_t adgs1408_do_soft_reset(struct adgs1408_dev *dev)
Definition: adgs1408.c:205
adgs1408_exit_round_robin
int32_t adgs1408_exit_round_robin(struct adgs1408_dev *dev)
Definition: adgs1408.c:366
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:83
adgs1408_rrobin_config::rrobin_sw8
bool rrobin_sw8
Definition: adgs1408.h:152
no_os_spi.h
Header file of SPI Interface.
adgs1408_spi_reg_read
int32_t adgs1408_spi_reg_read(struct adgs1408_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: adgs1408.c:87
adgs1408_init_param::burst_mode_en
enum adgs1408_state burst_mode_en
Definition: adgs1408.h:172
adgs1408_dev::daisy_chain_en
enum adgs1408_state daisy_chain_en
Definition: adgs1408.h:161
ADGS1408_REG_ERR_CONFIG
#define ADGS1408_REG_ERR_CONFIG
Definition: adgs1408.h:52
adgs1408_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: adgs1408.h:169
ID_ADGS1409
@ ID_ADGS1409
Definition: adgs1408.h:136
ADGS1408_RROBIN_SW8
#define ADGS1408_RROBIN_SW8(x)
Definition: adgs1408.h:102
adgs1408_enter_daisy_chain
int32_t adgs1408_enter_daisy_chain(struct adgs1408_dev *dev)
Definition: adgs1408.c:258
ADGS1408_ROUND_ROBIN_EN
#define ADGS1408_ROUND_ROBIN_EN
Definition: adgs1408.h:92
adgs1408_rrobin_config::rrobin_sw5
bool rrobin_sw5
Definition: adgs1408.h:149
adgs1408_do_soft_reset
int32_t adgs1408_do_soft_reset(struct adgs1408_dev *dev)
Definition: adgs1408.c:205
ADGS1408_DAISY_CHAIN_1
#define ADGS1408_DAISY_CHAIN_1
Definition: adgs1408.h:118
device
Definition: ad9361_util.h:75
ADGS1408_ENABLE
@ ADGS1408_ENABLE
Definition: adgs1408.h:140
ADGS1408_ALIGNMENT
#define ADGS1408_ALIGNMENT
Definition: adgs1408.h:127
adgs1408_rrobin_config::rrobin_sw7
bool rrobin_sw7
Definition: adgs1408.h:151
adgs1408_init_param
Definition: adgs1408.h:167
ADGS1408_REG_CNV_EDGE_SEL
#define ADGS1408_REG_CNV_EDGE_SEL
Definition: adgs1408.h:57
ADGS1408_RROBIN_SW3
#define ADGS1408_RROBIN_SW3(x)
Definition: adgs1408.h:107
adgs1408_init
int32_t adgs1408_init(struct adgs1408_dev **device, struct adgs1408_init_param init_param)
Definition: adgs1408.c:391
adgs1408.h
Header file of ADGS1408 Driver.
ADGS1408_RROBIN_SW7
#define ADGS1408_RROBIN_SW7(x)
Definition: adgs1408.h:101
ADGS1408_DISABLE
@ ADGS1408_DISABLE
Definition: adgs1408.h:141
ADGS1408_CLR_1
#define ADGS1408_CLR_1
Definition: adgs1408.h:85
adgs1408_rrobin_config::rrobin_sw6
bool rrobin_sw6
Definition: adgs1408.h:150
adgs1408_rrobin_config::rrobin_sw3
bool rrobin_sw3
Definition: adgs1408.h:147
adgs1408_send_daisy_chain_cmds
int32_t adgs1408_send_daisy_chain_cmds(struct adgs1408_dev *dev, uint8_t *cmds, uint8_t cmds_size)
Definition: adgs1408.c:282
adgs1408_rrobin_config
Definition: adgs1408.h:144
ADGS1408_RESET_1
#define ADGS1408_RESET_1
Definition: adgs1408.h:115
adgs1408_spi_reg_read_mask
int32_t adgs1408_spi_reg_read_mask(struct adgs1408_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t *data)
adgs1408_enter_daisy_chain
int32_t adgs1408_enter_daisy_chain(struct adgs1408_dev *dev)
Definition: adgs1408.c:258
adgs1408_dev::act_device
enum adgs1408_type act_device
Definition: adgs1408.h:164
adgs1408_enter_round_robin
int32_t adgs1408_enter_round_robin(struct adgs1408_dev *dev)
Definition: adgs1408.c:302
no_os_error.h
Error codes definition.
adgs1408_enter_round_robin
int32_t adgs1408_enter_round_robin(struct adgs1408_dev *dev)
Definition: adgs1408.c:302
ID_ADGS1408
@ ID_ADGS1408
Definition: adgs1408.h:135
adgs1408_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: adgs1408.h:157
adgs1408_init
int32_t adgs1408_init(struct adgs1408_dev **device, struct adgs1408_init_param init_param)
Definition: adgs1408.c:391
adgs1408_init_param::daisy_chain_en
enum adgs1408_state daisy_chain_en
Definition: adgs1408.h:173
ADGS1408_RROBIN_SW6
#define ADGS1408_RROBIN_SW6(x)
Definition: adgs1408.h:100
adgs1408_init_param::act_device
enum adgs1408_type act_device
Definition: adgs1408.h:176
adgs1408_spi_reg_write
int32_t adgs1408_spi_reg_write(struct adgs1408_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: adgs1408.c:139
adgs1408_dev::round_robin_en
enum adgs1408_state round_robin_en
Definition: adgs1408.h:162
ADGS1408_REG_BURST_EN
#define ADGS1408_REG_BURST_EN
Definition: adgs1408.h:54
adgs1408_init_param::round_robin_en
enum adgs1408_state round_robin_en
Definition: adgs1408.h:174
adgs1408_configure_round_robin
int32_t adgs1408_configure_round_robin(struct adgs1408_dev *dev, uint8_t cnv_polarity)
Definition: adgs1408.c:325
adgs1408_spi_reg_write
int32_t adgs1408_spi_reg_write(struct adgs1408_dev *dev, uint8_t reg_addr, uint8_t reg_data)
Definition: adgs1408.c:139
adgs1408_type
adgs1408_type
Definition: adgs1408.h:134
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:143
adgs1408_rrobin_config::rrobin_sw2
bool rrobin_sw2
Definition: adgs1408.h:146
adgs1408_exit_round_robin
int32_t adgs1408_exit_round_robin(struct adgs1408_dev *dev)
Definition: adgs1408.c:366
ADGS1408_RROBIN_SW4
#define ADGS1408_RROBIN_SW4(x)
Definition: adgs1408.h:108
adgs1408_dev
Definition: adgs1408.h:155
adgs1408_spi_reg_write_mask
int32_t adgs1408_spi_reg_write_mask(struct adgs1408_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
Definition: adgs1408.c:177
ADGS1408_RROBIN_SW5
#define ADGS1408_RROBIN_SW5(x)
Definition: adgs1408.h:99
ADGS1408_REG_SOFT_RESETB
#define ADGS1408_REG_SOFT_RESETB
Definition: adgs1408.h:58
adgs1408_init_param::crc_en
enum adgs1408_state crc_en
Definition: adgs1408.h:171
adgs1408_dev::crc_en
enum adgs1408_state crc_en
Definition: adgs1408.h:159
adgs1408_rrobin_config::rrobin_sw4
bool rrobin_sw4
Definition: adgs1408.h:148
ADGS1408_CRC_ERR_EN
#define ADGS1408_CRC_ERR_EN
Definition: adgs1408.h:79
ADGS1408_RROBIN_EXIT_4
#define ADGS1408_RROBIN_EXIT_4
Definition: adgs1408.h:125
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
adgs1408_state
adgs1408_state
Definition: adgs1408.h:139
adgs1408_init_param::rrobin_sw_config
struct adgs1408_rrobin_config rrobin_sw_config
Definition: adgs1408.h:175
adgs1408_remove
int32_t adgs1408_remove(struct adgs1408_dev *dev)
Free the resources allocated by adgs1408_init().
Definition: adgs1408.c:453
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:71
ADGS1408_RROBIN_EXIT_1
#define ADGS1408_RROBIN_EXIT_1
Definition: adgs1408.h:122
ADGS1408_RROBIN_EXIT_3
#define ADGS1408_RROBIN_EXIT_3
Definition: adgs1408.h:124
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:51
ADGS1408_RROBIN_EXIT_2
#define ADGS1408_RROBIN_EXIT_2
Definition: adgs1408.h:123
ADGS1408_RROBIN_SW2
#define ADGS1408_RROBIN_SW2(x)
Definition: adgs1408.h:106
adgs1408_send_daisy_chain_cmds
int32_t adgs1408_send_daisy_chain_cmds(struct adgs1408_dev *dev, uint8_t *cmds, uint8_t cmds_size)
Definition: adgs1408.c:282
adgs1408_compute_crc8
uint8_t adgs1408_compute_crc8(uint8_t *data, uint8_t data_size)
Definition: adgs1408.c:58
ADGS1408_REG_RROBIN_CHANNEL_CONFIG
#define ADGS1408_REG_RROBIN_CHANNEL_CONFIG
Definition: adgs1408.h:56
ADGS1408_CLR_2
#define ADGS1408_CLR_2
Definition: adgs1408.h:86
adgs1408_clear_err_flags
int32_t adgs1408_clear_err_flags(struct adgs1408_dev *dev)
Definition: adgs1408.c:231
adgs1408_spi_reg_read
int32_t adgs1408_spi_reg_read(struct adgs1408_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
Definition: adgs1408.c:87
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:121
ADGS1408_CRC8_POLY
#define ADGS1408_CRC8_POLY
Definition: adgs1408.h:129
adgs1408_rrobin_config::rrobin_sw1
bool rrobin_sw1
Definition: adgs1408.h:145
ADGS1408_RROBIN_SW1
#define ADGS1408_RROBIN_SW1(x)
Definition: adgs1408.h:105