Implementation of ad3552r Driver. More...
#include "ad3552r.h"
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_error.h"
#include "no_os_gpio.h"
#include "no_os_print_log.h"
#include "no_os_spi.h"
#include "no_os_timer.h"
#include "no_os_util.h"
Macros | |
#define | AD3552R_BYTES_PER_SAMPLE 4 |
#define | SEC_TO_10NS(x) |
#define | AD3552R_ATTR_REG(attr) |
#define | AD3552R_ATTR_MASK(attr) |
#define | AD3552R_CH_ATTR_REG(attr) |
#define | AD3552R_CH_ATTR_MASK(ch, attr) |
#define | AD3552R_MAX_REG_SIZE 3 |
#define | AD3552R_READ_BIT (1 << 7) |
#define | AD3552R_ADDR_MASK (~AD3552R_READ_BIT) |
#define | AD3552R_CRC_ENABLE_VALUE (NO_OS_BIT(6) | NO_OS_BIT(1)) |
#define | AD3552R_CRC_DISABLE_VALUE (NO_OS_BIT(1) | NO_OS_BIT(0)) |
#define | AD3552R_EXTERNAL_VREF_MASK NO_OS_BIT(1) |
#define | AD3552R_CRC_POLY 0x07 |
#define | AD3552R_CRC_SEED 0xA5 |
#define | AD3552R_SECONDARY_REGION_ADDR 0x28 |
#define | AD3552R_DEFAULT_CONFIG_B_VALUE 0x8 |
#define | AD3552R_DATA_IDX(x) |
#define | AD3552R_DEFAULT_DAC_UPDATE_PERIOD 1000 |
#define | AD3552R_SCRATCH_PAD_TEST_VAL1 0x34 |
#define | AD3552R_SCRATCH_PAD_TEST_VAL2 0xB2 |
#define | AD3552R_MAX_CH_NUM(id) |
#define | REG_DATA_LEN(is_fast) |
#define | AD3552R_GAIN_SCALE 1000 |
Enumerations | |
enum | ad3552r_spi_attributes { AD3552R_ADDR_ASCENSION = AD3552R_CRC_ENABLE + 1 , AD3552R_SINGLE_INST , AD3552R_STREAM_MODE , AD3552R_STREAM_LENGTH_KEEP_VALUE } |
Functions | |
uint8_t | ad3552r_reg_len (uint8_t addr) |
int32_t | ad3552r_single_transfer (struct ad3552r_desc *desc, struct ad3552_transfer_data *data) |
int32_t | ad3552r_transfer (struct ad3552r_desc *desc, struct ad3552_transfer_data *data) |
int32_t | ad3552r_write_reg (struct ad3552r_desc *desc, uint8_t addr, uint16_t val) |
int32_t | ad3552r_read_reg (struct ad3552r_desc *desc, uint8_t addr, uint16_t *val) |
int32_t | ad3552r_get_dev_value (struct ad3552r_desc *desc, enum ad3552r_dev_attributes attr, uint16_t *val) |
int32_t | ad3552r_set_dev_value (struct ad3552r_desc *desc, enum ad3552r_dev_attributes attr, uint16_t val) |
uint8_t | ad3552r_get_code_reg_addr (uint8_t ch, uint8_t is_dac, uint8_t is_fast) |
int32_t | ad3552r_simulatneous_update_enable (struct ad3552r_desc *desc) |
int32_t | ad3552r_get_ch_value (struct ad3552r_desc *desc, enum ad3552r_ch_attributes attr, uint8_t ch, uint16_t *val) |
int32_t | ad3552r_set_ch_value (struct ad3552r_desc *desc, enum ad3552r_ch_attributes attr, uint8_t ch, uint16_t val) |
int32_t | ad3552r_get_scale (struct ad3552r_desc *desc, uint8_t ch, int32_t *integer, int32_t *dec) |
int32_t | ad3552r_get_offset (struct ad3552r_desc *desc, uint8_t ch, int32_t *integer, int32_t *dec) |
int32_t | ad3552r_axi_init (struct ad3552r_desc *desc, struct ad3552r_init_param *init_param) |
int32_t | ad3552r_init (struct ad3552r_desc **desc, struct ad3552r_init_param *param) |
int32_t | ad3552r_remove (struct ad3552r_desc *desc) |
int32_t | ad3552r_reset (struct ad3552r_desc *desc) |
int32_t | ad3552r_ldac_trigger (struct ad3552r_desc *desc, uint16_t mask, uint8_t is_fast) |
int32_t | ad3552r_set_asynchronous (struct ad3552r_desc *desc, uint8_t enable) |
int32_t | ad3552r_axi_write_data (struct ad3552r_desc *desc, uint32_t *buf, uint16_t samples, bool cyclic, int cyclic_secs) |
Write data samples to dac. | |
int32_t | ad3552r_write_samples (struct ad3552r_desc *desc, uint16_t *data, uint32_t samples, uint32_t ch_mask, enum ad3552r_write_mode mode) |
Implementation of ad3552r Driver.
Copyright 2021(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AD3552R_ADDR_MASK (~AD3552R_READ_BIT) |
#define AD3552R_ATTR_MASK | ( | attr | ) |
#define AD3552R_ATTR_REG | ( | attr | ) |
#define AD3552R_BYTES_PER_SAMPLE 4 |
#define AD3552R_CH_ATTR_MASK | ( | ch, | |
attr ) |
#define AD3552R_CH_ATTR_REG | ( | attr | ) |
#define AD3552R_CRC_POLY 0x07 |
#define AD3552R_CRC_SEED 0xA5 |
#define AD3552R_DATA_IDX | ( | x | ) |
#define AD3552R_DEFAULT_CONFIG_B_VALUE 0x8 |
#define AD3552R_DEFAULT_DAC_UPDATE_PERIOD 1000 |
#define AD3552R_EXTERNAL_VREF_MASK NO_OS_BIT(1) |
#define AD3552R_GAIN_SCALE 1000 |
#define AD3552R_MAX_CH_NUM | ( | id | ) |
#define AD3552R_MAX_REG_SIZE 3 |
#define AD3552R_READ_BIT (1 << 7) |
#define AD3552R_SCRATCH_PAD_TEST_VAL1 0x34 |
#define AD3552R_SCRATCH_PAD_TEST_VAL2 0xB2 |
#define AD3552R_SECONDARY_REGION_ADDR 0x28 |
#define REG_DATA_LEN | ( | is_fast | ) |
#define SEC_TO_10NS | ( | x | ) |
int32_t ad3552r_axi_init | ( | struct ad3552r_desc * | desc, |
struct ad3552r_init_param * | init_param ) |
int32_t ad3552r_axi_write_data | ( | struct ad3552r_desc * | desc, |
uint32_t * | buf, | ||
uint16_t | samples, | ||
bool | cyclic, | ||
int | cyclic_secs ) |
Write data samples to dac.
desc | - The device structure. |
buf | - The buffer to fill. |
samples | - number of samples to write. |
cyclic | - cyclic transfer. |
cyclic_secs | - 0 means forever. |
int32_t ad3552r_get_ch_value | ( | struct ad3552r_desc * | desc, |
enum ad3552r_ch_attributes | attr, | ||
uint8_t | ch, | ||
uint16_t * | val ) |
uint8_t ad3552r_get_code_reg_addr | ( | uint8_t | ch, |
uint8_t | is_dac, | ||
uint8_t | is_fast ) |
int32_t ad3552r_get_dev_value | ( | struct ad3552r_desc * | desc, |
enum ad3552r_dev_attributes | attr, | ||
uint16_t * | val ) |
int32_t ad3552r_get_offset | ( | struct ad3552r_desc * | desc, |
uint8_t | ch, | ||
int32_t * | integer, | ||
int32_t * | dec ) |
int32_t ad3552r_get_scale | ( | struct ad3552r_desc * | desc, |
uint8_t | ch, | ||
int32_t * | integer, | ||
int32_t * | dec ) |
int32_t ad3552r_init | ( | struct ad3552r_desc ** | desc, |
struct ad3552r_init_param * | param ) |
int32_t ad3552r_ldac_trigger | ( | struct ad3552r_desc * | desc, |
uint16_t | mask, | ||
uint8_t | is_fast ) |
int32_t ad3552r_read_reg | ( | struct ad3552r_desc * | desc, |
uint8_t | addr, | ||
uint16_t * | val ) |
uint8_t ad3552r_reg_len | ( | uint8_t | addr | ) |
int32_t ad3552r_remove | ( | struct ad3552r_desc * | desc | ) |
int32_t ad3552r_reset | ( | struct ad3552r_desc * | desc | ) |
int32_t ad3552r_set_asynchronous | ( | struct ad3552r_desc * | desc, |
uint8_t | enable ) |
int32_t ad3552r_set_ch_value | ( | struct ad3552r_desc * | desc, |
enum ad3552r_ch_attributes | attr, | ||
uint8_t | ch, | ||
uint16_t | val ) |
int32_t ad3552r_set_dev_value | ( | struct ad3552r_desc * | desc, |
enum ad3552r_dev_attributes | attr, | ||
uint16_t | val ) |
int32_t ad3552r_simulatneous_update_enable | ( | struct ad3552r_desc * | desc | ) |
int32_t ad3552r_single_transfer | ( | struct ad3552r_desc * | desc, |
struct ad3552_transfer_data * | data ) |
int32_t ad3552r_transfer | ( | struct ad3552r_desc * | desc, |
struct ad3552_transfer_data * | data ) |
int32_t ad3552r_write_reg | ( | struct ad3552r_desc * | desc, |
uint8_t | addr, | ||
uint16_t | val ) |
int32_t ad3552r_write_samples | ( | struct ad3552r_desc * | desc, |
uint16_t * | data, | ||
uint32_t | samples, | ||
uint32_t | ch_mask, | ||
enum ad3552r_write_mode | mode ) |