Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/device_drivers/AD5172/ad5172.h

raw symbols SCIP
1 /**************************************************************************//**
2 * @file ad5172.h
3 * @brief Header file of AD5172 Driver for Microblaze processor. This driver
4 * supporting the following devices : AD5162, AD5172, AD5173, AD8403,
5 * AD8402, AD8400
6 * @author Istvan Csomortani ([email protected])
7 *
8 *******************************************************************************
9 * Copyright 2013(c) Analog Devices, Inc.
10 *
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without 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 IMPLIED
32 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY
33 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36 * INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 ******************************************************************************/
43 #ifndef __AD5172_H__
44 #define __AD5172_H__
45
46 #include "Communication.h"
47
48 /* Custom boolean type */
49 typedef enum
50 {
51 false,
52 true
53 } bool_t;
54
55 /* Communication types */
56 typedef enum
57 {
58 SPI,
59 I2C
60 } comm_type_t;
61
62 /* Supported devices */
63 typedef enum {
64 ID_AD5162,
65 ID_AD5172,
66 ID_AD5173,
67 ID_AD8403,
68 ID_AD8402,
69 ID_AD8400,
70 } AD5172_type_t;
71
72 /*****************************************************************************/
73 /* Device specific MACROs */
74 /*****************************************************************************/
75 /* GPIOs */
76 #define AD5172_RESET_OUT GPIO1_PIN_OUT
77 #define AD5172_RESET_LOW GPIO1_LOW
78 #define AD5172_RESET_HIGH GPIO1_HIGH
79
80 #define AD5172_SHUTDOWN_OUT GPIO3_PIN_OUT
81 #define AD5172_SHUTDOWN_LOW GPIO3_LOW
82 #define AD5172_SHUTDOWN_HIGH GPIO3_HIGH
83
84 /* I2C addresses */
85 #define AD5172_I2C_HARD_ADDR 0xB
86 /* Package pin-programmable address bits */
87 #define AD5172_I2C_PIN_ADDR1 0
88 #define AD5172_I2C_PIN_ADDR0 0
89 #define AD5172_I2C_PIN_ADDR_MASK 0x03
90
91 /* AD5172/3 use special commands */
92 #define AD5172_CNTR_MASK 0x68 // Mask of the control bits
93 #define AD5172_CNTR_A0_MASK 0x80 // Mask of the address bit
94 #define AD5172_CNTR_SD (1 << 6) // Shutdown bit
95 #define AD5172_OTP_T (1 << 5) // OTP programming bit
96 #define AD5172_OTP_OW (1 << 3) // Overwrites the fuse settings
97 #define AD5172_CNTR_A0_OFFSET 0x07 // Offset of the address bits
98 #define AD5172_OTP_VALID_MASK 0x03 // Mask of the OTP validation bits
99 #define AD5172_OTP_VALID_OFFSET 0x06 // Offset of the OTP validation bits
100 /* OTP validation bits */
101 #define AD5172_FUSE_READY 0x00
102 #define AD5172_FUSE_ERROR 0x01
103 #define AD5172_FUSE_SUCCESS 0x02
104
105 #define AD5172_SLAVE_ID 1
106
107 /*****************************************************************************/
108 /* Functions Prototypes */
109 /*****************************************************************************/
110 /* Initialize the communication with the device */
111 char AD5172_Init(AD5172_type_t device);
112
113 /* Send a command to the device */
114 void AD5172_Write(unsigned char channel,
115 unsigned char command,
116 unsigned char data);
117
118 /* Read back RDAC value from the device */
119 short AD5172_Read(unsigned char channel, unsigned char* fuseStatus);
120
121 #endif // __AD5172_H__