no-OS
Classes | Macros | Functions
ad5933.h File Reference

Header file of AD5933 Driver. More...

#include <stdint.h>
#include "no_os_i2c.h"
Include dependency graph for ad5933.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad5933_dev
 
struct  ad5933_init_param
 

Macros

#define AD5933_REG_CONTROL_HB   0x80
 
#define AD5933_REG_CONTROL_LB   0x81
 
#define AD5933_REG_FREQ_START   0x82
 
#define AD5933_REG_FREQ_INC   0x85
 
#define AD5933_REG_INC_NUM   0x88
 
#define AD5933_REG_SETTLING_CYCLES   0x8A
 
#define AD5933_REG_STATUS   0x8F
 
#define AD5933_REG_TEMP_DATA   0x92
 
#define AD5933_REG_REAL_DATA   0x94
 
#define AD5933_REG_IMAG_DATA   0x96
 
#define AD5933_CONTROL_FUNCTION(x)   ((x) << 4)
 
#define AD5933_CONTROL_RANGE(x)   ((x) << 1)
 
#define AD5933_CONTROL_PGA_GAIN(x)   ((x) << 0)
 
#define AD5933_CONTROL_RESET   (0x1 << 4)
 
#define AD5933_CONTROL_INT_SYSCLK   (0x0 << 3)
 
#define AD5933_CONTROL_EXT_SYSCLK   (0x1 << 3)
 
#define AD5933_FUNCTION_NOP   0x0
 
#define AD5933_FUNCTION_INIT_START_FREQ   0x1
 
#define AD5933_FUNCTION_START_SWEEP   0x2
 
#define AD5933_FUNCTION_INC_FREQ   0x3
 
#define AD5933_FUNCTION_REPEAT_FREQ   0x4
 
#define AD5933_FUNCTION_MEASURE_TEMP   0x9
 
#define AD5933_FUNCTION_POWER_DOWN   0xA
 
#define AD5933_FUNCTION_STANDBY   0xB
 
#define AD5933_RANGE_2000mVpp   0x0
 
#define AD5933_RANGE_200mVpp   0x1
 
#define AD5933_RANGE_400mVpp   0x2
 
#define AD5933_RANGE_1000mVpp   0x3
 
#define AD5933_GAIN_X5   0
 
#define AD5933_GAIN_X1   1
 
#define AD5933_15_CYCLES   15
 
#define AD5933_SETTLING_X1   0
 
#define AD5933_SETTLING_X2   1
 
#define AD5933_SETTLING_X4   3
 
#define AD5933_STAT_TEMP_VALID   (0x1 << 0)
 
#define AD5933_STAT_DATA_VALID   (0x1 << 1)
 
#define AD5933_STAT_SWEEP_DONE   (0x1 << 2)
 
#define AD5933_ADDRESS   0x0D
 
#define AD5933_BLOCK_WRITE   0xA0
 
#define AD5933_BLOCK_READ   0xA1
 
#define AD5933_ADDR_POINTER   0xB0
 
#define AD5933_INTERNAL_SYS_CLK   16000000ul
 
#define AD5933_MAX_INC_NUM   511
 

Functions

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. More...
 
int32_t ad5933_remove (struct ad5933_dev *dev)
 Free the resources allocated by ad5933_init(). More...
 
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. More...
 
uint32_t ad5933_get_register_value (struct ad5933_dev *dev, uint8_t register_address, uint8_t bytes_number)
 Reads the value of a register. More...
 
void ad5933_reset (struct ad5933_dev *dev)
 Resets the device. More...
 
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. More...
 
void ad5933_set_range_and_gain (struct ad5933_dev *dev, int8_t range, int8_t gain)
 Selects the range and gain of the device. More...
 
float ad5933_get_temperature (struct ad5933_dev *dev)
 Reads the temperature from the part and returns the data in degrees Celsius. More...
 
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. More...
 
void ad5933_start_sweep (struct ad5933_dev *dev)
 Starts the sweep operation. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Header file of AD5933 Driver.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2012(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ AD5933_15_CYCLES

#define AD5933_15_CYCLES   15

◆ AD5933_ADDR_POINTER

#define AD5933_ADDR_POINTER   0xB0

◆ AD5933_ADDRESS

#define AD5933_ADDRESS   0x0D

◆ AD5933_BLOCK_READ

#define AD5933_BLOCK_READ   0xA1

◆ AD5933_BLOCK_WRITE

#define AD5933_BLOCK_WRITE   0xA0

◆ AD5933_CONTROL_EXT_SYSCLK

#define AD5933_CONTROL_EXT_SYSCLK   (0x1 << 3)

◆ AD5933_CONTROL_FUNCTION

#define AD5933_CONTROL_FUNCTION (   x)    ((x) << 4)

◆ AD5933_CONTROL_INT_SYSCLK

#define AD5933_CONTROL_INT_SYSCLK   (0x0 << 3)

◆ AD5933_CONTROL_PGA_GAIN

#define AD5933_CONTROL_PGA_GAIN (   x)    ((x) << 0)

◆ AD5933_CONTROL_RANGE

#define AD5933_CONTROL_RANGE (   x)    ((x) << 1)

◆ AD5933_CONTROL_RESET

#define AD5933_CONTROL_RESET   (0x1 << 4)

◆ AD5933_FUNCTION_INC_FREQ

#define AD5933_FUNCTION_INC_FREQ   0x3

◆ AD5933_FUNCTION_INIT_START_FREQ

#define AD5933_FUNCTION_INIT_START_FREQ   0x1

◆ AD5933_FUNCTION_MEASURE_TEMP

#define AD5933_FUNCTION_MEASURE_TEMP   0x9

◆ AD5933_FUNCTION_NOP

#define AD5933_FUNCTION_NOP   0x0

◆ AD5933_FUNCTION_POWER_DOWN

#define AD5933_FUNCTION_POWER_DOWN   0xA

◆ AD5933_FUNCTION_REPEAT_FREQ

#define AD5933_FUNCTION_REPEAT_FREQ   0x4

◆ AD5933_FUNCTION_STANDBY

#define AD5933_FUNCTION_STANDBY   0xB

◆ AD5933_FUNCTION_START_SWEEP

#define AD5933_FUNCTION_START_SWEEP   0x2

◆ AD5933_GAIN_X1

#define AD5933_GAIN_X1   1

◆ AD5933_GAIN_X5

#define AD5933_GAIN_X5   0

◆ AD5933_INTERNAL_SYS_CLK

#define AD5933_INTERNAL_SYS_CLK   16000000ul

◆ AD5933_MAX_INC_NUM

#define AD5933_MAX_INC_NUM   511

◆ AD5933_RANGE_1000mVpp

#define AD5933_RANGE_1000mVpp   0x3

◆ AD5933_RANGE_2000mVpp

#define AD5933_RANGE_2000mVpp   0x0

◆ AD5933_RANGE_200mVpp

#define AD5933_RANGE_200mVpp   0x1

◆ AD5933_RANGE_400mVpp

#define AD5933_RANGE_400mVpp   0x2

◆ AD5933_REG_CONTROL_HB

#define AD5933_REG_CONTROL_HB   0x80

◆ AD5933_REG_CONTROL_LB

#define AD5933_REG_CONTROL_LB   0x81

◆ AD5933_REG_FREQ_INC

#define AD5933_REG_FREQ_INC   0x85

◆ AD5933_REG_FREQ_START

#define AD5933_REG_FREQ_START   0x82

◆ AD5933_REG_IMAG_DATA

#define AD5933_REG_IMAG_DATA   0x96

◆ AD5933_REG_INC_NUM

#define AD5933_REG_INC_NUM   0x88

◆ AD5933_REG_REAL_DATA

#define AD5933_REG_REAL_DATA   0x94

◆ AD5933_REG_SETTLING_CYCLES

#define AD5933_REG_SETTLING_CYCLES   0x8A

◆ AD5933_REG_STATUS

#define AD5933_REG_STATUS   0x8F

◆ AD5933_REG_TEMP_DATA

#define AD5933_REG_TEMP_DATA   0x92

◆ AD5933_SETTLING_X1

#define AD5933_SETTLING_X1   0

◆ AD5933_SETTLING_X2

#define AD5933_SETTLING_X2   1

◆ AD5933_SETTLING_X4

#define AD5933_SETTLING_X4   3

◆ AD5933_STAT_DATA_VALID

#define AD5933_STAT_DATA_VALID   (0x1 << 1)

◆ AD5933_STAT_SWEEP_DONE

#define AD5933_STAT_SWEEP_DONE   (0x1 << 2)

◆ AD5933_STAT_TEMP_VALID

#define AD5933_STAT_TEMP_VALID   (0x1 << 0)

Function Documentation

◆ ad5933_calculate_gain_factor()

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.

Reads the real and the imaginary data and calculates the Gain Factor.

Parameters
dev- The device structure.
calibration_impedance- The calibration impedance value.
freq_function- Frequency function. Example: AD5933_FUNCTION_INC_FREQ - Increment freq.; AD5933_FUNCTION_REPEAT_FREQ - Repeat freq..
Returns
gainFactor - Calculated gain factor.

◆ ad5933_calculate_impedance()

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.

Reads the real and the imaginary data and calculates the Impedance.

Parameters
dev- The device structure.
gain_factor- The gain factor.
freq_function- Frequency function. Example: AD5933_FUNCTION_INC_FREQ - Increment freq.; AD5933_FUNCTION_REPEAT_FREQ - Repeat freq..
Returns
impedance - Calculated impedance.

◆ ad5933_config_sweep()

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.

Configures the sweep parameters.

Parameters
dev- The device structure.
start_freq- Start frequency in Hz;
inc_freq- Frequency increment in Hz;
inc_num- Number of increments. Maximum value is 511(0x1FF).
Returns
None.

◆ ad5933_get_data()

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.

Reads the real and imaginary value from register.

Parameters
dev- The device structure.
freq_function- Frequency function.
imag_data- Pointer to imaginary data
real_data- Pointer to real data
Returns
None.
Here is the caller graph for this function:

◆ ad5933_get_register_value()

uint32_t ad5933_get_register_value ( struct ad5933_dev dev,
uint8_t  register_address,
uint8_t  bytes_number 
)

Reads the value of a register.

Reads the value of a register.

Parameters
dev- The device structure.
register_address- Address of the register.
bytes_number- Number of bytes.
Returns
registerValue - Value of the register.
Here is the caller graph for this function:

◆ ad5933_get_temperature()

float ad5933_get_temperature ( struct ad5933_dev dev)

Reads the temperature from the part and returns the data in degrees Celsius.

Reads the temp. from the part and returns the data in degrees Celsius.

Parameters
dev- The device structure.
Returns
temperature - Temperature.

◆ ad5933_init()

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.

Initializes the communication peripheral.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
ret - The result of the initialization procedure. Example: -1 - I2C peripheral was not initialized or the device is not present. 0 - I2C peripheral was initialized and the device is present.

◆ ad5933_remove()

int32_t ad5933_remove ( struct ad5933_dev dev)

Free the resources allocated by ad5933_init().

Free the resources allocated by ad5686_init().

Parameters
dev- The device structure.
Returns
ret - The result of the remove procedure.

◆ ad5933_reset()

void ad5933_reset ( struct ad5933_dev dev)

Resets the device.

Resets the device.

Parameters
dev- The device structure.
Returns
None.
Here is the caller graph for this function:

◆ ad5933_set_range_and_gain()

void ad5933_set_range_and_gain ( struct ad5933_dev dev,
int8_t  range,
int8_t  gain 
)

Selects the range and gain of the device.

Selects the range and gain of the device.

Parameters
dev- The device structure.
range- Range option. Example: AD5933_RANGE_2000mVpp AD5933_RANGE_200mVpp AD5933_RANGE_400mVpp

AD5933_RANGE_1000mVpp

Parameters
gain- Gain option. Example: AD5933_GAIN_X5 AD5933_GAIN_X1
Returns
None.

◆ ad5933_set_register_value()

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.

Writes data into a register.

Parameters
dev- The device structure.
register_address- Address of the register.
register_value- Data value to write.
bytes_number- Number of bytes.
Returns
None.
Here is the caller graph for this function:

◆ ad5933_set_settling_time()

void ad5933_set_settling_time ( struct ad5933_dev dev,
uint8_t  multiplier,
uint16_t  number_cycles 
)

Selects the number of settling cycles of the device.

Selects the number of settling cycles.

Parameters
dev- The device structure.
number_cycles- 9-bit number of cycles to wait before triggering ADC
multiplier- Multiply number of cycles by X1, X2 or X4 Example: AD5933_SETTLING_X1 AD5933_SETTLING_X2 AD5933_SETTLING_X4
Returns
None.

◆ ad5933_set_system_clk()

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.

Selects the source of the system clock.

Parameters
dev- The device structure.
clk_source- Selects the source of the system clock. Example: AD5933_CONTROL_INT_SYSCLK AD5933_CONTROL_EXT_SYSCLK
ext_clk_freq- Frequency value of the external clock, if used.
Returns
None.

◆ ad5933_start_sweep()

void ad5933_start_sweep ( struct ad5933_dev dev)

Starts the sweep operation.

Starts the sweep operation.

Parameters
dev- The device structure.
Returns
None.