![]() |
no-OS
|
Source file for the AD4170, AD4190 driver. More...
#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <string.h>#include "no_os_error.h"#include "no_os_delay.h"#include "no_os_crc8.h"#include "ad4170.h"Functions | |
| NO_OS_DECLARE_CRC8_TABLE (ad4170_crc8) | |
| int | ad4170_spi_reg_read (struct ad4170_dev *dev, uint32_t reg_addr, uint32_t *reg_data) |
| Read device register. | |
| int | ad4170_spi_reg_write (struct ad4170_dev *dev, uint32_t reg_addr, uint32_t reg_data) |
| Write device register. | |
| int | ad4170_spi_reg_write_mask (struct ad4170_dev *dev, uint32_t reg_addr, uint8_t mask, uint32_t reg_data) |
| SPI write device register using a mask. | |
| int | ad4170_reset_spi_interface (struct ad4170_dev *dev) |
| Reset the SPI interface by sending reset sequence to device. | |
| int | ad4170_get_data16 (struct ad4170_dev *dev, uint16_t *data) |
| Get data from register Data_16b. | |
| int | ad4170_get_data16s (struct ad4170_dev *dev, uint16_t *data, uint8_t *status) |
| Get data and status from register Data_16b_Status. | |
| int | ad4170_get_data24 (struct ad4170_dev *dev, uint32_t *data) |
| Get data from register Data_24b. | |
| int | ad4170_get_data24s (struct ad4170_dev *dev, uint32_t *data, uint8_t *status) |
| Get data and status from register Data_24b_Status. | |
| int | ad4170_get_data32 (struct ad4170_dev *dev, uint32_t *data) |
| Get data from register Data_32b. | |
| int | ad4170_get_ch_data (struct ad4170_dev *dev, uint8_t ch, uint32_t *data) |
| Get data from register Data_Per_Channel[n]. | |
| int | ad4170_get_status (struct ad4170_dev *dev, uint16_t *status) |
| Get status from register Data_Status. | |
| int | ad4170_read16 (struct ad4170_dev *dev, uint32_t *pbuf, uint16_t nb_samples) |
| Read multiple samples using direct register access from Data_16b. | |
| int | ad4170_read16s (struct ad4170_dev *dev, uint32_t *pbuf, uint16_t nb_samples) |
| Read multiple samples using direct register access from Data_16b_Status. | |
| int | ad4170_read24 (struct ad4170_dev *dev, uint32_t *pbuf, uint16_t nb_samples) |
| Read multiple samples using direct register access from Data_24. | |
| int | ad4170_read24s (struct ad4170_dev *dev, uint32_t *pbuf, uint16_t nb_samples) |
| Read multiple samples using direct register access from Data_24_Status. | |
| int | ad4170_read32 (struct ad4170_dev *dev, uint32_t *pbuf, uint16_t nb_samples) |
| Read multiple samples using direct register access from Data_32b. | |
| int | ad4170_continuous_read (struct ad4170_dev *dev, uint32_t *data_out, uint8_t *status_out, uint16_t nb_samples) |
| Read multiple samples in continuous read mode. | |
| int | ad4170_continuous_read_exit (struct ad4170_dev *dev) |
| Exit continuous read mode. | |
| int | ad4170_continuous_transmit_exit (struct ad4170_dev *dev) |
| Exit continuous transmit mode. | |
| int | ad4170_reset (struct ad4170_dev *dev) |
| Perform a software reset. | |
| int | ad4170_set_spi_settings (struct ad4170_dev *dev, const struct ad4170_spi_settings *spi_settings) |
| Set the AD4170 SPI settings. | |
| int | ad4170_set_pin_muxing (struct ad4170_dev *dev, struct ad4170_pin_muxing pin_muxing) |
| Set the AD4170 Pin Muxing settings. | |
| int | ad4170_set_dclk_div (struct ad4170_dev *dev, enum ad4170_dclk_div div) |
| Set the AD4170 DCLK configuration. | |
| int | ad4170_set_mclk_div (struct ad4170_dev *dev, enum ad4170_mclk_div div) |
| Set the AD4170 MCLK configuration. | |
| int | ad4170_set_clocksel (struct ad4170_dev *dev, enum ad4170_clocksel sel) |
| Set the AD4170 clock selection configuration. | |
| int | ad4170_set_standby_ctrl (struct ad4170_dev *dev, uint16_t standby_ctrl) |
| Set the AD4170 Standby control settings. | |
| int | ad4170_set_powerdown_sw (struct ad4170_dev *dev, uint16_t powerdown_sw) |
| Set the AD4170 Powerdown switches settings. | |
| int | ad4170_set_error_en (struct ad4170_dev *dev, uint16_t error_en) |
| Set the AD4170 Error enable settings. | |
| int | ad4170_set_error (struct ad4170_dev *dev, uint16_t error) |
| Set the Error register with a value to clear specific errors. | |
| int | ad4170_get_error (struct ad4170_dev *dev, uint16_t *error) |
| Get the Error register. | |
| int | ad4170_set_adc_ctrl (struct ad4170_dev *dev, struct ad4170_adc_ctrl adc_ctrl) |
| Set the AD4170 ADC Control. | |
| int | ad4170_set_channel_en (struct ad4170_dev *dev, uint16_t channel_en) |
| Enable AD4170 channels. | |
| int | ad4170_set_channel_setup (struct ad4170_dev *dev, uint8_t ch, struct ad4170_channel_setup setup) |
| Set the AD4170 Channel specific setup. | |
| int | ad4170_set_channel_map (struct ad4170_dev *dev, uint8_t ch, struct ad4170_channel_map map) |
| Set the AD4170 Channel specific map. | |
| int | ad4170_set_setup (struct ad4170_dev *dev, uint8_t n, struct ad4170_setup setup) |
| Configure an ADC setup. | |
| int | ad4170_set_ref_control (struct ad4170_dev *dev, bool enable) |
| Set the AD4170 Ref Control. | |
| int | ad4170_set_v_bias (struct ad4170_dev *dev, uint16_t ch_mask) |
| Set the AD4170 Voltage bias. | |
| int | ad4170_set_i_pullup (struct ad4170_dev *dev, uint16_t ch_mask) |
| Set the AD4170 Input pullup. | |
| int | ad4170_set_current_source (struct ad4170_dev *dev, uint8_t n, struct ad4170_current_source current_source) |
| Set the AD4170 Excitation Current. | |
| int | ad4170_set_fir_control (struct ad4170_dev *dev, struct ad4170_fir_control fir_control) |
| Set the AD4170 FIR control settings. | |
| int | ad4170_set_dac_config (struct ad4170_dev *dev, struct ad4170_dac_config config) |
| Set the AD4170 DAC settings. | |
| int | ad4170_set_dac_data (struct ad4170_dev *dev, uint16_t code) |
| Set the AD4170 DAC data by directly writing the DAT_DATA register. | |
| int | ad4170_set_dac_inputa (struct ad4170_dev *dev, uint16_t code) |
| Set the AD4170 DAC data by writing the INPUTA register to be loaded separately by LDAC or Toggle operations. | |
| int | ad4170_set_dac_inputb (struct ad4170_dev *dev, uint16_t code) |
| Set the AD4170 DAC data by writing the INPUTB register to be loaded separately by LDAC or Toggle operations. | |
| int | ad4170_dac_sw_ldac (struct ad4170_dev *dev, bool polarity) |
| Perform a software LDAC. | |
| int | ad4170_dac_sw_toggle (struct ad4170_dev *dev, bool polarity) |
| Perform a software toggle. | |
| int | ad4170_dac_hw_toggle (struct ad4170_dev *dev, bool polarity) |
| Perform a hardware toggle using the DIG_AUX2 pin, assumed to be pre-configured for this. | |
| int | ad4170_init (struct ad4170_dev **device, struct ad4170_init_param *init_param) |
| Initialize an AD4170 device structure. | |
| int | ad4170_remove (struct ad4170_dev *dev) |
| Remove the device and free al the resources. | |
| int | ad4170_regmap (struct ad4170_dev *dev) |
| Debugging function to print the register map to console. | |
Variables | |
| struct ad4170_config | ad4170_config_reset |
Source file for the AD4170, AD4190 driver.
Copyright 2020, 2023(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| int ad4170_continuous_read | ( | struct ad4170_dev * | dev, |
| uint32_t * | data_out, | ||
| uint8_t * | status_out, | ||
| uint16_t | nb_samples ) |
Read multiple samples in continuous read mode.
| dev | - The device structure. |
| data_out | - Output pointer where to store the data values. |
| status_out | - Output pointer where to store the status values. |
| nb_samples | - The number of samples to read. |
| int ad4170_continuous_read_exit | ( | struct ad4170_dev * | dev | ) |
Exit continuous read mode.
| dev | - The device structure. |
| int ad4170_continuous_transmit_exit | ( | struct ad4170_dev * | dev | ) |
Exit continuous transmit mode.
| dev | - The device structure. |
| int ad4170_dac_hw_toggle | ( | struct ad4170_dev * | dev, |
| bool | polarity ) |
Perform a hardware toggle using the DIG_AUX2 pin, assumed to be pre-configured for this.
| dev | - The device structure. |
| polarity | - Polarity of the toggle operation. |
| int ad4170_dac_sw_ldac | ( | struct ad4170_dev * | dev, |
| bool | polarity ) |
Perform a software LDAC.
| dev | - The device structure. |
| polarity | - Polarity of the LDAC operation. |
| int ad4170_dac_sw_toggle | ( | struct ad4170_dev * | dev, |
| bool | polarity ) |
Perform a software toggle.
| dev | - The device structure. |
| polarity | - Polarity of the toggle operation. |
| int ad4170_get_ch_data | ( | struct ad4170_dev * | dev, |
| uint8_t | ch, | ||
| uint32_t * | data ) |
Get data from register Data_Per_Channel[n].
This function assumes Per-Channel ADC Data is enabled, otherwise the output data may contain zeroes.
| dev | - The device structure. |
| ch | - The channel number (0 to 15) |
| data | - Output pointer where to store the data value. |
| int ad4170_get_data16 | ( | struct ad4170_dev * | dev, |
| uint16_t * | data ) |
Get data from register Data_16b.
| dev | - The device structure. |
| data | - Output pointer where to store the data value. |
| int ad4170_get_data16s | ( | struct ad4170_dev * | dev, |
| uint16_t * | data, | ||
| uint8_t * | status ) |
Get data and status from register Data_16b_Status.
| dev | - The device structure. |
| data | - Output pointer where to store the data value. |
| status | - Output pointer where to store the status value. |
| int ad4170_get_data24 | ( | struct ad4170_dev * | dev, |
| uint32_t * | data ) |
Get data from register Data_24b.
| dev | - The device structure. |
| data | - Output pointer where to store the data value. |
| int ad4170_get_data24s | ( | struct ad4170_dev * | dev, |
| uint32_t * | data, | ||
| uint8_t * | status ) |
Get data and status from register Data_24b_Status.
| dev | - The device structure. |
| data | - Output pointer where to store the data value. |
| status | - Output pointer where to store the status value. |
| int ad4170_get_data32 | ( | struct ad4170_dev * | dev, |
| uint32_t * | data ) |
Get data from register Data_32b.
| dev | - The device structure. |
| data | - Output pointer where to store the data value. |
| int ad4170_get_error | ( | struct ad4170_dev * | dev, |
| uint16_t * | error ) |
Get the Error register.
| dev | - The device structure. |
| error | - Pointer to where Error register content should be stored. |
| int ad4170_get_status | ( | struct ad4170_dev * | dev, |
| uint16_t * | status ) |
Get status from register Data_Status.
| dev | - The device structure. |
| status | - Output pointer where to store the status value. |
| int ad4170_init | ( | struct ad4170_dev ** | device, |
| struct ad4170_init_param * | init_param ) |
Initialize an AD4170 device structure.
| device | - Pointer to the device structure (memory is allocated within this function). |
| init_param | - Pointer to the initialization parameters. |
| int ad4170_read16 | ( | struct ad4170_dev * | dev, |
| uint32_t * | pbuf, | ||
| uint16_t | nb_samples ) |
Read multiple samples using direct register access from Data_16b.
| dev | - The device structure. |
| pbuf | - Output pointer where to store the data values. |
| nb_samples | - The number of samples to read. |
| int ad4170_read16s | ( | struct ad4170_dev * | dev, |
| uint32_t * | pbuf, | ||
| uint16_t | nb_samples ) |
Read multiple samples using direct register access from Data_16b_Status.
| dev | - The device structure. |
| pbuf | - Output pointer where to store the data values. |
| nb_samples | - The number of samples to read. |
| int ad4170_read24 | ( | struct ad4170_dev * | dev, |
| uint32_t * | pbuf, | ||
| uint16_t | nb_samples ) |
Read multiple samples using direct register access from Data_24.
| dev | - The device structure. |
| pbuf | - Output pointer where to store the data values. |
| nb_samples | - The number of samples to read. |
| int ad4170_read24s | ( | struct ad4170_dev * | dev, |
| uint32_t * | pbuf, | ||
| uint16_t | nb_samples ) |
Read multiple samples using direct register access from Data_24_Status.
| dev | - The device structure. |
| pbuf | - Output pointer where to store the data values. |
| nb_samples | - The number of samples to read. |
| int ad4170_read32 | ( | struct ad4170_dev * | dev, |
| uint32_t * | pbuf, | ||
| uint16_t | nb_samples ) |
Read multiple samples using direct register access from Data_32b.
| dev | - The device structure. |
| pbuf | - Output pointer where to store the data values. |
| nb_samples | - The number of samples to read. |
| int ad4170_regmap | ( | struct ad4170_dev * | dev | ) |
Debugging function to print the register map to console.
| dev | - The device structure. |
| int ad4170_remove | ( | struct ad4170_dev * | dev | ) |
Remove the device and free al the resources.
| dev | - The device structure. |
| int ad4170_reset | ( | struct ad4170_dev * | dev | ) |
Perform a software reset.
| dev | - The device structure. |
| int ad4170_reset_spi_interface | ( | struct ad4170_dev * | dev | ) |
Reset the SPI interface by sending reset sequence to device.
| dev | - The device structure. |
| int ad4170_set_adc_ctrl | ( | struct ad4170_dev * | dev, |
| struct ad4170_adc_ctrl | adc_ctrl ) |
Set the AD4170 ADC Control.
| dev | - The device structure. |
| adc_ctrl | - AD4170 ADC Control configuration. |
| int ad4170_set_channel_en | ( | struct ad4170_dev * | dev, |
| uint16_t | channel_en ) |
Enable AD4170 channels.
| dev | - The device structure. |
| channel_en | - Channel enable mask. |
| int ad4170_set_channel_map | ( | struct ad4170_dev * | dev, |
| uint8_t | ch, | ||
| struct ad4170_channel_map | map ) |
Set the AD4170 Channel specific map.
| dev | - The device structure. |
| ch | - The channel number (0 to 15). |
| map | - AD4170 Channel specific map configuration. |
| int ad4170_set_channel_setup | ( | struct ad4170_dev * | dev, |
| uint8_t | ch, | ||
| struct ad4170_channel_setup | setup ) |
Set the AD4170 Channel specific setup.
| dev | - The device structure. |
| ch | - The channel number (0 to 15). |
| setup | - AD4170 Channel specific setup configuration. |
| int ad4170_set_clocksel | ( | struct ad4170_dev * | dev, |
| enum ad4170_clocksel | sel ) |
Set the AD4170 clock selection configuration.
| dev | - The device structure. |
| sel | - AD4170 clock selection configuration. |
| int ad4170_set_current_source | ( | struct ad4170_dev * | dev, |
| uint8_t | n, | ||
| struct ad4170_current_source | current_source ) |
Set the AD4170 Excitation Current.
| dev | - The device structure. |
| n | - Current source number (0 to 3). |
| current_source | - Excitation current confguration. |
| int ad4170_set_dac_config | ( | struct ad4170_dev * | dev, |
| struct ad4170_dac_config | config ) |
Set the AD4170 DAC settings.
| dev | - The device structure. |
| config | - The DAC configuration. |
| int ad4170_set_dac_data | ( | struct ad4170_dev * | dev, |
| uint16_t | code ) |
Set the AD4170 DAC data by directly writing the DAT_DATA register.
| dev | - The device structure. |
| code | - The DAC code. |
| int ad4170_set_dac_inputa | ( | struct ad4170_dev * | dev, |
| uint16_t | code ) |
Set the AD4170 DAC data by writing the INPUTA register to be loaded separately by LDAC or Toggle operations.
| dev | - The device structure. |
| code | - The DAC code. |
| int ad4170_set_dac_inputb | ( | struct ad4170_dev * | dev, |
| uint16_t | code ) |
Set the AD4170 DAC data by writing the INPUTB register to be loaded separately by LDAC or Toggle operations.
| dev | - The device structure. |
| code | - The DAC code. |
| int ad4170_set_dclk_div | ( | struct ad4170_dev * | dev, |
| enum ad4170_dclk_div | div ) |
Set the AD4170 DCLK configuration.
| dev | - The device structure. |
| div | - AD4170 DCLK configuration. |
| int ad4170_set_error | ( | struct ad4170_dev * | dev, |
| uint16_t | error ) |
Set the Error register with a value to clear specific errors.
| dev | - The device structure. |
| error | - Error mask (set bits will be cleared from the Error register). |
| int ad4170_set_error_en | ( | struct ad4170_dev * | dev, |
| uint16_t | error_en ) |
Set the AD4170 Error enable settings.
| dev | - The device structure. |
| error_en | - AD4170 Error enable configuration. |
| int ad4170_set_fir_control | ( | struct ad4170_dev * | dev, |
| struct ad4170_fir_control | fir_control ) |
Set the AD4170 FIR control settings.
| dev | - The device structure. |
| fir_control | - FIR control configuration. |
| int ad4170_set_i_pullup | ( | struct ad4170_dev * | dev, |
| uint16_t | ch_mask ) |
Set the AD4170 Input pullup.
| dev | - The device structure. |
| ch_mask | - Input pullup enable mask. |
| int ad4170_set_mclk_div | ( | struct ad4170_dev * | dev, |
| enum ad4170_mclk_div | div ) |
Set the AD4170 MCLK configuration.
| dev | - The device structure. |
| div | - AD4170 MCLK configuration. |
| int ad4170_set_pin_muxing | ( | struct ad4170_dev * | dev, |
| struct ad4170_pin_muxing | pin_muxing ) |
Set the AD4170 Pin Muxing settings.
| dev | - The device structure. |
| pin_muxing | - AD4170 Pin Muxing configuration. |
| int ad4170_set_powerdown_sw | ( | struct ad4170_dev * | dev, |
| uint16_t | powerdown_sw ) |
Set the AD4170 Powerdown switches settings.
| dev | - The device structure. |
| powerdown_sw | - AD4170 Powerdown switches configuration. |
| int ad4170_set_ref_control | ( | struct ad4170_dev * | dev, |
| bool | enable ) |
Set the AD4170 Ref Control.
| dev | - The device structure. |
| enable | - Enable/Disable Ref Control. |
| int ad4170_set_setup | ( | struct ad4170_dev * | dev, |
| uint8_t | n, | ||
| struct ad4170_setup | setup ) |
Configure an ADC setup.
| dev | - The device structure. |
| n | - The setup number (0 to 8). |
| setup | - AD4170 setup configuration. |
| int ad4170_set_spi_settings | ( | struct ad4170_dev * | dev, |
| const struct ad4170_spi_settings * | spi_settings ) |
Set the AD4170 SPI settings.
| dev | - The device structure. |
| spi_settings | - AD4170 SPI configuration. |
| int ad4170_set_standby_ctrl | ( | struct ad4170_dev * | dev, |
| uint16_t | standby_ctrl ) |
Set the AD4170 Standby control settings.
| dev | - The device structure. |
| standby_ctrl | - AD4170 Standby control configuration. |
| int ad4170_set_v_bias | ( | struct ad4170_dev * | dev, |
| uint16_t | ch_mask ) |
Set the AD4170 Voltage bias.
| dev | - The device structure. |
| ch_mask | - Voltage bias enable mask. |
| int ad4170_spi_reg_read | ( | struct ad4170_dev * | dev, |
| uint32_t | reg_addr, | ||
| uint32_t * | reg_data ) |
Read device register.
| dev | - The device structure. |
| reg_addr | - The register address. |
| reg_data | - The data read from the register. |
| int ad4170_spi_reg_write | ( | struct ad4170_dev * | dev, |
| uint32_t | reg_addr, | ||
| uint32_t | reg_data ) |
Write device register.
| dev | - The device structure. |
| reg_addr | - The register address. |
| reg_data | - The register data. |
| int ad4170_spi_reg_write_mask | ( | struct ad4170_dev * | dev, |
| uint32_t | reg_addr, | ||
| uint8_t | mask, | ||
| uint32_t | reg_data ) |
SPI write device register using a mask.
| dev | - The device structure. |
| reg_addr | - The register address. |
| mask | - The mask. |
| reg_data | - The register data. |
| NO_OS_DECLARE_CRC8_TABLE | ( | ad4170_crc8 | ) |
| struct ad4170_config ad4170_config_reset |
ad4170_config default state when the chip is hardware/software reset.