Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/Pmods/PmodDA5/AD5781.h

raw symbols SCIP
1 /************************************************************************//***
2 * @file AD5781.h
3 * @brief Header file for AD5781 Driver
4 * @author ATofan ([email protected])
5 *
6 ******************************************************************************
7 * Copyright 2013(c) Analog Devices, Inc.
8 *
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification,
13 * are permitted provided that the following conditions are met:
14 * - Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 * - Neither the name of Analog Devices, Inc. nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 * - The use of this software may or may not infringe the patent rights
24 * of one or more patent holders. This license does not release you
25 * from the requirement that you obtain separate licenses from these
26 * patent holders to use this software.
27 * - Use of the software either in source or binary form, must be run
28 * on or directly connected to an Analog Devices Inc. component.
29 *
30 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
31 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
33 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
34 * INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 ******************************************************************************
42 * SVN Revision: $WCREV$
43 ******************************************************************************/
44 #ifndef __AD5781_H__
45 #define __AD5781_H__
46
47 /*****************************************************************************/
48 /***************************** Include Files *********************************/
49 /*****************************************************************************/
50 #include "xparameters.h"
51
52 /*****************************************************************************/
53 /********************** Macros and Constant Definitions **********************/
54 /*****************************************************************************/
55 ///DAC5781 Registers Definition
56 #define DAC_REG 0x1 /* Offset of DAC Register's Address */
57 #define DAC_CNT 0x2 /* Offset of Control Register's Address */
58 #define DAC_CC 0x3 /* Offset of Clearcode Register's Address */
59 #define DAC_SW 0x4 /* Offset of Software Control Register's Address */
60
61 ///Control Register's bits
62 #define LIN_COMP 0x3C0 /* Linearity error compensation for varying reference input span */
63 #define SDODIS 0x020 /* SDO pin enable/disable control */
64 #define BIN2SC 0x010 /* DAC register coding select */
65 #define DACTRI 0x008 /* DAC tristate control */
66 #define OPGND 0x004 /* Output ground clamp control */
67 #define RBUF 0x002 /* Output amplifier configuration control */
68
69 ///Software Control Register's bits
70 #define RST 0x4 /* Software control for Reset */
71 #define CLR 0x2 /* Software control for Clear */
72 #define LDAC 0x1 /* Software control for Load DAC */
73
74 ///User Defined Macros
75 #define REGWR(x) ((0x0 << 23) | ((DAC_REG << 20) | ((x) << 2))) /* Generate packet which writes the arguments value to the DAC Register */
76 #define REGRD(x) ((0x1 << 23) | ((DAC_REG << 20) | ((x) << 2))) /* Generate packet which reads the arguments value from the DAC Register */
77 #define UPDATE_DAC_REG ((DAC_SW << 20) | LDAC) /* Macro to assert the LDAC line from software */
78
79 ///User Defined Constants
80 static const unsigned char sinetable[256] = {
81 0x80, 0x83, 0x86, 0x89, 0x8C, 0x90, 0x93, 0x96,
82 0x99, 0x9C, 0x9F, 0xA2, 0xA5, 0xA8, 0xAB, 0xAE,
83 0xB1, 0xB3, 0xB6, 0xB9, 0xBC, 0xBF, 0xC1, 0xC4,
84 0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x02, 0x02, 0x03,
106 0x03, 0x04, 0x05, 0x06, 0x06, 0x07, 0x08, 0x0A,
107 0x0B, 0x0C, 0x0D, 0x0F, 0x10, 0x11, 0x13, 0x15,
108 0x16, 0x18, 0x1A, 0x1C, 0x1E, 0x20, 0x22, 0x24,
109 0x26, 0x28, 0x2B, 0x2D, 0x2F, 0x32, 0x34, 0x37,
110 0x39, 0x3C, 0x3F, 0x41, 0x44, 0x47, 0x4A, 0x4D,
111 0x4F, 0x52, 0x55, 0x58, 0x5B, 0x5E, 0x61, 0x64,
112 0x67, 0x6A, 0x6D, 0x70, 0x74, 0x77, 0x7A, 0x7D
113 };
114 static const unsigned char sawtable[256] = {
115 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
116 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
117 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
118 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
119 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
120 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
121 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
122 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
123 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
124 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
125 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
126 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
127 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
128 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
129 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
130 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F,
131 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
132 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F,
133 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
134 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F,
135 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
136 0xa8, 0xa9, 0xaA, 0xaB, 0xaC, 0xaD, 0xaE, 0xaF,
137 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
138 0xb8, 0xb9, 0xbA, 0xbB, 0xbC, 0xbD, 0xbE, 0xbF,
139 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
140 0xc8, 0xc9, 0xcA, 0xcB, 0xcC, 0xcD, 0xcE, 0xcF,
141 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
142 0xd8, 0xd9, 0xdA, 0xdB, 0xdC, 0xdD, 0xdE, 0xdF,
143 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
144 0xe8, 0xe9, 0xeA, 0xeB, 0xeC, 0xeD, 0xeE, 0xeF,
145 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
146 0xf8, 0xf9, 0xfA, 0xfB, 0xfC, 0xfD, 0xfE, 0xfF
147 };
148 static const unsigned char triangletable[256] = {
149 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e,
150 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
151 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e,
152 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
153 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e,
154 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
155 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e,
156 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
157 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e,
158 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
159 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae,
160 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
161 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce,
162 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
163 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee,
164 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfc, 0xfe,
165 0xfe, 0xfc, 0xfa, 0xf8, 0xf6, 0xf4, 0xf2, 0xf0,
166 0xee, 0xec, 0xea, 0xe8, 0xe6, 0xe4, 0xe2, 0xe0,
167 0xde, 0xdc, 0xda, 0xd8, 0xd6, 0xd4, 0xd2, 0xd0,
168 0xce, 0xcc, 0xca, 0xc8, 0xc6, 0xc4, 0xc2, 0xc0,
169 0xbe, 0xbc, 0xba, 0xb8, 0xb6, 0xb4, 0xb2, 0xb0,
170 0xae, 0xac, 0xaa, 0xa8, 0xa6, 0xa4, 0xa2, 0xa0,
171 0x9e, 0x9c, 0x9a, 0x98, 0x96, 0x94, 0x92, 0x90,
172 0x8e, 0x8c, 0x8a, 0x88, 0x86, 0x84, 0x82, 0x80,
173 0x7e, 0x7c, 0x7a, 0x78, 0x76, 0x74, 0x72, 0x70,
174 0x6e, 0x6c, 0x6a, 0x68, 0x66, 0x64, 0x62, 0x60,
175 0x5e, 0x5c, 0x5a, 0x58, 0x56, 0x54, 0x52, 0x50,
176 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x42, 0x40,
177 0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x30,
178 0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20,
179 0x1e, 0x1c, 0x1a, 0x18, 0x16, 0x14, 0x12, 0x10,
180 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x00
181 };
182
183 static const unsigned char squaretable[256] = {
184 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
185 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
186 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
187 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
188 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
189 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
190 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
191 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
192 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
193 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
194 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
195 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
196 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
197 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
198 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
199 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
216 };
217
218 void AD5781_DisplayMainMenu(void); /*!< Display Main Menu*/
219 void AD5781_DisplayMenu(void); /*!< Display Menu*/
220 void AD5781_DisplayWaveMenu(void); /*!< Display Wave Menu*/
221 void AD5781_SendData(int txData); /*!< Sending data to DAC*/
222 void AD5781_FixedValue(void); /*!< Display FixedValue Menu, and set the DAC Register*/
223 void AD5781_WaveGen(void); /*!< Generate one of the waveform from the Wave Menu's list */
224 void AD5781_ProgRamp(void); /*!< Runs Programmable Ramp Generation Mode Main Menu*/
225 void AD5781_InitDAC(void); /*!< Initial COnfiguration of the DAC5781*/
226 void DemoProgram(void);
227
228 #endif /* __AD5781_H__ */