no-OS
Loading...
Searching...
No Matches
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.
 
int32_t ad5686_remove (struct ad5686_dev *dev)
 Free the resources allocated by ad5686_init().
 
uint16_t ad5686_set_shift_reg (struct ad5686_dev *dev, uint8_t command, uint8_t address, uint16_t data)
 Write to input shift 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)
 
void ad5686_update_register (struct ad5686_dev *dev, enum ad5686_dac_channels channel)
 Update DAC Register n with contents of Input Register n.
 
void ad5686_write_update_register (struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint16_t data)
 Write to and update DAC channel n.
 
uint16_t ad5686_read_back_register (struct ad5686_dev *dev, enum ad5686_dac_channels channel)
 Read back Input Register n.
 
void ad5686_power_mode (struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint8_t mode)
 Set Power-down mode for DAC channel n.
 
void ad5686_ldac_mask (struct ad5686_dev *dev, enum ad5686_dac_channels channel, uint8_t enable)
 Set hardware LDAC mask register.
 
void ad5686_software_reset (struct ad5686_dev *dev)
 Software reset (power-on reset)
 
void ad5686_internal_reference (struct ad5686_dev *dev, uint8_t value)
 Write to Internal reference setup register.
 
void ad5686_daisy_chain_en (struct ad5686_dev *dev, uint8_t value)
 Set up DCEN register (daisy-chain enable)
 
void ad5686_read_back_en (struct ad5686_dev *dev, uint8_t value)
 Set up readback register (readback enable)
 
int32_t ad5686_gain_mode (struct ad5686_dev *dev, uint8_t value)
 Set Gain mode.
 

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.

SPDX-License-Identifier: BSD-3-Clause

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

◆ 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

◆ 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

◆ 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.

◆ 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.

◆ 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

◆ 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.

◆ 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

◆ 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.

◆ 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.