no-OS
Functions | Variables
ad7689.c File Reference

Source file for the ad7689 driver. More...

#include <stdlib.h>
#include "ad7689.h"
#include "no_os_util.h"
#include "no_os_error.h"
#include "no_os_print_log.h"
#include "no_os_delay.h"
#include "no_os_alloc.h"
Include dependency graph for ad7689.c:

Functions

int32_t ad7689_init (struct ad7689_dev **dev, struct ad7689_init_param *init_param)
 Initialize the ad7689 driver and create a descriptor. More...
 
int32_t ad7689_write_config (struct ad7689_dev *dev, struct ad7689_config *config)
 Write the device's CFG register. More...
 
int32_t ad7689_read_config (struct ad7689_dev *dev, struct ad7689_config *config)
 Read the device's CFG register. More...
 
int32_t ad7689_read (struct ad7689_dev *dev, uint16_t *data, uint32_t nb_samples)
 Read ADC samples. More...
 
int32_t ad7689_remove (struct ad7689_dev *dev)
 Remove the driver's descriptor by freeing the associated resources. More...
 

Variables

const char * ad7689_device_name []
 

Detailed Description

Source file for the ad7689 driver.

Author
Darius Berghe (dariu.nosp@m.s.be.nosp@m.rghe@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

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

◆ ad7689_init()

int32_t ad7689_init ( struct ad7689_dev **  dev,
struct ad7689_init_param init_param 
)

Initialize the ad7689 driver and create a descriptor.

Parameters
dev- Device descriptor to create.
init_param- Initialization parameters.
Returns
Returns negative error code or 0 in case of success. Example: -EINVAL - Bad input parameters. -ENOMEM - Failed to allocate memory. 0 - No errors encountered.

◆ ad7689_read()

int32_t ad7689_read ( struct ad7689_dev dev,
uint16_t *  data,
uint32_t  nb_samples 
)

Read ADC samples.

This function uses the RAC mode to perform the SPI transactions.

Parameters
dev- Device descriptor.
data- pointer to a large enough buffer where the data gets stored.
nb_samples- Number of samples to read.
Returns
Returns negative error code or 0 in case of success. Example: -EINVAL - Bad input parameters. 0 - No errors encountered.

◆ ad7689_read_config()

int32_t ad7689_read_config ( struct ad7689_dev dev,
struct ad7689_config config 
)

Read the device's CFG register.

If the readback is enabled when making this call, one SPI transaction is enough to retrieve the CFG register.

If the readback is disabled when making this call, it is temporarily enabled, then disabled back. 3 SPI transactions are needed to retrieve the CFG register.

Parameters
dev- Device descriptor.
config- pointer to location where the read configuration gets stored.
Returns
Returns negative error code or 0 in case of success. Example: -EINVAL - Bad input parameters. 0 - No errors encountered.

◆ ad7689_remove()

int32_t ad7689_remove ( struct ad7689_dev dev)

Remove the driver's descriptor by freeing the associated resources.

Parameters
dev- Device descriptor.
Returns
Returns negative error code or 0 in case of success. Example: -EINVAL - Bad input parameters. 0 - No errors encountered.

◆ ad7689_write_config()

int32_t ad7689_write_config ( struct ad7689_dev dev,
struct ad7689_config config 
)

Write the device's CFG register.

Parameters
dev- Device descriptor.
config- Configuration to write.
Returns
Returns negative error code or 0 in case of success. Example: -EINVAL - Bad input parameters. 0 - No errors encountered.
Here is the caller graph for this function:

Variable Documentation

◆ ad7689_device_name

const char* ad7689_device_name[]
Initial value:
= {
"AD7689",
"AD7682",
"AD7949",
"AD7699",
}