no-OS
|
Implementation of AD413X Driver. More...
#include <stdio.h>
#include <stdlib.h>
#include "ad413x.h"
#include "no_os_error.h"
#include "no_os_irq.h"
#include "no_os_print_log.h"
#include "no_os_delay.h"
#include "no_os_crc8.h"
#include "no_os_spi.h"
#include "no_os_alloc.h"
Functions | |
NO_OS_DECLARE_CRC8_TABLE (ad413x_crc8) | |
int32_t | ad413x_reg_write_msk (struct ad413x_dev *dev, uint32_t reg_addr, uint32_t data, uint32_t mask) |
int32_t | ad413x_set_adc_mode (struct ad413x_dev *dev, enum ad413x_adc_mode mode) |
int32_t | ad413x_set_int_ref (struct ad413x_dev *dev, enum ad413x_int_ref int_ref) |
int32_t | ad413x_data_stat_en (struct ad413x_dev *dev, uint8_t enable) |
int32_t | ad413x_set_gain (struct ad413x_dev *dev, enum ad413x_gain gain, enum ad413x_preset_nb reg_nb) |
int32_t | ad413x_set_ref (struct ad413x_dev *dev, enum ad413x_ref_sel ref, enum ad413x_preset_nb reg_nb) |
int32_t | ad413x_set_ref_buf (struct ad413x_dev *dev, struct ad413x_ref_buf ref_buf, enum ad413x_preset_nb reg_nb) |
int32_t | ad413x_set_filter (struct ad413x_dev *dev, enum ad413x_filter filter, enum ad413x_preset_nb reg_nb) |
int32_t | ad413x_set_settle_time (struct ad413x_dev *dev, enum ad413x_settle_time s_time, enum ad413x_preset_nb reg_nb) |
int32_t | ad413x_set_exc_current (struct ad413x_dev *dev, enum ad413x_exc_current iout0_exc, enum ad413x_exc_current iout1_exc, enum ad413x_preset_nb reg_nb) |
int32_t | ad413x_set_ch_preset (struct ad413x_dev *dev, uint8_t ch_nb, enum ad413x_preset_nb preset_nb) |
int32_t | ad413x_ch_exc_input (struct ad413x_dev *dev, uint8_t ch_nb, enum ad413x_input iout0_exc_inp, enum ad413x_input iout1_exc_inp) |
int32_t | ad413x_ch_en (struct ad413x_dev *dev, uint8_t ch_nb, uint8_t enable) |
int32_t | ad413x_pdsw_en (struct ad413x_dev *dev, uint8_t ch_nb, bool pdsw_en) |
int32_t | ad413x_adc_bipolar (struct ad413x_dev *dev, uint8_t enable) |
int32_t | ad413x_set_v_bias (struct ad413x_dev *dev, uint16_t v_bias_val) |
int32_t | ad413x_set_standby_ctrl (struct ad413x_dev *dev, struct ad413x_standby_ctrl standby_ctrl) |
int32_t | ad413x_set_mclk (struct ad413x_dev *dev, enum ad413x_mclk_sel clk) |
int32_t | ad413x_do_soft_reset (struct ad413x_dev *dev) |
int32_t | ad413x_reg_write (struct ad413x_dev *dev, uint32_t reg_addr, uint32_t reg_data) |
int32_t | ad413x_reg_read (struct ad413x_dev *dev, uint32_t reg_addr, uint32_t *reg_data) |
int32_t | ad413x_single_conv (struct ad413x_dev *dev, uint32_t *buffer, uint8_t ch_nb) |
int32_t | ad413x_continuous_conv (struct ad413x_dev *dev, uint32_t *buffer, uint8_t ch_nb, uint32_t sample_nb) |
int32_t | ad413x_preset_store (struct ad413x_dev *dev, struct ad413x_preset preset, enum ad413x_preset_nb preset_nb) |
int32_t | ad413x_init (struct ad413x_dev **device, struct ad413x_init_param init_param) |
int32_t | ad413x_remove (struct ad413x_dev *dev) |
Free the resources allocated by ad413x_init(). More... | |
Variables | |
uint32_t | timeout = 0xFFFFFF |
Implementation of AD413X Driver.
Copyright 2022(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 ad413x_adc_bipolar | ( | struct ad413x_dev * | dev, |
uint8_t | enable | ||
) |
Enable/disable bipolar data coding.
dev | - The device structure. |
enable | - 1 - Bipolar 0 - Unipolar |
int32_t ad413x_ch_en | ( | struct ad413x_dev * | dev, |
uint8_t | ch_nb, | ||
uint8_t | enable | ||
) |
Enable/disable channel.
dev | - The device structure. |
ch_nb | - The channel number. |
enable | - Channel status. |
int32_t ad413x_ch_exc_input | ( | struct ad413x_dev * | dev, |
uint8_t | ch_nb, | ||
enum ad413x_input | iout0_exc_inp, | ||
enum ad413x_input | iout1_exc_inp | ||
) |
Select the excitation source pins.
dev | - The device structure. |
ch_nb | - The channel number. |
iout0_exc_inp | - IOUT0 excitation input pin. |
iout1_exc_inp | - IOUT1 excitation input pin. |
int32_t ad413x_continuous_conv | ( | struct ad413x_dev * | dev, |
uint32_t * | buffer, | ||
uint8_t | ch_nb, | ||
uint32_t | sample_nb | ||
) |
Continuous conversion of each adc active channel.
dev | - The device structure. |
buffer | - Buffer to store read data. Buffer size needs to be at least equal to the number of active channels * samples number. Results will be stored in consecutive order of the active channels. |
ch_nb | - Number of active channels. |
sample_nb | - Samples number. |
int32_t ad413x_data_stat_en | ( | struct ad413x_dev * | dev, |
uint8_t | enable | ||
) |
Enable/disable DATA_STAT field.
dev | - The device structure. |
enable | - 0 DISABLE 1 ENABLE |
int32_t ad413x_do_soft_reset | ( | struct ad413x_dev * | dev | ) |
Do a SPI software reset.
dev | - The device structure. |
int32_t ad413x_init | ( | struct ad413x_dev ** | device, |
struct ad413x_init_param | init_param | ||
) |
Initialize the device.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int32_t ad413x_pdsw_en | ( | struct ad413x_dev * | dev, |
uint8_t | ch_nb, | ||
bool | pdsw_en | ||
) |
Enable/disable Power-Down Switch (PDSW).
dev | - The device structure. |
ch_nb | - The channel number. |
pdsw_en | - PDSW status. |
int32_t ad413x_preset_store | ( | struct ad413x_dev * | dev, |
struct ad413x_preset | preset, | ||
enum ad413x_preset_nb | preset_nb | ||
) |
Store adc channel presets.
dev | - The device structure. |
preset | - The structure to be saved as preset. |
preset_nb | - Preset's number. |
int32_t ad413x_reg_read | ( | struct ad413x_dev * | dev, |
uint32_t | reg_addr, | ||
uint32_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 ad413x_reg_write | ( | struct ad413x_dev * | dev, |
uint32_t | reg_addr, | ||
uint32_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 ad413x_reg_write_msk | ( | struct ad413x_dev * | dev, |
uint32_t | reg_addr, | ||
uint32_t | data, | ||
uint32_t | mask | ||
) |
SPI internal register write to device using a mask.
dev | - The device structure. |
reg_addr | - The register address. |
data | - The register data. |
mask | - The mask. |
int32_t ad413x_remove | ( | struct ad413x_dev * | dev | ) |
Free the resources allocated by ad413x_init().
dev | - The device structure. |
int32_t ad413x_set_adc_mode | ( | struct ad413x_dev * | dev, |
enum ad413x_adc_mode | mode | ||
) |
Set the mode of the ADC.
dev | - The device structure. |
mode | - The ADC mode Accepted values: AD4110_CONTINOUS_CONV_MODE AD4110_SINGLE_CONV_MODE AD4110_STANDBY_MODE AD4110_PW_DOWN_MODE AD4110_SYS_OFFSET_CAL AD4110_SYS_GAIN_CAL |
int32_t ad413x_set_ch_preset | ( | struct ad413x_dev * | dev, |
uint8_t | ch_nb, | ||
enum ad413x_preset_nb | preset_nb | ||
) |
Select preset for adc channel.
dev | - The device structure. |
ch_nb | - The channel number. |
preset_nb | - The preset number. |
int32_t ad413x_set_exc_current | ( | struct ad413x_dev * | dev, |
enum ad413x_exc_current | iout0_exc, | ||
enum ad413x_exc_current | iout1_exc, | ||
enum ad413x_preset_nb | reg_nb | ||
) |
Select excitation current value from config register.
dev | - The device structure. |
iout0_exc | - The Iout0 excitation current value. |
iout1_exc | - The Iout1 excitation current value. Accepted values: AD413X_EXC_OFF AD413X_EXC_10UA AD413X_EXC_20UA AD413X_EXC_50UA AD413X_EXC_100UA AD413X_EXC_150UA AD413X_EXC_200UA AD413X_EXC_100NA |
reg_nb | - Number of Configuration Register |
int32_t ad413x_set_filter | ( | struct ad413x_dev * | dev, |
enum ad413x_filter | filter, | ||
enum ad413x_preset_nb | reg_nb | ||
) |
Select filter from filter register.
dev | - The device structure. |
filter | - The filter type. Accepted values: AD413X_SYNC4_STANDALONE AD413X_SYNC4_SYNC1 AD413X_SYNC3_STANDALONE AD413X_SYNC3_REJ60 AD413X_SYNC3_SYNC1 AD413X_SYNC3_PF1 AD413X_SYNC3_PF2 AD413X_SYNC3_PF3 AD413X_SYNC3_PF4 |
reg_nb | - Number of Configuration Register |
int32_t ad413x_set_gain | ( | struct ad413x_dev * | dev, |
enum ad413x_gain | gain, | ||
enum ad413x_preset_nb | reg_nb | ||
) |
Set the gain from configuration register.
dev | - The device structure. |
gain | - The gain value. Accepted values: AD413X_GAIN_1 AD413X_GAIN_2 AD413X_GAIN_4 AD413X_GAIN_8 AD413X_GAIN_16 AD413X_GAIN_32 AD413X_GAIN_64 AD413X_GAIN_128 |
reg_nb | - Number of Configuration Register |
int32_t ad413x_set_int_ref | ( | struct ad413x_dev * | dev, |
enum ad413x_int_ref | int_ref | ||
) |
Set the internal reference.
dev | - The device structure. |
int_ref | - The internal reference option. Accepted values: AD413X_INTREF_DISABLED AD413X_INTREF_2_5V, AD413X_INTREF_1_25V |
int32_t ad413x_set_mclk | ( | struct ad413x_dev * | dev, |
enum ad413x_mclk_sel | clk | ||
) |
Set ADC master clock mode.
dev | - The device structure. |
clk | - The clock mode. Accepted values: AD413X_INT_76_8_KHZ_OUT_OFF AD413X_INT_76_8_KHZ_OUT_ON AD413X_EXT_76_8KHZ AD413X_EXT_153_6_KHZ_DIV_2 |
int32_t ad413x_set_ref | ( | struct ad413x_dev * | dev, |
enum ad413x_ref_sel | ref, | ||
enum ad413x_preset_nb | reg_nb | ||
) |
Select reference from configuration register.
dev | - The device structure. |
ref | - The reference value. Accepted values: AD413X_REFIN1 AD413X_REFIN2 AD413X_REFOUT_AVSS AD413X_AVDD_AVSS |
reg_nb | - Number of Configuration Register |
int32_t ad413x_set_ref_buf | ( | struct ad413x_dev * | dev, |
struct ad413x_ref_buf | ref_buf, | ||
enum ad413x_preset_nb | reg_nb | ||
) |
Select the reference buffers.
dev | - The device structure. |
ref_buf | - The reference buffer status. |
reg_nb | - Number of Configuration Register |
int32_t ad413x_set_settle_time | ( | struct ad413x_dev * | dev, |
enum ad413x_settle_time | s_time, | ||
enum ad413x_preset_nb | reg_nb | ||
) |
Select settle time from filter register.
dev | - The device structure. |
s_time | - The settle time value. Accepted values: AD413X_32_MCLK AD413X_64_MCLK AD413X_128_MCLK AD413X_256_MCLK AD413X_512_MCLK AD413X_1024_MCLK AD413X_2048_MCLK AD413X_4096_MCLK |
reg_nb | - Number of Configuration Register |
int32_t ad413x_set_standby_ctrl | ( | struct ad413x_dev * | dev, |
struct ad413x_standby_ctrl | standby_ctrl | ||
) |
Set standby control flags.
dev | - The device structure. |
standby_ctrl | - Standby control value |
int32_t ad413x_set_v_bias | ( | struct ad413x_dev * | dev, |
uint16_t | v_bias_val | ||
) |
Set output VBIAS on analog inputs.
dev | - The device structure. |
v_bias_val | - V_BIAS control register value |
int32_t ad413x_single_conv | ( | struct ad413x_dev * | dev, |
uint32_t * | buffer, | ||
uint8_t | ch_nb | ||
) |
Single conversion of each adc active channel.
dev | - The device structure. |
buffer | - Buffer to store read data. Buffer size needs to be at least equal to the number of active channels. Results will be stored in consecutive order of the active channels. |
ch_nb | - Number of active channels. |
NO_OS_DECLARE_CRC8_TABLE | ( | ad413x_crc8 | ) |
uint32_t timeout = 0xFFFFFF |