no-OS
Macros | Functions
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)   (0xFFFF >> (MAX_RESOLUTION - (x)))
 
#define DATA_OFFSET(x)   ((MAX_RESOLUTION - 2) - (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. More...
 
int32_t ad5446_remove (struct ad5446_dev *dev)
 Free the resources allocated by ad5446_init(). More...
 
void ad5446_set_register (struct ad5446_dev *dev, uint8_t command, uint16_t data)
 Writes to input register via SPI. More...
 
float ad5446_set_voltage (struct ad5446_dev *dev, float voltage, float vref, enum vout_type_t vout_type)
 Sets the output voltage. More...
 

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.

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

◆ CMD_MASK

#define CMD_MASK   0x3

◆ CMD_OFFSET

#define CMD_OFFSET   15

◆ DATA_MASK

#define DATA_MASK (   x)    (0xFFFF >> (MAX_RESOLUTION - (x)))

◆ DATA_OFFSET

#define DATA_OFFSET (   x)    ((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.
Returns
None.

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