no-OS
|
Implementation of AD5449 Driver. More...
Macros | |
#define | MAX_RESOLUTION 12 /* Maximum resolution of the supported devices */ |
#define | DATA_MASK 0xFFF /* Mask for 16 data bits */ |
#define | CMD_MASK 0xFF /* Mask for Command bits */ |
#define | CMD_OFFSET 12 /* Offset for Command */ |
#define | MSB_MASK 0xFF00 /* Most significant byte of the data word */ |
#define | MSB_OFFSET 8 |
#define | LSB_MASK 0x00FF /* Least significant byte of the data word */ |
#define | LSB_OFFSET 0 |
#define | PKT_LENGTH 2 /* SPI packet length in byte */ |
#define | TWO_BIT_MASK 0x3 |
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... | |
Implementation of AD5449 Driver.
Copyright 2013(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:
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.
#define CMD_MASK 0xFF /* Mask for Command bits */ |
#define CMD_OFFSET 12 /* Offset for Command */ |
#define DATA_MASK 0xFFF /* Mask for 16 data bits */ |
#define LSB_MASK 0x00FF /* Least significant byte of the data word */ |
#define LSB_OFFSET 0 |
#define MAX_RESOLUTION 12 /* Maximum resolution of the supported devices */ |
#define MSB_MASK 0xFF00 /* Most significant byte of the data word */ |
#define MSB_OFFSET 8 |
#define PKT_LENGTH 2 /* SPI packet length in byte */ |
#define TWO_BIT_MASK 0x3 |
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.
dev | - The device structure. |
type | - target scale when making a clear command Example: ZERO_SCALE = zero scale. MIDSCALE = midscale. |
void ad5449_daisy_chain_setup | ( | struct ad5449_dev * | dev, |
int8_t | value | ||
) |
Enable/disable the Daisy-Chain mode.
dev | - The device structure. |
value | - target scale when making a clear command Example: ZERO_SCALE = zero scale. MIDSCALE = midscale. |
int8_t ad5449_init | ( | struct ad5449_dev ** | device, |
struct ad5449_init_param | init_param | ||
) |
Initialize SPI and Initial Values for AD5449 Board.
device | - The device structure. |
init_param | - The structure that contains the device initial parameters. |
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.
dev | - The device structure. |
dac_value | - desired value to be written in register. |
void ad5449_load_channel | ( | struct ad5449_dev * | dev, |
uint8_t | channel, | ||
uint16_t | dac_value | ||
) |
Load selected DAC input register with a given value.
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. |
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.
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. |
uint16_t ad5449_readback_channel | ( | struct ad5449_dev * | dev, |
uint8_t | channel | ||
) |
Read from the selected DAC register.
dev | - The device structure. |
channel | - the chosen channel to read from. Example: AD5449_CH_A = 0; AD5449_CH_B = 1. |
int32_t ad5449_remove | ( | struct ad5449_dev * | dev | ) |
Free the resources allocated by ad5449_init().
dev | - The device structure. |
void ad5449_sclksetup | ( | struct ad5449_dev * | dev, |
int8_t | value | ||
) |
Set up the active clock edge of the SPI interface.
dev | - The device structure. |
value | - target scale when making a clear command Example: AD5449_CLOCK_NEGEDGE = Falling edge. (Default) AD5449_CLOCK_POSEDGE = Rising edge. |
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.
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 |
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.
dev | - The device structure. |
command | - command control bits. |
data | - data to be written in input register. |
void ad5449_update_all | ( | struct ad5449_dev * | dev | ) |
Update the DAC outputs. This function has a physical result just with devices with two channels.
dev | - The device structure. |