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

Header file of AD5686 Driver. This driver supporting the following devices: AD5684R, AD5685R, AD5686R, AD5694R, AD5695R, AD5696R,. More...

#include <stdint.h>
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_i2c.h"
Include dependency graph for ad5686.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ad5686_chip_info
 
struct  ad5686_dev
 
struct  ad5686_init_param
 

Macros

#define AD5686_CTRL_NOP   0
 
#define AD5686_CTRL_WRITE   1
 
#define AD5686_CTRL_UPDATE   2
 
#define AD5686_CTRL_WRITEUPDATE   3
 
#define AD5686_CTRL_PWR   4
 
#define AD5686_CTRL_LDAC_MASK   5
 
#define AD5686_CTRL_SWRESET   6
 
#define AD5686_CTRL_IREF_REG   7
 
#define AD5686_CTRL_DCEN   8
 
#define AD5686_CTRL_RB_REG   9
 
#define AD5683_CMD_WR_CTRL_REG   4
 
#define AD5683_CTRL_RB_REG   5
 
#define AD5686_PWRM_NORMAL   0
 
#define AD5686_PWRM_1K   1
 
#define AD5686_PWRM_100K   2
 
#define AD5686_PWRM_THREESTATE   3
 
#define AD5686_PWRM_MASK   3
 
#define AD5686_INTREF_EN   1
 
#define AD5686_INTREF_DIS   0
 
#define AD5686_DC_EN   1
 
#define AD5686_DC_DIS   0
 
#define AD5686_RB_EN   1
 
#define AD5686_RB_DIS   0
 
#define MAX_RESOLUTION   16
 
#define PKT_LENGTH   3
 
#define ADDR_MASK   0xFF
 
#define CMD_OFFSET   4
 
#define AD5686_CMD_MASK   0xFF
 
#define AD5686_MSB_MASK   0xFF00
 
#define AD5686_MSB_OFFSET   8
 
#define AD5686_LSB_MASK   0x00FF
 
#define AD5686_LSB_OFFSET   0
 
#define AD5683_MIDB_OFFSET   4
 
#define AD5683_MIDB_MASK   0xFF
 
#define AD5683_MSB_OFFSET   12
 
#define AD5683_MSB_MASK   0xF
 
#define AD5683_CMD_MASK   0xF
 
#define AD5683_LSB_MASK   0xF
 
#define AD5683_LSB_OFFSET   4
 
#define AD5683_REG_MAP   0
 
#define AD5686_REG_MAP   1
 
#define AD5683_CTRL_DCEN(x)   (((((x) & 0x1) << 0) << 10) & 0xFC00)
 
#define AD5683_CTRL_GM(x)   (((((x) & 0x1) << 1) << 10) & 0xFC00)
 
#define AD5683_CTRL_INT_REF(x)   (((((x) & 0x1) << 2) << 10) & 0xFC00)
 
#define AD5683_CTRL_PWRM(x)   (((((x) & 0x3) << 3) << 10) & 0xFC00)
 
#define AD5683_SW_RESET   ((((0x1) << 5) << 10) & 0xFC00)
 

Enumerations

enum  ad5686_type {
  ID_AD5671R,
  ID_AD5672R,
  ID_AD5673R,
  ID_AD5674,
  ID_AD5674R,
  ID_AD5675R,
  ID_AD5676,
  ID_AD5676R,
  ID_AD5677R,
  ID_AD5679,
  ID_AD5679R,
  ID_AD5686,
  ID_AD5684R,
  ID_AD5685R,
  ID_AD5686R,
  ID_AD5687,
  ID_AD5687R,
  ID_AD5689,
  ID_AD5689R,
  ID_AD5697R,
  ID_AD5694,
  ID_AD5694R,
  ID_AD5695R,
  ID_AD5696,
  ID_AD5696R,
  ID_AD5681R,
  ID_AD5682R,
  ID_AD5683R,
  ID_AD5683,
  ID_AD5691R,
  ID_AD5692R,
  ID_AD5693R,
  ID_AD5693
}
 
enum  comm_type {
  SPI,
  I2C
}
 
enum  ad5686_dac_channels {
  AD5686_CH_0 = 0,
  AD5686_CH_1,
  AD5686_CH_2,
  AD5686_CH_3,
  AD5686_CH_4,
  AD5686_CH_5,
  AD5686_CH_6,
  AD5686_CH_7,
  AD5686_CH_8,
  AD5686_CH_9,
  AD5686_CH_10,
  AD5686_CH_11,
  AD5686_CH_12,
  AD5686_CH_13,
  AD5686_CH_14,
  AD5686_CH_15
}
 

Functions

int32_t ad5686_init (struct ad5686_dev **device, struct ad5686_init_param init_param)
 Initializes the communication peripheral and the initial Values for AD5686 Board. More...
 
int32_t ad5686_remove (struct ad5686_dev *dev)
 Free the resources allocated by ad5686_init(). More...
 
uint16_t ad5686_set_shift_reg (struct ad5686_dev *dev, uint8_t command, uint8_t address, uint16_t data)
 Write to input shift register. More...
 
void ad5686_write_register (struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint16_t data)
 Write to Input Register n (dependent on LDAC) More...
 
void ad5686_update_register (struct ad5686_dev *dev, enum ad5686_dac_channels channel)
 Update DAC Register n with contents of Input Register n. More...
 
void ad5686_write_update_register (struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint16_t data)
 Write to and update DAC channel n. More...
 
uint16_t ad5686_read_back_register (struct ad5686_dev *dev, enum ad5686_dac_channels channel)
 Read back Input Register n. More...
 
void ad5686_power_mode (struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint8_t mode)
 Set Power-down mode for DAC channel n. More...
 
void ad5686_ldac_mask (struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint8_t enable)
 Set hardware LDAC mask register. More...
 
void ad5686_software_reset (struct ad5686_dev *dev)
 Software reset (power-on reset) More...
 
void ad5686_internal_reference (struct ad5686_dev *dev, uint8_t value)
 Write to Internal reference setup register. More...
 
void ad5686_daisy_chain_en (struct ad5686_dev *dev, uint8_t value)
 Set up DCEN register (daisy-chain enable) More...
 
void ad5686_read_back_en (struct ad5686_dev *dev, uint8_t value)
 Set up readback register (readback enable) More...
 
int32_t ad5686_gain_mode (struct ad5686_dev *dev, uint8_t value)
 Set Gain mode. More...
 

Detailed Description

Header file of AD5686 Driver. This driver supporting the following devices: AD5684R, AD5685R, AD5686R, AD5694R, AD5695R, AD5696R,.

Author
Istvan Csomortani (istva.nosp@m.n.cs.nosp@m.omort.nosp@m.ani@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 2013, 2020(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

◆ AD5683_CMD_MASK

#define AD5683_CMD_MASK   0xF

◆ AD5683_CMD_WR_CTRL_REG

#define AD5683_CMD_WR_CTRL_REG   4

◆ AD5683_CTRL_DCEN

#define AD5683_CTRL_DCEN (   x)    (((((x) & 0x1) << 0) << 10) & 0xFC00)

◆ AD5683_CTRL_GM

#define AD5683_CTRL_GM (   x)    (((((x) & 0x1) << 1) << 10) & 0xFC00)

◆ AD5683_CTRL_INT_REF

#define AD5683_CTRL_INT_REF (   x)    (((((x) & 0x1) << 2) << 10) & 0xFC00)

◆ AD5683_CTRL_PWRM

#define AD5683_CTRL_PWRM (   x)    (((((x) & 0x3) << 3) << 10) & 0xFC00)

◆ AD5683_CTRL_RB_REG

#define AD5683_CTRL_RB_REG   5

◆ AD5683_LSB_MASK

#define AD5683_LSB_MASK   0xF

◆ AD5683_LSB_OFFSET

#define AD5683_LSB_OFFSET   4

◆ AD5683_MIDB_MASK

#define AD5683_MIDB_MASK   0xFF

◆ AD5683_MIDB_OFFSET

#define AD5683_MIDB_OFFSET   4

◆ AD5683_MSB_MASK

#define AD5683_MSB_MASK   0xF

◆ AD5683_MSB_OFFSET

#define AD5683_MSB_OFFSET   12

◆ AD5683_REG_MAP

#define AD5683_REG_MAP   0

◆ AD5683_SW_RESET

#define AD5683_SW_RESET   ((((0x1) << 5) << 10) & 0xFC00)

◆ AD5686_CMD_MASK

#define AD5686_CMD_MASK   0xFF

◆ AD5686_CTRL_DCEN

#define AD5686_CTRL_DCEN   8

◆ AD5686_CTRL_IREF_REG

#define AD5686_CTRL_IREF_REG   7

◆ AD5686_CTRL_LDAC_MASK

#define AD5686_CTRL_LDAC_MASK   5

◆ AD5686_CTRL_NOP

#define AD5686_CTRL_NOP   0

◆ AD5686_CTRL_PWR

#define AD5686_CTRL_PWR   4

◆ AD5686_CTRL_RB_REG

#define AD5686_CTRL_RB_REG   9

◆ AD5686_CTRL_SWRESET

#define AD5686_CTRL_SWRESET   6

◆ AD5686_CTRL_UPDATE

#define AD5686_CTRL_UPDATE   2

◆ AD5686_CTRL_WRITE

#define AD5686_CTRL_WRITE   1

◆ AD5686_CTRL_WRITEUPDATE

#define AD5686_CTRL_WRITEUPDATE   3

◆ AD5686_DC_DIS

#define AD5686_DC_DIS   0

◆ AD5686_DC_EN

#define AD5686_DC_EN   1

◆ AD5686_INTREF_DIS

#define AD5686_INTREF_DIS   0

◆ AD5686_INTREF_EN

#define AD5686_INTREF_EN   1

◆ AD5686_LSB_MASK

#define AD5686_LSB_MASK   0x00FF

◆ AD5686_LSB_OFFSET

#define AD5686_LSB_OFFSET   0

◆ AD5686_MSB_MASK

#define AD5686_MSB_MASK   0xFF00

◆ AD5686_MSB_OFFSET

#define AD5686_MSB_OFFSET   8

◆ AD5686_PWRM_100K

#define AD5686_PWRM_100K   2

◆ AD5686_PWRM_1K

#define AD5686_PWRM_1K   1

◆ AD5686_PWRM_MASK

#define AD5686_PWRM_MASK   3

◆ AD5686_PWRM_NORMAL

#define AD5686_PWRM_NORMAL   0

◆ AD5686_PWRM_THREESTATE

#define AD5686_PWRM_THREESTATE   3

◆ AD5686_RB_DIS

#define AD5686_RB_DIS   0

◆ AD5686_RB_EN

#define AD5686_RB_EN   1

◆ AD5686_REG_MAP

#define AD5686_REG_MAP   1

◆ ADDR_MASK

#define ADDR_MASK   0xFF

◆ CMD_OFFSET

#define CMD_OFFSET   4

◆ MAX_RESOLUTION

#define MAX_RESOLUTION   16

◆ PKT_LENGTH

#define PKT_LENGTH   3

Enumeration Type Documentation

◆ ad5686_dac_channels

Enumerator
AD5686_CH_0 
AD5686_CH_1 
AD5686_CH_2 
AD5686_CH_3 
AD5686_CH_4 
AD5686_CH_5 
AD5686_CH_6 
AD5686_CH_7 
AD5686_CH_8 
AD5686_CH_9 
AD5686_CH_10 
AD5686_CH_11 
AD5686_CH_12 
AD5686_CH_13 
AD5686_CH_14 
AD5686_CH_15 

◆ ad5686_type

Enumerator
ID_AD5671R 
ID_AD5672R 
ID_AD5673R 
ID_AD5674 
ID_AD5674R 
ID_AD5675R 
ID_AD5676 
ID_AD5676R 
ID_AD5677R 
ID_AD5679 
ID_AD5679R 
ID_AD5686 
ID_AD5684R 
ID_AD5685R 
ID_AD5686R 
ID_AD5687 
ID_AD5687R 
ID_AD5689 
ID_AD5689R 
ID_AD5697R 
ID_AD5694 
ID_AD5694R 
ID_AD5695R 
ID_AD5696 
ID_AD5696R 
ID_AD5681R 
ID_AD5682R 
ID_AD5683R 
ID_AD5683 
ID_AD5691R 
ID_AD5692R 
ID_AD5693R 
ID_AD5693 

◆ comm_type

enum comm_type
Enumerator
SPI 
I2C 

Function Documentation

◆ ad5686_daisy_chain_en()

void ad5686_daisy_chain_en ( struct ad5686_dev dev,
uint8_t  value 
)

Set up DCEN register (daisy-chain enable)

Parameters
dev- The device structure.
value- Enable or disable daisy-chain mode Example : 'AD5686_DC_EN' - daisy-chain enable 'AD5686_DC_DIS' - daisy-chain disable
Returns
None.

◆ ad5686_gain_mode()

int32_t ad5686_gain_mode ( struct ad5686_dev dev,
uint8_t  value 
)

Set Gain mode.

Parameters
dev- The device structure.
value- Gain modes. Accepted values: Example : 'AD5683_GB_VREF' - 0V to VREF 'AD5683_GB_2VREF' - 0V to 2xVREF
Returns
None.

◆ ad5686_init()

int32_t ad5686_init ( struct ad5686_dev **  device,
struct ad5686_init_param  init_param 
)

Initializes the communication peripheral and the initial Values for AD5686 Board.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
ret - The result of the initialization procedure. Example: -1 - I2C peripheral was not initialized or the device is not present. 0 - I2C peripheral was initialized and the device is present.

◆ ad5686_internal_reference()

void ad5686_internal_reference ( struct ad5686_dev dev,
uint8_t  value 
)

Write to Internal reference setup register.

Parameters
dev- The device structure.
value- The internal reference register value Example : 'AD5686_INTREF_EN' - enable internal reference 'AD5686_INTREF_DIS' - disable internal reference
Returns
None.

◆ ad5686_ldac_mask()

void ad5686_ldac_mask ( struct ad5686_dev dev,
enum ad5686_dac_channels  channel,
uint8_t  enable 
)

Set hardware LDAC mask register.

Parameters
dev- The device structure.
channel- In case of which channel ignore transitions on the LDAC pin. Accepted values: AD5686_CH_0 AD5686_CH_1 AD5686_CH_2 AD5686_CH_3 AD5686_CH_4 AD5686_CH_5 AD5686_CH_6 AD5686_CH_7 AD5686_CH_8 AD5686_CH_9 AD5686_CH_10 AD5686_CH_11 AD5686_CH_12 AD5686_CH_13 AD5686_CH_14 AD5686_CH_15
enable- Enable/disable channel.
Returns
None.

◆ ad5686_power_mode()

void ad5686_power_mode ( struct ad5686_dev dev,
enum ad5686_dac_channels  channel,
uint8_t  mode 
)

Set Power-down mode for DAC channel n.

Parameters
dev- The device structure.
channel- The chosen channel to change the power-down mode. Accepted values: AD5686_CH_0 AD5686_CH_1 AD5686_CH_2 AD5686_CH_3 AD5686_CH_4 AD5686_CH_5 AD5686_CH_6 AD5686_CH_7 AD5686_CH_8 AD5686_CH_9 AD5686_CH_10 AD5686_CH_11 AD5686_CH_12 AD5686_CH_13 AD5686_CH_14 AD5686_CH_15
mode- Power-down operation modes. Accepted values: 'AD5686_PWRM_NORMAL' - Normal Mode 'AD5686_PWRM_1K' - Power-down mode 1kOhm to GND 'AD5686_PWRM_100K' - Power-down mode 100kOhm to GND 'AD5686_PWRM_THREESTATE' - Three-State 'AD5686_PWRM_100K' is not available for AD5674R/AD5679R.
Returns
None.

◆ ad5686_read_back_en()

void ad5686_read_back_en ( struct ad5686_dev dev,
uint8_t  value 
)

Set up readback register (readback enable)

Parameters
dev- The device structure.
value- Enable or disable daisy-chain mode Example : 'AD5686_RB_EN' - daisy-chain enable 'AD5686_RB_DIS' - daisy-chain disable
Returns
None.

◆ ad5686_read_back_register()

uint16_t ad5686_read_back_register ( struct ad5686_dev dev,
enum ad5686_dac_channels  channel 
)

Read back Input Register n.

Parameters
dev- The device structure.
channel- The channel which will be read back. Note: only one channel should be selected, if there will be selected more than one channel, the channel A will be read back by default Accepted values: AD5686_CH_0 AD5686_CH_1 AD5686_CH_2 AD5686_CH_3 AD5686_CH_4 AD5686_CH_5 AD5686_CH_6 AD5686_CH_7 AD5686_CH_8 AD5686_CH_9 AD5686_CH_10 AD5686_CH_11 AD5686_CH_12 AD5686_CH_13 AD5686_CH_14 AD5686_CH_15
Returns
read_back_data - value read from register.

◆ ad5686_remove()

int32_t ad5686_remove ( struct ad5686_dev dev)

Free the resources allocated by ad5686_init().

Parameters
dev- The device structure.
Returns
ret - The result of the remove procedure.

◆ ad5686_set_shift_reg()

uint16_t ad5686_set_shift_reg ( struct ad5686_dev dev,
uint8_t  command,
uint8_t  address,
uint16_t  data 
)

Write to input shift register.

Parameters
dev- The device structure.
command- Command control bits.
address- The address bits.
data- Data to be written in input register.
Returns
read_back_data - value read from register.

◆ ad5686_software_reset()

void ad5686_software_reset ( struct ad5686_dev dev)

Software reset (power-on reset)

Parameters
dev- The device structure.
Returns
None.

◆ ad5686_update_register()

void ad5686_update_register ( struct ad5686_dev dev,
enum ad5686_dac_channels  channel 
)

Update DAC Register n with contents of Input Register n.

Parameters
dev- The device structure.
channel- The chosen channel to write to. Accepted values: AD5686_CH_0 AD5686_CH_1 AD5686_CH_2 AD5686_CH_3 AD5686_CH_4 AD5686_CH_5 AD5686_CH_6 AD5686_CH_7 AD5686_CH_8 AD5686_CH_9 AD5686_CH_10 AD5686_CH_11 AD5686_CH_12 AD5686_CH_13 AD5686_CH_14 AD5686_CH_15
Returns
None.

◆ ad5686_write_register()

void ad5686_write_register ( struct ad5686_dev dev,
enum ad5686_dac_channels  channel,
uint16_t  data 
)

Write to Input Register n (dependent on LDAC)

Parameters
dev- The device structure.
channel- The chosen channel to write to. Accepted values: AD5686_CH_0 AD5686_CH_1 AD5686_CH_2 AD5686_CH_3 AD5686_CH_4 AD5686_CH_5 AD5686_CH_6 AD5686_CH_7 AD5686_CH_8 AD5686_CH_9 AD5686_CH_10 AD5686_CH_11 AD5686_CH_12 AD5686_CH_13 AD5686_CH_14 AD5686_CH_15
data- desired value to be written in register.
Returns
None.

◆ ad5686_write_update_register()

void ad5686_write_update_register ( struct ad5686_dev dev,
enum ad5686_dac_channels  channel,
uint16_t  data 
)

Write to and update DAC channel n.

Parameters
dev- The device structure.
channel- The chosen channel to write to. Accepted values: AD5686_CH_0 AD5686_CH_1 AD5686_CH_2 AD5686_CH_3 AD5686_CH_4 AD5686_CH_5 AD5686_CH_6 AD5686_CH_7 AD5686_CH_8 AD5686_CH_9 AD5686_CH_10 AD5686_CH_11 AD5686_CH_12 AD5686_CH_13 AD5686_CH_14 AD5686_CH_15
data- Desired value to be written in register.
Returns
None.