Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/device_drivers/AD5629R/ad5629r.h

raw symbols SCIP
1 /**************************************************************************//**
2 * @file ad5629r.h
3 * @brief Header file of AD5629R Driver for Microblaze processor.
4 * @author Lucian Sin ([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 modification,
12 * are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 * - Neither the name of Analog Devices, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 * - The use of this software may or may not infringe the patent rights
23 * of one or more patent holders. This license does not release you
24 * from the requirement that you obtain separate licenses from these
25 * patent holders to use this software.
26 * - Use of the software either in source or binary form, must be run
27 * on or directly connected to an Analog Devices Inc. component.
28 *
29 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
31 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 ******************************************************************************/
41
42 #ifndef _AD5629R_H_
43 #define _AD5629R_H_
44
45 /******************************************************************************/
46 /***************************** Include Files **********************************/
47 /******************************************************************************/
48 #include "Communication.h"
49
50 /******************************************************************************/
51 /******************* Macros and Constants Definitions *************************/
52 /******************************************************************************/
53 /* Supported devices */
54 typedef enum {
55 ID_AD5629R,
56 ID_AD5669R,
57 ID_AD5668,
58 ID_AD5648,
59 ID_AD5628,
60 } AD5629R_type;
61
62 /* AD5629R Device I2C Address */
63 #define AD5629R_I2C_ADDR_0 0x54 // A1=0 and A0=0 (A0_Pin=High)
64 #define AD5629R_I2C_ADDR_1 0x56 // A1=1 and A0=0 (A0_Pin=NC)
65 #define AD5629R_I2C_ADDR_2 0x57 // A1=1 and A0=1 (A0_Pin=Low)
66
67 #define MAX_RESOLUTION 16
68
69 /* Commands */
70 #define AD5629R_WRITE_N 0x0
71 #define AD5629R_UPDATE_N 0x1
72 #define AD5629R_WRITE_N_UPDATE_ALL 0x2
73 #define AD5629R_WRITE_N_UPDATE_N 0x3
74 #define AD5629R_POWER 0x4
75 #define AD5629R_LOAD_CLEAR_REG 0x5
76 #define AD5629R_LOAD_LDAC_REG 0x6
77 #define AD5629R_RESET 0x7
78 #define AD5629R_REFERENCE 0x8
79
80 /* AD5629R GPIO */
81 /* LDAC - GPIO0 */
82 #define AD5629R_LDAC_OUT GPIO0_PIN_OUT
83 #define AD5629R_LDAC_LOW GPIO0_LOW
84 #define AD5629R_LDAC_HIGH GPIO0_HIGH
85 /* CLR - GPIO1 */
86 #define AD5629R_CLR_OUT GPIO1_PIN_OUT
87 #define AD5629R_CLR_LOW GPIO1_LOW
88 #define AD5629R_CLR_HIGH GPIO1_HIGH
89
90 /* DAC Addresses */
91 #define AD5629R_DAC_A_ADDR 0x0
92 #define AD5629R_DAC_B_ADDR 0x1
93 #define AD5629R_DAC_C_ADDR 0x2
94 #define AD5629R_DAC_D_ADDR 0x3
95 #define AD5629R_DAC_E_ADDR 0x4
96 #define AD5629R_DAC_F_ADDR 0x5
97 #define AD5629R_DAC_G_ADDR 0x6
98 #define AD5629R_DAC_H_ADDR 0x7
99 #define AD5629R_DAC_ALL_ADDR 0xF
100
101 /* DAC Selection */
102 #define DAC_A_SEL 1
103 #define DAC_B_SEL 2
104 #define DAC_C_SEL 4
105 #define DAC_D_SEL 8
106 #define DAC_E_SEL 16
107 #define DAC_F_SEL 32
108 #define DAC_G_SEL 64
109 #define DAC_H_SEL 128
110
111 /* Power modes */
112 #define PWR_NORMAL 0
113 #define PWR_1K_TO_GND 1
114 #define PWR_100K_TO_GND 2
115 #define PWR_3_STATE 3
116
117 /* Clear code values */
118 #define CLR_TO_ZEROSCALE 0
119 #define CLR_TO_MIDSCALE 1
120 #define CLR_TO_FULLSCALE 2
121 #define CLR_NOOP 3
122
123 /* Internal reference status */
124 #define REF_ON 1
125 #define REF_OFF 0
126
127 #define AD5629R_SLAVE_ID 1
128
129 /******************************************************************************/
130 /************************ Functions Declarations ******************************/
131 /******************************************************************************/
132 /* Initializes the communication with the device. */
133 char AD5629R_Init(unsigned char devAddr, AD5629R_type device);
134 /* Writes a value to Input Register N of selected DAC channel. */
135 void AD5629R_WriteRegN(unsigned char dacN, unsigned short dacValue);
136 /* Updates selected DAC register. */
137 void AD5629R_UpdateDacN(unsigned char dacN);
138 /* Writes a value to Input Register N of selected DAC channel, then updates all. */
139 void AD5629R_WriteRegNUpdateAll(unsigned char dacN, unsigned short dacValue);
140 /* Writes a value to Input Register N and updates the respective DAC channel. */
141 void AD5629R_WriteRegNUpdateN(unsigned char dacN, unsigned short dacValue);
142 /* Sets the power mode for one or more selected DAC channels. */
143 void AD5629R_SetPowerMode(unsigned char dacSel, unsigned char mode);
144 /* Loads the Clear Code Register with a certain value. */
145 void AD5629R_LoadClearCodeReg(unsigned char clearValue);
146 /* Loads the LDAC register with a certain value. */
147 void AD5629R_LoadLdacReg(unsigned char dacSel);
148 /* Makes a power-on reset. */
149 void AD5629R_Reset(void);
150 /* Turns on/off the internal reference. */
151 void AD5629R_SetRef(unsigned char status);
152
153
154 #endif /* AD5629_H_ */