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

Header file of AD5449 Driver. This driver supporting the following devices: AD5415, AD5443, AD5432, AD5426, AD5429, AD5439, AD5449. More...

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

Go to the source code of this file.

Classes

struct  ad5449_chip_info
 
struct  ad5449_dev
 
struct  ad5449_init_param
 

Macros

#define AD5449_CTRL_NOP   0
 
#define AD5449_CTRL_LOADUPDATE(x)   (1 + 3 * (x))
 
#define AD5449_CTRL_READBACK(x)   (2 + 3 * (x))
 
#define AD5449_CTRL_LOAD(x)   (3 + 3 * (x))
 
#define AD5449_CTRL_UPDATEALL   7
 
#define AD5449_CTRL_LOADALL   8
 
#define AD5449_CTRL_DAISY_CHAIN   9
 
#define AD5449_CTRL_CLK_EDGE   10
 
#define AD5449_CTRL_CLR_ZERO   11
 
#define AD5449_CTRL_CLR_MID   12
 
#define AD5449_CTRL_REG   13
 
#define AD5449_CH_A   0
 
#define AD5449_CH_B   1
 
#define AD5449_ZERO_SCALE   0
 
#define AD5449_MID_SCALE   1
 
#define AD5449_CLOCK_NEGEDGE   0
 
#define AD5449_CLOCK_POSEDGE   1
 
#define AD5449_DAISY_CHAIN_DIS   0
 
#define AD5449_DAISY_CHAIN_EN   1
 
#define AD5449_SDO_MASK   (3 << 10)
 
#define AD5449_DSY_MASK   (1 << 9)
 
#define AD5449_HCLR_MASK   (1 << 8)
 
#define AD5449_SCLK_MASK   (1 << 7)
 
#define AD5449_SDO_BIT   10
 
#define AD5449_DSY_BIT   9
 
#define AD5449_HCLR_BIT   8
 
#define AD5449_SCLK_BIT   7
 
#define AD5449_LDAC_OUT
 
#define AD5449_LDAC_LOW
 
#define AD5449_LDAC_HIGH
 
#define AD5449_CLR_OUT
 
#define AD5449_CLR_LOW
 
#define AD5449_CLR_HIGH
 
#define AD5449_SDO_FULL   0
 
#define AD5449_SDO_WEAK   1
 
#define AD5449_SDO_OPEN_DRAIN   2
 
#define AD5449_SDO_DISABLE   3
 

Enumerations

enum  bool_t {
  false,
  true,
  false,
  true,
  false,
  true
}
 
enum  ad5449_type_t {
  ID_AD5415,
  ID_AD5426,
  ID_AD5429,
  ID_AD5432,
  ID_AD5439,
  ID_AD5443,
  ID_AD5449
}
 

Functions

int8_t ad5449_init (struct ad5449_dev **device, struct ad5449_init_param init_param)
 Initialize SPI and Initial Values for AD5449 Board. More...
 
int32_t ad5449_remove (struct ad5449_dev *dev)
 Free the resources allocated by ad5449_init(). More...
 
uint16_t ad5449_set_input_shift_reg (struct ad5449_dev *dev, uint16_t command, uint16_t data)
 Write to input register and read from output register via SPI. More...
 
void ad5449_load_update_channel (struct ad5449_dev *dev, uint8_t channel, uint16_t dac_value)
 Loads and updates the selected DAC with a given value. More...
 
void ad5449_load_channel (struct ad5449_dev *dev, uint8_t channel, uint16_t dac_value)
 Load selected DAC input register with a given value. More...
 
uint16_t ad5449_readback_channel (struct ad5449_dev *dev, uint8_t channel)
 Read from the selected DAC register. More...
 
void ad5449_update_all (struct ad5449_dev *dev)
 Update the DAC outputs. This function has a physical result just with devices with two channels. More...
 
void ad5449_load_all (struct ad5449_dev *dev, int16_t dac_value)
 Load the DAC input registers. This function has a physical result just with devices with two channels. More...
 
void ad5449_clear_scale_setup (struct ad5449_dev *dev, int8_t type)
 Set up the scale where to the output will be cleared on active CLR signal. More...
 
void ad5449_daisy_chain_setup (struct ad5449_dev *dev, int8_t value)
 Enable/disable the Daisy-Chain mode. More...
 
void ad5449_sdocontrol (struct ad5449_dev *dev, int8_t control_bits)
 Control the SDO output driver strength. This function is supported by the devices : AD5415, AD5429, AD5439, AD5449. More...
 
void ad5449_sclksetup (struct ad5449_dev *dev, int8_t value)
 Set up the active clock edge of the SPI interface. More...
 

Detailed Description

Header file of AD5449 Driver. This driver supporting the following devices: AD5415, AD5443, AD5432, AD5426, AD5429, AD5439, AD5449.

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(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

Macro Definition Documentation

◆ AD5449_CH_A

#define AD5449_CH_A   0

◆ AD5449_CH_B

#define AD5449_CH_B   1

◆ AD5449_CLOCK_NEGEDGE

#define AD5449_CLOCK_NEGEDGE   0

◆ AD5449_CLOCK_POSEDGE

#define AD5449_CLOCK_POSEDGE   1

◆ AD5449_CLR_HIGH

#define AD5449_CLR_HIGH
Value:
gpio_set_value(dev->gpio_clr, \

◆ AD5449_CLR_LOW

#define AD5449_CLR_LOW
Value:
gpio_set_value(dev->gpio_clr, \

◆ AD5449_CLR_OUT

#define AD5449_CLR_OUT
Value:

◆ AD5449_CTRL_CLK_EDGE

#define AD5449_CTRL_CLK_EDGE   10

◆ AD5449_CTRL_CLR_MID

#define AD5449_CTRL_CLR_MID   12

◆ AD5449_CTRL_CLR_ZERO

#define AD5449_CTRL_CLR_ZERO   11

◆ AD5449_CTRL_DAISY_CHAIN

#define AD5449_CTRL_DAISY_CHAIN   9

◆ AD5449_CTRL_LOAD

#define AD5449_CTRL_LOAD (   x)    (3 + 3 * (x))

◆ AD5449_CTRL_LOADALL

#define AD5449_CTRL_LOADALL   8

◆ AD5449_CTRL_LOADUPDATE

#define AD5449_CTRL_LOADUPDATE (   x)    (1 + 3 * (x))

◆ AD5449_CTRL_NOP

#define AD5449_CTRL_NOP   0

◆ AD5449_CTRL_READBACK

#define AD5449_CTRL_READBACK (   x)    (2 + 3 * (x))

◆ AD5449_CTRL_REG

#define AD5449_CTRL_REG   13

◆ AD5449_CTRL_UPDATEALL

#define AD5449_CTRL_UPDATEALL   7

◆ AD5449_DAISY_CHAIN_DIS

#define AD5449_DAISY_CHAIN_DIS   0

◆ AD5449_DAISY_CHAIN_EN

#define AD5449_DAISY_CHAIN_EN   1

◆ AD5449_DSY_BIT

#define AD5449_DSY_BIT   9

◆ AD5449_DSY_MASK

#define AD5449_DSY_MASK   (1 << 9)

◆ AD5449_HCLR_BIT

#define AD5449_HCLR_BIT   8

◆ AD5449_HCLR_MASK

#define AD5449_HCLR_MASK   (1 << 8)

◆ AD5449_LDAC_HIGH

#define AD5449_LDAC_HIGH
Value:
gpio_set_value(dev->gpio_ldac, \

◆ AD5449_LDAC_LOW

#define AD5449_LDAC_LOW
Value:
gpio_set_value(dev->gpio_ldac, \

◆ AD5449_LDAC_OUT

#define AD5449_LDAC_OUT
Value:

◆ AD5449_MID_SCALE

#define AD5449_MID_SCALE   1

◆ AD5449_SCLK_BIT

#define AD5449_SCLK_BIT   7

◆ AD5449_SCLK_MASK

#define AD5449_SCLK_MASK   (1 << 7)

◆ AD5449_SDO_BIT

#define AD5449_SDO_BIT   10

◆ AD5449_SDO_DISABLE

#define AD5449_SDO_DISABLE   3

◆ AD5449_SDO_FULL

#define AD5449_SDO_FULL   0

◆ AD5449_SDO_MASK

#define AD5449_SDO_MASK   (3 << 10)

◆ AD5449_SDO_OPEN_DRAIN

#define AD5449_SDO_OPEN_DRAIN   2

◆ AD5449_SDO_WEAK

#define AD5449_SDO_WEAK   1

◆ AD5449_ZERO_SCALE

#define AD5449_ZERO_SCALE   0

Enumeration Type Documentation

◆ ad5449_type_t

Enumerator
ID_AD5415 
ID_AD5426 
ID_AD5429 
ID_AD5432 
ID_AD5439 
ID_AD5443 
ID_AD5449 

◆ bool_t

enum bool_t
Enumerator
false 
true 
false 
true 
false 
true 

Function Documentation

◆ ad5449_clear_scale_setup()

void ad5449_clear_scale_setup ( struct ad5449_dev dev,
int8_t  type 
)

Set up the scale where to the output will be cleared on active CLR signal.

Parameters
dev- The device structure.
type- target scale when making a clear command Example: ZERO_SCALE = zero scale. MIDSCALE = midscale.
Returns
None.

◆ ad5449_daisy_chain_setup()

void ad5449_daisy_chain_setup ( struct ad5449_dev dev,
int8_t  value 
)

Enable/disable the Daisy-Chain mode.

Parameters
dev- The device structure.
value- target scale when making a clear command Example: ZERO_SCALE = zero scale. MIDSCALE = midscale.
Returns
None.

◆ ad5449_init()

int8_t ad5449_init ( struct ad5449_dev **  device,
struct ad5449_init_param  init_param 
)

Initialize SPI and Initial Values for AD5449 Board.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
retValue - Result of the initialization. Example: 0 - if initialization was successful; -1 - if initialization was unsuccessful.

◆ ad5449_load_all()

void ad5449_load_all ( struct ad5449_dev dev,
int16_t  dac_value 
)

Load the DAC input registers. This function has a physical result just with devices with two channels.

Parameters
dev- The device structure.
dac_value- desired value to be written in register.
Returns
None.

◆ ad5449_load_channel()

void ad5449_load_channel ( struct ad5449_dev dev,
uint8_t  channel,
uint16_t  dac_value 
)

Load selected DAC input register with a given value.

Parameters
dev- The device structure.
channel- the chosen channel to write to. Example: AD5449_CH_A = 0; AD5449_CH_B = 1.
dac_value- desired value to be written in register.
Returns
None.

◆ ad5449_load_update_channel()

void ad5449_load_update_channel ( struct ad5449_dev dev,
uint8_t  channel,
uint16_t  dac_value 
)

Loads and updates the selected DAC with a given value.

Parameters
dev- The device structure.
channel- the chosen channel to write to. Example: AD5449_CH_A = 0; AD5449_CH_B = 1.
dac_value- desired value to be written in register.
Returns
None.

◆ ad5449_readback_channel()

uint16_t ad5449_readback_channel ( struct ad5449_dev dev,
uint8_t  channel 
)

Read from the selected DAC register.

Parameters
dev- The device structure.
channel- the chosen channel to read from. Example: AD5449_CH_A = 0; AD5449_CH_B = 1.
Returns
dac_value - value read from the register.

◆ ad5449_remove()

int32_t ad5449_remove ( struct ad5449_dev dev)

Free the resources allocated by ad5449_init().

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

◆ ad5449_sclksetup()

void ad5449_sclksetup ( struct ad5449_dev dev,
int8_t  value 
)

Set up the active clock edge of the SPI interface.

Parameters
dev- The device structure.
value- target scale when making a clear command Example: AD5449_CLOCK_NEGEDGE = Falling edge. (Default) AD5449_CLOCK_POSEDGE = Rising edge.
Returns
None.

◆ ad5449_sdocontrol()

void ad5449_sdocontrol ( struct ad5449_dev dev,
int8_t  control_bits 
)

Control the SDO output driver strength. This function is supported by the devices : AD5415, AD5429, AD5439, AD5449.

Parameters
dev- The device structure.
control_bits- target scale when making a clear command Example: AD5449_SDO_FULL = Full SDO driver. AD5449_SDO_WEAK = Weak SDO driver. AD5449_SDO_OPEN_DRAIN = SDO configured as open drain AD5449_SDO_DISABLE = Disable SDO output
Returns
None.

◆ ad5449_set_input_shift_reg()

uint16_t ad5449_set_input_shift_reg ( struct ad5449_dev dev,
uint16_t  command,
uint16_t  data 
)

Write to input register and read from output register via SPI.

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

◆ ad5449_update_all()

void ad5449_update_all ( struct ad5449_dev dev)

Update the DAC outputs. This function has a physical result just with devices with two channels.

Parameters
dev- The device structure.
Returns
None.
gpio_direction_output
int32_t gpio_direction_output(struct gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: gpio.c:124
GPIO_LOW
@ GPIO_LOW
Definition: gpio.h:99
gpio_set_value
int32_t gpio_set_value(struct gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: gpio.c:160
GPIO_HIGH
@ GPIO_HIGH
Definition: gpio.h:101
iio_app_device::dev
void * dev
Definition: iio_app.h:60