![]() |
no-OS
|
Header file of AD5933 Driver. More...
Classes | |
| struct | ad5933_dev |
| struct | ad5933_init_param |
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. | |
Header file of AD5933 Driver.
Copyright 2012(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define AD5933_ADDR_POINTER 0xB0 |
| #define AD5933_ADDRESS 0x0D |
| #define AD5933_CONTROL_EXT_SYSCLK NO_OS_BIT(3) |
| #define AD5933_CONTROL_FUNCTION | ( | x | ) |
| #define AD5933_CONTROL_INT_SYSCLK (0x0 << 3) |
| #define AD5933_CONTROL_PGA_GAIN | ( | x | ) |
| #define AD5933_CONTROL_RANGE | ( | x | ) |
| #define AD5933_CONTROL_RESET NO_OS_BIT(4) |
| #define AD5933_FUNCTION_INC_FREQ 0x3 |
| #define AD5933_FUNCTION_INIT_START_FREQ 0x1 |
| #define AD5933_FUNCTION_MEASURE_TEMP 0x9 |
| #define AD5933_FUNCTION_NOP 0x0 |
| #define AD5933_FUNCTION_POWER_DOWN 0xA |
| #define AD5933_FUNCTION_REPEAT_FREQ 0x4 |
| #define AD5933_FUNCTION_STANDBY 0xB |
| #define AD5933_FUNCTION_START_SWEEP 0x2 |
| #define AD5933_INTERNAL_SYS_CLK 16776000ul |
| #define AD5933_MAX_INC_NUM 511 |
| #define AD5933_MAX_OUTPUT_FREQ | ( | clk | ) |
| #define AD5933_MAX_RETRIES 3000 |
| #define AD5933_MAX_SETTLING_CYCLES 0x7FC |
| #define AD5933_MIN_FREQ_INC 0.1f |
| #define AD5933_MIN_OUTPUT_FREQ | ( | clk | ) |
| #define AD5933_POWERUP_RETRIES 300 |
| #define AD5933_POWERUP_RETRY_MS 10 |
| #define AD5933_REG_CONTROL_HB 0x80 |
| #define AD5933_REG_CONTROL_LB 0x81 |
| #define AD5933_REG_FREQ_INC 0x85 |
| #define AD5933_REG_FREQ_START 0x82 |
| #define AD5933_REG_IMAG_DATA 0x94 |
| #define AD5933_REG_INC_NUM 0x88 |
| #define AD5933_REG_REAL_DATA 0x96 |
| #define AD5933_REG_SETTLING_CYCLES 0x8A |
| #define AD5933_REG_STATUS 0x8F |
| #define AD5933_REG_TEMP_DATA 0x92 |
| #define AD5933_SETTLING_CYCLES 50 |
| #define AD5933_STAT_DATA_VALID NO_OS_BIT(1) |
| #define AD5933_STAT_SWEEP_DONE NO_OS_BIT(2) |
| #define AD5933_STAT_TEMP_VALID NO_OS_BIT(0) |
| #define AD5933_STATUS_POLL_MS 1 |
| enum ad5933_clock_source |
| enum ad5933_output_range |
| enum ad5933_pga_gain |
| enum meas_mode |
| 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.
| dev | - The device structure. |
| gain_factor | - The gain factor pointer. |
| calibration_impedance | - The calibration impedance value. |
| measurement_mode | - 2-wire (default) or 4-wire. |
| 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.
| dev | - The device structure. |
| gain_factor | - The gain factor. |
| impedance | - Pointer to the Impedance in ohms. |
| measurement_mode | - 2-wire (default) or 4-wire. |
| 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.
| 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). |
| uint32_t ad5933_convert_freq_to_reg | ( | struct ad5933_dev * | dev, |
| double | frequency ) |
Converts a frequency value to the corresponding register binary value.
| dev | - The device structure. |
| frequency | - The frequency value in Hz. |
| 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.
| dev | - The device structure. |
| real | - Pointer to the signed 16-bit real component. |
| imag | - Pointer to the signed 16-bit imaginary component. |
| 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.
| dev | - The device structure. |
| freq_function | - Frequency function. |
| real | - Pointer to real data |
| imag | - Pointer to imaginary data |
| 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.
| dev | - The device structure. |
| magnitude | - Pointer to the DFT magnitude sqrt(real^2 + imag^2). |
| 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).
| dev | - The device structure. |
| system_phase | - The system phase captured at calibration in radians. |
| phase_rad | - Pointer to the impedance phase in radians. |
| 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.
| dev | - The device structure. |
| temperature | - Pointer to the sign-extended raw temperature code. |
| 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.
| dev | - The device structure. |
| data | - Pointer to the read register value. |
| register_address | - Address of the register. |
| bytes_number | - Number of bytes. |
| 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.
| dev | - The device structure. |
| temperature | - Pointer to the temperature value in degrees Celsius. |
| int ad5933_increment_freq | ( | struct ad5933_dev * | dev | ) |
Step to the next frequency point in the sweep.
| dev | - The device structure. |
| 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.
| device | - The device structure. |
| init_param | - The structure that contains the device initial parameters. |
| int ad5933_init_start_freq | ( | struct ad5933_dev * | dev | ) |
Enables the DDS to output the programmed start frequency for an indefinite time.
| dev | - The device structure. |
| 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.
| dev | - The device structure. |
| int ad5933_power_down | ( | struct ad5933_dev * | dev | ) |
Default state on power-up of the AD5933 is power-down mode.
| dev | - The device structure. |
| 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.
| dev | - The device structure. |
| reg | - Address of the register. |
| val | - Pointer to the read byte. |
| 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.
| dev | - The device structure. |
| reg | - Address of the register. |
| val | - Byte value to write. |
| int ad5933_remove | ( | struct ad5933_dev * | dev | ) |
Free the resources allocated by ad5933_init().
Free the resources allocated by ad5933_init().
| dev | - The device structure. |
| int ad5933_repeat_freq | ( | struct ad5933_dev * | dev | ) |
Repeat the current frequency point measurement.
| dev | - The device structure. |
| int ad5933_reset | ( | struct ad5933_dev * | dev | ) |
Resets the device.
Resets the device.
| dev | - The device structure. |
| 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.
| dev | - The device structure. |
| gain | - Gain option. |
| 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.
| dev | - The device structure. |
| range | - Range option (see enum ad5933_output_range). |
| 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.
| 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 |
| 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.
| dev | - The device structure. |
| register_address | - Address of the register. |
| register_value | - Data value to write. |
| bytes_number | - Number of bytes |
| 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.
| 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. |
| 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.
| 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. |
| int ad5933_setup | ( | struct ad5933_dev * | dev | ) |
Sets up the AD5933 device with the current configuration values.
Setup the device clock, range and gain.
| dev | - The device structure. |
| int ad5933_standby | ( | struct ad5933_dev * | dev | ) |
Powers up the part for general operation.
| dev | - The device structure. |
| int ad5933_start_sweep | ( | struct ad5933_dev * | dev | ) |
ADC starts measuring after the programmed number of settling time cycles has elapsed.
| dev | - The device structure. |
| 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.
| dev | The device structure. |
| done | Pointer to integer that will be non-zero if sweep done, 0 otherwise. |
| 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.
| dev | - The device structure. |
| mask | - Status bits to wait for. |
| status_out | - Optional pointer to receive the last status read. |