no-OS
Loading...
Searching...
No Matches
ad5446.c File Reference

Implementation of AD5446 Driver. This driver supporting the following devices: AD5553, AD5543, AD5542A, AD5541A, AD5512A, AD5453, AD5452, AD5451, AD5450, AD5446, AD5444. More...

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

Macros

#define MAX_RESOLUTION   16 /* Maximum resolution of supported devices */
 
#define DATA_MASK(x)
 
#define DATA_OFFSET(x)
 
#define MSB_MASK   0xFF00
 
#define MSB_OFFSET   8
 
#define LSB_MASK   0x00FF
 
#define LSB_OFFSET   0
 
#define CMD_MASK   0x3
 
#define CMD_OFFSET   15
 
#define PKT_LENGTH   2 /* SPI packet length in byte */
 

Functions

int8_t ad5446_init (struct ad5446_dev **device, struct ad5446_init_param init_param)
 Initialize SPI and Initial Values for AD5446 Board.
 
int32_t ad5446_remove (struct ad5446_dev *dev)
 Free the resources allocated by ad5446_init().
 
void ad5446_set_register (struct ad5446_dev *dev, uint8_t command, uint16_t data)
 Writes to input register via SPI.
 
float ad5446_set_voltage (struct ad5446_dev *dev, float voltage, float vref, enum vout_type_t vout_type)
 Sets the output voltage.
 

Detailed Description

Implementation of AD5446 Driver. This driver supporting the following devices: AD5553, AD5543, AD5542A, AD5541A, AD5512A, AD5453, AD5452, AD5451, AD5450, AD5446, AD5444.

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.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ CMD_MASK

#define CMD_MASK   0x3

◆ CMD_OFFSET

#define CMD_OFFSET   15

◆ DATA_MASK

#define DATA_MASK ( x)
Value:
(0xFFFF >> (MAX_RESOLUTION - (x)))
#define MAX_RESOLUTION
Definition ad5446.c:17

◆ DATA_OFFSET

#define DATA_OFFSET ( x)
Value:
((MAX_RESOLUTION - 2) - (x))

◆ LSB_MASK

#define LSB_MASK   0x00FF

◆ LSB_OFFSET

#define LSB_OFFSET   0

◆ MAX_RESOLUTION

#define MAX_RESOLUTION   16 /* Maximum resolution of supported devices */

◆ MSB_MASK

#define MSB_MASK   0xFF00

◆ MSB_OFFSET

#define MSB_OFFSET   8

◆ PKT_LENGTH

#define PKT_LENGTH   2 /* SPI packet length in byte */

Function Documentation

◆ ad5446_init()

int8_t ad5446_init ( struct ad5446_dev ** device,
struct ad5446_init_param init_param )

Initialize SPI and Initial Values for AD5446 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.

◆ ad5446_remove()

int32_t ad5446_remove ( struct ad5446_dev * dev)

Free the resources allocated by ad5446_init().

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

◆ ad5446_set_register()

void ad5446_set_register ( struct ad5446_dev * dev,
uint8_t command,
uint16_t data )

Writes to input register via SPI.

Parameters
dev- The device structure.
command- Command to be transmitted to the device.
data- Data to be written in input register.

◆ ad5446_set_voltage()

float ad5446_set_voltage ( struct ad5446_dev * dev,
float voltage,
float vref,
enum vout_type_t vout_type )

Sets the output voltage.

Parameters
dev- The device structure.
voltage- The voltage value in volts
vref- The voltage reference used by the device in volts.
vout_type- Voltage output type: unipolar/unipolar_inv/bipolar
Returns
Actual voltage that the device can output.