no-OS
Loading...
Searching...
No Matches
ad5933.h File Reference

Header file of AD5933 Driver. More...

#include <stdint.h>
#include "no_os_i2c.h"
#include "no_os_util.h"
#include "no_os_delay.h"
Include dependency graph for ad5933.h:

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   0x96
 
#define AD5933_REG_IMAG_DATA   0x94
 
#define AD5933_CONTROL_FUNCTION(x)
 
#define AD5933_CONTROL_RANGE(x)
 
#define AD5933_CONTROL_PGA_GAIN(x)
 
#define AD5933_CONTROL_RESET   NO_OS_BIT(4)
 
#define AD5933_CONTROL_INT_SYSCLK   (0x0 << 3)
 
#define AD5933_CONTROL_EXT_SYSCLK   NO_OS_BIT(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_SETTLING_CYCLES   50
 
#define AD5933_MAX_SETTLING_CYCLES   0x7FC
 
#define AD5933_STAT_TEMP_VALID   NO_OS_BIT(0)
 
#define AD5933_STAT_DATA_VALID   NO_OS_BIT(1)
 
#define AD5933_STAT_SWEEP_DONE   NO_OS_BIT(2)
 
#define AD5933_ADDRESS   0x0D
 
#define AD5933_ADDR_POINTER   0xB0
 
#define AD5933_INTERNAL_SYS_CLK   16776000ul
 
#define AD5933_MAX_INC_NUM   511
 
#define AD5933_MAX_RETRIES   3000
 
#define AD5933_STATUS_POLL_MS   1
 
#define AD5933_POWERUP_RETRIES   300
 
#define AD5933_POWERUP_RETRY_MS   10
 
#define AD5933_MIN_OUTPUT_FREQ(clk)
 
#define AD5933_MAX_OUTPUT_FREQ(clk)
 
#define AD5933_MIN_FREQ_INC   0.1f
 

Enumerations

enum  ad5933_clock_source {
  AD5933_CLOCK_SOURCE_INTERNAL = AD5933_CONTROL_INT_SYSCLK ,
  AD5933_CLOCK_SOURCE_EXTERNAL = AD5933_CONTROL_EXT_SYSCLK
}
 
enum  ad5933_output_range {
  AD5933_RANGE_2000mVpp ,
  AD5933_RANGE_200mVpp ,
  AD5933_RANGE_400mVpp ,
  AD5933_RANGE_1000mVpp
}
 
enum  ad5933_pga_gain {
  AD5933_GAIN_X5 ,
  AD5933_GAIN_X1
}
 
enum  ad5933_settling_cycle_multiplier {
  AD5933_SETTLING_X1 = 0 ,
  AD5933_SETTLING_X2 = 1 ,
  AD5933_SETTLING_X4 = 3
}
 
enum  meas_mode {
  AD5933_MEAS_MODE_2W ,
  AD5933_MEAS_MODE_4W
}
 

Functions

int ad5933_init (struct ad5933_dev **device, struct ad5933_init_param *init_param)
 Initializes the communication peripheral and the initial Values for AD5933 Board.
 
int ad5933_setup (struct ad5933_dev *dev)
 Sets up the AD5933 device with the current configuration values.
 
int ad5933_remove (struct ad5933_dev *dev)
 Free the resources allocated by ad5933_init().
 
int ad5933_reg_write (struct ad5933_dev *dev, uint8_t reg, uint8_t val)
 Write a single byte into a register.
 
int ad5933_reg_read (struct ad5933_dev *dev, uint8_t reg, uint8_t *val)
 Read a single byte from a register.
 
int ad5933_set_register_value (struct ad5933_dev *dev, uint8_t register_address, uint32_t register_value, uint8_t bytes_number)
 Write a multi-byte value into a register.
 
int ad5933_get_register_value (struct ad5933_dev *dev, uint32_t *data, uint8_t register_address, uint8_t bytes_number)
 Reads a multi-byte value from a register.
 
int ad5933_reset (struct ad5933_dev *dev)
 Resets the device.
 
int ad5933_set_system_clk (struct ad5933_dev *dev, enum ad5933_clock_source clk_source, uint32_t ext_clk_freq)
 Selects the source of the system clock.
 
int ad5933_set_range_and_gain (struct ad5933_dev *dev, enum ad5933_output_range range, enum ad5933_pga_gain gain)
 Selects the range and gain of the device.
 
int ad5933_set_range (struct ad5933_dev *dev, enum ad5933_output_range range)
 Selects the output excitation range of the device.
 
int ad5933_set_gain (struct ad5933_dev *dev, enum ad5933_pga_gain gain)
 Selects the PGA gain of the device.
 
int ad5933_get_temperature (struct ad5933_dev *dev, float *temperature)
 Reads the temperature from the part and returns the data in degrees Celsius.
 
int ad5933_config_sweep (struct ad5933_dev *dev, double start_freq, double inc_freq, uint16_t num_increments)
 Configures the sweep parameters: Start frequency, Frequency increment and Number of increments.
 
int ad5933_get_data (struct ad5933_dev *dev, uint8_t freq_function, int16_t *real, int16_t *imag)
 Reads the real and imaginary value from register after requesting a frequency function.
 
int ad5933_calculate_gain_factor (struct ad5933_dev *dev, double *gain_factor, double calibration_impedance, enum meas_mode measurement_mode)
 Reads the real and the imaginary data and calculates the Gain Factor.
 
int ad5933_calculate_impedance (struct ad5933_dev *dev, double gain_factor, double *impedance, enum meas_mode measurement_mode)
 Reads the real and the imaginary data and calculates the Impedance.
 
int ad5933_set_settling_time (struct ad5933_dev *dev, uint16_t number_cycles)
 Selects the number of settling cycles of the device.
 
int ad5933_wait_status (struct ad5933_dev *dev, uint8_t mask, uint8_t *status_out)
 Polls the status register until (status & mask) is set or timeout.
 
int ad5933_get_raw_temperature (struct ad5933_dev *dev, int32_t *temperature)
 Reads the raw temperature from the part.
 
int ad5933_get_magnitude (struct ad5933_dev *dev, double *magnitude)
 Reads the real and imaginary data and calculates the DFT magnitude.
 
int ad5933_get_phase (struct ad5933_dev *dev, double system_phase, double *phase_rad)
 Reads the data and calculates the impedance phase in radians. The system phase captured at calibration is subtracted to yield the phase due to the impedance alone.
 
int ad5933_initialize_sweep (struct ad5933_dev *dev)
 Initializes the sweep sequence documented in the datasheet. Unknown impedance is connected to the output and the start frequency is applied. The device is now ready to start the sweep.
 
int ad5933_init_start_freq (struct ad5933_dev *dev)
 Enables the DDS to output the programmed start frequency for an indefinite time.
 
int ad5933_start_sweep (struct ad5933_dev *dev)
 ADC starts measuring after the programmed number of settling time cycles has elapsed.
 
int ad5933_increment_freq (struct ad5933_dev *dev)
 Step to the next frequency point in the sweep.
 
int ad5933_repeat_freq (struct ad5933_dev *dev)
 Repeat the current frequency point measurement.
 
int ad5933_power_down (struct ad5933_dev *dev)
 Default state on power-up of the AD5933 is power-down mode.
 
int ad5933_standby (struct ad5933_dev *dev)
 Powers up the part for general operation.
 
uint32_t ad5933_convert_freq_to_reg (struct ad5933_dev *dev, double frequency)
 Converts a frequency value to the corresponding register binary value.
 
int ad5933_get_current_data (struct ad5933_dev *dev, int16_t *real, int16_t *imag)
 Reads the real and imaginary value from register.
 
int ad5933_sweep_done (struct ad5933_dev *dev, int32_t *done)
 Check if a frequency sweep has completed.
 

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.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ AD5933_ADDR_POINTER

#define AD5933_ADDR_POINTER   0xB0

◆ AD5933_ADDRESS

#define AD5933_ADDRESS   0x0D

◆ AD5933_CONTROL_EXT_SYSCLK

#define AD5933_CONTROL_EXT_SYSCLK   NO_OS_BIT(3)

◆ AD5933_CONTROL_FUNCTION

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

◆ AD5933_CONTROL_INT_SYSCLK

#define AD5933_CONTROL_INT_SYSCLK   (0x0 << 3)

◆ AD5933_CONTROL_PGA_GAIN

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

◆ AD5933_CONTROL_RANGE

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

◆ AD5933_CONTROL_RESET

#define AD5933_CONTROL_RESET   NO_OS_BIT(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_INTERNAL_SYS_CLK

#define AD5933_INTERNAL_SYS_CLK   16776000ul

◆ AD5933_MAX_INC_NUM

#define AD5933_MAX_INC_NUM   511

◆ AD5933_MAX_OUTPUT_FREQ

#define AD5933_MAX_OUTPUT_FREQ ( clk)
Value:
((double)(clk) / 32.0)

◆ AD5933_MAX_RETRIES

#define AD5933_MAX_RETRIES   3000

◆ AD5933_MAX_SETTLING_CYCLES

#define AD5933_MAX_SETTLING_CYCLES   0x7FC

◆ AD5933_MIN_FREQ_INC

#define AD5933_MIN_FREQ_INC   0.1f

◆ AD5933_MIN_OUTPUT_FREQ

#define AD5933_MIN_OUTPUT_FREQ ( clk)
Value:
((double)(clk) / 16384.0)

◆ AD5933_POWERUP_RETRIES

#define AD5933_POWERUP_RETRIES   300

◆ AD5933_POWERUP_RETRY_MS

#define AD5933_POWERUP_RETRY_MS   10

◆ 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   0x94

◆ AD5933_REG_INC_NUM

#define AD5933_REG_INC_NUM   0x88

◆ AD5933_REG_REAL_DATA

#define AD5933_REG_REAL_DATA   0x96

◆ 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_CYCLES

#define AD5933_SETTLING_CYCLES   50

◆ AD5933_STAT_DATA_VALID

#define AD5933_STAT_DATA_VALID   NO_OS_BIT(1)

◆ AD5933_STAT_SWEEP_DONE

#define AD5933_STAT_SWEEP_DONE   NO_OS_BIT(2)

◆ AD5933_STAT_TEMP_VALID

#define AD5933_STAT_TEMP_VALID   NO_OS_BIT(0)

◆ AD5933_STATUS_POLL_MS

#define AD5933_STATUS_POLL_MS   1

Enumeration Type Documentation

◆ ad5933_clock_source

Enumerator
AD5933_CLOCK_SOURCE_INTERNAL 
AD5933_CLOCK_SOURCE_EXTERNAL 

◆ ad5933_output_range

Enumerator
AD5933_RANGE_2000mVpp 
AD5933_RANGE_200mVpp 
AD5933_RANGE_400mVpp 
AD5933_RANGE_1000mVpp 

◆ ad5933_pga_gain

Enumerator
AD5933_GAIN_X5 
AD5933_GAIN_X1 

◆ ad5933_settling_cycle_multiplier

Enumerator
AD5933_SETTLING_X1 
AD5933_SETTLING_X2 
AD5933_SETTLING_X4 

◆ meas_mode

enum meas_mode
Enumerator
AD5933_MEAS_MODE_2W 
AD5933_MEAS_MODE_4W 

Function Documentation

◆ ad5933_calculate_gain_factor()

int ad5933_calculate_gain_factor ( struct ad5933_dev * dev,
double * gain_factor,
double calibration_impedance,
enum meas_mode measurement_mode )

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.
gain_factor- The gain factor pointer.
calibration_impedance- The calibration impedance value.
measurement_mode- 2-wire (default) or 4-wire.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_calculate_impedance()

int ad5933_calculate_impedance ( struct ad5933_dev * dev,
double gain_factor,
double * impedance,
enum meas_mode measurement_mode )

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.
impedance- Pointer to the Impedance in ohms.
measurement_mode- 2-wire (default) or 4-wire.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_config_sweep()

int ad5933_config_sweep ( struct ad5933_dev * dev,
double start_freq,
double inc_freq,
uint16_t num_increments )

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;
num_increments- Number of increments. Maximum value is 511(0x1FF).

◆ ad5933_convert_freq_to_reg()

uint32_t ad5933_convert_freq_to_reg ( struct ad5933_dev * dev,
double frequency )

Converts a frequency value to the corresponding register binary value.

Parameters
dev- The device structure.
frequency- The frequency value in Hz.
Returns
Binary code to write into the corresponding register.

◆ ad5933_get_current_data()

int ad5933_get_current_data ( struct ad5933_dev * dev,
int16_t * real,
int16_t * imag )

Reads the real and imaginary value from register.

Reads the real and imaginary value from register.

The caller must have waited for the point to become valid.

Parameters
dev- The device structure.
real- Pointer to the signed 16-bit real component.
imag- Pointer to the signed 16-bit imaginary component.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_get_data()

int ad5933_get_data ( struct ad5933_dev * dev,
uint8_t freq_function,
int16_t * real,
int16_t * imag )

Reads the real and imaginary value from register after requesting a frequency function.

Reads the real and imaginary value for a given frequency function.

Parameters
dev- The device structure.
freq_function- Frequency function.
real- Pointer to real data
imag- Pointer to imaginary data
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_get_magnitude()

int ad5933_get_magnitude ( struct ad5933_dev * dev,
double * magnitude )

Reads the real and imaginary data and calculates the DFT magnitude.

Reads the real and imaginary data and calculates the magnitude.

Parameters
dev- The device structure.
magnitude- Pointer to the DFT magnitude sqrt(real^2 + imag^2).
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_get_phase()

int ad5933_get_phase ( struct ad5933_dev * dev,
double system_phase,
double * phase_rad )

Reads the data and calculates the impedance phase in radians. The system phase captured at calibration is subtracted to yield the phase due to the impedance alone.

Reads the real and imaginary data and calculates the phase (radians).

Parameters
dev- The device structure.
system_phase- The system phase captured at calibration in radians.
phase_rad- Pointer to the impedance phase in radians.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_get_raw_temperature()

int ad5933_get_raw_temperature ( struct ad5933_dev * dev,
int32_t * temperature )

Reads the raw temperature from the part.

Reads the raw temperature (14-bit two's complement) from the part.

The temperature sensor returns a 14-bit two's-complement code (13 data bits plus a sign bit); the caller converts to degrees Celsius by dividing by 32.

Parameters
dev- The device structure.
temperature- Pointer to the sign-extended raw temperature code.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_get_register_value()

int ad5933_get_register_value ( struct ad5933_dev * dev,
uint32_t * data,
uint8_t register_address,
uint8_t bytes_number )

Reads a multi-byte value from a register.

Reads a multi-byte, MSB-first value from a register.

Parameters
dev- The device structure.
data- Pointer to the read register value.
register_address- Address of the register.
bytes_number- Number of bytes.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_get_temperature()

int ad5933_get_temperature ( struct ad5933_dev * dev,
float * temperature )

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

Reads the temperature value and converts it to degrees Celsius.

Parameters
dev- The device structure.
temperature- Pointer to the temperature value in degrees Celsius.

◆ ad5933_increment_freq()

int ad5933_increment_freq ( struct ad5933_dev * dev)

Step to the next frequency point in the sweep.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_init()

int 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_init_start_freq()

int ad5933_init_start_freq ( struct ad5933_dev * dev)

Enables the DDS to output the programmed start frequency for an indefinite time.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_initialize_sweep()

int ad5933_initialize_sweep ( struct ad5933_dev * dev)

Initializes the sweep sequence documented in the datasheet. Unknown impedance is connected to the output and the start frequency is applied. The device is now ready to start the sweep.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_power_down()

int ad5933_power_down ( struct ad5933_dev * dev)

Default state on power-up of the AD5933 is power-down mode.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_reg_read()

int ad5933_reg_read ( struct ad5933_dev * dev,
uint8_t reg,
uint8_t * val )

Read a single byte from a register.

Reads a single byte from a register.

Parameters
dev- The device structure.
reg- Address of the register.
val- Pointer to the read byte.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_reg_write()

int ad5933_reg_write ( struct ad5933_dev * dev,
uint8_t reg,
uint8_t val )

Write a single byte into a register.

Writes a single byte into a register.

Parameters
dev- The device structure.
reg- Address of the register.
val- Byte value to write.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_remove()

int ad5933_remove ( struct ad5933_dev * dev)

Free the resources allocated by ad5933_init().

Free the resources allocated by ad5933_init().

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

◆ ad5933_repeat_freq()

int ad5933_repeat_freq ( struct ad5933_dev * dev)

Repeat the current frequency point measurement.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_reset()

int ad5933_reset ( struct ad5933_dev * dev)

Resets the device.

Resets the device.

Parameters
dev- The device structure.

◆ ad5933_set_gain()

int ad5933_set_gain ( struct ad5933_dev * dev,
enum ad5933_pga_gain gain )

Selects the PGA gain of the device.

Selects the gain of the device.

Parameters
dev- The device structure.
gain- Gain option.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_set_range()

int ad5933_set_range ( struct ad5933_dev * dev,
enum ad5933_output_range range )

Selects the output excitation range of the device.

Selects the range of the device.

Parameters
dev- The device structure.
range- Range option (see enum ad5933_output_range).
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_set_range_and_gain()

int ad5933_set_range_and_gain ( struct ad5933_dev * dev,
enum ad5933_output_range range,
enum ad5933_pga_gain 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
gain- Gain option. Example: AD5933_GAIN_X5 AD5933_GAIN_X1

◆ ad5933_set_register_value()

int ad5933_set_register_value ( struct ad5933_dev * dev,
uint8_t register_address,
uint32_t register_value,
uint8_t bytes_number )

Write a multi-byte value into a register.

Writes a multi-byte, MSB-first value 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
0 in case of success, negative error code otherwise.

◆ ad5933_set_settling_time()

int ad5933_set_settling_time ( struct ad5933_dev * dev,
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 is inferred based on the number of cycles.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_set_system_clk()

int ad5933_set_system_clk ( struct ad5933_dev * dev,
enum ad5933_clock_source 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.

◆ ad5933_setup()

int ad5933_setup ( struct ad5933_dev * dev)

Sets up the AD5933 device with the current configuration values.

Setup the device clock, range and gain.

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

◆ ad5933_standby()

int ad5933_standby ( struct ad5933_dev * dev)

Powers up the part for general operation.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_start_sweep()

int ad5933_start_sweep ( struct ad5933_dev * dev)

ADC starts measuring after the programmed number of settling time cycles has elapsed.

Parameters
dev- The device structure.
Returns
0 in case of success, negative error code otherwise.

◆ ad5933_sweep_done()

int ad5933_sweep_done ( struct ad5933_dev * dev,
int32_t * done )

Check if a frequency sweep has completed.

Reads the STATUS register and extracts the SWEEP_DONE bit to indicate whether the AD5933 has finished the current frequency sweep.

Parameters
devThe device structure.
donePointer to integer that will be non-zero if sweep done, 0 otherwise.
Returns
0 on success, negative error code on failure.

◆ ad5933_wait_status()

int ad5933_wait_status ( struct ad5933_dev * dev,
uint8_t mask,
uint8_t * status_out )

Polls the status register until (status & mask) is set or timeout.

Polls the status register until (status & mask) or timeout.

Parameters
dev- The device structure.
mask- Status bits to wait for.
status_out- Optional pointer to receive the last status read.
Returns
0 when the mask is satisfied, -EAGAIN on timeout, or another negative error code on I2C failure.