Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/device_drivers/AD5449/ad5449.h

raw symbols SCIP
1 /***************************************************************************//**
2 * @file AD5449.h
3 * @brief Header file of AD5449 Driver. This driver supporting the following
4 * devices: AD5415, AD5443, AD5432, AD5426, AD5429, AD5439, AD5449
5 *
6 * @author Istvan Csomortani ([email protected])
7 ********************************************************************************
8 * Copyright 2013(c) Analog Devices, Inc.
9 *
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification,
14 * are permitted provided that the following conditions are met:
15 * - Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * - Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in
19 * the documentation and/or other materials provided with the
20 * distribution.
21 * - Neither the name of Analog Devices, Inc. nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 * - The use of this software may or may not infringe the patent rights
25 * of one or more patent holders. This license does not release you
26 * from the requirement that you obtain separate licenses from these
27 * patent holders to use this software.
28 * - Use of the software either in source or binary form, must be run
29 * on or directly connected to an Analog Devices Inc. component.
30 *
31 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
32 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
33 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
41 * DAMAGE.
42 *
43 *******************************************************************************/
44
45 /******************************************************************************/
46 /***************************** Include Files **********************************/
47 /******************************************************************************/
48 #include "Communication.h"
49
50 typedef enum
51 {
52 false,
53 true
54 } bool_t;
55
56 /* Supported devices */
57 typedef enum {
58 ID_AD5415,
59 ID_AD5426,
60 ID_AD5429,
61 ID_AD5432,
62 ID_AD5439,
63 ID_AD5443,
64 ID_AD5449,
65 } AD5449_type_t;
66
67 /* Control Bits */
68 #define AD5449_CTRL_NOP 0
69 #define AD5449_CTRL_LOADUPDATE(x) (1 + 3 * (x))
70 #define AD5449_CTRL_READBACK(x) (2 + 3 * (x))
71 #define AD5449_CTRL_LOAD(x) (3 + 3 * (x))
72 #define AD5449_CTRL_UPDATEALL 7
73 #define AD5449_CTRL_LOADALL 8
74 #define AD5449_CTRL_DAISY_CHAIN 9
75 #define AD5449_CTRL_CLK_EDGE 10
76 #define AD5449_CTRL_CLR_ZERO 11
77 #define AD5449_CTRL_CLR_MID 12
78 #define AD5449_CTRL_REG 13
79
80 /* AD5449 channels */
81 #define AD5449_CH_A 0
82 #define AD5449_CH_B 1
83
84 /* Clear target scales */
85 #define AD5449_ZERO_SCALE 0
86 #define AD5449_MID_SCALE 1
87
88 /* Active clock edge */
89 #define AD5449_CLOCK_NEGEDGE 0
90 #define AD5449_CLOCK_POSEDGE 1
91
92 /* Daisy-Chain Control */
93 #define AD5449_DAISY_CHAIN_DIS 0
94 #define AD5449_DAISY_CHAIN_EN 1
95
96 /* AD5449_CTRL_REG definition */
97 #define AD5449_SDO_MASK (3 << 10)
98 #define AD5449_DSY_MASK (1 << 9)
99 #define AD5449_HCLR_MASK (1 << 8)
100 #define AD5449_SCLK_MASK (1 << 7)
101 #define AD5449_SDO_BIT 10
102 #define AD5449_DSY_BIT 9
103 #define AD5449_HCLR_BIT 8
104 #define AD5449_SCLK_BIT 7
105
106 /* AD5449 GPIO */
107 #define AD5449_LDAC_OUT GPIO1_PIN_OUT
108 #define AD5449_LDAC_LOW GPIO1_LOW
109 #define AD5449_LDAC_HIGH GPIO1_HIGH
110
111 #define AD5449_CLR_OUT GPIO2_PIN_OUT
112 #define AD5449_CLR_LOW GPIO2_LOW
113 #define AD5449_CLR_HIGH GPIO2_HIGH
114
115 /* SDO Control Bits */
116 #define AD5449_SDO_FULL 0
117 #define AD5449_SDO_WEAK 1
118 #define AD5449_SDO_OPEN_DRAIN 2
119 #define AD5449_SDO_DISABLE 3
120
121 /* SPI slave device ID */
122 #if(defined(AD5443) || defined(AD5432) || defined(AD5426))
123 #define AD5449_SLAVE_ID 3
124 #else
125 #define AD5449_SLAVE_ID 1
126 #endif
127 /******************************************************************************/
128 /************************ Functions Declarations ******************************/
129 /******************************************************************************/
130 /* Initialize SPI and Initial Values for AD5449 Board. */
131 char AD5449_Init(AD5449_type_t device);
132
133 /* Write to shift register via SPI. */
134 unsigned short AD5449_SetInputShiftReg(unsigned short command,
135 unsigned short data);
136
137 /* Load and updates the selected DAC with a given value. */
138 void AD5449_LoadUpdateChannel(unsigned char channel, unsigned short dacValue);
139
140 /* Load selected DAC input register with a given value. */
141 void AD5449_LoadChannel(unsigned char channel, unsigned short dacValue);
142
143 /* Read from the selected DAC register. */
144 unsigned short AD5449_ReadbackChannel(unsigned char channel);
145
146 /* Update the DAC outputs (all channels). */
147 void AD5449_UpdateAll(void);
148
149 /* Load the DAC input registers. */
150 void AD5449_LoadAll(short dacValue);
151
152 /* Set up the scale where to the output will be cleared on active CLR signal */
153 void AD5449_ClearScaleSetup(char type);
154
155 /* Enable/disable the Daisy-Chain mode */
156 void AD5449_DaisyChainSetup(char value);
157
158 /* Control the SDO output driver strength */
159 void AD5449_SDOControl(char controlBits);
160
161 /* Set up the active clock edge of the SPI interface */
162 void AD5449_SCLKSetup(char value);