no-OS
Functions | Variables
ad9250.c File Reference

Implementation of AD9250 Driver. More...

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

Functions

int32_t ad9250_set_bits_to_reg (struct ad9250_dev *dev, uint32_t register_address, uint8_t bits_value, uint8_t mask)
 Sets a bit/group of bits inside a register without modifying other bits. More...
 
int32_t ad9250_is_shadow_register (int32_t register_address)
 Checks if the register is shadowed. More...
 
int32_t ad9250_setup (struct ad9250_dev **device, struct ad9250_init_param init_param)
 Configures the device. More...
 
int32_t ad9250_remove (struct ad9250_dev *dev)
 Free the resources allocated by ad9250_setup(). More...
 
int32_t ad9250_read (struct ad9250_dev *dev, int32_t register_address)
 Reads the value of the selected register. More...
 
int32_t ad9250_write (struct ad9250_dev *dev, int32_t register_address, int32_t register_value)
 Writes a value to the selected register. More...
 
int32_t ad9250_transfer (struct ad9250_dev *dev)
 Initiates a transfer and waits for the operation to end. Note: This function may be called after a shadowed register was written, so that the internal update can actually take place. More...
 
int32_t ad9250_soft_reset (struct ad9250_dev *dev)
 Resets all registers to their default values. More...
 
int32_t ad9250_chip_pwr_mode (struct ad9250_dev *dev, int32_t mode)
 Configures the power mode of the chip. More...
 
int32_t ad9250_select_channel_for_config (struct ad9250_dev *dev, int32_t channel)
 Selects a channel as the current channel for further configurations. More...
 
int32_t ad9250_test_mode (struct ad9250_dev *dev, int32_t mode)
 Sets the ADC's test mode. More...
 
int32_t ad9250_offset_adj (struct ad9250_dev *dev, int32_t adj)
 Sets the offset adjustment. More...
 
int32_t ad9250_output_disable (struct ad9250_dev *dev, int32_t en)
 Disables (1) or enables (0) the data output. Note: This function modifies a shadowed register, therefore a call of ad9250_transfer() is required for the internal update to take place. More...
 
int32_t ad9250_output_invert (struct ad9250_dev *dev, int32_t invert)
 Activates the inverted (1) or normal (0) output mode. Note: This function modifies a shadowed register, therefore a call of ad9250_transfer() is required for the internal update to take place. More...
 
int32_t ad9250_output_format (struct ad9250_dev *dev, int32_t format)
 Specifies the output format. Note: This function modifies a shadowed register, therefore a call of ad9250_transfer() is required for the internal update to take place. More...
 
int32_t ad9250_reset_pn9 (struct ad9250_dev *dev, int32_t rst)
 Sets (1) or clears (0) the reset short PN sequence bit(PN9). More...
 
int32_t ad9250_reset_pn23 (struct ad9250_dev *dev, int32_t rst)
 Sets (1) or clears (0) the reset long PN sequence bit(PN23). More...
 
int32_t ad9250_set_user_pattern (struct ad9250_dev *dev, int32_t pattern_no, int32_t user_pattern)
 Configures a User Test Pattern. More...
 
int32_t ad9250_bist_enable (struct ad9250_dev *dev, int32_t enable)
 Enables the Build-In-Self-Test. More...
 
int32_t ad9250_bist_reset (struct ad9250_dev *dev, int32_t reset)
 Resets the Build-In-Self-Test. More...
 
int32_t ad9250_jesd204b_set_frames (struct ad9250_dev *dev, int32_t k_frames)
 Sets number of frames per multiframe (K). More...
 
int32_t ad9250_jesd204b_setup (struct ad9250_dev *dev)
 Configures the JESD204B interface. More...
 
int32_t ad9250_jesd204b_pwr_mode (struct ad9250_dev *dev, int32_t mode)
 Configures the power mode of the JESD204B data transmit block. More...
 
int32_t ad9250_jesd204b_select_test_injection_point (struct ad9250_dev *dev, int32_t inj_point)
 Selects the point in the processing path of a lane, where the test data will be inserted. More...
 
int32_t ad9250_jesd204b_test_mode (struct ad9250_dev *dev, int32_t test_mode)
 Selects a JESD204B test mode. More...
 
int32_t ad9250_jesd204b_invert_logic (struct ad9250_dev *dev, int32_t invert)
 Inverts the logic of JESD204B bits. More...
 
int32_t ad9250_fast_detect_setup (struct ad9250_dev *dev)
 Configures the Fast-Detect module. More...
 
int32_t ad9250_dcc_enable (struct ad9250_dev *dev, int32_t enable)
 Enables DC correction for use in the output data signal path. More...
 
int32_t ad9250_dcc_bandwidth (struct ad9250_dev *dev, int32_t bw)
 Selects the bandwidth value for the DC correction circuit. More...
 
int32_t ad9250_dcc_freeze (struct ad9250_dev *dev, int32_t freeze)
 Freezes DC correction value. More...
 

Variables

const int32_t shadow_regs [SHADOW_REGISTER_COUNT]
 

Detailed Description

Implementation of AD9250 Driver.

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

Copyright 2013(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

◆ ad9250_bist_enable()

int32_t ad9250_bist_enable ( struct ad9250_dev dev,
int32_t  enable 
)

Enables the Build-In-Self-Test.

Parameters
dev- The device structure.
enable- enable option.
Returns
Returns negative error code or the state of the enable bit.

◆ ad9250_bist_reset()

int32_t ad9250_bist_reset ( struct ad9250_dev dev,
int32_t  reset 
)

Resets the Build-In-Self-Test.

Parameters
dev- The device structure.
reset- reset option.
Returns
Returns negative error code or the state of the reset bit.

◆ ad9250_chip_pwr_mode()

int32_t ad9250_chip_pwr_mode ( struct ad9250_dev dev,
int32_t  mode 
)

Configures the power mode of the chip.

Parameters
dev- The device structure.
mode- The power mode. Example: 00 � normal operation(default); 01 � power-down; 10 - standby.
Returns
Returns negative error code or the set power mode.

◆ ad9250_dcc_bandwidth()

int32_t ad9250_dcc_bandwidth ( struct ad9250_dev dev,
int32_t  bw 
)

Selects the bandwidth value for the DC correction circuit.

Parameters
dev- The device structure.
bw- DC correction bandwidth. Example: 0 - 2387.32 Hz at Sample Rate of 245.76 MSPS 1 - 1193.66 Hz at Sample Rate of 245.76 MSPS ... 13 - 0.29 Hz at Sample Rate of 245.76 MSPS
Returns
Returns negative error code or the state of the bandwidth bits.

◆ ad9250_dcc_enable()

int32_t ad9250_dcc_enable ( struct ad9250_dev dev,
int32_t  enable 
)

Enables DC correction for use in the output data signal path.

Parameters
dev- The device structure.
enable- enable option. Example: 0 - correction off 1 - correction on
Returns
Returns negative error code or the status of the enable bit.

◆ ad9250_dcc_freeze()

int32_t ad9250_dcc_freeze ( struct ad9250_dev dev,
int32_t  freeze 
)

Freezes DC correction value.

Parameters
dev- The device structure.
freeze- freeze option. Example: 0 - calculates the correction value 1 - freezes the DC correction at its current state
Returns
Returns negative error code or the status of the freeze bit.

◆ ad9250_fast_detect_setup()

int32_t ad9250_fast_detect_setup ( struct ad9250_dev dev)

Configures the Fast-Detect module.

Parameters
dev- The device structure.
Returns
Returns negative error code or 0 in case of success.
Here is the caller graph for this function:

◆ ad9250_is_shadow_register()

int32_t ad9250_is_shadow_register ( int32_t  register_address)

Checks if the register is shadowed.

Parameters
register_address- The address of the register to be checked.
Returns
Returns the index of the shadow register or 0 if the register is not shadowed.
Here is the caller graph for this function:

◆ ad9250_jesd204b_invert_logic()

int32_t ad9250_jesd204b_invert_logic ( struct ad9250_dev dev,
int32_t  invert 
)

Inverts the logic of JESD204B bits.

Parameters
dev- The device structure.
invert- Invert option. Example: 1 - Activates the inverted mode 0 - Activates the normal mode
Returns
Returns negative error code or the set mode.
Here is the caller graph for this function:

◆ ad9250_jesd204b_pwr_mode()

int32_t ad9250_jesd204b_pwr_mode ( struct ad9250_dev dev,
int32_t  mode 
)

Configures the power mode of the JESD204B data transmit block.

Parameters
dev- The device structure.
mode- The power mode. Example: 00 � normal operation(default); 01 � power-down; 10 - standby.
Returns
Returns negative error code or the set power mode.

◆ ad9250_jesd204b_select_test_injection_point()

int32_t ad9250_jesd204b_select_test_injection_point ( struct ad9250_dev dev,
int32_t  inj_point 
)

Selects the point in the processing path of a lane, where the test data will be inserted.

Parameters
dev- The device structure.
inj_point- The point in the processing path of a lane. Example: 1 - a 10-bit data is inserted at 8B/10B ENCODER output 2 - a 8-bit at scrambler input
Returns
Returns negative error code or the status of the data injection point bit.

◆ ad9250_jesd204b_set_frames()

int32_t ad9250_jesd204b_set_frames ( struct ad9250_dev dev,
int32_t  k_frames 
)

Sets number of frames per multiframe (K).

Parameters
dev- The device structure.
k_frames- Number of frames. Must be a multiple of 4. Range: Ceil(17/F) to 32, where F - is the number of octets per frame.
Returns
Returns negative error code or actual number of frames that can be set.
Here is the caller graph for this function:

◆ ad9250_jesd204b_setup()

int32_t ad9250_jesd204b_setup ( struct ad9250_dev dev)

Configures the JESD204B interface.

Parameters
dev- The device structure.
Returns
Returns negative error code or 0 in case of success.
Here is the caller graph for this function:

◆ ad9250_jesd204b_test_mode()

int32_t ad9250_jesd204b_test_mode ( struct ad9250_dev dev,
int32_t  test_mode 
)

Selects a JESD204B test mode.

Parameters
dev- The device structure.
test_mode- mode option. Example: 0 - test mode disabled 1 - alternating checker board 2 - 1/0 word toggle 3 - PN23 sequence 4 - PN9 sequence 5 - continuous/repeat user test mode 6 - single user test mode 7 - reserved 8 - modified RPAT test sequence 12 - PN7 sequence 13 - PN15 sequence
Returns
Returns the set test mode or negative error code.

◆ ad9250_offset_adj()

int32_t ad9250_offset_adj ( struct ad9250_dev dev,
int32_t  adj 
)

Sets the offset adjustment.

Parameters
dev- The device structure.
adj- The offset adjust value in LSBs from +31 to -32.
Returns
Returns negative error code or the set offset adjustment.

◆ ad9250_output_disable()

int32_t ad9250_output_disable ( struct ad9250_dev dev,
int32_t  en 
)

Disables (1) or enables (0) the data output. Note: This function modifies a shadowed register, therefore a call of ad9250_transfer() is required for the internal update to take place.

Parameters
dev- The device structure.
en- Enable option. Example: 1 - Disables the data output; 0 - Enables the data output(default).
Returns
Returns negative error code or the output disable state.

◆ ad9250_output_format()

int32_t ad9250_output_format ( struct ad9250_dev dev,
int32_t  format 
)

Specifies the output format. Note: This function modifies a shadowed register, therefore a call of ad9250_transfer() is required for the internal update to take place.

Parameters
dev- The device structure.
format- The output format. Example: 0 � offset binary(default); 1 � two's complement;
Returns
Returns negative error code or the set output format.

◆ ad9250_output_invert()

int32_t ad9250_output_invert ( struct ad9250_dev dev,
int32_t  invert 
)

Activates the inverted (1) or normal (0) output mode. Note: This function modifies a shadowed register, therefore a call of ad9250_transfer() is required for the internal update to take place.

Parameters
dev- The device structure.
invert- Invert option. Example: 1 - Activates the inverted output mode; 0 - Activates the normal output mode(default).
Returns
Returns negative error code or the set output mode.

◆ ad9250_read()

int32_t ad9250_read ( struct ad9250_dev dev,
int32_t  register_address 
)

Reads the value of the selected register.

Parameters
dev- The device structure.
register_address- The address of the register to read.
Returns
reg_value - The register's value or negative error code.
Here is the caller graph for this function:

◆ ad9250_remove()

int32_t ad9250_remove ( struct ad9250_dev dev)

Free the resources allocated by ad9250_setup().

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

◆ ad9250_reset_pn23()

int32_t ad9250_reset_pn23 ( struct ad9250_dev dev,
int32_t  rst 
)

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

Parameters
dev- The device structure.
rst- Enable option. Example: 1 - The PN sequence is held in reset; 0 - The PN sequence resumes from the seed value(0x3AFF).
Returns
Returns negative error code or the set PN23 status.

◆ ad9250_reset_pn9()

int32_t ad9250_reset_pn9 ( struct ad9250_dev dev,
int32_t  rst 
)

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

Parameters
dev- The device structure.
rst- Enable option. Example: 1 - The PN sequence is held in reset; 0 - The PN sequence resumes from the seed value(0x92).
Returns
Returns negative error code or the set PN9 status.

◆ ad9250_select_channel_for_config()

int32_t ad9250_select_channel_for_config ( struct ad9250_dev dev,
int32_t  channel 
)

Selects a channel as the current channel for further configurations.

Parameters
dev- The device structure.
channel- Channel option. Example 1 - channel A 2 - channel B 3 - channel A and channel B
Returns
Returns negative error code or the selected channel.

◆ ad9250_set_bits_to_reg()

int32_t ad9250_set_bits_to_reg ( struct ad9250_dev dev,
uint32_t  register_address,
uint8_t  bits_value,
uint8_t  mask 
)

Sets a bit/group of bits inside a register without modifying 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
Returns negative error code or 0 in case of success.
Here is the caller graph for this function:

◆ ad9250_set_user_pattern()

int32_t ad9250_set_user_pattern ( struct ad9250_dev dev,
int32_t  pattern_no,
int32_t  user_pattern 
)

Configures a User Test Pattern.

Parameters
dev- The device structure.
pattern_no- Selects the patterns to be configured. Range 1..4.
user_pattern- Users's pattern.
Returns
Returns negative error code or the selected user pattern.

◆ ad9250_setup()

int32_t ad9250_setup ( struct ad9250_dev **  device,
struct ad9250_init_param  init_param 
)

Configures the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
Returns negative error code or 0 in case of success.

◆ ad9250_soft_reset()

int32_t ad9250_soft_reset ( struct ad9250_dev dev)

Resets all registers to their default values.

Parameters
dev- The device structure.
Returns
Returns negative error code or 0 in case of success.
Here is the caller graph for this function:

◆ ad9250_test_mode()

int32_t ad9250_test_mode ( struct ad9250_dev dev,
int32_t  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 sequence long 6 -> PN 9 short 7 -> one/zero word toggle 8 -> user test mode 9 to 14 -> unused 15 -> ramp output
Returns
Returns the set test mode or negative error code.

◆ ad9250_transfer()

int32_t ad9250_transfer ( struct ad9250_dev dev)

Initiates a transfer and waits for the operation to end. Note: This function may be called after a shadowed register was written, so that the internal update can actually take place.

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

◆ ad9250_write()

int32_t ad9250_write ( struct ad9250_dev dev,
int32_t  register_address,
int32_t  register_value 
)

Writes a value to the selected register.

Parameters
dev- The device structure.
register_address- The address of the register to write to.
register_value- The value to write to the register.
Returns
Returns 0 in case of success or negative error code.
Here is the caller graph for this function:

Variable Documentation

◆ shadow_regs

const int32_t shadow_regs[SHADOW_REGISTER_COUNT]
Initial value:
= {
0,
0x01,
0x00,
0x00,
0x00,
0x00,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00,
0x00
}