Implementation of AD5449 Driver.
More...
#include <stdlib.h>
#include "ad5449.h"
#include "no_os_alloc.h"
|
| int8_t | ad5449_init (struct ad5449_dev **device, struct ad5449_init_param init_param) |
| | Initialize SPI and Initial Values for AD5449 Board.
|
| |
| int32_t | ad5449_remove (struct ad5449_dev *dev) |
| | Free the resources allocated by ad5449_init().
|
| |
| 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.
|
| |
| 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.
|
| |
| void | ad5449_load_channel (struct ad5449_dev *dev, uint8_t channel, uint16_t dac_value) |
| | Load selected DAC input register with a given value.
|
| |
| uint16_t | ad5449_readback_channel (struct ad5449_dev *dev, uint8_t channel) |
| | Read from the selected DAC 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.
|
| |
| 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.
|
| |
| 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.
|
| |
| void | ad5449_daisy_chain_setup (struct ad5449_dev *dev, int8_t value) |
| | Enable/disable the Daisy-Chain mode.
|
| |
| 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.
|
| |
| void | ad5449_sclksetup (struct ad5449_dev *dev, int8_t value) |
| | Set up the active clock edge of the SPI interface.
|
| |
Implementation of AD5449 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(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
◆ CMD_MASK
| #define CMD_MASK 0xFF /* Mask for Command bits */ |
◆ CMD_OFFSET
| #define CMD_OFFSET 12 /* Offset for Command */ |
◆ DATA_MASK
| #define DATA_MASK 0xFFF /* Mask for 16 data bits */ |
◆ LSB_MASK
| #define LSB_MASK 0x00FF /* Least significant byte of the data word */ |
◆ LSB_OFFSET
◆ MAX_RESOLUTION
| #define MAX_RESOLUTION 12 /* Maximum resolution of the supported devices */ |
◆ MSB_MASK
| #define MSB_MASK 0xFF00 /* Most significant byte of the data word */ |
◆ MSB_OFFSET
◆ PKT_LENGTH
| #define PKT_LENGTH 2 /* SPI packet length in byte */ |
◆ TWO_BIT_MASK
◆ 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. |
◆ 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. |
◆ ad5449_init()
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. |
◆ 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. |
◆ 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. |
◆ 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()
Free the resources allocated by ad5449_init().
- Parameters
-
| dev | - The device structure. |
- Returns
- 0 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. |
◆ 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 |
◆ 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()
Update the DAC outputs. This function has a physical result just with devices with two channels.
- Parameters
-
| dev | - The device structure. |