no-OS
Functions
ad5686.c File Reference

Implementation of AD5686 Driver. More...

#include <stdlib.h>
#include "ad5686.h"
#include "no_os_alloc.h"
Include dependency graph for ad5686.c:

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

Implementation of AD5686 Driver.

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.

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.