![]() |
no-OS
|
#include <stdint.h>#include <stdbool.h>#include "no_os_spi.h"#include "no_os_gpio.h"#include "no_os_util.h"#include "no_os_crc8.h"Go to the source code of this file.
Classes | |
| struct | ad3530r_transfer_config |
| struct | ad3530r_transfer_data |
| struct | ad3530r_desc |
| struct | ad3530r_init_param |
Functions | |
| int | ad3530r_reg_write (struct ad3530r_desc *desc, uint32_t reg_addr, uint16_t reg_val) |
| Write into device register. | |
| int | ad3530r_reg_read (struct ad3530r_desc *desc, uint32_t reg_addr, uint16_t *reg_val) |
| Read from device register. | |
| int | ad3530r_spi_write_mask (struct ad3530r_desc *desc, uint32_t addr, uint32_t mask, uint16_t val) |
| SPI write to device using a mask. | |
| int | ad3530r_update_interface_cfg (struct ad3530r_desc *desc, struct ad3530r_transfer_config *cfg) |
| Updates the interface configuration. | |
| int | ad3530r_multiple_reg_write (struct ad3530r_desc *desc, uint32_t start_addr, uint8_t buff_len, uint8_t *buff) |
| Write multiple register's values. | |
| int | ad3530r_multiple_reg_read (struct ad3530r_desc *desc, uint32_t addr, uint8_t buff_len, uint8_t *buff) |
| Read multiple register's values. | |
| int | ad3530r_set_reference (struct ad3530r_desc *desc, enum ad3530r_ch_vref_select reference_selector) |
| int | ad3530r_set_operating_mode (struct ad3530r_desc *desc, uint8_t chn_num, enum ad3530r_operating_mode chn_op_mode) |
| int | ad3530r_set_output_range (struct ad3530r_desc *desc, enum ad3530r_ch_output_range range_sel) |
| int | ad3530r_set_crc_enable (struct ad3530r_desc *desc, bool en_di) |
| int | ad3530r_set_mux_out_select (struct ad3530r_desc *desc, enum ad3530r_mux_out_select mux_output_sel) |
| int | ad3530r_set_hw_ldac (struct ad3530r_desc *desc, uint16_t mask_hw_ldac) |
| int | ad3530r_set_sw_ldac (struct ad3530r_desc *desc, uint16_t mask_sw_ldac) |
| int | ad3530r_set_dac_value (struct ad3530r_desc *desc, uint16_t dac_value, uint8_t dac_channel, enum ad3530r_write_mode write_mode) |
| int | ad3530r_set_multidac_value (struct ad3530r_desc *desc, uint16_t dac_value, uint16_t dac_chn_mask, enum ad3530r_write_mode write_mode) |
| int | ad3530r_sw_ldac_trigger (struct ad3530r_desc *desc) |
| Trigger the LDAC using software. | |
| int | ad3530r_hw_ldac_trigger (struct ad3530r_desc *desc) |
| Trigger the LDAC using hardware. | |
| int | ad3530r_reset (struct ad3530r_desc *desc) |
| Perform a hard/soft reset. | |
| int | ad3530r_init (struct ad3530r_desc **desc, struct ad3530r_init_param *init_param) |
| Initialize the device structure. | |
| int | ad3530r_remove (struct ad3530r_desc *desc) |
| Free the device descriptor. | |
| uint32_t | get_reg_addr (uint32_t addr, enum ad3530r_id chip_id, enum ad3530r_ch_sel ch_sel) |
| Get adjusted register address based on the chip id selected. | |
| #define AD3530R_ADDR | ( | x | ) |
| #define AD3530R_ADDR_MASK (~AD3530R_READ_BIT) |
| #define AD3530R_CH_DAC_DATA_LSB | ( | x | ) |
| #define AD3530R_CH_DAC_DATA_MSB | ( | x | ) |
| #define AD3530R_CH_GRP | ( | x | ) |
| #define AD3530R_CRC_POLY 0x07 |
| #define AD3530R_CRC_SEED 0xA5 |
| #define AD3530R_DEFAULT_STATUS_REG_VAL 0x04 |
| #define AD3530R_EXTERNAL_VREF_MASK NO_OS_BIT(1) |
| #define AD3530R_LDAC_PULSE_US 1 |
| #define AD3530R_LEN | ( | x | ) |
| #define AD3530R_MASK_ACTIVE_INTERFACE_MODE NO_OS_GENMASK(3, 2) |
| #define AD3530R_MASK_ADDR_ASCENSION NO_OS_BIT(5) |
| #define AD3530R_MASK_CH | ( | ch | ) |
| #define AD3530R_MASK_CLOCK_COUNTING_ERROR NO_OS_BIT(4) |
| #define AD3530R_MASK_CRC_ENABLE (NO_OS_GENMASK(7, 6) | NO_OS_GENMASK(1, 0)) |
| #define AD3530R_MASK_DEVICE_REVISION NO_OS_GENMASK(3, 0) |
| #define AD3530R_MASK_GRADE NO_OS_GENMASK(7, 4) |
| #define AD3530R_MASK_HW_LDAC_EN_0 | ( | x | ) |
| #define AD3530R_MASK_INTERFACE_NOT_READY NO_OS_BIT(7) |
| #define AD3530R_MASK_INVALID_OR_NO_CRC NO_OS_BIT(3) |
| #define AD3530R_MASK_LENGTH 0xFF |
| #define AD3530R_MASK_MUX_SELECT NO_OS_GENMASK(4, 0) |
| #define AD3530R_MASK_OPERATING_MODE | ( | x | ) |
| #define AD3530R_MASK_OPERATING_MODES NO_OS_GENMASK(1, 0) |
| #define AD3530R_MASK_OUTPUT_RANGE NO_OS_BIT(2) |
| #define AD3530R_MASK_PARTIAL_REGISTER_ACCESS NO_OS_BIT(1) |
| #define AD3530R_MASK_REERENCE_SELECT NO_OS_BIT(0) |
| #define AD3530R_MASK_SDO_ACTIVE NO_OS_BIT(4) |
| #define AD3530R_MASK_SHORT_INSTRUCTION NO_OS_BIT(3) |
| #define AD3530R_MASK_SINGLE_INST NO_OS_BIT(7) |
| #define AD3530R_MASK_STREAM_LENGTH_KEEP_VALUE NO_OS_BIT(2) |
| #define AD3530R_MASK_STRICT_REGISTER_ACCESS NO_OS_BIT(5) |
| #define AD3530R_MASK_SW_LDAC_EN_0 | ( | x | ) |
| #define AD3530R_MASK_SW_LDAC_TRIG_B NO_OS_BIT(7) |
| #define AD3530R_MAX_CHANNEL_OP_MODE_0 4 |
| #define AD3530R_MAX_REG_SIZE 2 |
| #define AD3530R_MAX_SHORT_REG_ADDR (AD3530R_R1B | 0x80) |
| #define AD3530R_NUM_CH 8 |
| #define AD3530R_NUM_MUX_OUT_SELECTS 27 |
| #define AD3530R_NUM_REGS 45 |
| #define AD3530R_R1B (1ul << 16) |
| #define AD3530R_R2B (2ul << 16) |
| #define AD3530R_READ_BIT NO_OS_BIT(7) |
| #define AD3530R_REG_ADDR_CHIP_GRADE (AD3530R_R1B | 0x06) |
| #define AD3530R_REG_ADDR_CHIP_TYPE (AD3530R_R1B | 0x03) |
| #define AD3530R_REG_ADDR_DAC_CHN | ( | x | ) |
| #define AD3530R_REG_ADDR_DEVICE_CONFIG (AD3530R_R1B | 0x02) |
| #define AD3530R_REG_ADDR_HW_LDAC_EN_0 (AD3530R_R1B | 0xD0) |
| #define AD3530R_REG_ADDR_INPUT_CHN | ( | x | ) |
| #define AD3530R_REG_ADDR_INTERFACE_CONFIG_A (AD3530R_R1B | 0x00) |
| #define AD3530R_REG_ADDR_INTERFACE_CONFIG_B (AD3530R_R1B | 0x01) |
| #define AD3530R_REG_ADDR_INTERFACE_CONFIG_C (AD3530R_R1B | 0x10) |
| #define AD3530R_REG_ADDR_INTERFACE_STATUS_A (AD3530R_R1B | 0x11) |
| #define AD3530R_REG_ADDR_MAX 0xF9 |
| #define AD3530R_REG_ADDR_MULTI_DAC_CH (AD3530R_R2B | 0XE2) |
| #define AD3530R_REG_ADDR_MULTI_DAC_SEL_0 (AD3530R_R1B | 0XE4) |
| #define AD3530R_REG_ADDR_MULTI_INPUT_CH (AD3530R_R2B | 0XE6) |
| #define AD3530R_REG_ADDR_MULTI_INPUT_SEL_0 (AD3530R_R1B | 0XE8) |
| #define AD3530R_REG_ADDR_MUX_OUT_SELECT (AD3530R_R1B | 0x93) |
| #define AD3530R_REG_ADDR_OPERATING_MODE_0 (AD3530R_R1B | 0x20) |
| #define AD3530R_REG_ADDR_OPERATING_MODE_1 (AD3530R_R1B | 0x21) |
| #define AD3530R_REG_ADDR_OPERATING_MODE_CHN | ( | x | ) |
| #define AD3530R_REG_ADDR_OUTPUT_CONTROL_0 (AD3530R_R1B | 0x2A) |
| #define AD3530R_REG_ADDR_PRODUCT_ID_H (AD3530R_R1B | 0x05) |
| #define AD3530R_REG_ADDR_PRODUCT_ID_L (AD3530R_R1B | 0x04) |
| #define AD3530R_REG_ADDR_REF_CONTROL_0 (AD3530R_R1B | 0x3C) |
| #define AD3530R_REG_ADDR_SCRATCH_PAD (AD3530R_R1B | 0x0A) |
| #define AD3530R_REG_ADDR_SPI_REVISION (AD3530R_R1B | 0x0B) |
| #define AD3530R_REG_ADDR_STATUS_CONTROL (AD3530R_R1B | 0xC2) |
| #define AD3530R_REG_ADDR_STREAM_MODE (AD3530R_R1B | 0x0E) |
| #define AD3530R_REG_ADDR_SW_LDAC_EN_0 (AD3530R_R1B | 0xD1) |
| #define AD3530R_REG_ADDR_SW_LDAC_TRIG_A (AD3530R_R1B | 0XE5) |
| #define AD3530R_REG_ADDR_SW_LDAC_TRIG_B (AD3530R_R1B | 0XE9) |
| #define AD3530R_REG_ADDR_TRANSFER_REGISTER (AD3530R_R1B | 0x0F) |
| #define AD3530R_REG_ADDR_VENDOR_H (AD3530R_R1B | 0x0D) |
| #define AD3530R_REG_ADDR_VENDOR_L (AD3530R_R1B | 0x0C) |
| #define AD3530R_SCRATCH_PAD_TEST_VAL 0x34 |
| #define AD3530R_WRITE_BIT_LONG_INSTR 0x00 |
| #define AD3531R_CH_REG_OFFSET 8 |
| #define AD3531R_NUM_CH 4 |
| #define AD3531R_NUM_MUX_OUT_SELECTS 27 |
| #define AD3531R_REG_ADDR_MAX 0xE9 |
| enum ad3530r_ch_sel |
| enum ad3530r_id |
Signals to monitor on MUX_OUT pin.
| enum ad3530r_status |
| enum ad3530r_write_mode |
| int ad3530r_hw_ldac_trigger | ( | struct ad3530r_desc * | desc | ) |
Trigger the LDAC using hardware.
| desc | - The device structure. |
| int ad3530r_init | ( | struct ad3530r_desc ** | desc, |
| struct ad3530r_init_param * | init_param ) |
Initialize the device structure.
| desc | - The device structure to be initialized. |
| init_param | - Initialization parameter for the device descriptor. |
| int ad3530r_multiple_reg_read | ( | struct ad3530r_desc * | desc, |
| uint32_t | addr, | ||
| uint8_t | count, | ||
| uint8_t * | buff ) |
Read multiple register's values.
| desc | - The device structure. |
| addr | - Starting register address to read from. |
| count | - Number of bytes to read. |
| buff | - Buffer to store data. |
| int ad3530r_multiple_reg_write | ( | struct ad3530r_desc * | desc, |
| uint32_t | start_addr, | ||
| uint8_t | count, | ||
| uint8_t * | buff ) |
Write multiple register's values.
| desc | - The device structure. |
| start_addr | - Starting register address to write into. |
| count | - Number of bytes to write. |
| buff | - Buffer to write data from. |
| int ad3530r_reg_read | ( | struct ad3530r_desc * | desc, |
| uint32_t | reg_addr, | ||
| uint16_t * | reg_val ) |
Read from device register.
| desc | - The device structure. |
| reg_addr | - The register's address. |
| reg_val | - The register's read value. |
| int ad3530r_reg_write | ( | struct ad3530r_desc * | desc, |
| uint32_t | reg_addr, | ||
| uint16_t | reg_val ) |
Write into device register.
| desc | - The device structure. |
| reg_addr | - The register's address. |
| reg_val | - The register's value. |
| int ad3530r_remove | ( | struct ad3530r_desc * | desc | ) |
Free the device descriptor.
| desc | - The device structure. |
| int ad3530r_reset | ( | struct ad3530r_desc * | desc | ) |
Perform a hard/soft reset.
| desc | - The device structure. |
| int ad3530r_set_crc_enable | ( | struct ad3530r_desc * | desc, |
| bool | en_di ) |
Configures the CRC selection bit .
| desc | - The device structure. |
| en_di | - boolean selection for crc bit. |
| int ad3530r_set_dac_value | ( | struct ad3530r_desc * | desc, |
| uint16_t | dac_value, | ||
| uint8_t | dac_channel, | ||
| enum ad3530r_write_mode | write_mode ) |
Set dac value based on the user selected DAC update mode.
| desc | - The device structure. |
| dac_value | - value that will be set in the register. |
| dac_channel | - selected channel. |
| write_mode | - selected write mode. |
| int ad3530r_set_hw_ldac | ( | struct ad3530r_desc * | desc, |
| uint16_t | mask_hw_ldac ) |
Set the hardware ldac configuration.
| desc | - The device structure. |
| mask_hw_ldac | - The array contains HW LDAC channel masks. |
| int ad3530r_set_multidac_value | ( | struct ad3530r_desc * | desc, |
| uint16_t | dac_value, | ||
| uint16_t | dac_chn_mask, | ||
| enum ad3530r_write_mode | write_mode ) |
Sets dac value for multiple channels.
| desc | - The device structure. |
| dac_value | - value that will be set in the register. |
| dac_chn_mask | - mask for selected channels. |
| write_mode | - selected write mode. |
| int ad3530r_set_mux_out_select | ( | struct ad3530r_desc * | desc, |
| enum ad3530r_mux_out_select | mux_output_sel ) |
Set the multiplexer output select register.
| desc | - The device structure. |
| mux_output_sel | - signal to be monitored on the mux_out pin. |
| int ad3530r_set_operating_mode | ( | struct ad3530r_desc * | desc, |
| uint8_t | chn_num, | ||
| enum ad3530r_operating_mode | chn_op_mode ) |
Set operating mode for each channel.
| desc | - The device structure. |
| chn_num | - Channel number to be configured. |
| chn_op_mode | - Operation mode to be set. |
| int ad3530r_set_output_range | ( | struct ad3530r_desc * | desc, |
| enum ad3530r_ch_output_range | range_sel ) |
Set output range for all channels.
| desc | - The device structure. |
| range_sel | - Output range to be selected. |
| int ad3530r_set_reference | ( | struct ad3530r_desc * | desc, |
| enum ad3530r_ch_vref_select | reference_selector ) |
Set reference configuration.
| desc | - The device structure. |
| reference_selector | - The reference to be selected. |
| int ad3530r_set_sw_ldac | ( | struct ad3530r_desc * | desc, |
| uint16_t | mask_sw_ldac ) |
Set the software ldac configuration.
| desc | - The device structure. |
| mask_sw_ldac | - The array contains SW LDAC channel masks. |
| int ad3530r_spi_write_mask | ( | struct ad3530r_desc * | desc, |
| uint32_t | addr, | ||
| uint32_t | mask, | ||
| uint16_t | val ) |
SPI write to device using a mask.
| desc | - The device structure. |
| addr | - The register's address. |
| mask | - The mask for a specific register field. |
| val | - The register's value. |
| int ad3530r_sw_ldac_trigger | ( | struct ad3530r_desc * | desc | ) |
Trigger the LDAC using software.
| desc | - The device structure. |
| int ad3530r_update_interface_cfg | ( | struct ad3530r_desc * | desc, |
| struct ad3530r_transfer_config * | cfg ) |
Updates the interface configuration.
| desc | - The device structure. |
| cfg | - Updated interface configuration structure. |
| uint32_t get_reg_addr | ( | uint32_t | addr, |
| enum ad3530r_id | chip_id, | ||
| enum ad3530r_ch_sel | ch_sel ) |
Get adjusted register address based on the chip id selected.
| addr | - The Base register address. |
| chip_id | - Device id. |
| ch_sel | - Channel set selection. Available options: CH_0_TO_7, CH_8_TO_15 |