no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad5933.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef __AD5933_H__
34#define __AD5933_H__
35
36#include <stdint.h>
37#include "no_os_i2c.h"
38
39/* AD5933 Registers */
40#define AD5933_REG_CONTROL_HB 0x80 // HB of the Control register
41#define AD5933_REG_CONTROL_LB 0x81 // LB of the Control register
42#define AD5933_REG_FREQ_START 0x82 // Start frequency
43#define AD5933_REG_FREQ_INC 0x85 // Frequency increment
44#define AD5933_REG_INC_NUM 0x88 // Number of increments
45#define AD5933_REG_SETTLING_CYCLES 0x8A // Number of settling time cycles
46#define AD5933_REG_STATUS 0x8F // Status
47#define AD5933_REG_TEMP_DATA 0x92 // Temperature data
48#define AD5933_REG_REAL_DATA 0x94 // Real data
49#define AD5933_REG_IMAG_DATA 0x96 // Imaginary data
50
51/* AD5933_REG_CONTROL_HB Bits */
52#define AD5933_CONTROL_FUNCTION(x) ((x) << 4)
53#define AD5933_CONTROL_RANGE(x) ((x) << 1)
54#define AD5933_CONTROL_PGA_GAIN(x) ((x) << 0)
55
56/* AD5933_REG_CONTROL_LB Bits */
57#define AD5933_CONTROL_RESET (0x1 << 4)
58#define AD5933_CONTROL_INT_SYSCLK (0x0 << 3)
59#define AD5933_CONTROL_EXT_SYSCLK (0x1 << 3)
60
61/* AD5933_CONTROL_FUNCTION(x) options */
62#define AD5933_FUNCTION_NOP 0x0
63#define AD5933_FUNCTION_INIT_START_FREQ 0x1
64#define AD5933_FUNCTION_START_SWEEP 0x2
65#define AD5933_FUNCTION_INC_FREQ 0x3
66#define AD5933_FUNCTION_REPEAT_FREQ 0x4
67#define AD5933_FUNCTION_MEASURE_TEMP 0x9
68#define AD5933_FUNCTION_POWER_DOWN 0xA
69#define AD5933_FUNCTION_STANDBY 0xB
70
71/* AD5933_CONTROL_RANGE(x) options */
72#define AD5933_RANGE_2000mVpp 0x0
73#define AD5933_RANGE_200mVpp 0x1
74#define AD5933_RANGE_400mVpp 0x2
75#define AD5933_RANGE_1000mVpp 0x3
76
77/* AD5933_CONTROL_PGA_GAIN(x) options */
78#define AD5933_GAIN_X5 0
79#define AD5933_GAIN_X1 1
80
81/* AD5933 Default number of settling cycles */
82#define AD5933_15_CYCLES 15
83
84/* AD5933 settling cycles mulitiplier */
85#define AD5933_SETTLING_X1 0
86#define AD5933_SETTLING_X2 1
87#define AD5933_SETTLING_X4 3
88
89/* AD5933_REG_STATUS Bits */
90#define AD5933_STAT_TEMP_VALID (0x1 << 0)
91#define AD5933_STAT_DATA_VALID (0x1 << 1)
92#define AD5933_STAT_SWEEP_DONE (0x1 << 2)
93
94/* AD5933 Address */
95#define AD5933_ADDRESS 0x0D
96
97/* AD5933 Block Commands */
98#define AD5933_BLOCK_WRITE 0xA0
99#define AD5933_BLOCK_READ 0xA1
100#define AD5933_ADDR_POINTER 0xB0
101
102/* AD5933 Specifications */
103#define AD5933_INTERNAL_SYS_CLK 16000000ul // 16MHz
104#define AD5933_MAX_INC_NUM 511 // Maximum increment number
105
107 /* I2C */
109 /* Device Settings */
114};
115
117 /* I2C */
119 /* Device Settings */
124};
125
127int32_t ad5933_init(struct ad5933_dev **device,
129
131int32_t ad5933_remove(struct ad5933_dev *dev);
132
135 uint8_t register_address,
136 uint32_t register_value,
137 uint8_t bytes_number);
138
140uint32_t ad5933_get_register_value(struct ad5933_dev *dev,
141 uint8_t register_address,
142 uint8_t bytes_number);
143
145void ad5933_reset(struct ad5933_dev *dev);
146
148void ad5933_set_system_clk(struct ad5933_dev *dev,
149 int8_t clk_source,
150 uint32_t ext_clk_freq);
151
154 int8_t range,
155 int8_t gain);
156
158float ad5933_get_temperature(struct ad5933_dev *dev);
159
161void ad5933_config_sweep(struct ad5933_dev *dev,
162 uint32_t start_freq,
163 uint32_t inc_freq,
164 uint16_t inc_num);
165
167void ad5933_start_sweep(struct ad5933_dev *dev);
168
170void ad5933_get_data(struct ad5933_dev *dev,
171 uint8_t freq_function,
172 short *imag_data,
173 short *real_data);
174
177 uint32_t calibration_impedance,
178 uint8_t freq_function);
179
181double ad5933_calculate_impedance(struct ad5933_dev *dev,
182 double gain_factor,
183 uint8_t freq_function);
184
186void ad5933_set_settling_time(struct ad5933_dev *dev,
187 uint8_t mulitplier,
188 uint16_t number_cycles);
189
190#endif /* __AD5933_H__ */
void ad5933_set_system_clk(struct ad5933_dev *dev, int8_t clk_source, uint32_t ext_clk_freq)
Selects the source of the system clock.
Definition ad5933.c:173
float ad5933_get_temperature(struct ad5933_dev *dev)
Reads the temperature from the part and returns the data in degrees Celsius.
Definition ad5933.c:227
void ad5933_start_sweep(struct ad5933_dev *dev)
Starts the sweep operation.
Definition ad5933.c:310
uint32_t ad5933_get_register_value(struct ad5933_dev *dev, uint8_t register_address, uint8_t bytes_number)
Reads the value of a register.
Definition ad5933.c:127
void ad5933_reset(struct ad5933_dev *dev)
Resets the device.
Definition ad5933.c:156
int32_t ad5933_remove(struct ad5933_dev *dev)
Free the resources allocated by ad5933_init().
Definition ad5933.c:84
void ad5933_set_range_and_gain(struct ad5933_dev *dev, int8_t range, int8_t gain)
Selects the range and gain of the device.
Definition ad5933.c:204
double ad5933_calculate_gain_factor(struct ad5933_dev *dev, uint32_t calibration_impedance, uint8_t freq_function)
Reads the real and the imaginary data and calculates the Gain Factor.
Definition ad5933.c:392
void ad5933_set_register_value(struct ad5933_dev *dev, uint8_t register_address, uint32_t register_value, uint8_t bytes_number)
Writes data into a register.
Definition ad5933.c:103
void ad5933_set_settling_time(struct ad5933_dev *dev, uint8_t mulitplier, uint16_t number_cycles)
Selects the number of settling cycles of the device.
Definition ad5933.c:449
int32_t ad5933_init(struct ad5933_dev **device, struct ad5933_init_param init_param)
Initializes the communication peripheral and the initial Values for AD5933 Board.
Definition ad5933.c:55
void ad5933_config_sweep(struct ad5933_dev *dev, uint32_t start_freq, uint32_t inc_freq, uint16_t inc_num)
Configures the sweep parameters: Start frequency, Frequency increment and Number of increments.
Definition ad5933.c:266
double ad5933_calculate_impedance(struct ad5933_dev *dev, double gain_factor, uint8_t freq_function)
Reads the real and the imaginary data and calculates the Impedance.
Definition ad5933.c:420
void ad5933_get_data(struct ad5933_dev *dev, uint8_t freq_function, short *imag_data, short *real_data)
Reads the real and imaginary value from register.
Definition ad5933.c:349
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
Header file of I2C Interface.
Definition ad5933.h:106
uint32_t current_sys_clk
Definition ad5933.h:110
struct no_os_i2c_desc * i2c_desc
Definition ad5933.h:108
uint8_t current_range
Definition ad5933.h:113
uint8_t current_clock_source
Definition ad5933.h:111
uint8_t current_gain
Definition ad5933.h:112
Definition ad5933.h:116
struct no_os_i2c_init_param i2c_init
Definition ad5933.h:118
uint8_t current_clock_source
Definition ad5933.h:121
uint8_t current_range
Definition ad5933.h:123
uint32_t current_sys_clk
Definition ad5933.h:120
uint8_t current_gain
Definition ad5933.h:122
Definition ad9361_util.h:63
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52