no-OS
|
Header file of AD7193 Driver. More...
Go to the source code of this file.
Classes | |
struct | ad7193_dev |
struct | ad7193_init_param |
Macros | |
#define | AD7193_SLAVE_ID 1 |
#define | AD7193_REG_COMM 0 |
#define | AD7193_REG_STAT 0 |
#define | AD7193_REG_MODE 1 |
#define | AD7193_REG_CONF 2 |
#define | AD7193_REG_DATA 3 |
#define | AD7193_REG_ID 4 |
#define | AD7193_REG_GPOCON 5 |
#define | AD7193_REG_OFFSET 6 |
#define | AD7193_REG_FULLSCALE 7 |
#define | AD7193_COMM_WEN (1 << 7) |
#define | AD7193_COMM_WRITE (0 << 6) |
#define | AD7193_COMM_READ (1 << 6) |
#define | AD7193_COMM_ADDR(x) (((x) & 0x7) << 3) |
#define | AD7193_COMM_CREAD (1 << 2) |
#define | AD7193_STAT_RDY (1 << 7) |
#define | AD7193_STAT_ERR (1 << 6) |
#define | AD7193_STAT_NOREF (1 << 5) |
#define | AD7193_STAT_PARITY (1 << 4) |
#define | AD7193_STAT_CH3 (1 << 3) |
#define | AD7193_STAT_CH2 (1 << 2) |
#define | AD7193_STAT_CH1 (1 << 1) |
#define | AD7193_STAT_CH0 (1 << 0) |
#define | AD7193_MODE_SEL(x) (((uint32_t)(x) & 0x7) << 21) |
#define | AD7193_MODE_DAT_STA ((uint32_t)1 << 20) |
#define | AD7193_MODE_CLKSRC(x) (((uint32_t)(x) & 0x3) << 18) |
#define | AD7193_MODE_AVG(x) (((uint32_t)(x) & 0x3) << 16) |
#define | AD7193_MODE_SINC3 (1 << 15) |
#define | AD7193_MODE_ENPAR (1 << 13) |
#define | AD7193_MODE_CLKDIV (1 << 12) |
#define | AD7193_MODE_SCYCLE (1 << 11) |
#define | AD7193_MODE_REJ60 (1 << 10) |
#define | AD7193_MODE_RATE(x) ((x) & 0x3FF) |
#define | AD7193_AVG_NONE 0 |
#define | AD7193_AVG_BY_2 1 |
#define | AD7193_AVG_BY_8 2 |
#define | AD7193_AVG_BY_16 3 |
#define | AD7193_CONF_CHOP ((uint32_t)1 << 23) |
#define | AD7193_CONF_REFSEL ((uint32_t)1 << 20) |
#define | AD7193_CONF_PSEUDO ((uint32_t)1 << 18) |
#define | AD7193_CONF_CHAN(x) ((uint32_t)((x) & 0x3FF) << 8) |
#define | AD7193_CONF_BURN (1 << 7) |
#define | AD7193_CONF_REFDET (1 << 6) |
#define | AD7193_CONF_BUF (1 << 4) |
#define | AD7193_CONF_UNIPOLAR (1 << 3) |
#define | AD7193_CONF_GAIN(x) ((x) & 0x7) |
#define | AD7193_CH_0 0 |
#define | AD7193_CH_1 1 |
#define | AD7193_CH_2 2 |
#define | AD7193_CH_3 3 |
#define | AD7193_CH_4 4 |
#define | AD7193_CH_5 5 |
#define | AD7193_CH_6 6 |
#define | AD7193_CH_7 7 |
#define | AD7193_CH_TEMP 8 |
#define | AD7193_CH_SHORT 9 |
#define | ID_AD7193 0x2 |
#define | AD7193_ID_MASK 0x0F |
#define | AD7193_GPOCON_BPDSW (1 << 6) |
#define | AD7193_GPOCON_GP32EN (1 << 5) |
#define | AD7193_GPOCON_GP10EN (1 << 4) |
#define | AD7193_GPOCON_P3DAT (1 << 3) |
#define | AD7193_GPOCON_P2DAT (1 << 2) |
#define | AD7193_GPOCON_P1DAT (1 << 1) |
#define | AD7193_GPOCON_P0DAT (1 << 0) |
#define | AD7193_CH_MASK(x) BIT(x) |
Functions | |
int | ad7193_init (struct ad7193_dev **device, struct ad7193_init_param init_param) |
Initializes the communication peripheral and the initial Values for AD7193 Board and resets the device. More... | |
int | ad7193_remove (struct ad7193_dev *dev) |
Free the resources allocated by ad7193_init(). More... | |
int | ad7193_set_register_value (struct ad7193_dev *dev, uint8_t reg_addr, uint32_t reg_value, uint8_t bytes_number) |
Writes data into a register. More... | |
int | ad7193_get_register_value (struct ad7193_dev *dev, uint8_t reg_addr, uint8_t bytes_number, uint32_t *reg_data) |
Reads the value of a register. More... | |
int | ad7193_set_masked_register_value (struct ad7193_dev *dev, uint8_t reg_addr, uint32_t mask, uint32_t data, uint8_t bytes) |
Write masked data into device register. More... | |
int | ad7193_reset (struct ad7193_dev *dev) |
Resets the device. More... | |
int | ad7193_set_operating_mode (struct ad7193_dev *dev, enum ad7193_adc_modes opt_mode) |
Sets device into the specified operating mode. More... | |
int | ad7193_wait_rdy_go_low (struct ad7193_dev *dev) |
Waits for RDY pin to go low. More... | |
int | ad7193_channels_select (struct ad7193_dev *dev, uint16_t chn_mask) |
Selects the channels to be enabled. More... | |
int | ad7193_calibrate (struct ad7193_dev *dev, uint8_t mode, uint8_t channel) |
Performs the given calibration to the specified channel. More... | |
int | ad7193_config_input_mode (struct ad7193_dev *dev, uint8_t mode) |
Configures the input mode of the ADC. More... | |
int | ad7193_buffer_select (struct ad7193_dev *dev, uint8_t buff_en) |
Enables or disables the buffer on the ADC input channels. More... | |
int | ad7193_output_rate_select (struct ad7193_dev *dev, uint16_t out_rate_code) |
Selects the filter output data rate of the ADC. More... | |
int | ad7193_clock_select (struct ad7193_dev *dev, enum ad7193_adc_clock clk_select) |
Selects the clock source of the ADC. More... | |
int | ad7193_set_bridge_switch (struct ad7193_dev *dev, uint8_t bpdsw_select) |
Opens or closes the bridge power-down switch of the ADC. More... | |
int | ad7193_range_setup (struct ad7193_dev *dev, uint8_t polarity, enum ad7193_adc_range range) |
Selects the polarity of the conversion and the ADC input range. More... | |
int | ad7193_single_conversion (struct ad7193_dev *dev, uint32_t *reg_data) |
Returns the result of a single conversion. More... | |
int | ad7193_continuous_read_avg (struct ad7193_dev *dev, uint8_t sample_number, uint32_t *samples_avg) |
Returns the average of several conversion results. More... | |
int | ad7193_temperature_read (struct ad7193_dev *dev, float *temp) |
Read data from temperature sensor and converts it to Celsius degrees. More... | |
float | ad7193_convert_to_volts (struct ad7193_dev *dev, uint32_t raw_data, float v_ref) |
Converts 24-bit raw data to milivolts. More... | |
Header file of AD7193 Driver.
Copyright 2012(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.
#define AD7193_AVG_BY_16 3 |
#define AD7193_AVG_BY_2 1 |
#define AD7193_AVG_BY_8 2 |
#define AD7193_AVG_NONE 0 |
#define AD7193_CH_0 0 |
#define AD7193_CH_1 1 |
#define AD7193_CH_2 2 |
#define AD7193_CH_3 3 |
#define AD7193_CH_4 4 |
#define AD7193_CH_5 5 |
#define AD7193_CH_6 6 |
#define AD7193_CH_7 7 |
#define AD7193_CH_MASK | ( | x | ) | BIT(x) |
#define AD7193_CH_SHORT 9 |
#define AD7193_CH_TEMP 8 |
#define AD7193_COMM_ADDR | ( | x | ) | (((x) & 0x7) << 3) |
#define AD7193_COMM_CREAD (1 << 2) |
#define AD7193_COMM_READ (1 << 6) |
#define AD7193_COMM_WEN (1 << 7) |
#define AD7193_COMM_WRITE (0 << 6) |
#define AD7193_CONF_BUF (1 << 4) |
#define AD7193_CONF_BURN (1 << 7) |
#define AD7193_CONF_CHAN | ( | x | ) | ((uint32_t)((x) & 0x3FF) << 8) |
#define AD7193_CONF_CHOP ((uint32_t)1 << 23) |
#define AD7193_CONF_GAIN | ( | x | ) | ((x) & 0x7) |
#define AD7193_CONF_PSEUDO ((uint32_t)1 << 18) |
#define AD7193_CONF_REFDET (1 << 6) |
#define AD7193_CONF_REFSEL ((uint32_t)1 << 20) |
#define AD7193_CONF_UNIPOLAR (1 << 3) |
#define AD7193_GPOCON_BPDSW (1 << 6) |
#define AD7193_GPOCON_GP10EN (1 << 4) |
#define AD7193_GPOCON_GP32EN (1 << 5) |
#define AD7193_GPOCON_P0DAT (1 << 0) |
#define AD7193_GPOCON_P1DAT (1 << 1) |
#define AD7193_GPOCON_P2DAT (1 << 2) |
#define AD7193_GPOCON_P3DAT (1 << 3) |
#define AD7193_ID_MASK 0x0F |
#define AD7193_MODE_AVG | ( | x | ) | (((uint32_t)(x) & 0x3) << 16) |
#define AD7193_MODE_CLKDIV (1 << 12) |
#define AD7193_MODE_CLKSRC | ( | x | ) | (((uint32_t)(x) & 0x3) << 18) |
#define AD7193_MODE_DAT_STA ((uint32_t)1 << 20) |
#define AD7193_MODE_ENPAR (1 << 13) |
#define AD7193_MODE_RATE | ( | x | ) | ((x) & 0x3FF) |
#define AD7193_MODE_REJ60 (1 << 10) |
#define AD7193_MODE_SCYCLE (1 << 11) |
#define AD7193_MODE_SEL | ( | x | ) | (((uint32_t)(x) & 0x7) << 21) |
#define AD7193_MODE_SINC3 (1 << 15) |
#define AD7193_REG_COMM 0 |
#define AD7193_REG_CONF 2 |
#define AD7193_REG_DATA 3 |
#define AD7193_REG_FULLSCALE 7 |
#define AD7193_REG_GPOCON 5 |
#define AD7193_REG_ID 4 |
#define AD7193_REG_MODE 1 |
#define AD7193_REG_OFFSET 6 |
#define AD7193_REG_STAT 0 |
#define AD7193_SLAVE_ID 1 |
#define AD7193_STAT_CH0 (1 << 0) |
#define AD7193_STAT_CH1 (1 << 1) |
#define AD7193_STAT_CH2 (1 << 2) |
#define AD7193_STAT_CH3 (1 << 3) |
#define AD7193_STAT_ERR (1 << 6) |
#define AD7193_STAT_NOREF (1 << 5) |
#define AD7193_STAT_PARITY (1 << 4) |
#define AD7193_STAT_RDY (1 << 7) |
#define ID_AD7193 0x2 |
enum ad7193_adc_clock |
enum ad7193_adc_modes |
enum ad7193_adc_range |
int ad7193_buffer_select | ( | struct ad7193_dev * | dev, |
uint8_t | buff_en | ||
) |
Enables or disables the buffer on the ADC input channels.
Enables or disables the buffer on the ADC input channels
dev | - The device structure. |
buff_en | - Enable/disable option. Example: 0 - Buffer disabled 1 - Buffer Enabled |
int ad7193_calibrate | ( | struct ad7193_dev * | dev, |
uint8_t | mode, | ||
uint8_t | channel | ||
) |
Performs the given calibration to the specified channel.
Performs the given calibration to the specified channel.
dev | - The device structure. |
mode | - Calibration type. |
channel | - Channel to be calibrated. |
int ad7193_channels_select | ( | struct ad7193_dev * | dev, |
uint16_t | chn_mask | ||
) |
Selects the channels to be enabled.
Selects the channels to be enabled.
dev | - The device structure. |
chn_mask | - Channel mask. Example: AD7193_CH_0 - AIN1(+) - AIN2(-); (Pseudo = 0) AD7193_CH_1 - AIN3(+) - AIN4(-); (Pseudo = 0) AD7193_TEMP - Temperature sensor AD7193_SHORT - AIN2(+) - AIN2(-); (Pseudo = 0) |
int ad7193_clock_select | ( | struct ad7193_dev * | dev, |
enum ad7193_adc_clock | clk_select | ||
) |
Selects the clock source of the ADC.
Selects the clock source of the ADC
dev | - The device structure. |
clk_select | - Clock source to be selected. Accepted values: AD7193_EXT_CRYSTAL_MCLK1_MCLK2 AD7193_EXT_CRYSTAL_MCLK2 AD7193_INT_CLK_4_92_MHZ_TRIST AD7193_INT_CLK_4_92_MHZ |
int ad7193_config_input_mode | ( | struct ad7193_dev * | dev, |
uint8_t | mode | ||
) |
Configures the input mode of the ADC.
Configures the input mode of the ADC
dev | - The device structure. |
mode | - Mode selection. Example: 0 - Differential Analog Inputs 1 - Pseudo Differential Analog Inputs |
int ad7193_continuous_read_avg | ( | struct ad7193_dev * | dev, |
uint8_t | sample_number, | ||
uint32_t * | samples_avg | ||
) |
Returns the average of several conversion results.
Returns the average of several conversion results.
dev | - The device structure. |
sample_number | - the number of samples |
samples_avg | - Average of the samples read |
float ad7193_convert_to_volts | ( | struct ad7193_dev * | dev, |
uint32_t | raw_data, | ||
float | v_ref | ||
) |
Converts 24-bit raw data to milivolts.
Converts 24-bit raw data to volts.
dev | - The device structure. |
raw_data | - 24-bit data sample. |
v_ref | - The value of the voltage reference used by the device. |
int ad7193_get_register_value | ( | struct ad7193_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t | bytes_number, | ||
uint32_t * | reg_data | ||
) |
Reads the value of a register.
Reads the value of a register.
dev | - The device structure. |
reg_addr | - Address of the register. |
bytes_number | - Number of bytes that will be read. |
reg_data | - Data read from the register. |
int ad7193_init | ( | struct ad7193_dev ** | device, |
struct ad7193_init_param | init_param | ||
) |
Initializes the communication peripheral and the initial Values for AD7193 Board and resets the device.
Checks if the AD7139 part is present.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int ad7193_output_rate_select | ( | struct ad7193_dev * | dev, |
uint16_t | out_rate_code | ||
) |
Selects the filter output data rate of the ADC.
Selects the filter output data rate of the ADC
dev | - The device structure. |
out_rate_code | - Filter output data rate code. |
int ad7193_range_setup | ( | struct ad7193_dev * | dev, |
uint8_t | polarity, | ||
enum ad7193_adc_range | range | ||
) |
Selects the polarity of the conversion and the ADC input range.
Selects the polarity of the conversion and the ADC input range.
dev | - The device structure. |
polarity | - Polarity select bit. Example: 0 - bipolar operation is selected. 1 - unipolar operation is selected. |
range | - Gain select bits. These bits are written by the user to select the ADC input range. |
int ad7193_remove | ( | struct ad7193_dev * | dev | ) |
Free the resources allocated by ad7193_init().
Free the resources allocated by ad7193_init().
dev | - The device structure. |
int ad7193_reset | ( | struct ad7193_dev * | dev | ) |
Resets the device.
Resets the device.
dev | - The device structure. |
int ad7193_set_bridge_switch | ( | struct ad7193_dev * | dev, |
uint8_t | bpdsw_select | ||
) |
Opens or closes the bridge power-down switch of the ADC.
Opens or closes the bridge power-down switch of the ADC
dev | - The device structure. |
bpdsw_select | - Option to open or close bridge power-down switch. 0 - Switch Opened 1 - Switch Closed |
int ad7193_set_masked_register_value | ( | struct ad7193_dev * | dev, |
uint8_t | reg_addr, | ||
uint32_t | mask, | ||
uint32_t | reg_data, | ||
uint8_t | bytes | ||
) |
Write masked data into device register.
dev | - The device structure. |
reg_addr | - Address of the register. |
mask | - The mask. |
reg_data | - Register data to be written. |
bytes | - Number of bytes that will be read. |
int ad7193_set_operating_mode | ( | struct ad7193_dev * | dev, |
enum ad7193_adc_modes | opt_mode | ||
) |
Sets device into the specified operating mode.
Set the device into specified operating mode.
dev | - The device structure. |
opt_mode | - Operating mode to be set. Accepted values: AD7193_MODE_CONT AD7193_MODE_SINGLE AD7193_MODE_IDLE AD7193_MODE_PWRDN AD7193_MODE_CAL_INT_ZERO AD7193_MODE_CAL_INT_FULL AD7193_MODE_CAL_SYS_ZERO AD7193_MODE_CAL_SYS_FULL |
int ad7193_set_register_value | ( | struct ad7193_dev * | dev, |
uint8_t | reg_addr, | ||
uint32_t | reg_val, | ||
uint8_t | bytes_number | ||
) |
Writes data into a register.
Writes data into a register.
dev | - The device structure. |
reg_addr | - Address of the register. |
reg_val | - Data value to write. |
bytes_number | - Number of bytes to be written. |
int ad7193_single_conversion | ( | struct ad7193_dev * | dev, |
uint32_t * | reg_data | ||
) |
Returns the result of a single conversion.
Returns the result of a single conversion.
dev | - The device structure. |
reg_data | - Buffer to store sampled register data |
int ad7193_temperature_read | ( | struct ad7193_dev * | dev, |
float * | temp | ||
) |
Read data from temperature sensor and converts it to Celsius degrees.
Read data from temperature sensor and converts it to Celsius degrees.
dev | - The device structure. |
temp | - Stores the temperature result. |
int ad7193_wait_rdy_go_low | ( | struct ad7193_dev * | dev | ) |
Waits for RDY pin to go low.
Waits for RDY pin to go low.