Go to the documentation of this file.
53 #define AD405X_REG_INTERFACE_CONFIG_A 0x00
54 #define AD405X_REG_INTERFACE_CONFIG_B 0x01
55 #define AD405X_REG_DEVICE_CONFIG 0x02
56 #define AD405X_REG_DEVICE_TYPE 0x03
57 #define AD405X_REG_PRODUCT_ID_L 0x04
58 #define AD405X_REG_PRODUCT_ID_H 0x05
59 #define AD405X_REG_CHIP_GRADE 0x06
60 #define AD405X_REG_SCRATCH_PAD 0x0A
61 #define AD405X_REG_SPI_REVISION 0x0B
62 #define AD405X_REG_VENDOR_L 0x0C
63 #define AD405X_REG_VENDOR_H 0x0D
64 #define AD405X_REG_STREAM_MODE 0x0E
65 #define AD405X_REG_TRANSFER_CONFIG 0x0F
66 #define AD405X_REG_INTERFACE_CONFIG_C 0x10
67 #define AD405X_REG_INTERFACE_STATUS 0x11
68 #define AD405X_REG_MODE_SET 0x20
69 #define AD405X_REG_ADC_MODES 0x21
70 #define AD405X_REG_ADC_CONFIG 0x22
71 #define AD405X_REG_AVG_CONFIG 0x23
72 #define AD405X_REG_GPIO_CONFIG 0x24
73 #define AD405X_REG_INTR_CONFIG 0x25
74 #define AD405X_REG_CHOP_CONFIG 0x26
75 #define AD405X_REG_TIMER_CONFIG 0x27
76 #define AD405X_REG_MAX_THRESH 0x28
77 #define AD405X_REG_MIN_THRESH 0x2A
78 #define AD405X_REG_MAX_HYST 0x2C
79 #define AD405X_REG_MIN_HYST 0x2D
80 #define AD405X_REG_MON_VAL 0x2E
81 #define AD405X_REG_FUSE_CRC 0x40
82 #define AD405X_REG_DEVICE_STATUS 0x41
83 #define AD405X_REG_MAX_INTR 0x42
84 #define AD405X_REG_MIN_INTR 0x44
87 #define AD405X_SW_RESET_MSK NO_OS_BIT(7) | NO_OS_BIT(0)
90 #define AD405X_SINGLE_INST_MSK NO_OS_BIT(7)
91 #define AD405X_SHORT_INST_MSK NO_OS_BIT(3)
94 #define AD405X_STRICT_REG_ACCESS_MSK NO_OS_BIT(5)
97 #define AD405X_ADC_DATA_FORMAT_MSK NO_OS_BIT(7)
98 #define AD405X_ADC_MODES_MSK NO_OS_GENMASK(1, 0)
99 #define AD405X_SAMPLE_MODE 0x00
100 #define AD405X_BURST_AVERAGING_MODE NO_OS_BIT(0)
101 #define AD405X_AVERAGING_MODE NO_OS_BIT(1)
102 #define AD405X_AUTONOMOUS_MODE NO_OS_GENMASK(1, 0)
105 #define AD405X_ENTER_ADC_MODE_MSK NO_OS_BIT(0)
106 #define AD405X_ENTER_ADC_MODE NO_OS_BIT(0)
109 #define AD405X_FS_BURST_AUTO_MSK NO_OS_GENMASK(7, 4)
112 #define AD405X_AVG_WIN_LEN_MSK NO_OS_GENMASK(3, 0)
115 #define AD405X_DEV_EN_POL_MSK NO_OS_BIT(7)
116 #define AD405X_GP1_MODE_MSK NO_OS_GENMASK(6, 4)
117 #define AD405X_INVERT_ON_CHOP_MSK NO_OS_BIT(3)
118 #define AD405X_GP0_MODE_MSK NO_OS_GENMASK(2, 0)
120 #define AD405X_DEV_EN_POL_LOW ~NO_OS_BIT(7)
121 #define AD405X_DEV_EN_POL_HIGH NO_OS_BIT(7)
123 #define AD405X_INVERT_ON_CHOP_OFF ~NO_OS_BIT(3)
124 #define AD405X_INVERT_ON_CHOP_ON NO_OS_BIT(3)
127 #define AD405X_SW_RESET NO_OS_BIT(7) | NO_OS_BIT(0)
128 #define AD405X_SPI_READ NO_OS_BIT(7)
129 #define BYTE_ADDR_H NO_OS_GENMASK(15, 8)
130 #define BYTE_ADDR_L NO_OS_GENMASK(7, 0)
131 #define AD405X_DEVICE_TYPE NO_OS_GENMASK(2, 0)
@ AD405X_TWOS_COMPLEMENT
Definition: ad405x.h:216
enum ad405x_avg_filter_l ad405x_get_averaging_filter_length(struct ad405x_dev *dev)
Get averaging filter window length.
Definition: ad405x.c:545
enum ad405x_operation_mode operation_mode
Definition: ad405x.h:241
@ AD405X_GP_MODE_LOW
Definition: ad405x.h:202
int ad405x_read(struct ad405x_dev *dev, uint8_t reg_addr, uint8_t *reg_val)
Read device register.
Definition: ad405x.c:105
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
@ AD405X_INVERT_ON_CHOP_ENABLED
Definition: ad405x.h:192
#define AD405X_SPI_READ
Definition: ad405x.h:128
#define AD405X_REG_INTERFACE_CONFIG_A
Definition: ad405x.h:53
ad405x_operation_mode
Definition: ad405x.h:138
#define AD405X_INVERT_ON_CHOP_MSK
Definition: ad405x.h:117
@ AD405X_LENGTH_2
Definition: ad405x.h:169
struct no_os_gpio_desc * gpio_gpio1
Definition: ad405x.h:247
enum ad405x_sample_rate rate
Definition: ad405x.h:282
int ad405x_convst(struct ad405x_dev *dev)
Toggle the CNV pin to start a conversion.
Definition: ad405x.c:383
struct no_os_gpio_desc * gpio_cnv
Definition: ad405x.h:243
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
@ AD405X_250_SPS
Definition: ad405x.h:159
#define AD405X_BURST_AVERAGING_MODE
Definition: ad405x.h:100
@ AD405X_LENGTH_32
Definition: ad405x.h:173
ad405x_avg_filter_l
Definition: ad405x.h:168
int ad405x_soft_reset(struct ad405x_dev *dev)
Software reset the device.
Definition: ad405x.c:199
Header file of SPI Interface.
@ AD405X_INVERT_ON_CHOP_DISABLED
Definition: ad405x.h:191
@ AD405X_LENGTH_8
Definition: ad405x.h:171
@ AD405X_GP_1
Definition: ad405x.h:210
int ad405x_update_bits(struct ad405x_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_val)
Update specific register bits.
Definition: ad405x.c:132
enum ad405x_avg_filter_l ad405x_get_averaging_filter_length(struct ad405x_dev *dev)
Get averaging filter window length.
Definition: ad405x.c:545
@ AD405X_LENGTH_16
Definition: ad405x.h:172
@ AD405X_BURST_AVERAGING_MODE_OP
Definition: ad405x.h:142
@ AD405X_GP_MODE_HIGH
Definition: ad405x.h:203
int ad405x_set_sample_rate(struct ad405x_dev *dev, enum ad405x_sample_rate rate)
Select sample rate for Burst and Autonomous Modes.
Definition: ad405x.c:482
int ad405x_remove(struct ad405x_dev *dev)
Remove the device and release resources.
Definition: ad405x.c:890
@ AD405X_AVERAGING_MODE_OP
Definition: ad405x.h:141
@ AD405X_LENGTH_2048
Definition: ad405x.h:179
@ AD405X_LENGTH_4
Definition: ad405x.h:170
Header file of Delay functions.
@ AD405X_200_SPS
Definition: ad405x.h:160
@ AD405X_GP_MODE_CHOP
Definition: ad405x.h:201
int ad405x_set_data_format(struct ad405x_dev *dev, enum ad405x_out_data_format data_format)
Set output data format.
Definition: ad405x.c:737
@ AD405X_LENGTH_512
Definition: ad405x.h:177
@ AD405X_GP_MODE_DEV_RDY
Definition: ad405x.h:204
int ad405x_set_dev_en_polarity(struct ad405x_dev *dev, enum ad405x_dev_en_polarity polarity)
Set DEV_EN signal polarity.
Definition: ad405x.c:560
#define pr_info(fmt, args...)
Definition: no_os_print_log.h:115
@ AD405X_125_SPS
Definition: ad405x.h:163
#define AD405X_REG_TIMER_CONFIG
Definition: ad405x.h:75
@ AD405X_NON_PERSISTENT_AUTO_MODE_OP
Definition: ad405x.h:144
int ad405x_set_gp_mode(struct ad405x_dev *dev, enum ad405x_gp_select gp, enum ad405x_gp_mode mode)
Set GP mode.
Definition: ad405x.c:662
int ad405x_init(struct ad405x_dev **device, struct ad405x_init_param init_param)
Initialize the device.
Definition: ad405x.c:806
struct no_os_gpio_init_param * gpio_gpio1
Definition: ad405x.h:280
int ad405x_set_averaging_mode(struct ad405x_dev *dev)
Enter Averaging Mode.
Definition: ad405x.c:290
Definition: ad9361_util.h:69
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
#define AD405X_REG_ADC_MODES
Definition: ad405x.h:69
ad405x_gp_mode
Definition: ad405x.h:196
enum ad405x_invert_on_chop ad405x_get_invert_on_chop_state(struct ad405x_dev *dev)
Get INVERT_ON_CHOP setting.
Definition: ad405x.c:646
int ad405x_set_operation_mode(struct ad405x_dev *dev, enum ad405x_operation_mode mode)
Set operation mode.
Definition: ad405x.c:346
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:124
int ad405x_set_config_mode(struct ad405x_dev *dev)
Enter Config Mode.
Definition: ad405x.c:323
int ad405x_set_averaging_filter_length(struct ad405x_dev *dev, enum ad405x_avg_filter_l length)
Set averaging filter window length.
Definition: ad405x.c:508
@ AD405X_166_SPS
Definition: ad405x.h:161
int ad405x_remove(struct ad405x_dev *dev)
Remove the device and release resources.
Definition: ad405x.c:890
int ad405x_spi_data_read(struct ad405x_dev *dev, int32_t *data)
Read conversion data.
Definition: ad405x.c:410
enum ad405x_operation_mode operation_mode
Definition: ad405x.h:274
#define AD405X_DEV_EN_POL_MSK
Definition: ad405x.h:115
@ AD405X_CONFIG_MODE_OP
Definition: ad405x.h:139
int ad405x_set_config_mode(struct ad405x_dev *dev)
Enter Config Mode.
Definition: ad405x.c:323
struct no_os_gpio_init_param * gpio_gpio0
Definition: ad405x.h:278
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
@ AD405X_ADC_MODE_OP
Definition: ad405x.h:140
@ AD405X_LENGTH_4096
Definition: ad405x.h:180
@ AD405X_140_SPS
Definition: ad405x.h:162
int ad405x_set_sample_rate(struct ad405x_dev *dev, enum ad405x_sample_rate rate)
Select sample rate for Burst and Autonomous Modes.
Definition: ad405x.c:482
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
int ad405x_init(struct ad405x_dev **device, struct ad405x_init_param init_param)
Initialize the device.
Definition: ad405x.c:806
int ad405x_write(struct ad405x_dev *dev, uint8_t reg_addr, uint8_t reg_val)
Write device register.
Definition: ad405x.c:83
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
@ AD405X_1_MSPS
Definition: ad405x.h:150
int ad405x_convst(struct ad405x_dev *dev)
Toggle the CNV pin to start a conversion.
Definition: ad405x.c:383
#define AD405X_GP0_MODE_MSK
Definition: ad405x.h:118
@ AD405X_LENGTH_256
Definition: ad405x.h:176
enum ad405x_invert_on_chop ad405x_get_invert_on_chop_state(struct ad405x_dev *dev)
Get INVERT_ON_CHOP setting.
Definition: ad405x.c:646
int ad405x_set_dev_en_polarity(struct ad405x_dev *dev, enum ad405x_dev_en_polarity polarity)
Set DEV_EN signal polarity.
Definition: ad405x.c:560
#define AD405X_ADC_MODES_MSK
Definition: ad405x.h:98
int ad405x_soft_reset(struct ad405x_dev *dev)
Software reset the device.
Definition: ad405x.c:199
int ad405x_read_val(struct ad405x_dev *dev, int32_t *data)
Trigger conversion and read data.
Definition: ad405x.c:460
@ AD405X_GP_MODE_DRDY
Definition: ad405x.h:199
@ AD405X_1_KSPS
Definition: ad405x.h:156
enum ad405x_sample_rate rate
Definition: ad405x.h:249
#define AD405X_AVERAGING_MODE
Definition: ad405x.h:101
enum ad405x_device_type active_device
Definition: ad405x.h:272
uint32_t no_os_get_unaligned_be24(uint8_t *buf)
@ AD405X_GP_MODE_INTR
Definition: ad405x.h:198
@ AD405X_DEV_EN_ACTIVE_LOW
Definition: ad405x.h:185
@ ID_AD4050
Definition: ad405x.h:221
@ AD405X_333_KSPS
Definition: ad405x.h:151
int ad405x_reset_pattern_command(struct ad405x_dev *dev)
Definition: ad405x.c:178
enum ad405x_gp_mode ad405x_get_gp_mode(struct ad405x_dev *dev, enum ad405x_gp_select gp)
Get GP mode setting.
Definition: ad405x.c:714
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
@ PROD_ID_AD4052
Definition: ad405x.h:228
enum ad405x_dev_en_polarity ad405x_get_dev_en_polarity(struct ad405x_dev *dev)
Get DEV_EN signal polarity.
Definition: ad405x.c:585
#define AD405X_REG_GPIO_CONFIG
Definition: ad405x.h:72
enum ad405x_out_data_format data_format
Definition: ad405x.h:261
int ad405x_exit_command(struct ad405x_dev *dev)
Send EXIT command.
Definition: ad405x.c:158
@ AD405X_DEV_EN_ACTIVE_HIGH
Definition: ad405x.h:186
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
@ ID_AD4052
Definition: ad405x.h:222
@ AD405X_GP_MODE_HIGH_Z
Definition: ad405x.h:197
int ad405x_read_val(struct ad405x_dev *dev, int32_t *data)
Trigger conversion and read data.
Definition: ad405x.c:460
enum ad405x_gp_mode gp0_mode
Definition: ad405x.h:259
int ad405x_set_gp_mode(struct ad405x_dev *dev, enum ad405x_gp_select gp, enum ad405x_gp_mode mode)
Set GP mode.
Definition: ad405x.c:662
enum ad405x_gp_mode gp1_mode
Definition: ad405x.h:255
@ AD405X_LENGTH_128
Definition: ad405x.h:175
@ AD405X_111_SPS
Definition: ad405x.h:164
ad405x_gp_select
Definition: ad405x.h:208
#define AD405X_SW_RESET
Definition: ad405x.h:127
@ AD405X_500_SPS
Definition: ad405x.h:157
struct no_os_spi_desc * spi_desc
Definition: ad405x.h:237
ad405x_dev_en_polarity
Definition: ad405x.h:184
@ AD405X_GP_0
Definition: ad405x.h:209
ad405x_sample_rate
Definition: ad405x.h:148
int ad405x_spi_data_read(struct ad405x_dev *dev, int32_t *data)
Read conversion data.
Definition: ad405x.c:410
#define AD405X_ENTER_ADC_MODE_MSK
Definition: ad405x.h:105
@ AD405X_2_MSPS
Definition: ad405x.h:149
int ad405x_set_burst_averaging_mode(struct ad405x_dev *dev)
Enter Burst Averaging Mode.
Definition: ad405x.c:257
#define AD405X_FS_BURST_AUTO_MSK
Definition: ad405x.h:109
int ad405x_set_adc_mode(struct ad405x_dev *dev)
Enter ADC Mode.
Definition: ad405x.c:224
int ad405x_disable_invert_on_chop(struct ad405x_dev *dev)
Disable INVERT_ON_CHOP.
Definition: ad405x.c:622
AD405X Device structure.
Definition: ad405x.h:235
@ AD405X_33_KSPS
Definition: ad405x.h:153
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
struct no_os_gpio_desc * gpio_gpio0
Definition: ad405x.h:245
struct no_os_spi_init_param * spi_init
Definition: ad405x.h:270
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
enum ad405x_invert_on_chop invert_on_chop_status
Definition: ad405x.h:257
int ad405x_enable_invert_on_chop(struct ad405x_dev *dev)
Enable INVERT_ON_CHOP.
Definition: ad405x.c:598
#define AD405X_AVG_WIN_LEN_MSK
Definition: ad405x.h:112
@ AD405X_STRAIGHT_BINARY
Definition: ad405x.h:215
@ AD405X_GP_MODE_DEV_EN
Definition: ad405x.h:200
struct no_os_gpio_init_param * gpio_cnv
Definition: ad405x.h:276
@ AD405X_100_KSPS
Definition: ad405x.h:152
#define AD405X_GP1_MODE_MSK
Definition: ad405x.h:116
int ad405x_set_operation_mode(struct ad405x_dev *dev, enum ad405x_operation_mode mode)
Set operation mode.
Definition: ad405x.c:346
enum ad405x_gp_mode ad405x_get_gp_mode(struct ad405x_dev *dev, enum ad405x_gp_select gp)
Get GP mode setting.
Definition: ad405x.c:714
@ PROD_ID_AD4050
Definition: ad405x.h:227
@ AD405X_333_SPS
Definition: ad405x.h:158
enum ad405x_dev_en_polarity ad405x_get_dev_en_polarity(struct ad405x_dev *dev)
Get DEV_EN signal polarity.
Definition: ad405x.c:585
#define AD405X_REG_PRODUCT_ID_L
Definition: ad405x.h:57
int ad405x_enable_invert_on_chop(struct ad405x_dev *dev)
Enable INVERT_ON_CHOP.
Definition: ad405x.c:598
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
Header file of GPIO Interface.
int ad405x_disable_invert_on_chop(struct ad405x_dev *dev)
Disable INVERT_ON_CHOP.
Definition: ad405x.c:622
#define AD405X_REG_PRODUCT_ID_H
Definition: ad405x.h:58
enum ad405x_avg_filter_l filter_length
Definition: ad405x.h:251
ad405x_device_type
Definition: ad405x.h:220
int ad405x_set_averaging_filter_length(struct ad405x_dev *dev, enum ad405x_avg_filter_l length)
Set averaging filter window length.
Definition: ad405x.c:508
@ AD405X_LENGTH_64
Definition: ad405x.h:174
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
ad405x_product_id
Definition: ad405x.h:226
enum ad405x_avg_filter_l filter_length
Definition: ad405x.h:284
@ AD405X_3_KSPS
Definition: ad405x.h:155
Header file of utility functions.
int ad405x_update_bits(struct ad405x_dev *dev, uint8_t reg_addr, uint8_t mask, uint8_t reg_val)
Update specific register bits.
Definition: ad405x.c:132
#define AD405X_REG_MODE_SET
Definition: ad405x.h:68
@ AD405X_PERSISTENT_AUTO_MODE_OP
Definition: ad405x.h:143
ad405x_invert_on_chop
Definition: ad405x.h:190
enum ad405x_device_type active_device
Definition: ad405x.h:239
#define AD405X_SW_RESET_MSK
Definition: ad405x.h:87
int ad405x_set_burst_averaging_mode(struct ad405x_dev *dev)
Enter Burst Averaging Mode.
Definition: ad405x.c:257
ad405x_out_data_format
Definition: ad405x.h:214
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
int ad405x_set_adc_mode(struct ad405x_dev *dev)
Enter ADC Mode.
Definition: ad405x.c:224
int ad405x_reset_pattern_command(struct ad405x_dev *dev)
Definition: ad405x.c:178
@ AD405X_10_KSPS
Definition: ad405x.h:154
#define AD405X_ADC_DATA_FORMAT_MSK
Definition: ad405x.h:97
int ad405x_set_data_format(struct ad405x_dev *dev, enum ad405x_out_data_format data_format)
Set output data format.
Definition: ad405x.c:737
Error macro definition for ARM Compiler.
#define AD405X_SAMPLE_MODE
Definition: ad405x.h:99
int ad405x_read(struct ad405x_dev *dev, uint8_t reg_addr, uint8_t *reg_val)
Read device register.
Definition: ad405x.c:105
int ad405x_write(struct ad405x_dev *dev, uint8_t reg_addr, uint8_t reg_val)
Write device register.
Definition: ad405x.c:83
int ad405x_exit_command(struct ad405x_dev *dev)
Send EXIT command.
Definition: ad405x.c:158
enum ad405x_dev_en_polarity polarity
Definition: ad405x.h:253
#define AD405X_REG_AVG_CONFIG
Definition: ad405x.h:71
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
@ AD405X_LENGTH_1024
Definition: ad405x.h:178
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75