no-OS
Functions | Variables
ad7768.c File Reference

Implementation of AD7768 Driver. More...

#include <stdio.h>
#include <stdlib.h>
#include "ad7768.h"
Include dependency graph for ad7768.c:

Functions

int32_t ad7768_spi_read (ad7768_dev *dev, uint8_t reg_addr, uint8_t *reg_data)
 
int32_t ad7768_spi_write (ad7768_dev *dev, uint8_t reg_addr, uint8_t reg_data)
 
int32_t ad7768_spi_read_mask (ad7768_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t *data)
 
int32_t ad7768_spi_write_mask (ad7768_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t data)
 
int32_t ad7768_set_sleep_mode (ad7768_dev *dev, ad7768_sleep_mode mode)
 
int32_t ad7768_get_sleep_mode (ad7768_dev *dev, ad7768_sleep_mode *mode)
 
int32_t ad7768_set_mode_pins (ad7768_dev *dev, uint8_t state)
 
int32_t ad7768_set_power_mode (ad7768_dev *dev, ad7768_power_mode mode)
 
int32_t ad7768_get_power_mode (ad7768_dev *dev, ad7768_power_mode *mode)
 
int32_t ad7768_set_mclk_div (ad7768_dev *dev, ad7768_mclk_div clk_div)
 
int32_t ad7768_get_mclk_div (ad7768_dev *dev, ad7768_mclk_div *clk_div)
 
int32_t ad7768_set_dclk_div (ad7768_dev *dev, ad7768_dclk_div clk_div)
 
int32_t ad7768_get_dclk_div (ad7768_dev *dev, ad7768_dclk_div *clk_div)
 
int32_t ad7768_set_conv_op (ad7768_dev *dev, ad7768_conv_op conv_op)
 
int32_t ad7768_get_conv_op (ad7768_dev *dev, ad7768_conv_op *conv_op)
 
int32_t ad7768_set_crc_sel (ad7768_dev *dev, ad7768_crc_sel crc_sel)
 
int32_t ad7768_get_crc_sel (ad7768_dev *dev, ad7768_crc_sel *crc_sel)
 
int32_t ad7768_set_ch_state (ad7768_dev *dev, ad7768_ch ch, ad7768_ch_state state)
 
int32_t ad7768_get_ch_state (ad7768_dev *dev, ad7768_ch ch, ad7768_ch_state *state)
 
int32_t ad7768_set_mode_config (ad7768_dev *dev, ad7768_ch_mode mode, ad7768_filt_type filt_type, ad7768_dec_rate dec_rate)
 
int32_t ad7768_get_mode_config (ad7768_dev *dev, ad7768_ch_mode mode, ad7768_filt_type *filt_type, ad7768_dec_rate *dec_rate)
 
int32_t ad7768_set_ch_mode (ad7768_dev *dev, ad7768_ch ch, ad7768_ch_mode mode)
 
int32_t ad7768_get_ch_mode (ad7768_dev *dev, ad7768_ch ch, ad7768_ch_mode *mode)
 
int32_t ad7768_setup (ad7768_dev **device, ad7768_init_param init_param)
 

Variables

const uint8_t standard_pin_ctrl_mode_sel [3][4]
 
const uint8_t one_shot_pin_ctrl_mode_sel [3][4]
 

Detailed Description

Implementation of AD7768 Driver.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

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

◆ ad7768_get_ch_mode()

int32_t ad7768_get_ch_mode ( ad7768_dev dev,
ad7768_ch  ch,
ad7768_ch_mode mode 
)

Get the channel mode.

Parameters
dev- The device structure.
ch- The channel number. Accepted values: AD7768_CH0 AD7768_CH1 AD7768_CH2 AD7768_CH3 AD7768_CH4 AD7768_CH5 AD7768_CH6 AD7768_CH7
mode- The channel mode.
Returns
0 in case of success, negative error code otherwise.

◆ ad7768_get_ch_state()

int32_t ad7768_get_ch_state ( ad7768_dev dev,
ad7768_ch  ch,
ad7768_ch_state state 
)

Get the channel state.

Parameters
dev- The device structure.
ch- The channel number. Accepted values: AD7768_CH0 AD7768_CH1 AD7768_CH2 AD7768_CH3 AD7768_CH4 AD7768_CH5 AD7768_CH6 AD7768_CH7
state- The channel state.
Returns
0 in case of success, negative error code otherwise.

◆ ad7768_get_conv_op()

int32_t ad7768_get_conv_op ( ad7768_dev dev,
ad7768_conv_op conv_op 
)

Get the conversion operation mode.

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

◆ ad7768_get_crc_sel()

int32_t ad7768_get_crc_sel ( ad7768_dev dev,
ad7768_crc_sel crc_sel 
)

Get the CRC selection.

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

◆ ad7768_get_dclk_div()

int32_t ad7768_get_dclk_div ( ad7768_dev dev,
ad7768_dclk_div clk_div 
)

Get the DCLK divider.

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

◆ ad7768_get_mclk_div()

int32_t ad7768_get_mclk_div ( ad7768_dev dev,
ad7768_mclk_div clk_div 
)

Get the MCLK divider.

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

◆ ad7768_get_mode_config()

int32_t ad7768_get_mode_config ( ad7768_dev dev,
ad7768_ch_mode  mode,
ad7768_filt_type filt_type,
ad7768_dec_rate dec_rate 
)

Get the mode configuration.

Parameters
dev- The device structure.
mode- The channel mode.
filt_type- The filter type.
dec_rate- The decimation rate.
Returns
0 in case of success, negative error code otherwise.

◆ ad7768_get_power_mode()

int32_t ad7768_get_power_mode ( ad7768_dev dev,
ad7768_power_mode mode 
)

Get the device power mode.

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

◆ ad7768_get_sleep_mode()

int32_t ad7768_get_sleep_mode ( ad7768_dev dev,
ad7768_sleep_mode mode 
)

Get the device sleep mode.

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

◆ ad7768_set_ch_mode()

int32_t ad7768_set_ch_mode ( ad7768_dev dev,
ad7768_ch  ch,
ad7768_ch_mode  mode 
)

Set the channel mode.

Parameters
dev- The device structure.
ch- The channel number. Accepted values: AD7768_CH0 AD7768_CH1 AD7768_CH2 AD7768_CH3 AD7768_CH4 AD7768_CH5 AD7768_CH6 AD7768_CH7
mode- The channel mode. Accepted values: AD7768_MODE_A AD7768_MODE_B
Returns
0 in case of success, negative error code otherwise.

◆ ad7768_set_ch_state()

int32_t ad7768_set_ch_state ( ad7768_dev dev,
ad7768_ch  ch,
ad7768_ch_state  state 
)

Set the channel state.

Parameters
dev- The device structure.
ch- The channel number. Accepted values: AD7768_CH0 AD7768_CH1 AD7768_CH2 AD7768_CH3 AD7768_CH4 AD7768_CH5 AD7768_CH6 AD7768_CH7
state- The channel state. Accepted values: AD7768_ENABLED AD7768_STANDBY
Returns
0 in case of success, negative error code otherwise.

◆ ad7768_set_conv_op()

int32_t ad7768_set_conv_op ( ad7768_dev dev,
ad7768_conv_op  conv_op 
)

Set the conversion operation mode.

Parameters
dev- The device structure.
conv_op- The conversion operation mode. Accepted values: AD7768_STANDARD_CONV AD7768_ONE_SHOT_CONV
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7768_set_crc_sel()

int32_t ad7768_set_crc_sel ( ad7768_dev dev,
ad7768_crc_sel  crc_sel 
)

Set the CRC selection.

Parameters
dev- The device structure.
crc_sel- The CRC selection. Accepted values: AD7768_NO_CRC AD7768_CRC_4 AD7768_CRC_16
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7768_set_dclk_div()

int32_t ad7768_set_dclk_div ( ad7768_dev dev,
ad7768_dclk_div  clk_div 
)

Set the DCLK divider.

Parameters
dev- The device structure.
clk_div- The DCLK divider. Accepted values: AD7768_DCLK_DIV_1 AD7768_DCLK_DIV_2 AD7768_DCLK_DIV_4 AD7768_DCLK_DIV_8
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7768_set_mclk_div()

int32_t ad7768_set_mclk_div ( ad7768_dev dev,
ad7768_mclk_div  clk_div 
)

Set the MCLK divider.

Parameters
dev- The device structure.
clk_div- The MCLK divider. Accepted values: AD7768_MCLK_DIV_32 AD7768_MCLK_DIV_8 AD7768_MCLK_DIV_4
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7768_set_mode_config()

int32_t ad7768_set_mode_config ( ad7768_dev dev,
ad7768_ch_mode  mode,
ad7768_filt_type  filt_type,
ad7768_dec_rate  dec_rate 
)

Set the mode configuration.

Parameters
dev- The device structure.
mode- The channel mode. Accepted values: AD7768_MODE_A AD7768_MODE_B
filt_type- The filter type. Accepted values: AD7768_FILTER_WIDEBAND AD7768_FILTER_SINC,
dec_rate- The decimation rate. Accepted values: AD7768_DEC_X32 AD7768_DEC_X64 AD7768_DEC_X128 AD7768_DEC_X256 AD7768_DEC_X512 AD7768_DEC_X1024
Returns
0 in case of success, negative error code otherwise.

◆ ad7768_set_mode_pins()

int32_t ad7768_set_mode_pins ( ad7768_dev dev,
uint8_t  state 
)

Internal set MODEx pins function.

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

◆ ad7768_set_power_mode()

int32_t ad7768_set_power_mode ( ad7768_dev dev,
ad7768_power_mode  mode 
)

Set the device power mode.

Parameters
dev- The device structure.
mode- The device power mode. Accepted values: AD7768_ECO AD7768_MEDIAN AD7768_FAST
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7768_set_sleep_mode()

int32_t ad7768_set_sleep_mode ( ad7768_dev dev,
ad7768_sleep_mode  mode 
)

Set the device sleep mode.

Parameters
dev- The device structure.
mode- The device sleep mode. Accepted values: AD7768_ACTIVE AD7768_SLEEP
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad7768_setup()

int32_t ad7768_setup ( ad7768_dev **  device,
ad7768_init_param  init_param 
)

Initialize the device.

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

◆ ad7768_spi_read()

int32_t ad7768_spi_read ( ad7768_dev dev,
uint8_t  reg_addr,
uint8_t *  reg_data 
)

SPI read from device.

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

◆ ad7768_spi_read_mask()

int32_t ad7768_spi_read_mask ( ad7768_dev dev,
uint8_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
0 in case of success, negative error code otherwise.

◆ ad7768_spi_write()

int32_t ad7768_spi_write ( ad7768_dev dev,
uint8_t  reg_addr,
uint8_t  reg_data 
)

SPI write to device.

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

◆ ad7768_spi_write_mask()

int32_t ad7768_spi_write_mask ( ad7768_dev dev,
uint8_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
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

Variable Documentation

◆ one_shot_pin_ctrl_mode_sel

const uint8_t one_shot_pin_ctrl_mode_sel[3][4]
Initial value:
= {
{0xC, 0xFF, 0xFF, 0xFF},
{0xD, 0xFF, 0xFF, 0xFF},
{0xF, 0xE, 0xFF, 0xFF},
}

◆ standard_pin_ctrl_mode_sel

const uint8_t standard_pin_ctrl_mode_sel[3][4]
Initial value:
= {
{0x0, 0x1, 0x2, 0x3},
{0x4, 0x5, 0x6, 0x7},
{0x8, 0x9, 0xA, 0xB},
}