no-OS
|
Implementation of AD7779 Driver. More...
#include <stdio.h>
#include <stdlib.h>
#include "ad7779.h"
#include "no_os_util.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
Variables | |
const uint8_t | pin_mode_options [16][4] |
Implementation of AD7779 Driver.
Copyright 2016(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:
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.
int32_t ad7771_get_sinc5_filter_state | ( | ad7779_dev * | dev, |
ad7779_state * | state | ||
) |
Get the state (enable, disable) of the SINC5 filter.
dev | - The device structure. |
state | - The SINC5 filter state. |
int32_t ad7771_set_sinc5_filter_state | ( | ad7779_dev * | dev, |
ad7779_state | state | ||
) |
Set the state (enable, disable) of the SINC5 filter.
dev | - The device structure. |
state | - The SINC5 filter state. Accepted values: AD7779_ENABLE AD7779_DISABLE |
uint8_t ad7779_compute_crc8 | ( | uint8_t * | data, |
uint8_t | data_size | ||
) |
Compute CRC8 checksum.
data | - The data buffer. |
data_size | - The size of the data buffer. |
int32_t ad7779_do_single_sar_conv | ( | ad7779_dev * | dev, |
ad7779_sar_mux | mux, | ||
uint16_t * | sar_code | ||
) |
Do a single SAR conversion.
dev | - The device structure. |
mux | - The SAR mux input configuration. Accepted values: AD7779_AUXAINP_AUXAINN AD7779_DVBE_AVSSX AD7779_REF1P_REF1N AD7779_REF2P_REF2N AD7779_REF_OUT_AVSSX AD7779_VCM_AVSSX AD7779_AREG1CAP_AVSSX_ATT AD7779_AREG2CAP_AVSSX_ATT AD7779_DREGCAP_DGND_ATT AD7779_AVDD1A_AVSSX_ATT AD7779_AVDD1B_AVSSX_ATT AD7779_AVDD2A_AVSSX_ATT AD7779_AVDD2B_AVSSX_ATT AD7779_IOVDD_DGND_ATT AD7779_AVDD4_AVSSX AD7779_DGND_AVSS1A_ATT AD7779_DGND_AVSS1B_ATT AD7779_DGND_AVSSX_ATT AD7779_AVDD4_AVSSX_ATT AD7779_REF1P_AVSSX AD7779_REF2P_AVSSX AD7779_AVSSX_AVDD4_ATT |
sar_code | - SAR conversion code. |
int32_t ad7779_do_spi_soft_reset | ( | ad7779_dev * | dev | ) |
Do a SPI software reset.
dev | - The device structure. |
int32_t ad7779_do_update_mode_pins | ( | ad7779_dev * | dev | ) |
Update the state of the MODEx pins according to the settings specified in the device structure.
dev | - The device structure. |
int32_t ad7779_get_dclk_div | ( | ad7779_dev * | dev, |
ad7779_dclk_div * | div | ||
) |
Get the DCLK divider.
dev | - The device structure. |
div | - The DCLK divider. |
int32_t ad7779_get_dec_rate | ( | ad7779_dev * | dev, |
uint16_t * | int_val, | ||
uint16_t * | dec_val | ||
) |
Get the decimation rate.
dev | - The device structure. |
int_val | - The integer value. |
dec_val | - The decimal value. |
int32_t ad7779_get_gain | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
ad7779_gain * | gain | ||
) |
Get the gain of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
gain | - The gain value. |
int32_t ad7779_get_gain_corr | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
uint32_t * | gain | ||
) |
Get the gain correction of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
gain | - The gain value. |
int32_t ad7779_get_offset_corr | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
uint32_t * | offset | ||
) |
Get the offset correction of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
offset | - The offset value. |
int32_t ad7779_get_power_mode | ( | ad7779_dev * | dev, |
ad7779_pwr_mode * | pwr_mode | ||
) |
Get the power mode.
dev | - The device structure. |
pwr_mode | - The power mode. |
int32_t ad7779_get_ref_buf_op_mode | ( | ad7779_dev * | dev, |
ad7779_refx_pin | refx_pin, | ||
ad7779_ref_buf_op_mode * | mode | ||
) |
Get the reference buffer operation mode of the selected pin.
dev | - The device structure. |
refx_pin | - The selected pin. Accepted values: AD7779_REFX_P AD7779_REFX_N |
mode | - The reference buffer operation mode. Accepted values: AD7779_REF_BUF_ENABLED AD7779_REF_BUF_PRECHARGED AD7779_REF_BUF_DISABLED |
int32_t ad7779_get_reference_type | ( | ad7779_dev * | dev, |
ad7779_ref_type * | ref_type | ||
) |
Get the reference type.
dev | - The device structure. |
ref_type | - The reference type. |
int32_t ad7779_get_sar_cfg | ( | ad7779_dev * | dev, |
ad7779_state * | state, | ||
ad7779_sar_mux * | mux | ||
) |
Get the SAR ADC configuration.
dev | - The device structure. |
state | - The SAR ADC state. |
mux | - The SAR mux input configuration. |
int32_t ad7779_get_spi_op_mode | ( | ad7779_dev * | dev, |
ad7779_spi_op_mode * | mode | ||
) |
Get SPI operation mode.
dev | - The device structure. |
mode | - The SPI operation mode. |
int32_t ad7779_get_state | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
ad7779_state * | state | ||
) |
Get the state (enable, disable) of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
state | - The channel state. |
int32_t ad7779_get_sync_offset | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
uint8_t * | sync_offset | ||
) |
Get the synchronization offset of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
sync_offset | - The synchronization offset value. |
int32_t ad7779_init | ( | ad7779_dev ** | device, |
ad7779_init_param | init_param | ||
) |
Initialize the device.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int32_t ad7779_remove | ( | ad7779_dev * | dev | ) |
Free the resources allocated by ad7779_init().
dev | - The device structure. |
int32_t ad7779_set_dclk_div | ( | ad7779_dev * | dev, |
ad7779_dclk_div | div | ||
) |
Set the DCLK divider.
dev | - The device structure. |
div | - The DCLK divider. Accepted values: AD7779_DCLK_DIV_1 AD7779_DCLK_DIV_2 AD7779_DCLK_DIV_4 AD7779_DCLK_DIV_8 AD7779_DCLK_DIV_16 AD7779_DCLK_DIV_32 AD7779_DCLK_DIV_64 AD7779_DCLK_DIV_128 |
int32_t ad7779_set_dec_rate | ( | ad7779_dev * | dev, |
uint16_t | int_val, | ||
uint16_t | dec_val | ||
) |
Set the decimation rate.
dev | - The device structure. |
int_val | - The integer value. |
dec_val | - The decimal value. |
int32_t ad7779_set_gain | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
ad7779_gain | gain | ||
) |
Set the gain of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
gain | - The gain value. Accepted values: AD7779_GAIN_1 AD7779_GAIN_2 AD7779_GAIN_4 AD7779_GAIN_8 |
int32_t ad7779_set_gain_corr | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
uint32_t | gain | ||
) |
Set the gain correction of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
gain | - The gain value. |
int32_t ad7779_set_offset_corr | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
uint32_t | offset | ||
) |
Set the offset correction of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
offset | - The offset value. |
int32_t ad7779_set_power_mode | ( | ad7779_dev * | dev, |
ad7779_pwr_mode | pwr_mode | ||
) |
Set the power mode.
dev | - The device structure. |
pwr_mode | - The power mode. Accepted values: AD7779_HIGH_RES AD7779_LOW_PWR |
int32_t ad7779_set_ref_buf_op_mode | ( | ad7779_dev * | dev, |
ad7779_refx_pin | refx_pin, | ||
ad7779_ref_buf_op_mode | mode | ||
) |
Set the reference buffer operation mode of the selected pin.
dev | - The device structure. |
refx_pin | - The selected pin. Accepted values: AD7779_REFX_P AD7779_REFX_N |
mode | - The reference buffer operation mode. Accepted values: AD7779_REF_BUF_ENABLED AD7779_REF_BUF_PRECHARGED AD7779_REF_BUF_DISABLED |
int32_t ad7779_set_reference_type | ( | ad7779_dev * | dev, |
ad7779_ref_type | ref_type | ||
) |
Set the reference type.
dev | - The device structure. |
ref_type | - The reference type. Accepted values: AD7779_EXT_REF AD7779_INT_REF AD7779_EXT_SUPPLY AD7779_EXT_REF_INV |
int32_t ad7779_set_sar_cfg | ( | ad7779_dev * | dev, |
ad7779_state | state, | ||
ad7779_sar_mux | mux | ||
) |
Set the SAR ADC configuration.
dev | - The device structure. |
state | - The SAR ADC state. Accepted values: AD7779_ENABLE AD7779_DISABLE |
mux | - The SAR mux input configuration. Accepted values: AD7779_AUXAINP_AUXAINN AD7779_DVBE_AVSSX AD7779_REF1P_REF1N AD7779_REF2P_REF2N AD7779_REF_OUT_AVSSX AD7779_VCM_AVSSX AD7779_AREG1CAP_AVSSX_ATT AD7779_AREG2CAP_AVSSX_ATT AD7779_DREGCAP_DGND_ATT AD7779_AVDD1A_AVSSX_ATT AD7779_AVDD1B_AVSSX_ATT AD7779_AVDD2A_AVSSX_ATT AD7779_AVDD2B_AVSSX_ATT AD7779_IOVDD_DGND_ATT AD7779_AVDD4_AVSSX AD7779_DGND_AVSS1A_ATT AD7779_DGND_AVSS1B_ATT AD7779_DGND_AVSSX_ATT AD7779_AVDD4_AVSSX_ATT AD7779_REF1P_AVSSX AD7779_REF2P_AVSSX AD7779_AVSSX_AVDD4_ATT |
int32_t ad7779_set_spi_op_mode | ( | ad7779_dev * | dev, |
ad7779_spi_op_mode | mode | ||
) |
Set SPI operation mode.
dev | - The device structure. |
mode | - The SPI operation mode. Accepted values: AD7779_INT_REG AD7779_SD_CONV AD7779_SAR_CONV |
int32_t ad7779_set_state | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
ad7779_state | state | ||
) |
Set the state (enable, disable) of the channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
state | - The channel state. Accepted values: AD7779_ENABLE AD7779_DISABLE |
int32_t ad7779_set_sync_offset | ( | ad7779_dev * | dev, |
ad7779_ch | ch, | ||
uint8_t | sync_offset | ||
) |
Set the synchronization offset of the selected channel.
dev | - The device structure. |
ch | - The channel number. Accepted values: AD7779_CH0 AD7779_CH1 AD7779_CH2 AD7779_CH3 AD7779_CH4 AD7779_CH5 AD7779_CH6 AD7779_CH7 |
sync_offset | - The synchronization offset value. |
int32_t ad7779_spi_int_reg_read | ( | ad7779_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t * | reg_data | ||
) |
SPI internal register read from device.
dev | - The device structure. |
reg_addr | - The register address. |
reg_data | - The register data. |
int32_t ad7779_spi_int_reg_read_mask | ( | ad7779_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t | mask, | ||
uint8_t * | data | ||
) |
SPI internal register read from device using a mask.
dev | - The device structure. |
reg_addr | - The register address. |
mask | - The mask. |
data | - The register data. |
int32_t ad7779_spi_int_reg_write | ( | ad7779_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t | reg_data | ||
) |
SPI internal register write to device.
dev | - The device structure. |
reg_addr | - The register address. |
reg_data | - The register data. |
int32_t ad7779_spi_int_reg_write_mask | ( | ad7779_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t | mask, | ||
uint8_t | data | ||
) |
SPI internal register write to device using a mask.
dev | - The device structure. |
reg_addr | - The register address. |
mask | - The mask. |
data | - The register data. |
int32_t ad7779_spi_sar_read_code | ( | ad7779_dev * | dev, |
ad7779_sar_mux | mux_next_conv, | ||
uint16_t * | sar_code | ||
) |
SPI SAR conversion code read.
dev | - The device structure. |
mux_next_conv | - The SAR mux input configuration for the next conversion. Accepted values: AD7779_AUXAINP_AUXAINN AD7779_DVBE_AVSSX AD7779_REF1P_REF1N AD7779_REF2P_REF2N AD7779_REF_OUT_AVSSX AD7779_VCM_AVSSX AD7779_AREG1CAP_AVSSX_ATT AD7779_AREG2CAP_AVSSX_ATT AD7779_DREGCAP_DGND_ATT AD7779_AVDD1A_AVSSX_ATT AD7779_AVDD1B_AVSSX_ATT AD7779_AVDD2A_AVSSX_ATT AD7779_AVDD2B_AVSSX_ATT AD7779_IOVDD_DGND_ATT AD7779_AVDD4_AVSSX AD7779_DGND_AVSS1A_ATT AD7779_DGND_AVSS1B_ATT AD7779_DGND_AVSSX_ATT AD7779_AVDD4_AVSSX_ATT AD7779_REF1P_AVSSX AD7779_REF2P_AVSSX AD7779_AVSSX_AVDD4_ATT |
sar_code | - SAR conversion code. |
const uint8_t pin_mode_options[16][4] |