no-OS
Classes | Macros | Enumerations | Functions
ad5766.h File Reference

Header file of AD5766 Driver. More...

#include <stdint.h>
#include "no-os/delay.h"
#include "no-os/gpio.h"
#include "no-os/spi.h"
Include dependency graph for ad5766.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad5766_dev
 
struct  ad5766_init_param
 

Macros

#define AD5766_CMD_NOP_MUX_OUT   0x00
 
#define AD5766_CMD_SDO_CNTRL   0x01
 
#define AD5766_CMD_WR_IN_REG(x)   (0x10 | ((x) & 0xF))
 
#define AD5766_CMD_WR_DAC_REG(x)   (0x20 | ((x) & 0xF))
 
#define AD5766_CMD_SW_LDAC   0x30
 
#define AD5766_CMD_SPAN_REG   0x40
 
#define AD5766_CMD_WR_PWR_DAC   0x50
 
#define AD5766_CMD_WR_PWR_DITHER   0x51
 
#define AD5766_CMD_WR_DAC_REG_ALL   0x60
 
#define AD5766_CMD_SW_FULL_RESET   0x70
 
#define AD5766_CMD_READBACK_REG(x)   (0x80 | ((x) & 0xF))
 
#define AD5766_CMD_DITHER_SIG_1   0x90
 
#define AD5766_CMD_DITHER_SIG_2   0xA0
 
#define AD5766_CMD_INV_DITHER   0xB0
 
#define AD5766_CMD_DITHER_SCALE_1   0xC0
 
#define AD5766_CMD_DITHER_SCALE_2   0xD0
 
#define AD5766_SDO_EN   (1 << 0)
 
#define AD5766_LDAC(x)   (1 << ((x) & 0xF))
 
#define AD5766_CFG_CLR(x)   (((x) & 0x3) << 3)
 
#define AD5766_SPAN(x)   (((x) & 0x7) << 0)
 
#define AD5766_PWDN(x)   (1 << ((x) & 0xF))
 
#define AD5766_RESET   0x1234
 
#define AD5766_N0(x)   (1 << (2 * ((x) & 0xF)))
 
#define AD5766_N1(x)   (2 << (2 * ((x) & 0xF)))
 
#define AD5766_INV_D(x)   (1 << ((x) & 0xF))
 
#define AD5766_75(x)   (1 << (2 * ((x) & 0xF)))
 
#define AD5766_50(x)   (2 << (2 * ((x) & 0xF)))
 
#define AD5766_25(x)   (3 << (2 * ((x) & 0xF)))
 

Enumerations

enum  ad5766_state {
  AD5766_ENABLE,
  AD5766_DISABLE
}
 
enum  ad5766_dac {
  AD5766_DAC_0,
  AD5766_DAC_1,
  AD5766_DAC_2,
  AD5766_DAC_3,
  AD5766_DAC_4,
  AD5766_DAC_5,
  AD5766_DAC_6,
  AD5766_DAC_7,
  AD5766_DAC_8,
  AD5766_DAC_9,
  AD5766_DAC_10,
  AD5766_DAC_11,
  AD5766_DAC_12,
  AD5766_DAC_13,
  AD5766_DAC_14,
  AD5766_DAC_15
}
 
enum  ad5766_span {
  AD5766_M_20V_TO_0V,
  AD5766_M_16V_TO_0V,
  AD5766_M_10V_TO_0V,
  AD5766_M_12V_TO_P_14V,
  AD5766_M_16V_TO_P_10V,
  AD5766_M_5V_TO_P_6V,
  AD5766_M_10V_TO_P_10V
}
 
enum  ad5766_clr {
  AD5766_ZERO,
  AD5766_MID,
  AD5766_FULL
}
 

Functions

int32_t ad5766_spi_cmd_write (struct ad5766_dev *dev, uint8_t cmd, uint16_t data)
 
int32_t ad5766_spi_readback_reg (struct ad5766_dev *dev, enum ad5766_dac dac, uint32_t *data)
 
int32_t ad5766_set_sw_ldac (struct ad5766_dev *dev, uint16_t setting)
 
int32_t ad5766_set_clr_span (struct ad5766_dev *dev, enum ad5766_clr clr, enum ad5766_span span)
 
int32_t ad5766_set_pwr_dac (struct ad5766_dev *dev, uint16_t setting)
 
int32_t ad5766_set_pwr_dither (struct ad5766_dev *dev, uint16_t setting)
 
int32_t ad5766_set_dither_signal (struct ad5766_dev *dev, uint32_t setting)
 
int32_t ad5766_set_inv_dither (struct ad5766_dev *dev, uint16_t setting)
 
int32_t ad5766_set_dither_scale (struct ad5766_dev *dev, uint32_t setting)
 
int32_t ad5766_do_soft_reset (struct ad5766_dev *dev)
 
int32_t ad5766_set_in_reg (struct ad5766_dev *dev, enum ad5766_dac dac, uint16_t data)
 
int32_t ad5766_set_dac_reg (struct ad5766_dev *dev, enum ad5766_dac dac, uint16_t data)
 
int32_t ad5766_set_dac_reg_all (struct ad5766_dev *dev, uint16_t data)
 
int32_t ad5766_init (struct ad5766_dev **device, struct ad5766_init_param init_param)
 
int32_t ad5766_remove (struct ad5766_dev *dev)
 Free the resources allocated by ad5766_init(). More...
 

Detailed Description

Header file of AD5766 Driver.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2016(c) Analog Devices, Inc.

All rights reserved.

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 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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

◆ AD5766_25

#define AD5766_25 (   x)    (3 << (2 * ((x) & 0xF)))

◆ AD5766_50

#define AD5766_50 (   x)    (2 << (2 * ((x) & 0xF)))

◆ AD5766_75

#define AD5766_75 (   x)    (1 << (2 * ((x) & 0xF)))

◆ AD5766_CFG_CLR

#define AD5766_CFG_CLR (   x)    (((x) & 0x3) << 3)

◆ AD5766_CMD_DITHER_SCALE_1

#define AD5766_CMD_DITHER_SCALE_1   0xC0

◆ AD5766_CMD_DITHER_SCALE_2

#define AD5766_CMD_DITHER_SCALE_2   0xD0

◆ AD5766_CMD_DITHER_SIG_1

#define AD5766_CMD_DITHER_SIG_1   0x90

◆ AD5766_CMD_DITHER_SIG_2

#define AD5766_CMD_DITHER_SIG_2   0xA0

◆ AD5766_CMD_INV_DITHER

#define AD5766_CMD_INV_DITHER   0xB0

◆ AD5766_CMD_NOP_MUX_OUT

#define AD5766_CMD_NOP_MUX_OUT   0x00

◆ AD5766_CMD_READBACK_REG

#define AD5766_CMD_READBACK_REG (   x)    (0x80 | ((x) & 0xF))

◆ AD5766_CMD_SDO_CNTRL

#define AD5766_CMD_SDO_CNTRL   0x01

◆ AD5766_CMD_SPAN_REG

#define AD5766_CMD_SPAN_REG   0x40

◆ AD5766_CMD_SW_FULL_RESET

#define AD5766_CMD_SW_FULL_RESET   0x70

◆ AD5766_CMD_SW_LDAC

#define AD5766_CMD_SW_LDAC   0x30

◆ AD5766_CMD_WR_DAC_REG

#define AD5766_CMD_WR_DAC_REG (   x)    (0x20 | ((x) & 0xF))

◆ AD5766_CMD_WR_DAC_REG_ALL

#define AD5766_CMD_WR_DAC_REG_ALL   0x60

◆ AD5766_CMD_WR_IN_REG

#define AD5766_CMD_WR_IN_REG (   x)    (0x10 | ((x) & 0xF))

◆ AD5766_CMD_WR_PWR_DAC

#define AD5766_CMD_WR_PWR_DAC   0x50

◆ AD5766_CMD_WR_PWR_DITHER

#define AD5766_CMD_WR_PWR_DITHER   0x51

◆ AD5766_INV_D

#define AD5766_INV_D (   x)    (1 << ((x) & 0xF))

◆ AD5766_LDAC

#define AD5766_LDAC (   x)    (1 << ((x) & 0xF))

◆ AD5766_N0

#define AD5766_N0 (   x)    (1 << (2 * ((x) & 0xF)))

◆ AD5766_N1

#define AD5766_N1 (   x)    (2 << (2 * ((x) & 0xF)))

◆ AD5766_PWDN

#define AD5766_PWDN (   x)    (1 << ((x) & 0xF))

◆ AD5766_RESET

#define AD5766_RESET   0x1234

◆ AD5766_SDO_EN

#define AD5766_SDO_EN   (1 << 0)

◆ AD5766_SPAN

#define AD5766_SPAN (   x)    (((x) & 0x7) << 0)

Enumeration Type Documentation

◆ ad5766_clr

enum ad5766_clr
Enumerator
AD5766_ZERO 
AD5766_MID 
AD5766_FULL 

◆ ad5766_dac

enum ad5766_dac
Enumerator
AD5766_DAC_0 
AD5766_DAC_1 
AD5766_DAC_2 
AD5766_DAC_3 
AD5766_DAC_4 
AD5766_DAC_5 
AD5766_DAC_6 
AD5766_DAC_7 
AD5766_DAC_8 
AD5766_DAC_9 
AD5766_DAC_10 
AD5766_DAC_11 
AD5766_DAC_12 
AD5766_DAC_13 
AD5766_DAC_14 
AD5766_DAC_15 

◆ ad5766_span

Enumerator
AD5766_M_20V_TO_0V 
AD5766_M_16V_TO_0V 
AD5766_M_10V_TO_0V 
AD5766_M_12V_TO_P_14V 
AD5766_M_16V_TO_P_10V 
AD5766_M_5V_TO_P_6V 
AD5766_M_10V_TO_P_10V 

◆ ad5766_state

Enumerator
AD5766_ENABLE 
AD5766_DISABLE 

Function Documentation

◆ ad5766_do_soft_reset()

int32_t ad5766_do_soft_reset ( struct ad5766_dev dev)

Do a software reset.

Parameters
dev- The device structure.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad5766_init()

int32_t ad5766_init ( struct ad5766_dev **  device,
struct ad5766_init_param  init_param 
)

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_remove()

int32_t ad5766_remove ( struct ad5766_dev dev)

Free the resources allocated by ad5766_init().

Parameters
dev- The device structure.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad5766_set_clr_span()

int32_t ad5766_set_clr_span ( struct ad5766_dev dev,
enum ad5766_clr  clr,
enum ad5766_span  span 
)

Set clear code and span settings.

Parameters
dev- The device structure.
clr- The clear code setting. Accepted values: AD5766_ZERO AD5766_MID AD5766_FULL
span- The span setting. Accepted values: AD5766_M_20V_TO_0V AD5766_M_16V_TO_0V AD5766_M_10V_TO_0V AD5766_M_12V_TO_P_14V AD5766_M_16V_TO_P_10V AD5766_M_5V_TO_P_6V AD5766_M_10V_TO_P_10V
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_set_dac_reg()

int32_t ad5766_set_dac_reg ( struct ad5766_dev dev,
enum ad5766_dac  dac,
uint16_t  data 
)

Set the DAC register for the selected channel.

Parameters
dev- The device structure.
dac- The selected channel.
data- The register data.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad5766_set_dac_reg_all()

int32_t ad5766_set_dac_reg_all ( struct ad5766_dev dev,
uint16_t  data 
)

Set the DAC register for all channels.

Parameters
dev- The device structure.
data- The register data.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad5766_set_dither_scale()

int32_t ad5766_set_dither_scale ( struct ad5766_dev dev,
uint32_t  setting 
)

Enable the dither scaling for the selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: AD5766_75(x) | AD5766_50(y) | AD5766_25(z) | ...
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_set_dither_signal()

int32_t ad5766_set_dither_signal ( struct ad5766_dev dev,
uint32_t  setting 
)

Enable the dither signal for the selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: AD5766_N0(x) | AD5766_N1(y) | ...
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_set_in_reg()

int32_t ad5766_set_in_reg ( struct ad5766_dev dev,
enum ad5766_dac  dac,
uint16_t  data 
)

Set the input register for the selected channel.

Parameters
dev- The device structure.
dac- The selected channel.
data- The register data.
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad5766_set_inv_dither()

int32_t ad5766_set_inv_dither ( struct ad5766_dev dev,
uint16_t  setting 
)

Invert the dither signal for the selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: AD5766_INV_D(x) | AD5766_INV_D(y) | ...
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_set_pwr_dac()

int32_t ad5766_set_pwr_dac ( struct ad5766_dev dev,
uint16_t  setting 
)

Power down the selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: AD5766_PWDN(x) | AD5766_PWDN(y) | ...
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_set_pwr_dither()

int32_t ad5766_set_pwr_dither ( struct ad5766_dev dev,
uint16_t  setting 
)

Power down the dither block for the selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: AD5766_PWDN(x) | AD5766_PWDN(y) | ...
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_set_sw_ldac()

int32_t ad5766_set_sw_ldac ( struct ad5766_dev dev,
uint16_t  setting 
)

Set software LDAC for the selected channels.

Parameters
dev- The device structure.
setting- The setting. Accepted values: AD5766_LDAC(x) | AD5766_LDAC(y) | ...
Returns
SUCCESS in case of success, negative error code otherwise.

◆ ad5766_spi_cmd_write()

int32_t ad5766_spi_cmd_write ( struct ad5766_dev dev,
uint8_t  cmd,
uint16_t  data 
)

SPI command write to device.

Parameters
dev- The device structure.
cmd- The command.
data- The data.
Returns
SUCCESS in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ ad5766_spi_readback_reg()

int32_t ad5766_spi_readback_reg ( struct ad5766_dev dev,
enum ad5766_dac  dac,
uint32_t *  data 
)

SPI readback register from device.

Parameters
dev- The device structure.
dac- The dac address.
data- The register data.
Returns
SUCCESS in case of success, negative error code otherwise.