no-OS
Macros | Functions
ad463x.c File Reference

Implementation of AD463x Driver. More...

#include <stdlib.h>
#include <stdio.h>
#include "no-os/error.h"
#include "no-os/delay.h"
#include "ad463x.h"
#include "no-os/print_log.h"
Include dependency graph for ad463x.c:

Macros

#define AD463x_TEST_DATA   0xAA
 

Functions

int32_t ad463x_spi_reg_read (struct ad463x_dev *dev, uint16_t reg_addr, uint8_t *reg_data)
 Read device register. More...
 
int32_t ad463x_spi_reg_write (struct ad463x_dev *dev, uint16_t reg_addr, uint8_t reg_data)
 Write device register. More...
 
int32_t ad463x_spi_reg_write_masked (struct ad463x_dev *dev, uint16_t reg_addr, uint8_t mask, uint8_t data)
 SPI write device register using a mask. More...
 
int32_t ad463x_set_pwr_mode (struct ad463x_dev *dev, uint8_t mode)
 Set power mode. More...
 
int32_t ad463x_set_avg_frame_len (struct ad463x_dev *dev, uint8_t mode)
 Set average frame length. More...
 
int32_t ad463x_set_drive_strength (struct ad463x_dev *dev, uint8_t mode)
 Set drive strength. More...
 
int32_t ad463x_exit_reg_cfg_mode (struct ad463x_dev *dev)
 Exit register configuration mode. More...
 
int32_t ad463x_set_ch_gain (struct ad463x_dev *dev, uint8_t ch_idx, uint64_t gain)
 Set channel gain. More...
 
int32_t ad463x_set_ch_offset (struct ad463x_dev *dev, uint8_t ch_idx, uint32_t offset)
 Set channel offset. More...
 
int32_t ad463x_read_data (struct ad463x_dev *dev, uint32_t *buf, uint16_t samples)
 Read from device. Enter register mode to read/write registers. More...
 
int32_t ad463x_init (struct ad463x_dev **device, struct ad463x_init_param *init_param)
 Initialize the device. More...
 
int32_t ad463x_remove (struct ad463x_dev *dev)
 Free the memory allocated by ad463x_init(). More...
 

Detailed Description

Implementation of AD463x Driver.

Author
Antoniu Miclaus (anton.nosp@m.iu.m.nosp@m.iclau.nosp@m.s@an.nosp@m.alog..nosp@m.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:

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.

Macro Definition Documentation

◆ AD463x_TEST_DATA

#define AD463x_TEST_DATA   0xAA

Function Documentation

◆ ad463x_exit_reg_cfg_mode()

int32_t ad463x_exit_reg_cfg_mode ( struct ad463x_dev dev)

Exit register configuration mode.

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

◆ ad463x_init()

int32_t ad463x_init ( struct ad463x_dev **  device,
struct ad463x_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.

Perform Hardware Reset

Here is the caller graph for this function:

◆ ad463x_read_data()

int32_t ad463x_read_data ( struct ad463x_dev dev,
uint32_t *  buf,
uint16_t  samples 
)

Read from device. Enter register mode to read/write registers.

Parameters
[in]dev- ad469x_dev device handler.
[out]buf- data buffer.
[in]samples- sample number.
Returns
SUCCESS in case of success, FAILURE otherwise.
Here is the caller graph for this function:

◆ ad463x_remove()

int32_t ad463x_remove ( struct ad463x_dev dev)

Free the memory allocated by ad463x_init().

Parameters
[in]dev- Pointer to the device handler.
Returns
SUCCESS in case of success, FAILURE otherwise
Here is the caller graph for this function:

◆ ad463x_set_avg_frame_len()

int32_t ad463x_set_avg_frame_len ( struct ad463x_dev dev,
uint8_t  mode 
)

Set average frame length.

Parameters
dev- The device structure.
mode- Average filter frame length mode.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad463x_set_ch_gain()

int32_t ad463x_set_ch_gain ( struct ad463x_dev dev,
uint8_t  ch_idx,
uint64_t  gain 
)

Set channel gain.

Parameters
dev- The device structure.
ch_idx- The channel index.
gain- The gain value scaled by 10000. Example: to set gain 1.5, use 150000
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad463x_set_ch_offset()

int32_t ad463x_set_ch_offset ( struct ad463x_dev dev,
uint8_t  ch_idx,
uint32_t  offset 
)

Set channel offset.

Parameters
dev- The device structure.
ch_idx- The channel index.
offset- The channel offset.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad463x_set_drive_strength()

int32_t ad463x_set_drive_strength ( struct ad463x_dev dev,
uint8_t  mode 
)

Set drive strength.

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

◆ ad463x_set_pwr_mode()

int32_t ad463x_set_pwr_mode ( struct ad463x_dev dev,
uint8_t  mode 
)

Set power mode.

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

◆ ad463x_spi_reg_read()

int32_t ad463x_spi_reg_read ( struct ad463x_dev dev,
uint16_t  reg_addr,
uint8_t *  reg_data 
)

Read device register.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The data read from the register.
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad463x_spi_reg_write()

int32_t ad463x_spi_reg_write ( struct ad463x_dev dev,
uint16_t  reg_addr,
uint8_t  reg_data 
)

Write device register.

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.
Here is the caller graph for this function:

◆ ad463x_spi_reg_write_masked()

int32_t ad463x_spi_reg_write_masked ( struct ad463x_dev dev,
uint16_t  reg_addr,
uint8_t  mask,
uint8_t  data 
)

SPI write device register 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.
Here is the caller graph for this function: