![]() |
no-OS
|
Header file of AD405X Driver. More...
#include <stdint.h>#include "no_os_util.h"#include "no_os_i3c.h"#include "no_os_spi.h"#include "no_os_gpio.h"Classes | |
| union | ad405x_comm_init_param |
| struct | ad405x_init_param |
| Structure holding the parameters for AD405X device initialization. More... | |
| union | ad405x_comm_desc |
| struct | ad405x_thresh |
| AD405X threshold configuration values. Entry positions matter. More... | |
| struct | ad405x_i3c_extra |
| AD405X Device I3C structure. More... | |
| struct | ad405x_spi_extra |
| AD405X Device SPI structure. More... | |
| union | ad405x_extra |
| struct | ad405x_dev |
| AD405X Device structure. More... | |
Functions | |
| int | ad405x_init (struct ad405x_dev **device, struct ad405x_init_param init_param) |
| Initialize the communication device. | |
| int | ad405x_remove (struct ad405x_dev *dev) |
| Remove device and free the resources allocated by ad405x_init(). | |
| int | ad405x_soft_reset (struct ad405x_dev *dev) |
| Soft reset of the device. For I3C, the I3C peripheral is not reset, keeping its dynamic address and any other I3C property. | |
| int | ad405x_clear_reset_flags (struct ad405x_dev *dev) |
| Clear reset flags. | |
| int | ad405x_read (struct ad405x_dev *dev, uint8_t addr, uint8_t *data, uint8_t size) |
| Read device registers. | |
| int | ad405x_write (struct ad405x_dev *dev, uint8_t addr, uint8_t *data, uint8_t size) |
| Write registers. | |
| int | ad405x_get_adc (struct ad405x_dev *dev, int32_t *value) |
| Get formatted ADC reading. If gp0 is set as data ready, will be used to delay the acquisition until the signal is deserted (SPI only). | |
| int | ad405x_get_raw (struct ad405x_dev *dev, uint32_t *raw) |
| Get raw ADC reading. | |
| int | ad405x_get_sts_reg (struct ad405x_dev *dev, uint8_t *status_flags, uint8_t *intf_status_flags) |
| Read the interface status and status registers. | |
| int | ad405x_clear_sts_reg (struct ad405x_dev *dev, uint8_t *status_flags, uint8_t *intf_status_flags) |
| Write to clear the interface status and status registers. | |
| int | ad405x_test_scratch_pad (struct ad405x_dev *dev) |
| Test the scratch pad register. A pseudo-random value to test against is defined at compile time. | |
| int | ad405x_set_adc_mode (struct ad405x_dev *dev) |
| Enter ADC Mode. | |
| int | ad405x_set_burst_averaging_mode (struct ad405x_dev *dev) |
| Enter Burst Averaging Mode. | |
| int | ad405x_set_persistent_auto_mode (struct ad405x_dev *dev) |
| Enter Persistent Auto Mode. | |
| int | ad405x_set_nonpersistent_auto_mode (struct ad405x_dev *dev) |
| Enter Non-Persistent Auto Mode. | |
| int | ad405x_set_operation_mode (struct ad405x_dev *dev, enum ad405x_operation_mode mode) |
| Set operation mode. | |
| int | ad405x_set_sample_rate (struct ad405x_dev *dev, enum ad405x_sample_rate rate) |
| Select sample rate for Burst and Autonomous Modes. | |
| enum ad405x_sample_rate | ad405x_get_sample_rate (struct ad405x_dev *dev) |
| Get sample rate for Burst and Autonomous Modes. | |
| int | ad405x_set_avg_filter_length (struct ad405x_dev *dev, enum ad405x_avg_filter_l length) |
| Set averaging filter window length. | |
| enum ad405x_avg_filter_l | ad405x_get_avg_filter_length (struct ad405x_dev *dev) |
| Get averaging filter window length. | |
| int | ad405x_set_dev_en_polarity (struct ad405x_dev *dev, enum ad405x_dev_en_polarity polarity) |
| Set DEV_EN signal polarity. | |
| enum ad405x_dev_en_polarity | ad405x_get_dev_en_polarity (struct ad405x_dev *dev) |
| Get DEV_EN signal polarity. | |
| int | ad405x_set_dev_en_timer_pwr_on (struct ad405x_dev *dev, enum ad405x_dev_en_timer_pwr_on time) |
| Set DEV_EN TIMER_PWR_ON. | |
| enum ad405x_dev_en_timer_pwr_on | ad405x_get_dev_en_timer_pwr_on (struct ad405x_dev *dev) |
| Get DEV_EN TIMER_PWR_ON. | |
| int | ad405x_enable_invert_on_chop (struct ad405x_dev *dev) |
| Enable INVERT_ON_CHOP. | |
| int | ad405x_disable_invert_on_chop (struct ad405x_dev *dev) |
| Disable INVERT_ON_CHOP. | |
| enum ad405x_invert_on_chop | ad405x_get_invert_on_chop_state (struct ad405x_dev *dev) |
| Get INVERT_ON_CHOP setting. | |
| int | ad405x_set_gp_mode (struct ad405x_dev *dev, enum ad405x_gp_select gp, enum ad405x_gp_mode mode) |
| Set GP mode. | |
| enum ad405x_gp_mode | ad405x_get_gp_mode (struct ad405x_dev *dev, enum ad405x_gp_select gp) |
| Get GP mode setting. | |
| int | ad405x_set_data_format (struct ad405x_dev *dev, enum ad405x_out_data_format data_format) |
| Set output data format. | |
| int | ad405x_set_data_format_straight_binary (struct ad405x_dev *dev) |
| Set ADC output data format as straight binary. | |
| int | ad405x_set_data_format_twos_complement (struct ad405x_dev *dev) |
| Set ADC output data format as two's complement. | |
| enum ad405x_out_data_format | ad405x_get_data_format (struct ad405x_dev *dev) |
| Get output data format setting. | |
| int | ad405x_set_threshold (struct ad405x_dev *dev, struct ad405x_thresh *thresh) |
| Set threshold configuration. A simple memory swap puts the ad405x_thresh strict into format to write the 6 registers of interest. | |
| int | ad405x_get_threshold (struct ad405x_dev *dev, struct ad405x_thresh *thresh) |
| Get threshold configuration. | |
| int | ad405x_exit_command (struct ad405x_dev *dev) |
| Send EXIT command (SPI only). | |
| int | ad405x_trigger_adc_conv (struct ad405x_dev *dev) |
| Trigger an ADC conversion (SPI only). Toggle the CNV pin to start the conversion. | |
| int | ad405x_set_averaging_mode (struct ad405x_dev *dev) |
| Enter Averaging Mode (SPI only). | |
| int | ad405x_set_config_mode (struct ad405x_dev *dev, enum ad405x_operation_mode *mode) |
| Enter Configuration Mode (SPI only). | |
| int | ad405x_test_common_ccc (struct ad405x_dev *dev) |
| Test the GETBCR, GETDCR, GETPID, AND GETSTATUS CCCs (I3C only). Compare received BCR and DCR against expected values. | |
| int | ad405x_pool_ibi_config (struct ad405x_dev *dev) |
| Pool IBI status and config registers (I3C only). Values are updated on the device descriptor. | |
| int | ad405x_set_ibi_enable (struct ad405x_dev *dev, bool enable) |
| Enable/disable IBI (I3C only). | |
| int | ad405x_set_ibi_mask (struct ad405x_dev *dev, uint16_t en_mask) |
| Set IBI mask (I3C only). | |
Header file of AD405X Driver.
Copyright 2024~2025(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
| #define AD405X_ADC_DATA_FORMAT_MSK NO_OS_BIT(7) |
| #define AD405X_ADC_MODE 0x00 |
| #define AD405X_ADC_MODES_MSK NO_OS_GENMASK(1, 0) |
| #define AD405X_AVERAGING_MODE NO_OS_BIT(1) |
| #define AD405X_AVG_WIN_LEN_MSK NO_OS_GENMASK(3, 0) |
| #define AD405X_BUFF_SIZE 7 |
| #define AD405X_BURST_AVERAGING_MODE NO_OS_BIT(0) |
| #define AD405X_CLEAR_NOT_RDY_FLAG NO_OS_BIT(7) |
| #define AD405X_CLEAR_RESET_FLAG NO_OS_BIT(6) |
| #define AD405X_DEV_EN_POL_MSK NO_OS_BIT(7) |
| #define AD405X_ENTER_ADC_MODE NO_OS_BIT(0) |
| #define AD405X_ENTER_ADC_MODE_MSK NO_OS_BIT(0) |
| #define AD405X_ENTER_AUTO_MODE NO_OS_BIT(2) |
| #define AD405X_ENTER_AUTO_MODE_MSK NO_OS_BIT(2) |
| #define AD405X_FS_BURST_AUTO_MSK NO_OS_GENMASK(7, 4) |
| #define AD405X_GP0_MODE_MSK NO_OS_GENMASK(2, 0) |
| #define AD405X_GP1_MODE_MSK NO_OS_GENMASK(6, 4) |
| #define AD405X_I3C_BCR 0x26 |
| #define AD405X_I3C_DCR 0x00 |
| #define AD405X_I3C_PID | ( | x | ) |
| #define AD405X_I3C_PID_ 0x02ee00700000 |
| #define AD405X_I3C_PID_INSTANCE_ID | ( | x | ) |
| #define AD405X_IBI_EN_CONV_TRIGGER | ( | x | ) |
| #define AD405X_IBI_EN_CONV_TRIGGER_GET | ( | x | ) |
| #define AD405X_IBI_EN_MAX_SET | ( | x | ) |
| #define AD405X_IBI_EN_MIN_SET | ( | x | ) |
| #define AD405X_IBI_STS_EN | ( | x | ) |
| #define AD405X_INTF_STATUS_FLAGS_MSK | ( | x | ) |
| #define AD405X_INVERT_ON_CHOP_MSK NO_OS_BIT(3) |
| #define AD405X_ISTS_NOT_RDY_ERROR | ( | x | ) |
| #define AD405X_NONPERSISTENT_AUTO_MODE NO_OS_GENMASK(1, 0) |
| #define AD405X_PERSISTENT_AUTO_MODE NO_OS_GENMASK(1, 0) |
| #define AD405X_PROD_ID_0_RESET | ( | x | ) |
| #define AD405X_PROD_ID_1_RESET 0x00 |
| #define AD405X_REG_ADC_CONFIG 0x22 |
| #define AD405X_REG_ADC_IBI_EN 0x31 |
| #define AD405X_REG_ADC_MODES 0x21 |
| #define AD405X_REG_AVG_CONFIG 0x23 |
| #define AD405X_REG_CHOP_CONFIG 0x26 |
| #define AD405X_REG_CONV_AUTO 0x58 |
| #define AD405X_REG_CONV_READ | ( | x | ) |
| #define AD405X_REG_CONV_TRIGGER | ( | x | ) |
| #define AD405X_REG_DEVICE_CONFIG 0x02 |
| #define AD405X_REG_DEVICE_STATUS 0x41 |
| #define AD405X_REG_FUSE_CRC 0x40 |
| #define AD405X_REG_GPIO_CONFIG 0x24 |
| #define AD405X_REG_GRP_ADDR 0x47 |
| #define AD405X_REG_IBI_STATUS 0x48 |
| #define AD405X_REG_INTF_CONFIG_A 0x00 |
| #define AD405X_REG_INTF_IBI_EN 0x30 |
| #define AD405X_REG_INTF_STATUS 0x11 |
| #define AD405X_REG_INTR_CONFIG 0x25 |
| #define AD405X_REG_MAX_HYST_REG 0x2C |
| #define AD405X_REG_MAX_INTR | ( | x | ) |
| #define AD405X_REG_MAX_THRESH_REG | ( | x | ) |
| #define AD405X_REG_MIN_HYST_REG 0x2D |
| #define AD405X_REG_MIN_INTR | ( | x | ) |
| #define AD405X_REG_MIN_THRESH_REG | ( | x | ) |
| #define AD405X_REG_MODE_SET 0x20 |
| #define AD405X_REG_MON_VAL_REG | ( | x | ) |
| #define AD405X_REG_PROD_ID_0 0x04 |
| #define AD405X_REG_PROD_ID_1 0x05 |
| #define AD405X_REG_SCRATCH_PAD 0x0A |
| #define AD405X_REG_STREAM_MODE 0x0E |
| #define AD405X_REG_TGT_ADDR 0x46 |
| #define AD405X_REG_TIMER_CONFIG 0x27 |
| #define AD405X_REG_VENDOR_H 0x0D |
| #define AD405X_REG_VENDOR_L 0x0C |
| #define AD405X_RESET_CODE 0x81 |
| #define AD405X_SPI_READ NO_OS_BIT(7) |
| #define AD405X_STATUS_FLAGS_MSK | ( | x | ) |
| #define AD405X_STS_DEVICE_READY | ( | x | ) |
| #define AD405X_STS_DEVICE_RESET | ( | x | ) |
| #define AD405X_TIMER_PWR_ON_MSK NO_OS_GENMASK(3, 0) |
| #define AD405X_VENDOR_I3C_H_RESET 0x01 |
| #define AD405X_VENDOR_I3C_L_RESET 0x77 |
| #define AD405X_VENDOR_SPI_H_RESET 0x04 |
| #define AD405X_VENDOR_SPI_L_RESET 0x56 |
| enum ad405x_avg_filter_l |
| enum ad405x_comm_type |
AD405X DEV_EN power-on timer setting
| enum ad405x_gp_mode |
| enum ad405x_gp_select |
| enum ad405x_sample_rate |
| enum ad405x_type |
| int ad405x_clear_reset_flags | ( | struct ad405x_dev * | dev | ) |
Clear reset flags.
Clear reset flags of device
| dev | - The device descriptor. |
| int ad405x_clear_sts_reg | ( | struct ad405x_dev * | dev, |
| uint8_t * | status_flags, | ||
| uint8_t * | intf_status_flags ) |
Write to clear the interface status and status registers.
Write to clear the interface status and status registers
| dev | - The device descriptor. |
| status_flags | - Status register value (optional). |
| intf_status_flags | - Interface register value (optional). |
| int ad405x_disable_invert_on_chop | ( | struct ad405x_dev * | dev | ) |
Disable INVERT_ON_CHOP.
Disable INVERT_ON_CHOP
| dev | - The device descriptor. |
| int ad405x_enable_invert_on_chop | ( | struct ad405x_dev * | dev | ) |
Enable INVERT_ON_CHOP.
Enable INVERT_ON_CHOP
| dev | - The device descriptor. |
| int ad405x_exit_command | ( | struct ad405x_dev * | dev | ) |
Send EXIT command (SPI only).
Send EXIT command (SPI only)
| dev | - The device descriptor. |
| int ad405x_get_adc | ( | struct ad405x_dev * | dev, |
| int32_t * | value ) |
Get formatted ADC reading. If gp0 is set as data ready, will be used to delay the acquisition until the signal is deserted (SPI only).
Get formatted ADC reading
| dev | - The device descriptor. |
| value | - ADC value. |
| enum ad405x_avg_filter_l ad405x_get_avg_filter_length | ( | struct ad405x_dev * | dev | ) |
Get averaging filter window length.
Get averaging filter window length
| dev | - The device descriptor. |
| enum ad405x_out_data_format ad405x_get_data_format | ( | struct ad405x_dev * | dev | ) |
Get output data format setting.
Get ADC output data format
| dev | - The device descriptor. |
| 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 descriptor. |
| enum ad405x_dev_en_timer_pwr_on ad405x_get_dev_en_timer_pwr_on | ( | struct ad405x_dev * | dev | ) |
Get DEV_EN TIMER_PWR_ON.
Get DEV_EN TIMER_PWR_ON
| dev | - The device descriptor. |
| 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
| dev | - The device descriptor. |
| 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 descriptor. |
| int ad405x_get_raw | ( | struct ad405x_dev * | dev, |
| uint32_t * | raw ) |
Get raw ADC reading.
Get raw ADC reading
| dev | - The device descriptor. |
| raw | - Raw ADC data. |
| enum ad405x_sample_rate ad405x_get_sample_rate | ( | struct ad405x_dev * | dev | ) |
Get sample rate for Burst and Autonomous Modes.
Get sample rate for Burst and Autonomous Modes
| dev | - The device descriptor. |
| int ad405x_get_sts_reg | ( | struct ad405x_dev * | dev, |
| uint8_t * | status_flags, | ||
| uint8_t * | intf_status_flags ) |
Read the interface status and status registers.
Reads the interface status and status registers
| dev | - The device descriptor. |
| status_flags | - Status register value. |
| intf_status_flags | - Interface register value (optional). |
| int ad405x_get_threshold | ( | struct ad405x_dev * | dev, |
| struct ad405x_thresh * | thresh ) |
Get threshold configuration.
Get threshold configuration
| dev | - The device descriptor. |
| thresh | - The threshold configuration structure. |
| int ad405x_init | ( | struct ad405x_dev ** | device, |
| struct ad405x_init_param | init_param ) |
Initialize the communication device.
Initialize the device
| device | - The device descriptor. |
| init_param | - The device initial descriptor. |
| int ad405x_pool_ibi_config | ( | struct ad405x_dev * | dev | ) |
Pool IBI status and config registers (I3C only). Values are updated on the device descriptor.
Pool IBI status and config registers (I3C only)
| dev | - The device descriptor. |
| int ad405x_read | ( | struct ad405x_dev * | dev, |
| uint8_t | addr, | ||
| uint8_t * | data, | ||
| uint8_t | size ) |
Read device registers.
Read device registers
| dev | - The device descriptor. |
| addr | - Address of the base register. |
| data | - The read data buffer |
| size | - The number of bytes to be read. |
| int ad405x_remove | ( | struct ad405x_dev * | dev | ) |
Remove device and free the resources allocated by ad405x_init().
Remove device and free resources allocated by ad405x_init()
| dev | - The device descriptor. |
| int ad405x_set_adc_mode | ( | struct ad405x_dev * | dev | ) |
Enter ADC Mode.
Enter ADC Mode
| dev | - The device descriptor. |
| int ad405x_set_averaging_mode | ( | struct ad405x_dev * | dev | ) |
Enter Averaging Mode (SPI only).
Enter Averaging Mode (SPI only)
| dev | - The device descriptor. |
| int ad405x_set_avg_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 descriptor. |
| length | - Averaging filter length value. |
| int ad405x_set_burst_averaging_mode | ( | struct ad405x_dev * | dev | ) |
Enter Burst Averaging Mode.
Enter Burst Averaging Mode
| dev | - The device descriptor. |
| int ad405x_set_config_mode | ( | struct ad405x_dev * | dev, |
| enum ad405x_operation_mode * | mode ) |
Enter Configuration Mode (SPI only).
Enter Configuration Mode (SPI only)
| dev | - The device descriptor. |
| mode | - Store the current op mode, to resume later (optional). |
| 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 descriptor. |
| data_format | - Format select. |
| int ad405x_set_data_format_straight_binary | ( | struct ad405x_dev * | dev | ) |
Set ADC output data format as straight binary.
Set ADC output data format as straight binary
| dev | - The device descriptor. |
| int ad405x_set_data_format_twos_complement | ( | struct ad405x_dev * | dev | ) |
Set ADC output data format as two's complement.
Set ADC output data format as two's complement
| dev | - The device descriptor. |
| 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 descriptor. |
| polarity | - DEV_EN signal polarity. |
| int ad405x_set_dev_en_timer_pwr_on | ( | struct ad405x_dev * | dev, |
| enum ad405x_dev_en_timer_pwr_on | time ) |
Set DEV_EN TIMER_PWR_ON.
Set DEV_EN TIMER_PWR_ON
| dev | - The device descriptor. |
| time | - DEV_EN power-on timer setting. |
| 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 descriptor. |
| gp | - GP1/GP0 select. |
| mode | - mode select. |
| int ad405x_set_ibi_enable | ( | struct ad405x_dev * | dev, |
| bool | enable ) |
Enable/disable IBI (I3C only).
Enable/disable IBI (I3C only)
| dev | - The device descriptor. |
| enable | - Enable IBI. |
| int ad405x_set_ibi_mask | ( | struct ad405x_dev * | dev, |
| uint16_t | en_mask ) |
Set IBI mask (I3C only).
Set IBI mask (I3C only)
| dev | - The device descriptor. |
| en_mask | - Enable interface and ADC flags. |
| int ad405x_set_nonpersistent_auto_mode | ( | struct ad405x_dev * | dev | ) |
Enter Non-Persistent Auto Mode.
Enter Non Persistent Auto Mode
| dev | - The device descriptor. |
| int ad405x_set_operation_mode | ( | struct ad405x_dev * | dev, |
| enum ad405x_operation_mode | mode ) |
Set operation mode.
Set operation mode
| dev | - The device descriptor. |
| mode | - Operation mode. |
| int ad405x_set_persistent_auto_mode | ( | struct ad405x_dev * | dev | ) |
Enter Persistent Auto Mode.
Enter Persistent Auto Mode
| dev | - The device descriptor. |
| 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 descriptor. |
| rate | - The sample rate. |
| int ad405x_set_threshold | ( | struct ad405x_dev * | dev, |
| struct ad405x_thresh * | thresh ) |
Set threshold configuration. A simple memory swap puts the ad405x_thresh strict into format to write the 6 registers of interest.
Set threshold configuration
| dev | - The device descriptor. |
| thresh | - The threshold configuration structure. |
| int ad405x_soft_reset | ( | struct ad405x_dev * | dev | ) |
Soft reset of the device. For I3C, the I3C peripheral is not reset, keeping its dynamic address and any other I3C property.
Soft reset the device
| dev | - The device descriptor. |
| int ad405x_test_common_ccc | ( | struct ad405x_dev * | dev | ) |
Test the GETBCR, GETDCR, GETPID, AND GETSTATUS CCCs (I3C only). Compare received BCR and DCR against expected values.
Test common CCCs (I3C only)
| dev | - The device descriptor. |
| int ad405x_test_scratch_pad | ( | struct ad405x_dev * | dev | ) |
Test the scratch pad register. A pseudo-random value to test against is defined at compile time.
Test scratch register pad register
| dev | - The device descriptor. |
| int ad405x_trigger_adc_conv | ( | struct ad405x_dev * | dev | ) |
Trigger an ADC conversion (SPI only). Toggle the CNV pin to start the conversion.
Trigger an ADC conversion (SPI only)
| dev | - The device descriptor. |
| int ad405x_write | ( | struct ad405x_dev * | dev, |
| uint8_t | addr, | ||
| uint8_t * | data, | ||
| uint8_t | size ) |
Write registers.
Write device registers
| dev | - The device descriptor. |
| addr | - Address of the base register. |
| data | - The data which is going to be written. |
| size | - The number of bytes to be written. |