no-OS
|
#include <stdint.h>
#include <string.h>
#include "no_os_util.h"
#include "no_os_spi.h"
#include "no_os_gpio.h"
Go to the source code of this file.
Classes | |
struct | ad405x_dev |
AD405X Device structure. More... | |
struct | ad405x_init_param |
Functions | |
int | ad405x_write (struct ad405x_dev *dev, uint8_t reg_addr, uint8_t reg_val) |
Write device register. More... | |
int | ad405x_read (struct ad405x_dev *dev, uint8_t reg_addr, uint8_t *reg_val) |
Read device register. More... | |
int | ad405x_update_bits (struct ad405x_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_val) |
Update specific register bits. More... | |
int | ad405x_exit_command (struct ad405x_dev *dev) |
Send EXIT command. More... | |
int | ad405x_reset_pattern_command (struct ad405x_dev *dev) |
int | ad405x_soft_reset (struct ad405x_dev *dev) |
Software reset the device. More... | |
int | ad405x_set_adc_mode (struct ad405x_dev *dev) |
Enter ADC Mode. More... | |
int | ad405x_set_burst_averaging_mode (struct ad405x_dev *dev) |
Enter Burst Averaging Mode. More... | |
int | ad405x_set_config_mode (struct ad405x_dev *dev) |
Enter Config Mode. More... | |
int | ad405x_set_operation_mode (struct ad405x_dev *dev, enum ad405x_operation_mode mode) |
Set operation mode. More... | |
int | ad405x_convst (struct ad405x_dev *dev) |
Toggle the CNV pin to start a conversion. More... | |
int | ad405x_spi_data_read (struct ad405x_dev *dev, int32_t *data) |
Read conversion data. More... | |
int | ad405x_read_val (struct ad405x_dev *dev, int32_t *data) |
Trigger conversion and read data. More... | |
int | ad405x_set_sample_rate (struct ad405x_dev *dev, enum ad405x_sample_rate rate) |
Select sample rate for Burst and Autonomous Modes. More... | |
int | ad405x_set_averaging_filter_length (struct ad405x_dev *dev, enum ad405x_avg_filter_l length) |
Set averaging filter window length. More... | |
enum ad405x_avg_filter_l | ad405x_get_averaging_filter_length (struct ad405x_dev *dev) |
Get averaging filter window length. More... | |
int | ad405x_set_dev_en_polarity (struct ad405x_dev *dev, enum ad405x_dev_en_polarity polarity) |
Set DEV_EN signal polarity. More... | |
enum ad405x_dev_en_polarity | ad405x_get_dev_en_polarity (struct ad405x_dev *dev) |
Get DEV_EN signal polarity. More... | |
int | ad405x_enable_invert_on_chop (struct ad405x_dev *dev) |
Enable INVERT_ON_CHOP. More... | |
int | ad405x_disable_invert_on_chop (struct ad405x_dev *dev) |
Disable INVERT_ON_CHOP. More... | |
enum ad405x_invert_on_chop | ad405x_get_invert_on_chop_state (struct ad405x_dev *dev) |
Get INVERT_ON_CHOP setting. More... | |
int | ad405x_set_gp_mode (struct ad405x_dev *dev, enum ad405x_gp_select gp, enum ad405x_gp_mode mode) |
Set GP mode. More... | |
enum ad405x_gp_mode | ad405x_get_gp_mode (struct ad405x_dev *dev, enum ad405x_gp_select gp) |
Get GP mode setting. More... | |
int | ad405x_set_data_format (struct ad405x_dev *dev, enum ad405x_out_data_format data_format) |
Set output data format. More... | |
int | ad405x_init (struct ad405x_dev **device, struct ad405x_init_param init_param) |
Initialize the device. More... | |
int | ad405x_remove (struct ad405x_dev *dev) |
Remove the device and release resources. More... | |
#define AD405X_ADC_DATA_FORMAT_MSK NO_OS_BIT(7) |
AD405X_REG_ADC_MODES Bit definition
#define AD405X_ADC_MODES_MSK NO_OS_GENMASK(1, 0) |
#define AD405X_AUTONOMOUS_MODE NO_OS_GENMASK(1, 0) |
#define AD405X_AVERAGING_MODE NO_OS_BIT(1) |
#define AD405X_AVG_WIN_LEN_MSK NO_OS_GENMASK(3, 0) |
AD405X_REG_AVG_CONFIG Bit Definitions
#define AD405X_BURST_AVERAGING_MODE NO_OS_BIT(0) |
#define AD405X_DEV_EN_POL_HIGH NO_OS_BIT(7) |
#define AD405X_DEV_EN_POL_LOW ~NO_OS_BIT(7) |
#define AD405X_DEV_EN_POL_MSK NO_OS_BIT(7) |
AD405X_REG_GPIO_CONFIG Bit Definitions
#define AD405X_DEVICE_TYPE NO_OS_GENMASK(2, 0) |
#define AD405X_ENTER_ADC_MODE NO_OS_BIT(0) |
#define AD405X_ENTER_ADC_MODE_MSK NO_OS_BIT(0) |
AD405X_REG_MODE_SET Bit definition
#define AD405X_FS_BURST_AUTO_MSK NO_OS_GENMASK(7, 4) |
AD405X_REG_TIMER_CONFIG Bit Definitions
#define AD405X_GP0_MODE_MSK NO_OS_GENMASK(2, 0) |
#define AD405X_GP1_MODE_MSK NO_OS_GENMASK(6, 4) |
#define AD405X_INVERT_ON_CHOP_MSK NO_OS_BIT(3) |
#define AD405X_INVERT_ON_CHOP_OFF ~NO_OS_BIT(3) |
#define AD405X_INVERT_ON_CHOP_ON NO_OS_BIT(3) |
#define AD405X_REG_ADC_CONFIG 0x22 |
#define AD405X_REG_ADC_MODES 0x21 |
#define AD405X_REG_AVG_CONFIG 0x23 |
#define AD405X_REG_CHIP_GRADE 0x06 |
#define AD405X_REG_CHOP_CONFIG 0x26 |
#define AD405X_REG_DEVICE_CONFIG 0x02 |
#define AD405X_REG_DEVICE_STATUS 0x41 |
#define AD405X_REG_DEVICE_TYPE 0x03 |
#define AD405X_REG_FUSE_CRC 0x40 |
#define AD405X_REG_GPIO_CONFIG 0x24 |
#define AD405X_REG_INTERFACE_CONFIG_A 0x00 |
Register Definition
#define AD405X_REG_INTERFACE_CONFIG_B 0x01 |
#define AD405X_REG_INTERFACE_CONFIG_C 0x10 |
#define AD405X_REG_INTERFACE_STATUS 0x11 |
#define AD405X_REG_INTR_CONFIG 0x25 |
#define AD405X_REG_MAX_HYST 0x2C |
#define AD405X_REG_MAX_INTR 0x42 |
#define AD405X_REG_MAX_THRESH 0x28 |
#define AD405X_REG_MIN_HYST 0x2D |
#define AD405X_REG_MIN_INTR 0x44 |
#define AD405X_REG_MIN_THRESH 0x2A |
#define AD405X_REG_MODE_SET 0x20 |
#define AD405X_REG_MON_VAL 0x2E |
#define AD405X_REG_PRODUCT_ID_H 0x05 |
#define AD405X_REG_PRODUCT_ID_L 0x04 |
#define AD405X_REG_SCRATCH_PAD 0x0A |
#define AD405X_REG_SPI_REVISION 0x0B |
#define AD405X_REG_STREAM_MODE 0x0E |
#define AD405X_REG_TIMER_CONFIG 0x27 |
#define AD405X_REG_TRANSFER_CONFIG 0x0F |
#define AD405X_REG_VENDOR_H 0x0D |
#define AD405X_REG_VENDOR_L 0x0C |
#define AD405X_SAMPLE_MODE 0x00 |
#define AD405X_SHORT_INST_MSK NO_OS_BIT(3) |
#define AD405X_SINGLE_INST_MSK NO_OS_BIT(7) /* Should be set to 0. */ |
AD405X_REG_INTERFACE_CONFIG_B Bit Definition
#define AD405X_SPI_READ NO_OS_BIT(7) |
#define AD405X_STRICT_REG_ACCESS_MSK NO_OS_BIT(5) |
AD405X_REG_INTERFACE_CONFIG_C Bit Definition
AD405X_REG_INTERFACE_CONFIG_A Bit Definition
#define BYTE_ADDR_H NO_OS_GENMASK(15, 8) |
#define BYTE_ADDR_L NO_OS_GENMASK(7, 0) |
enum ad405x_avg_filter_l |
enum ad405x_device_type |
enum ad405x_gp_mode |
enum ad405x_gp_select |
enum ad405x_product_id |
enum ad405x_sample_rate |
int ad405x_convst | ( | struct ad405x_dev * | dev | ) |
Toggle the CNV pin to start a conversion.
Toggle the CNV pin to start a conversion.
dev | - The device structure. |
CNV High Time 10 ns
int ad405x_disable_invert_on_chop | ( | struct ad405x_dev * | dev | ) |
Disable INVERT_ON_CHOP.
Disable INVERT_ON_CHOP
dev | - The device structure. |
int ad405x_enable_invert_on_chop | ( | struct ad405x_dev * | dev | ) |
Enable INVERT_ON_CHOP.
Enable INVERT_ON_CHOP
dev | - The device structure. |
int ad405x_exit_command | ( | struct ad405x_dev * | dev | ) |
Send EXIT command.
Send EXIT command.
dev- | The device structure. |
enum ad405x_avg_filter_l ad405x_get_averaging_filter_length | ( | struct ad405x_dev * | dev | ) |
Get averaging filter window length.
Get averaging filter window length
dev | - The device structure. |
enum ad405x_dev_en_polarity ad405x_get_dev_en_polarity | ( | struct ad405x_dev * | dev | ) |
Get DEV_EN signal polarity.
Get DEV_EN signal polarity
dev | - The device structure. |
enum ad405x_gp_mode ad405x_get_gp_mode | ( | struct ad405x_dev * | dev, |
enum ad405x_gp_select | gp | ||
) |
Get GP mode setting.
Get GP mode setting
G
dev | - The device structure. |
gp | - GP1/GP0 select. |
enum ad405x_invert_on_chop ad405x_get_invert_on_chop_state | ( | struct ad405x_dev * | dev | ) |
Get INVERT_ON_CHOP setting.
Get INVERT_ON_CHOP setting
dev | - The device structure. |
int ad405x_init | ( | struct ad405x_dev ** | device, |
struct ad405x_init_param | init_param | ||
) |
Initialize the device.
Initialize the device.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
int ad405x_read | ( | struct ad405x_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t * | reg_val | ||
) |
Read device register.
Read data from a register
dev | - The device structure. |
reg_addr | - The register address. |
reg_val | - The data read from the register. |
int ad405x_read_val | ( | struct ad405x_dev * | dev, |
int32_t * | data | ||
) |
Trigger conversion and read data.
Trigger conversion adn read data.
dev | - The device structure. |
data | - Pointer to location of buffer where to store the data. |
int ad405x_remove | ( | struct ad405x_dev * | dev | ) |
Remove the device and release resources.
Remove the device and release resources.
dev | - The device structure. |
int ad405x_reset_pattern_command | ( | struct ad405x_dev * | dev | ) |
Send RESET command.
Send RESET pattern command.
dev- | The device structure. |
int ad405x_set_adc_mode | ( | struct ad405x_dev * | dev | ) |
Enter ADC Mode.
Enter ADC Mode
dev | - The device structure. |
int ad405x_set_averaging_filter_length | ( | struct ad405x_dev * | dev, |
enum ad405x_avg_filter_l | length | ||
) |
Set averaging filter window length.
Set averaging filter window length
dev | - The device structure. |
length | - Averaging filter window length. |
int ad405x_set_burst_averaging_mode | ( | struct ad405x_dev * | dev | ) |
Enter Burst Averaging Mode.
Enter Burst Averaging Mode
dev | - The device structure. |
int ad405x_set_config_mode | ( | struct ad405x_dev * | dev | ) |
Enter Config Mode.
Enter Config Mode
dev | - The device structure. |
int ad405x_set_data_format | ( | struct ad405x_dev * | dev, |
enum ad405x_out_data_format | data_format | ||
) |
Set output data format.
Set adc output data format
dev | - The device structure. |
data_format | - format select. |
int ad405x_set_dev_en_polarity | ( | struct ad405x_dev * | dev, |
enum ad405x_dev_en_polarity | polarity | ||
) |
Set DEV_EN signal polarity.
Set DEV_EN signal polarity
dev | - The device structure. |
polarity | - DEV_EN signal polarity. |
int ad405x_set_gp_mode | ( | struct ad405x_dev * | dev, |
enum ad405x_gp_select | gp, | ||
enum ad405x_gp_mode | mode | ||
) |
Set GP mode.
Set GP mode
dev | - The device structure. |
gp | - GP1/GP0 select. |
mode | - mode select. |
int ad405x_set_operation_mode | ( | struct ad405x_dev * | dev, |
enum ad405x_operation_mode | mode | ||
) |
Set operation mode.
Set operation mode
dev | - The device structure. |
mode | - Operation mode. |
int ad405x_set_sample_rate | ( | struct ad405x_dev * | dev, |
enum ad405x_sample_rate | rate | ||
) |
Select sample rate for Burst and Autonomous Modes.
Select sample rate for Burst and Autonomous Modes.
dev | - The device structure. |
rate | - Sample rate. |
int ad405x_soft_reset | ( | struct ad405x_dev * | dev | ) |
Software reset the device.
Software Reset.
dev | - The device structure. |
int ad405x_spi_data_read | ( | struct ad405x_dev * | dev, |
int32_t * | data | ||
) |
Read conversion data.
Read conversion data.
dev | - The device structure. |
data | - Pointer to location of buffer where to store the data. |
int ad405x_update_bits | ( | struct ad405x_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t | mask, | ||
uint8_t | reg_val | ||
) |
Update specific register bits.
Update specific register bits
dev | - The device structure. |
reg_addr | - The register address. |
mask | - Specific bits mask. |
reg_val | - The data to be written. |
int ad405x_write | ( | struct ad405x_dev * | dev, |
uint8_t | reg_addr, | ||
uint8_t | reg_val | ||
) |
Write device register.
Write data into a register
dev- | The device structure. |
reg_addr | - The register address. |
reg_val | - The data to be written. |