no-OS
Functions | Variables
ad5933.c File Reference

Implementation of AD5933 Driver. More...

#include <stdlib.h>
#include "ad5933.h"
#include <math.h>
Include dependency graph for ad5933.c:

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 multiplier, uint16_t number_cycles)
 Selects the number of settling cycles of the device. More...
 

Variables

const int32_t pow_2_27 = 134217728ul
 

Detailed Description

Implementation 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.

All rights reserved.

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

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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.

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.

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.

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.

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.

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.

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.

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.

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().

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.

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.

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.

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.

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.

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.

Parameters
dev- The device structure.
Returns
None.

Variable Documentation

◆ pow_2_27

const int32_t pow_2_27 = 134217728ul