no-OS
Functions
ad9467.c File Reference

Implementation of AD9467 Driver. More...

#include <stdlib.h>
#include "ad9467.h"
#include "no_os_alloc.h"
Include dependency graph for ad9467.c:

Functions

int32_t ad9467_setup (struct ad9467_dev **device, struct ad9467_init_param init_param)
 Configures the test mode and the output mode to a default state. More...
 
int32_t ad9467_remove (struct ad9467_dev *dev)
 Free the resources allocated by ad9467_setup(). More...
 
int32_t ad9467_write (struct ad9467_dev *dev, uint16_t reg_addr, uint8_t reg_val)
 Writes data into a register. More...
 
int32_t ad9467_read (struct ad9467_dev *dev, uint16_t reg_addr, uint8_t *reg_val)
 Reads data from a register. More...
 
uint32_t ad9467_set_bits_to_reg (struct ad9467_dev *dev, uint16_t register_address, uint8_t bits_value, uint8_t mask)
 Sets a bit or a group of bits inside a register without modifying the other bits. More...
 
int32_t ad9467_pwr_mode (struct ad9467_dev *dev, int32_t mode, int32_t *ret_mode)
 Configures the power mode. More...
 
int32_t ad9467_test_mode (struct ad9467_dev *dev, int32_t mode, int32_t *ret_mode)
 Sets the ADC's test mode. More...
 
int32_t ad9467_reset_pn9 (struct ad9467_dev *dev, int32_t rst, int32_t *ret_stat)
 Sets (1) or clears (0) the reset short PN sequence bit(PN9). More...
 
int32_t ad9467_reset_pn23 (struct ad9467_dev *dev, int32_t rst, int32_t *ret_stat)
 Sets (1) or clears (0) the reset long PN sequence bit(PN23). More...
 
int32_t ad9467_external_ref (struct ad9467_dev *dev, int32_t en, int32_t *ret_stat)
 Enables (1) or disables (0) the external voltage reference. More...
 
int32_t ad9467_analog_input_disconnect (struct ad9467_dev *dev, int32_t en, int32_t *ret_stat)
 Disconnects (1) or connects (0) the analog input from or to the the ADC channel. More...
 
int32_t ad9467_offset_adj (struct ad9467_dev *dev, int32_t adj, int32_t *ret_stat)
 Sets the offset adjustment. More...
 
int32_t ad9467_output_disable (struct ad9467_dev *dev, int32_t en, int32_t *ret_stat)
 Disables (1) or enables (0) the data output. More...
 
int32_t ad9467_output_invert (struct ad9467_dev *dev, int32_t invert, int32_t *ret_stat)
 Activates the inverted (1) or normal (0) output mode. More...
 
int32_t ad9467_output_format (struct ad9467_dev *dev, int32_t format, int32_t *ret_stat)
 Specifies the output format. More...
 
int32_t ad9467_coarse_lvds_adj (struct ad9467_dev *dev, int32_t lvds_adj, int32_t *ret_stat)
 Determines LVDS output properties. More...
 
int32_t ad9467_output_current_adj (struct ad9467_dev *dev, int32_t adj, int32_t *ret_stat)
 Sets the output current adjustment. More...
 
int32_t ad9467_dco_clock_invert (struct ad9467_dev *dev, int32_t invert, int32_t *ret_stat)
 Activates the normal (0) or inverted (1) DCO clock. More...
 
int32_t ad9467_dco_output_clock_delay (struct ad9467_dev *dev, int32_t delay, int32_t *ret_stat)
 Configures the clock delay setting. More...
 
int32_t ad9467_full_scale_range (struct ad9467_dev *dev, float v_fs, float *ret_stat)
 Configures the full-scale input voltage selection. More...
 
int32_t ad9467_analog_input_coupling (struct ad9467_dev *dev, int32_t coupling_mode, int32_t *ret_stat)
 Sets the AC coupling(0) or DC coupling(1) mode. More...
 
int32_t ad9467_buffer_current_1 (struct ad9467_dev *dev, int32_t percentage, int32_t *ret_stat)
 Changes the input buffer current(1). More...
 
int32_t ad9467_buffer_current_2 (struct ad9467_dev *dev, int32_t percentage, int32_t *ret_stat)
 Changes the input buffer current(2). More...
 
int32_t ad9467_transfer (struct ad9467_dev *dev)
 Initiates a transfer and waits for the operation to end. More...
 

Detailed Description

Implementation of AD9467 Driver.

Author
DNechita (Dan.N.nosp@m.echi.nosp@m.ta@an.nosp@m.alog.nosp@m..com)

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.

Function Documentation

◆ ad9467_analog_input_coupling()

int32_t ad9467_analog_input_coupling ( struct ad9467_dev dev,
int32_t  coupling_mode,
int32_t *  ret_stat 
)

Sets the AC coupling(0) or DC coupling(1) mode.

Parameters
dev- The device structure.
coupling_mode- Input coupling mode selection. Example: 0 - AC coupling; 1 - DC coupling(default).
ret_stat- Return parameter of the set coupling mode.
Returns
Error code.

◆ ad9467_analog_input_disconnect()

int32_t ad9467_analog_input_disconnect ( struct ad9467_dev dev,
int32_t  en,
int32_t *  ret_stat 
)

Disconnects (1) or connects (0) the analog input from or to the the ADC channel.

Parameters
dev- The device structure.
en- Enable option. Example: 1 - Disconnects the analog input. 0 - Connects the analog input(default).
ret_stat- Return parameter of the set analog input disconnect status.
Returns
Error code.

◆ ad9467_buffer_current_1()

int32_t ad9467_buffer_current_1 ( struct ad9467_dev dev,
int32_t  percentage,
int32_t *  ret_stat 
)

Changes the input buffer current(1).

Parameters
dev- The device structure.
percentage- Buffer current select 1. Example: +530% +520% ...
  • 80%(default) ...
  • 20%
  • 10%
  • 0%
  • 10%
  • 20% ...
  • 90% -100%
ret_stat- Return parameter of the set buffer current.
Returns
Error code.

◆ ad9467_buffer_current_2()

int32_t ad9467_buffer_current_2 ( struct ad9467_dev dev,
int32_t  percentage,
int32_t *  ret_stat 
)

Changes the input buffer current(2).

Parameters
dev- The device structure.
percentage- Buffer current select 2. Example: +530% +520% ...
  • 80%(default) ...
  • 20%
  • 10%
  • 0%
  • 10%
  • 20% ...
  • 90% -100%
ret_stat- Return parameter of the set buffer current.
Returns
Error code.

◆ ad9467_coarse_lvds_adj()

int32_t ad9467_coarse_lvds_adj ( struct ad9467_dev dev,
int32_t  lvds_adj,
int32_t *  ret_stat 
)

Determines LVDS output properties.

Parameters
dev- The device structure.
lvds_adj- Coarse LVDS adjust. Example: 0 - 3.0 mA output current level(default); 1 - 1.71 mA output current level.
ret_stat- Return parameter of the set LVDS adjust state.
Returns
Error code.

◆ ad9467_dco_clock_invert()

int32_t ad9467_dco_clock_invert ( struct ad9467_dev dev,
int32_t  invert,
int32_t *  ret_stat 
)

Activates the normal (0) or inverted (1) DCO clock.

Parameters
dev- The device structure.
invert- Invert option. Example: 0 - Activates the normal DCO clock(default); 1 - Activates the inverted DCO clock.
ret_stat- Return parameter of the set DCO clock inversion status.
Returns
Error code.

◆ ad9467_dco_output_clock_delay()

int32_t ad9467_dco_output_clock_delay ( struct ad9467_dev dev,
int32_t  delay,
int32_t *  ret_stat 
)

Configures the clock delay setting.

Parameters
dev- The device structure.
delay- The clock delay setting in ps {0, 100, 200, ..., 3200}. Setting the delay to 0 disables the DCO output clock delay.
ret_stat- Return parameter of the set clock delay.
Returns
Error code.

◆ ad9467_external_ref()

int32_t ad9467_external_ref ( struct ad9467_dev dev,
int32_t  en,
int32_t *  ret_stat 
)

Enables (1) or disables (0) the external voltage reference.

Parameters
dev- The device structure.
en- Enable option. Example: 1 - Enables the external reference; 0 - Disables the external reference(default).
ret_stat- Return parameter of the set external reference enable state.
Returns
Error code.

◆ ad9467_full_scale_range()

int32_t ad9467_full_scale_range ( struct ad9467_dev dev,
float  v_fs,
float *  ret_stat 
)

Configures the full-scale input voltage selection.

Parameters
dev- The device structure.
v_fs- Full-scale input voltage selection. Example: 2.0 V p-p 2.1 V p-p 2.2 V p-p 2.3 V p-p 2.4 V p-p 2.5 V p-p(default)
ret_stat- Return parameter of the set input voltage selection.
Returns
Error code.

◆ ad9467_offset_adj()

int32_t ad9467_offset_adj ( struct ad9467_dev dev,
int32_t  adj,
int32_t *  ret_stat 
)

Sets the offset adjustment.

Parameters
dev- The device structure.
adj- The offset adjust value in LSBs from +127 to -128.
ret_stat- Return parameter of the set offset adjustment.
Returns
Error code.

◆ ad9467_output_current_adj()

int32_t ad9467_output_current_adj ( struct ad9467_dev dev,
int32_t  adj,
int32_t *  ret_stat 
)

Sets the output current adjustment.

Parameters
dev- The device structure.
adj- The output current adjustment. Example: 001 = 3.0 mA output drive current (default); 010 = 2.79 mA output drive current; 011 = 2.57 mA output drive current; 100 = 2.35 mA output drive current; 101 = 2.14 mA output drive current; 110 = 1.93 mA output drive current; 111 = 1.71 mA output drive current;
ret_stat- Return parameter of the set current adjustment.
Returns
Error code.

◆ ad9467_output_disable()

int32_t ad9467_output_disable ( struct ad9467_dev dev,
int32_t  en,
int32_t *  ret_stat 
)

Disables (1) or enables (0) the data output.

Parameters
dev- The device structure.
en- Enable option. Example: 1 - Disables the data output; 0 - Enables the data output(default).
ret_stat- Return parameter of the set output disable state.
Returns
Error code.

◆ ad9467_output_format()

int32_t ad9467_output_format ( struct ad9467_dev dev,
int32_t  format,
int32_t *  ret_stat 
)

Specifies the output format.

Parameters
dev- The device structure.
format- The output format. Example: 0 � offset binary(default); 1 � two's complement; 2 � gray code; 3 � reserved.
ret_stat- Return parameter of the set output format.
Returns
Negative error code or the set output format.
Here is the caller graph for this function:

◆ ad9467_output_invert()

int32_t ad9467_output_invert ( struct ad9467_dev dev,
int32_t  invert,
int32_t *  ret_stat 
)

Activates the inverted (1) or normal (0) output mode.

Parameters
dev- The device structure.
invert- Invert option. Example: 1 - Activates the inverted output mode; 0 - Activates the normal output mode(default).
ret_stat- Return parameter of the set output mode.
Returns
Error code.
Here is the caller graph for this function:

◆ ad9467_pwr_mode()

int32_t ad9467_pwr_mode ( struct ad9467_dev dev,
int32_t  mode,
int32_t *  ret_mode 
)

Configures the power mode.

Parameters
dev- The device structure.
mode- The power mode. Example: 00 � normal operation(default); 01 � full power-down;
ret_mode- Return parameter of the set power mode.
Returns
Error code.

◆ ad9467_read()

int32_t ad9467_read ( struct ad9467_dev dev,
uint16_t  reg_addr,
uint8_t *  reg_val 
)

Reads data from a register.

Parameters
dev- The device structure.
reg_addr- The address of the register to be read.
reg_val- The value read from the register.
Returns
Returns the read data or negative error code.
Here is the caller graph for this function:

◆ ad9467_remove()

int32_t ad9467_remove ( struct ad9467_dev dev)

Free the resources allocated by ad9467_setup().

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

◆ ad9467_reset_pn23()

int32_t ad9467_reset_pn23 ( struct ad9467_dev dev,
int32_t  rst,
int32_t *  ret_stat 
)

Sets (1) or clears (0) the reset long PN sequence bit(PN23).

Parameters
dev- The device structure.
rst- Reset option. Example: 1 - The PN sequence is held in reset; 0 - The PN sequence resumes from the seed value(0x3AFF).
ret_stat- Return parameter of the set PN23 status.
Returns
Error code.
Here is the caller graph for this function:

◆ ad9467_reset_pn9()

int32_t ad9467_reset_pn9 ( struct ad9467_dev dev,
int32_t  rst,
int32_t *  ret_stat 
)

Sets (1) or clears (0) the reset short PN sequence bit(PN9).

Parameters
dev- The device structure.
rst- Reset option. Example: 1 - The PN sequence is held in reset; 0 - The PN sequence resumes from the seed value(0x92).
ret_stat- Return parameter of the set PN9 status.
Returns
Error code.
Here is the caller graph for this function:

◆ ad9467_set_bits_to_reg()

uint32_t ad9467_set_bits_to_reg ( struct ad9467_dev dev,
uint16_t  register_address,
uint8_t  bits_value,
uint8_t  mask 
)

Sets a bit or a group of bits inside a register without modifying the other bits.

Parameters
dev- The device structure.
register_address- The address of the register to be written.
bits_value- The value of the bit/bits.
mask- The bit/bits position in the register.
Returns
Negative error code or 0 in case of success.
Here is the caller graph for this function:

◆ ad9467_setup()

int32_t ad9467_setup ( struct ad9467_dev **  device,
struct ad9467_init_param  init_param 
)

Configures the test mode and the output mode to a default state.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
Negative error code or 0 in case of success.
Here is the caller graph for this function:

◆ ad9467_test_mode()

int32_t ad9467_test_mode ( struct ad9467_dev dev,
int32_t  mode,
int32_t *  ret_mode 
)

Sets the ADC's test mode.

Parameters
dev- The device structure.
mode- ADC test mode. Example: 0 -> off(default) 1 -> midscale short 2 -> +FS short 3 -> -FS short 4 -> checkerboard output 5 -> PN 23 sequence 6 -> PN 9 sequence 7 -> one/zero word toggle
ret_mode- Return parameter of the set test mode.
Returns
Error code.
Here is the caller graph for this function:

◆ ad9467_transfer()

int32_t ad9467_transfer ( struct ad9467_dev dev)

Initiates a transfer and waits for the operation to end.

Returns
Negative error code or 0 in case of success.
Here is the caller graph for this function:

◆ ad9467_write()

int32_t ad9467_write ( struct ad9467_dev dev,
uint16_t  reg_addr,
uint8_t  reg_val 
)

Writes data into a register.

Parameters
dev- The device structure.
reg_addr- The address of the register to be written.
reg_val- The value to be written into the register.
Returns
Returns 0 in case of success or negative error code.
Here is the caller graph for this function: