no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ad3552r.c File Reference

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"
Include dependency graph for ad3552r.c:

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)
 

Detailed Description

Implementation of ad3552r Driver.

Author
Mihail Chindris (Mihai.nosp@m.l.Ch.nosp@m.indri.nosp@m.s@an.nosp@m.alog..nosp@m.com)

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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

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.

Macro Definition Documentation

◆ AD3552R_ADDR_MASK

#define AD3552R_ADDR_MASK   (~AD3552R_READ_BIT)

◆ AD3552R_ATTR_MASK

#define AD3552R_ATTR_MASK ( attr)
Value:
addr_mask_map[attr][1]

◆ AD3552R_ATTR_REG

#define AD3552R_ATTR_REG ( attr)
Value:
addr_mask_map[attr][0]

◆ AD3552R_BYTES_PER_SAMPLE

#define AD3552R_BYTES_PER_SAMPLE   4

◆ AD3552R_CH_ATTR_MASK

#define AD3552R_CH_ATTR_MASK ( ch,
attr )
Value:
addr_mask_map_ch[attr][(ch) + 1]

◆ AD3552R_CH_ATTR_REG

#define AD3552R_CH_ATTR_REG ( attr)
Value:
addr_mask_map_ch[attr][0]

◆ AD3552R_CRC_DISABLE_VALUE

#define AD3552R_CRC_DISABLE_VALUE   (NO_OS_BIT(1) | NO_OS_BIT(0))

◆ AD3552R_CRC_ENABLE_VALUE

#define AD3552R_CRC_ENABLE_VALUE   (NO_OS_BIT(6) | NO_OS_BIT(1))

◆ AD3552R_CRC_POLY

#define AD3552R_CRC_POLY   0x07

◆ AD3552R_CRC_SEED

#define AD3552R_CRC_SEED   0xA5

◆ AD3552R_DATA_IDX

#define AD3552R_DATA_IDX ( x)
Value:
(1 + (x))

◆ AD3552R_DEFAULT_CONFIG_B_VALUE

#define AD3552R_DEFAULT_CONFIG_B_VALUE   0x8

◆ AD3552R_DEFAULT_DAC_UPDATE_PERIOD

#define AD3552R_DEFAULT_DAC_UPDATE_PERIOD   1000

◆ AD3552R_EXTERNAL_VREF_MASK

#define AD3552R_EXTERNAL_VREF_MASK   NO_OS_BIT(1)

◆ AD3552R_GAIN_SCALE

#define AD3552R_GAIN_SCALE   1000

◆ AD3552R_MAX_CH_NUM

#define AD3552R_MAX_CH_NUM ( id)
Value:
((id) == AD3542R_ID || (id) == AD3552R_ID ?\
@ AD3542R_ID
Definition ad3552r.h:165
@ AD3552R_ID
Definition ad3552r.h:167
@ AD3552R_NUM_CHANNELS
Definition ad3552r.h:238
@ AD3551R_NUM_CHANNELS
Definition ad3552r.h:237

◆ AD3552R_MAX_REG_SIZE

#define AD3552R_MAX_REG_SIZE   3

◆ AD3552R_READ_BIT

#define AD3552R_READ_BIT   (1 << 7)

◆ AD3552R_SCRATCH_PAD_TEST_VAL1

#define AD3552R_SCRATCH_PAD_TEST_VAL1   0x34

◆ AD3552R_SCRATCH_PAD_TEST_VAL2

#define AD3552R_SCRATCH_PAD_TEST_VAL2   0xB2

◆ AD3552R_SECONDARY_REGION_ADDR

#define AD3552R_SECONDARY_REGION_ADDR   0x28

◆ REG_DATA_LEN

#define REG_DATA_LEN ( is_fast)
Value:
((is_fast) ? AD3552R_STORAGE_BITS_FAST_MODE / 8 :\
#define AD3552R_STORAGE_BITS_PREC_MODE
Definition ad3552r.h:152
#define AD3552R_STORAGE_BITS_FAST_MODE
Definition ad3552r.h:154

◆ SEC_TO_10NS

#define SEC_TO_10NS ( x)
Value:
((x) * 100000000)

Enumeration Type Documentation

◆ ad3552r_spi_attributes

Enumerator
AD3552R_ADDR_ASCENSION 
AD3552R_SINGLE_INST 
AD3552R_STREAM_MODE 
AD3552R_STREAM_LENGTH_KEEP_VALUE 

Function Documentation

◆ ad3552r_axi_init()

int32_t ad3552r_axi_init ( struct ad3552r_desc * desc,
struct ad3552r_init_param * init_param )
Here is the caller graph for this function:

◆ ad3552r_axi_write_data()

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.

Parameters
desc- The device structure.
buf- The buffer to fill.
samples- number of samples to write.
cyclic- cyclic transfer.
cyclic_secs- 0 means forever.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad3552r_get_ch_value()

int32_t ad3552r_get_ch_value ( struct ad3552r_desc * desc,
enum ad3552r_ch_attributes attr,
uint8_t ch,
uint16_t * val )

◆ ad3552r_get_code_reg_addr()

uint8_t ad3552r_get_code_reg_addr ( uint8_t ch,
uint8_t is_dac,
uint8_t is_fast )
Here is the caller graph for this function:

◆ ad3552r_get_dev_value()

int32_t ad3552r_get_dev_value ( struct ad3552r_desc * desc,
enum ad3552r_dev_attributes attr,
uint16_t * val )

◆ ad3552r_get_offset()

int32_t ad3552r_get_offset ( struct ad3552r_desc * desc,
uint8_t ch,
int32_t * integer,
int32_t * dec )

◆ ad3552r_get_scale()

int32_t ad3552r_get_scale ( struct ad3552r_desc * desc,
uint8_t ch,
int32_t * integer,
int32_t * dec )

◆ ad3552r_init()

int32_t ad3552r_init ( struct ad3552r_desc ** desc,
struct ad3552r_init_param * param )
Here is the caller graph for this function:

◆ ad3552r_ldac_trigger()

int32_t ad3552r_ldac_trigger ( struct ad3552r_desc * desc,
uint16_t mask,
uint8_t is_fast )
Here is the caller graph for this function:

◆ ad3552r_read_reg()

int32_t ad3552r_read_reg ( struct ad3552r_desc * desc,
uint8_t addr,
uint16_t * val )
Here is the caller graph for this function:

◆ ad3552r_reg_len()

uint8_t ad3552r_reg_len ( uint8_t addr)
Here is the caller graph for this function:

◆ ad3552r_remove()

int32_t ad3552r_remove ( struct ad3552r_desc * desc)
Here is the caller graph for this function:

◆ ad3552r_reset()

int32_t ad3552r_reset ( struct ad3552r_desc * desc)
Here is the caller graph for this function:

◆ ad3552r_set_asynchronous()

int32_t ad3552r_set_asynchronous ( struct ad3552r_desc * desc,
uint8_t enable )

◆ ad3552r_set_ch_value()

int32_t ad3552r_set_ch_value ( struct ad3552r_desc * desc,
enum ad3552r_ch_attributes attr,
uint8_t ch,
uint16_t val )

◆ ad3552r_set_dev_value()

int32_t ad3552r_set_dev_value ( struct ad3552r_desc * desc,
enum ad3552r_dev_attributes attr,
uint16_t val )
Here is the caller graph for this function:

◆ ad3552r_simulatneous_update_enable()

int32_t ad3552r_simulatneous_update_enable ( struct ad3552r_desc * desc)

◆ ad3552r_single_transfer()

int32_t ad3552r_single_transfer ( struct ad3552r_desc * desc,
struct ad3552_transfer_data * data )
Here is the caller graph for this function:

◆ ad3552r_transfer()

int32_t ad3552r_transfer ( struct ad3552r_desc * desc,
struct ad3552_transfer_data * data )
Here is the caller graph for this function:

◆ ad3552r_write_reg()

int32_t ad3552r_write_reg ( struct ad3552r_desc * desc,
uint8_t addr,
uint16_t val )
Here is the caller graph for this function:

◆ ad3552r_write_samples()

int32_t ad3552r_write_samples ( struct ad3552r_desc * desc,
uint16_t * data,
uint32_t samples,
uint32_t ch_mask,
enum ad3552r_write_mode mode )
Here is the caller graph for this function: