Debian Codegraph @

thirdparty/analogdevicesinc/no-OS/drivers/AD7780/AD7780.h

raw symbols SCIP
1 /***************************************************************************//**
2 * @file AD7780.h
3 * @brief AD7780 header file.
4 * @author DNechita ([email protected])
5 ********************************************************************************
6 * Copyright 2012(c) Analog Devices, Inc.
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * - Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * - Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
17 * distribution.
18 * - Neither the name of Analog Devices, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 * - The use of this software may or may not infringe the patent rights
22 * of one or more patent holders. This license does not release you
23 * from the requirement that you obtain separate licenses from these
24 * patent holders to use this software.
25 * - Use of the software either in source or binary form, must be run
26 * on or directly connected to an Analog Devices Inc. component.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 ********************************************************************************
40 * SVN Revision: $WCREV$
41 *******************************************************************************/
42 #ifndef __AD7780_H__
43 #define __AD7780_H__
44
45 /******************************************************************************/
46 /***************************** Include Files **********************************/
47 /******************************************************************************/
48 #include "Communication.h"
49
50 /******************************************************************************/
51 /************************** AD7780 Definitions ********************************/
52 /******************************************************************************/
53
54 /* DOUT/RDY pin */
55 #define AD7780_RDY_STATE SPI_MISO
56
57 /* PDRST pin */
58 #define AD7780_PDRST_PIN_OUT SPI_CS_PIN_OUT
59 #define AD7780_PDRST_HIGH SPI_CS_HIGH
60 #define AD7780_PDRST_LOW SPI_CS_LOW
61
62 /* FILTER pin */
63 #define AD7780_FILTER_PIN_OUT GPIO1_PIN_OUT
64 #define AD7780_FILTER_HIGH GPIO1_HIGH
65 #define AD7780_FILTER_LOW GPIO1_LOW
66
67 /* GAIN pin */
68 #define AD7780_GAIN_PIN_OUT GPIO2_PIN_OUT
69 #define AD7780_GAIN_HIGH GPIO2_HIGH
70 #define AD7780_GAIN_LOW GPIO2_LOW
71
72 /* Status bits */
73 #define AD7780_STAT_RDY (1 << 7) // Ready bit.
74 #define AD7780_STAT_FILTER (1 << 6) // Filter bit.
75 #define AD7780_STAT_ERR (1 << 5) // Error bit.
76 #define AD7780_STAT_ID1 (1 << 4) // ID bits.
77 #define AD7780_STAT_ID0 (1 << 3) // ID bits.
78 #define AD7780_STAT_GAIN (1 << 2) // Gain bit.
79 #define AD7780_STAT_PAT1 (1 << 1) // Status pattern bits.
80 #define AD7780_STAT_PAT0 (1 << 0) // Status pattern bits.
81
82 #define AD7780_ID_NUMBER 0x08
83
84 /******************************************************************************/
85 /************************ Functions Declarations ******************************/
86 /******************************************************************************/
87
88 /*! Initializes the communication peripheral and checks if the device is
89 present. */
90 char AD7780_Init(void);
91
92 /*! Waits for DOUT/RDY pin to go low. */
93 char AD7780_WaitRdyGoLow(void);
94
95 /*! Reads a 24-bit sample from the ADC. */
96 long AD7780_ReadSample(unsigned char* pStatus);
97
98 /*! Converts the 24-bit raw value to volts. */
99 float AD7780_ConvertToVoltage(unsigned long rawSample, float vRef, unsigned char gain);
100
101 #endif /* __AD7780_H__ */