no-OS
|
#include <stdint.h>
#include <stdbool.h>
#include "no_os_util.h"
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_error.h"
Go to the source code of this file.
Classes | |
struct | ad4858_conv_data |
ADC conversion data structure. More... | |
struct | ad4858_init_param |
AD4858 init parameters structure used for initializing the ad4858_dev. More... | |
struct | ad4858_dev |
AD4858 device descriptor. More... | |
Functions | |
int | ad4858_init (struct ad4858_dev **device, struct ad4858_init_param *init_param) |
Initialize an AD4858 device structure. More... | |
int | ad4858_remove (struct ad4858_dev *dev) |
Remove an AD4858 device (free memory allocated by ad4858_init function). More... | |
int | ad4858_reg_write (struct ad4858_dev *dev, uint32_t reg_addr, uint32_t reg_val) |
Write device register. More... | |
int | ad4858_reg_read (struct ad4858_dev *dev, uint32_t reg_addr, uint32_t *reg_val) |
Read device register. More... | |
int | ad4858_reg_mask (struct ad4858_dev *dev, uint32_t reg_addr, uint32_t mask, uint32_t reg_val) |
Update specific register bits of an input register. More... | |
int | ad4858_soft_reset (struct ad4858_dev *dev) |
Perform an AD4858 software reset. More... | |
int | ad4858_set_operating_mode (struct ad4858_dev *dev, enum ad4858_operating_mode mode) |
Set the device operating mode. More... | |
int | ad4858_set_spi_data_mode (struct ad4858_dev *dev, enum ad4858_spi_data_mode mode) |
Set the SPI data mode. More... | |
int | ad4858_set_config_interface_mode (struct ad4858_dev *dev) |
Set device config interface mode. More... | |
int | ad4858_set_data_interface_mode (struct ad4858_dev *dev) |
Set device data interface mode. More... | |
int | ad4858_enable_osr (struct ad4858_dev *dev, bool osr_status) |
Enable OSR. More... | |
int | ad4858_set_osr_ratio (struct ad4858_dev *dev, enum ad4858_osr_ratio osr_ratio) |
Set OSR ratio. More... | |
int | ad4858_set_packet_format (struct ad4858_dev *dev, enum ad4858_packet_format packet_format) |
Set packet format. More... | |
int | ad4858_enable_test_pattern (struct ad4858_dev *dev, bool test_pattern) |
Enable/Disable test pattern on ADC data output. More... | |
int | ad4858_set_chn_softspan (struct ad4858_dev *dev, uint8_t chn, enum ad4858_chn_softspan chn_softspan) |
Set channel softspan. More... | |
int | ad4858_set_chn_offset (struct ad4858_dev *dev, uint8_t chn, uint32_t offset) |
Set channel offset. More... | |
int | ad4858_set_chn_gain (struct ad4858_dev *dev, uint8_t chn, uint16_t gain) |
Set channel gain. More... | |
int | ad4858_set_chn_phase (struct ad4858_dev *dev, uint8_t chn, uint16_t phase) |
Set channel phase. More... | |
int | ad4858_set_chn_or_limit (struct ad4858_dev *dev, uint8_t chn, uint32_t or_limit) |
Set channel overrange (OR) limit. More... | |
int | ad4858_set_chn_ur_limit (struct ad4858_dev *dev, uint8_t chn, uint32_t ur_limit) |
Set channel underrange (UR) limit. More... | |
int | ad4858_convst (struct ad4858_dev *dev) |
Toggle the CNV pin to start a conversion. More... | |
int | ad4858_perform_conv (struct ad4858_dev *dev) |
Perform ADC conversion. More... | |
int | ad4858_spi_data_read (struct ad4858_dev *dev, struct ad4858_conv_data *data) |
Read ADC conversion data over SPI. More... | |
int | ad4858_read_data (struct ad4858_dev *dev, struct ad4858_conv_data *data) |
Read ADC data (for all channels). More... | |
int | ad4858_enable_ch_sleep (struct ad4858_dev *dev, uint8_t chn, enum ad4858_ch_sleep_value sleep_status) |
Enable/Disable channel sleep. More... | |
int | ad4858_enable_ch_seamless_hdr (struct ad4858_dev *dev, uint8_t chn, enum ad4858_ch_seamless_hdr seamless_hdr_status) |
Enable/Disable seamless hdr. More... | |
#define AD4851_PRODUCT_ID_L 0x67 |
#define AD4852_PRODUCT_ID_L 0x66 |
#define AD4853_PRODUCT_ID_L 0x65 |
#define AD4854_PRODUCT_ID_L 0x64 |
#define AD4855_PRODUCT_ID_L 0x63 |
#define AD4856_PRODUCT_ID_L 0x62 |
#define AD4857_PRODUCT_ID_L 0x61 |
#define AD4858_ACTIVE_INF_MODE_MSK NO_OS_GENMASK(3,2) |
AD4858_REG_INTERFACE_CONFIG_C bit masks
#define AD4858_ADDR | ( | x | ) | ((x) & 0xFFFF) |
#define AD4858_ADDR_ASCENSION_MSK NO_OS_BIT(5) |
#define AD4858_ADDR_INVALID_ERR_MSK NO_OS_BIT(0) |
AD4858_REG_INTERFACE_STATUS_A bit masks
#define AD4858_CLK_COUNT_ERR_MSK NO_OS_BIT(4) |
#define AD4858_CRC_ENABLE_MSK NO_OS_GENMASK(7,6) |
#define AD4858_CRC_ERR_MSK NO_OS_BIT(3) |
#define AD4858_CSDO_ON_SDO_MSK NO_OS_BIT(0) |
AD4858_REG_SPI_CONFIG_D bit masks
#define AD4858_DEF_CHN_GAIN 0x8000 |
#define AD4858_DEF_CHN_OFFSET 0x0 |
#define AD4858_DEF_CHN_OR 0x7ffff0 |
#define AD4858_DEF_CHN_PHASE 0x0 |
#define AD4858_DEF_CHN_SOFTSPAN 0xf |
#define AD4858_DEF_CHN_UR 0x800000 |
#define AD4858_KEEP_STRM_LEN_MSK NO_OS_BIT(2) |
AD4858_REG_TRANSFER_CONFIG bit masks
#define AD4858_LEN | ( | x | ) | ((x) >> 16) |
#define AD4858_NOT_READY_ERR_MSK NO_OS_BIT(7) |
#define AD4858_NUM_CHANNELS 8 |
#define AD4858_OPERATING_MODES_MSK NO_OS_GENMASK(1,0) |
AD4858_REG_DEVICE_CONFIG bit masks
#define AD4858_OS_ENABLE_MSK NO_OS_BIT(7) |
AD4858_REG_OVERSAMPLE bit masks
#define AD4858_OS_RATIO_MSK NO_OS_GENMASK(3,0) |
#define AD4858_PACKET_FORMAT_MSK NO_OS_GENMASK(1,0) |
#define AD4858_PRODUCT_ID_L 0x60 |
#define AD4858_R1B (1ul << 16) |
#define AD4858_R2B (2ul << 16) |
#define AD4858_R3B (3ul << 16) |
#define AD4858_R4B (4ul << 16) |
#define AD4858_REG_CH_GAIN | ( | chn | ) | (AD4858_R2B | (0x2E + (0x12 * chn))) |
#define AD4858_REG_CH_OFFSET | ( | chn | ) | (AD4858_R3B | (0x2B + (0x12 * chn))) |
#define AD4858_REG_CH_OR | ( | chn | ) | (AD4858_R3B | (0x32 + (0x12 * chn))) |
#define AD4858_REG_CH_OR_STATUS (AD4858_R1B | 0x21) |
#define AD4858_REG_CH_PHASE | ( | chn | ) | (AD4858_R2B | (0x30 + (0x12 * chn))) |
#define AD4858_REG_CH_SLEEP (AD4858_R1B | 0x29) |
#define AD4858_REG_CH_SOFTSPAN | ( | chn | ) | (AD4858_R1B | (0x2A + (0x12 * chn))) |
#define AD4858_REG_CH_TESTPAT | ( | chn | ) | (AD4858_R4B | (0x38 + (0x12 * chn))) |
#define AD4858_REG_CH_UR | ( | chn | ) | (AD4858_R3B | (0x35 + (0x12 * chn))) |
#define AD4858_REG_CH_UR_STATUS (AD4858_R1B | 0x22) |
#define AD4858_REG_CHIP_GRADE (AD4858_R1B | 0x06) |
#define AD4858_REG_CHIP_TYPE (AD4858_R1B | 0x03) |
#define AD4858_REG_DEVICE_CONFIG (AD4858_R1B | 0x02) |
#define AD4858_REG_DEVICE_CTRL (AD4858_R1B | 0x25) |
#define AD4858_REG_DEVICE_STATUS (AD4858_R1B | 0x20) |
#define AD4858_REG_INTERFACE_CONFIG_A (AD4858_R1B | 0x00) |
Register definitions
#define AD4858_REG_INTERFACE_CONFIG_B (AD4858_R1B | 0x01) |
#define AD4858_REG_INTERFACE_CONFIG_C (AD4858_R1B | 0x10) |
#define AD4858_REG_INTERFACE_STATUS_A (AD4858_R1B | 0x11) |
#define AD4858_REG_OVERSAMPLE (AD4858_R1B | 0x27) |
#define AD4858_REG_PACKET (AD4858_R1B | 0x26) |
#define AD4858_REG_PRODUCT_ID_H (AD4858_R1B | 0x05) |
#define AD4858_REG_PRODUCT_ID_L (AD4858_R1B | 0x04) |
#define AD4858_REG_RD_BIT_MSK NO_OS_BIT(7) |
Miscellaneous Definitions
#define AD4858_REG_REGMAP_CRC (AD4858_R2B | 0x23) |
#define AD4858_REG_SCRATCH_PAD (AD4858_R1B | 0x0A) |
#define AD4858_REG_SEAMLESS_HDR (AD4858_R1B | 0x28) |
#define AD4858_REG_SPI_CONFIG_D (AD4858_R1B | 0x14) |
#define AD4858_REG_SPI_REV (AD4858_R1B | 0x0B) |
#define AD4858_REG_STREAM_MODE (AD4858_R1B | 0x0E) |
#define AD4858_REG_TRANSFER_CONFIG (AD4858_R1B | 0x0F) |
#define AD4858_REG_VENDOR_H (AD4858_R1B | 0x0D) |
#define AD4858_REG_VENDOR_L (AD4858_R1B | 0x0C) |
#define AD4858_SDO_ENABLE_MSK NO_OS_BIT(4) |
#define AD4858_SINGLE_INST_MSK NO_OS_BIT(7) |
AD4858_REG_INTERFACE_CONFIG_B bit masks
#define AD4858_SOFTSPAN_MSK NO_OS_GENMASK(3,0) |
AD4858_REG_CH_SOFTSPAN bit masks
#define AD4858_STATUS_BIT0_MSK NO_OS_BIT(4) |
#define AD4858_STATUS_BIT1_MSK NO_OS_BIT(5) |
#define AD4858_STATUS_BIT2_MSK NO_OS_BIT(6) |
#define AD4858_STATUS_BIT3_MSK NO_OS_BIT(7) |
#define AD4858_TEST_PATTERN_MSK NO_OS_BIT(2) |
AD4858_REG_PACKET bit masks
#define AD4858_WR_TO_RD_ONLY_ERR_MSK NO_OS_BIT(2) |
#define AD4858I_PRODUCT_ID_L 0x6F |
#define AD485X_PRODUCT_ID_H 0x00 |
enum ad4858_chn_softspan |
Channel softspan.
enum ad4858_osr_ratio |
enum ad4858_packet_format |
enum ad4858_prod_id |
enum ad4858_spi_data_mode |
int ad4858_convst | ( | struct ad4858_dev * | dev | ) |
Toggle the CNV pin to start a conversion.
dev | - Pointer to the device structure. |
int ad4858_enable_ch_seamless_hdr | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
enum ad4858_ch_seamless_hdr | seamless_hdr_status | ||
) |
Enable/Disable seamless hdr.
dev | - Pointer to the device structure. |
chn | - Input channel. |
seamless_hdr_status | - seamless hdr status. |
int ad4858_enable_ch_sleep | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
enum ad4858_ch_sleep_value | sleep_status | ||
) |
Enable/Disable channel sleep.
dev | - Pointer to the device structure. |
chn | - Input channel. |
sleep_status | - Sleep status. |
int ad4858_enable_osr | ( | struct ad4858_dev * | dev, |
bool | osr_status | ||
) |
Enable OSR.
dev | - Pointer to the device structure. |
osr_status | - OSR enable/disable status. |
int ad4858_enable_test_pattern | ( | struct ad4858_dev * | dev, |
bool | test_pattern | ||
) |
Enable/Disable test pattern on ADC data output.
dev | - Pointer to the device structure. |
test_pattern | - Test pattern enable status. |
int ad4858_init | ( | struct ad4858_dev ** | device, |
struct ad4858_init_param * | init_param | ||
) |
Initialize an AD4858 device structure.
device | - Pointer to the device structure (memory is allocated within this function). |
init_param | - Pointer to the initialization parameters. |
int ad4858_perform_conv | ( | struct ad4858_dev * | dev | ) |
Perform ADC conversion.
dev | - Pointer to the device structure. |
int ad4858_read_data | ( | struct ad4858_dev * | dev, |
struct ad4858_conv_data * | data | ||
) |
Read ADC data (for all channels).
dev | - Pointer to the device structure. |
data | - Pointer to adc conversion data structure. |
int ad4858_reg_mask | ( | struct ad4858_dev * | dev, |
uint32_t | reg_addr, | ||
uint32_t | mask, | ||
uint32_t | reg_val | ||
) |
Update specific register bits of an input register.
dev | - The device structure. |
reg_addr | - The register address. |
mask | - Specific bits mask. |
reg_val | - The data to be written. |
int ad4858_reg_read | ( | struct ad4858_dev * | dev, |
uint32_t | reg_addr, | ||
uint32_t * | reg_val | ||
) |
Read device register.
dev | - The device structure. |
reg_addr | - The register address. |
reg_val | - The data read from the register. |
int ad4858_reg_write | ( | struct ad4858_dev * | dev, |
uint32_t | reg_addr, | ||
uint32_t | reg_val | ||
) |
Write device register.
dev- | The device structure. |
reg_addr | - The register address. |
reg_val | - The data to be written. |
int ad4858_remove | ( | struct ad4858_dev * | dev | ) |
Remove an AD4858 device (free memory allocated by ad4858_init function).
dev | - Pointer to the device structure. |
int ad4858_set_chn_gain | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
uint16_t | gain | ||
) |
Set channel gain.
dev | - Pointer to the device structure. |
chn | - Input channel. |
gain | - Gain value. |
int ad4858_set_chn_offset | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
uint32_t | offset | ||
) |
Set channel offset.
dev | - Pointer to the device structure. |
chn | - Input channel. |
offset | - Offset value. |
int ad4858_set_chn_or_limit | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
uint32_t | or_limit | ||
) |
Set channel overrange (OR) limit.
dev | - Pointer to the device structure. |
chn | - Input channel. |
or_limit | - Overrange limit. |
int ad4858_set_chn_phase | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
uint16_t | phase | ||
) |
Set channel phase.
dev | - Pointer to the device structure. |
chn | - Input channel. |
phase | - Phase value. |
int ad4858_set_chn_softspan | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
enum ad4858_chn_softspan | chn_softspan | ||
) |
Set channel softspan.
dev | - Pointer to the device structure. |
chn | - Input channel. |
chn_softspan | - Softspan value. |
int ad4858_set_chn_ur_limit | ( | struct ad4858_dev * | dev, |
uint8_t | chn, | ||
uint32_t | ur_limit | ||
) |
Set channel underrange (UR) limit.
dev | - Pointer to the device structure. |
chn | - Input channel. |
ur_limit | - Underrange limit. |
int ad4858_set_config_interface_mode | ( | struct ad4858_dev * | dev | ) |
Set device config interface mode.
dev | - Pointer to the device structure. |
int ad4858_set_data_interface_mode | ( | struct ad4858_dev * | dev | ) |
Set device data interface mode.
dev | - Pointer to the device structure. |
int ad4858_set_operating_mode | ( | struct ad4858_dev * | dev, |
enum ad4858_operating_mode | mode | ||
) |
Set the device operating mode.
dev | - Pointer to the device structure. |
mode | - Operating mode. |
int ad4858_set_osr_ratio | ( | struct ad4858_dev * | dev, |
enum ad4858_osr_ratio | osr_ratio | ||
) |
Set OSR ratio.
dev | - Pointer to the device structure. |
osr_ratio | - OSR ratio. |
int ad4858_set_packet_format | ( | struct ad4858_dev * | dev, |
enum ad4858_packet_format | packet_format | ||
) |
Set packet format.
dev | - Pointer to the device structure. |
packet_format | - Packet format. |
int ad4858_set_spi_data_mode | ( | struct ad4858_dev * | dev, |
enum ad4858_spi_data_mode | mode | ||
) |
Set the SPI data mode.
dev | - Pointer to the device structure. |
mode | - SPI data mode. |
int ad4858_soft_reset | ( | struct ad4858_dev * | dev | ) |
Perform an AD4858 software reset.
dev | - Pointer to the device structure. |
int ad4858_spi_data_read | ( | struct ad4858_dev * | dev, |
struct ad4858_conv_data * | data | ||
) |
Read ADC conversion data over SPI.
dev | - Pointer to the device structure. |
data | - Pointer to adc conversion data structure. |