Analog Devices / Mbed OS EVAL-AD4696

Dependencies:   platform_drivers

Embed: (wiki syntax)

« Back to documentation index

ad469x.c File Reference

ad469x.c File Reference

Implementation of ad469x Driver. More...

Go to the source code of this file.

Functions

int32_t ad469x_spi_reg_read (struct ad469x_dev *dev, uint16_t reg_addr, uint8_t *reg_data)
 Read from device.
int32_t ad469x_spi_reg_write (struct ad469x_dev *dev, uint16_t reg_addr, uint8_t reg_data)
 Write to device.
int32_t ad469x_spi_read_mask (struct ad469x_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t *data)
 SPI read from device using a mask.
int32_t ad469x_spi_write_mask (struct ad469x_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data)
 SPI write to device using a mask.
int32_t ad469x_set_reg_access_mode (struct ad469x_dev *dev, enum ad469x_reg_access access)
 Configure register access mode.
static int32_t ad469x_init_gpio (struct ad469x_dev *dev, struct ad469x_init_param *init_param)
 Initialize GPIO driver handlers for the GPIOs in the system.
int32_t ad469x_adv_seq_osr (struct ad469x_dev *dev, uint16_t ch, enum ad469x_osr_ratios ratio)
 Configure over sampling ratio in advanced sequencer mode.
static int32_t ad469x_seq_osr_clear (struct ad469x_dev *dev)
 Configure over sampling ratio to 1 in single and two cycle modes.
int32_t ad469x_std_seq_osr (struct ad469x_dev *dev, enum ad469x_osr_ratios ratio)
 Configure over sampling ratio in standard sequencer mode.
int32_t ad469x_set_channel_sequence (struct ad469x_dev *dev, enum ad469x_channel_sequencing seq)
 Set channel sequence.
int32_t ad469x_adv_sequence_set_num_slots (struct ad469x_dev *dev, uint8_t num_slots)
 Configure advanced sequencer number of slots, temp channel not included.
int32_t ad469x_adv_sequence_set_slot (struct ad469x_dev *dev, uint8_t slot, uint8_t channel)
 Advanced sequencer, assign channel to a slot.
int32_t ad469x_std_sequence_ch (struct ad469x_dev *dev, uint32_t ch_mask)
 Configure standard sequencer channels.
int32_t ad469x_sequence_enable_temp (struct ad469x_dev *dev)
 Enable temperature read at the end of the sequence, for standard and advanced sequencer.
int32_t ad469x_sequence_disable_temp (struct ad469x_dev *dev)
 Disable temperature read at the end of the sequence, for standard and advanced sequencer.
int32_t ad469x_set_busy (struct ad469x_dev *dev, enum ad469x_busy_gp_sel gp_sel)
 Configure converter busy indicator to the output of the specified port.
int32_t ad469x_enter_conversion_mode (struct ad469x_dev *dev)
 Enter conversion mode.
int32_t ad469x_exit_conversion_mode (struct ad469x_dev *dev)
 Exit conversion mode.
static int32_t ad469x_adv_seq_osr_get_util_data (struct ad469x_dev *dev, uint16_t cur_sample, uint32_t *sample)
 Advanced sequencer, get util data bits in a sample.
int32_t ad469x_seq_read_data (struct ad469x_dev *dev, uint32_t *buf, uint16_t samples)
 Read from device when converter has the channel sequencer activated.
int32_t ad469x_read_data (struct ad469x_dev *dev, uint8_t channel, uint32_t *buf, uint16_t samples)
 Read from device.
int32_t ad469x_init (struct ad469x_dev **device, struct ad469x_init_param *init_param)
 Initialize the device.
int32_t ad469x_remove (struct ad469x_dev *dev)
 Free the memory allocated by ad469x_init().

Variables

const uint8_t ad469x_device_resol []
 Device resolution.

Detailed Description

Implementation of ad469x Driver.

Author:
Cristian Pop (cristian.pop@analog.com)

Copyright 2021(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:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • 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.
  • 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.
  • The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software.
  • Use of the software either in source or binary form, must be run on or directly connected to an Analog Devices Inc. component.

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.

Definition in file ad469x.c.


Function Documentation

int32_t ad469x_adv_seq_osr ( struct ad469x_dev dev,
uint16_t  ch,
enum ad469x_osr_ratios  ratio 
)

Configure over sampling ratio in advanced sequencer mode.

Parameters:
[in]dev- ad469x_dev device handler.
[in]ch- Channel to configure.
[in]ratio- OSR ratio.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 272 of file ad469x.c.

static int32_t ad469x_adv_seq_osr_get_util_data ( struct ad469x_dev dev,
uint16_t  cur_sample,
uint32_t *  sample 
) [static]

Advanced sequencer, get util data bits in a sample.

Parameters:
[in]dev- ad469x_dev device handler.
[in]cur_sample- Current sample number
[in]sample- Sample data
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 672 of file ad469x.c.

int32_t ad469x_adv_sequence_set_num_slots ( struct ad469x_dev dev,
uint8_t  num_slots 
)

Configure advanced sequencer number of slots, temp channel not included.

Parameters:
[in]dev- ad469x_dev device handler.
[in]num_slots- Number of slots, max value = 0x7f
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 455 of file ad469x.c.

int32_t ad469x_adv_sequence_set_slot ( struct ad469x_dev dev,
uint8_t  slot,
uint8_t  channel 
)

Advanced sequencer, assign channel to a slot.

Parameters:
[in]dev- ad469x_dev device handler.
[in]slot- Slot number [0x00, 0x7f]
[in]channel- Assigned channel [0x00, 0x0f].
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 483 of file ad469x.c.

int32_t ad469x_enter_conversion_mode ( struct ad469x_dev dev )

Enter conversion mode.

To exit conversion mode send a 5 bit conversion mode command AD469x_CMD_REG_CONFIG_MODE

Parameters:
[in]dev- ad469x_dev device handler.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 607 of file ad469x.c.

int32_t ad469x_exit_conversion_mode ( struct ad469x_dev dev )

Exit conversion mode.

Enter register mode to read/write registers

Parameters:
[in]dev- ad469x_dev device handler.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 621 of file ad469x.c.

int32_t ad469x_init ( struct ad469x_dev **  device,
struct ad469x_init_param init_param 
)

Initialize the device.

Parameters:
[out]device- The device structure.
[in]init_param- The structure that contains the device initial parameters.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 797 of file ad469x.c.

static int32_t ad469x_init_gpio ( struct ad469x_dev dev,
struct ad469x_init_param init_param 
) [static]

Initialize GPIO driver handlers for the GPIOs in the system.

ad469x_init() helper function.

Parameters:
[out]dev- ad469x_dev device handler.
[in]init_param- Pointer to the initialization structure.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Reset to configure pins

Initialize the BUSY GPIO descriptor

Definition at line 224 of file ad469x.c.

int32_t ad469x_read_data ( struct ad469x_dev dev,
uint8_t  channel,
uint32_t *  buf,
uint16_t  samples 
)

Read from device.

Enter register mode to read/write registers

Parameters:
[in]dev- ad469x_dev device handler.
[in]channel- ad469x selected channel.
[out]buf- data buffer.
[in]samples- sample number.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 736 of file ad469x.c.

int32_t ad469x_remove ( struct ad469x_dev dev )

Free the memory allocated by ad469x_init().

Parameters:
[in]dev- Pointer to the device handler.
Returns:
SUCCESS in case of success, FAILURE otherwise

Definition at line 901 of file ad469x.c.

static int32_t ad469x_seq_osr_clear ( struct ad469x_dev dev ) [static]

Configure over sampling ratio to 1 in single and two cycle modes.

Parameters:
[in]dev- ad469x_dev device handler.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 304 of file ad469x.c.

int32_t ad469x_seq_read_data ( struct ad469x_dev dev,
uint32_t *  buf,
uint16_t  samples 
)

Read from device when converter has the channel sequencer activated.

Enter register mode to read/write registers

Parameters:
[in]dev- ad469x_dev device handler.
[out]buf- data buffer.
[in]samples- Number of samples per channel. For example, if with ad469x_std_sequence_ch 2 channel where activated, buf will be filled with 10 samples for each of them. If temp is enable, the there will be an other 10 samples for temperature
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 702 of file ad469x.c.

int32_t ad469x_sequence_disable_temp ( struct ad469x_dev dev )

Disable temperature read at the end of the sequence, for standard and advanced sequencer.

Parameters:
[in]dev- ad469x_dev device handler.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 554 of file ad469x.c.

int32_t ad469x_sequence_enable_temp ( struct ad469x_dev dev )

Enable temperature read at the end of the sequence, for standard and advanced sequencer.

Parameters:
[in]dev- ad469x_dev device handler.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 532 of file ad469x.c.

int32_t ad469x_set_busy ( struct ad469x_dev dev,
enum ad469x_busy_gp_sel  gp_sel 
)

Configure converter busy indicator to the output of the specified port.

Parameters:
[in]dev- ad469x_dev device handler.
[in]gp_sel- Port.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 576 of file ad469x.c.

int32_t ad469x_set_channel_sequence ( struct ad469x_dev dev,
enum ad469x_channel_sequencing  seq 
)

Set channel sequence.

Parameters:
[in]dev- ad469x_dev device handler.
[in]seq- Channel sequence.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 356 of file ad469x.c.

int32_t ad469x_set_reg_access_mode ( struct ad469x_dev dev,
enum ad469x_reg_access  access 
)

Configure register access mode.

Parameters:
[in]dev- ad469x_dev device handler.
[in]access- Access mode
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 208 of file ad469x.c.

int32_t ad469x_spi_read_mask ( struct ad469x_dev dev,
uint16_t  reg_addr,
uint8_t  mask,
uint8_t *  data 
)

SPI read from device using a mask.

Parameters:
dev- The device structure.
reg_addr- The register address.
mask- The mask.
data- The register data.
Returns:
SUCCESS in case of success, negative error code otherwise.

Definition at line 159 of file ad469x.c.

int32_t ad469x_spi_reg_read ( struct ad469x_dev dev,
uint16_t  reg_addr,
uint8_t *  reg_data 
)

Read from device.

Parameters:
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns:
SUCCESS in case of success, negative error code otherwise.

Definition at line 78 of file ad469x.c.

int32_t ad469x_spi_reg_write ( struct ad469x_dev dev,
uint16_t  reg_addr,
uint8_t  reg_data 
)

Write to device.

Parameters:
dev- The device structure.
reg_addr- The register address.
reg_data- The register data. @eturn SUCCESS in case of success, negative error code otherwise.

Definition at line 118 of file ad469x.c.

int32_t ad469x_spi_write_mask ( struct ad469x_dev dev,
uint16_t  reg_addr,
uint8_t  mask,
uint8_t  data 
)

SPI write to device using a mask.

Parameters:
dev- The device structure.
reg_addr- The register address.
mask- The mask.
data- The register data.
Returns:
SUCCESS in case of success, negative error code otherwise.

Definition at line 184 of file ad469x.c.

int32_t ad469x_std_seq_osr ( struct ad469x_dev dev,
enum ad469x_osr_ratios  ratio 
)

Configure over sampling ratio in standard sequencer mode.

Parameters:
[in]dev- ad469x_dev device handler.
[in]ratio- OSR ratio.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 330 of file ad469x.c.

int32_t ad469x_std_sequence_ch ( struct ad469x_dev dev,
uint32_t  ch_mask 
)

Configure standard sequencer channels.

Parameters:
[in]dev- ad469x_dev device handler.
[in]ch_mask- Extra channels to activate.
Returns:
SUCCESS in case of success, FAILURE otherwise.

Definition at line 505 of file ad469x.c.


Variable Documentation

const uint8_t ad469x_device_resol[]
Initial value:
 {
    [AD469x_OSR_1] = 16,
    [AD469x_OSR_4] = 17,
    [AD469x_OSR_16] = 18,
    [AD469x_OSR_64] = 19
}

Device resolution.

Definition at line 60 of file ad469x.c.