| 1 | /***************************************************************************//** |
| 2 | * @file AD7193.h |
| 3 | * @brief Header file of AD7193 Driver. |
| 4 | * @author ATofan ([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 | |
| 43 | /*****************************************************************************/ |
| 44 | /***************************** Include Files *********************************/ |
| 45 | /*****************************************************************************/ |
| 46 | #include "xil_types.h" |
| 47 | #include "xparameters.h" |
| 48 | |
| 49 | /*****************************************************************************/ |
| 50 | /******************* AD7193 Definitions **************************************/ |
| 51 | /*****************************************************************************/ |
| 52 | #define CommunicationsReg 0x00 |
| 53 | #define StatusReg 0x00 |
| 54 | #define ModeReg 0x01 |
| 55 | #define ConfigurationReg 0x02 |
| 56 | #define DataReg 0x03 |
| 57 | #define IDReg 0x04 |
| 58 | #define GPOCONReg 0x05 |
| 59 | #define OffsetReg 0x06 |
| 60 | #define FullScaleReg 0x07 |
| 61 | // Register size in bytes |
| 62 | #define CommunicationsRegLen 1 |
| 63 | #define StatusRegLen 1 |
| 64 | #define ModeRegLen 3 |
| 65 | #define ConfigurationRegLen 3 |
| 66 | #define DataRegLen 3 |
| 67 | #define DataInfoRegLen 4 |
| 68 | #define IDRegLen 1 |
| 69 | #define GPOCONRegLen 1 |
| 70 | #define OffsetRegLen 3 |
| 71 | #define FullScaleRegLen 3 |
| 72 | |
| 73 | /*****************************************************************************/ |
| 74 | /******************* AD7193 Registers Bits ***********************************/ |
| 75 | /*****************************************************************************/ |
| 76 | // Communications Register 0x00 |
| 77 | #define WEN 7 |
| 78 | #define RnW 6 |
| 79 | #define RS2 5 |
| 80 | #define RS1 4 |
| 81 | #define RS0 3 |
| 82 | #define CREAD 2 |
| 83 | #define CR1 1 // Must be programmed to 0 |
| 84 | #define CR0 0 // Must be programmed to 0 |
| 85 | // Status Register 0x00 |
| 86 | #define RDY 7 |
| 87 | #define ERR 6 |
| 88 | #define NOREF 5 |
| 89 | #define Parity 4 |
| 90 | #define CHD3 3 |
| 91 | #define CHD2 2 |
| 92 | #define CHD1 1 |
| 93 | #define CHD0 0 |
| 94 | // Mode Register 0x01 |
| 95 | #define MD2 23 |
| 96 | #define MD1 22 |
| 97 | #define MD0 21 |
| 98 | #define DAT_STA 20 |
| 99 | #define CLK1 19 |
| 100 | #define CLK0 18 |
| 101 | #define AVG1 17 |
| 102 | #define AVG0 16 |
| 103 | #define SINC3 15 |
| 104 | #define ENPAR 13 |
| 105 | #define CLK_DIV 12 |
| 106 | #define Single 11 |
| 107 | #define REJ60 10 |
| 108 | #define FS9 9 |
| 109 | #define FS8 8 |
| 110 | #define FS7 7 |
| 111 | #define FS6 6 |
| 112 | #define FS5 5 |
| 113 | #define FS4 4 |
| 114 | #define FS3 3 |
| 115 | #define FS2 2 |
| 116 | #define FS1 1 |
| 117 | #define FS0 0 |
| 118 | // Configuration Register 0x02 |
| 119 | #define Chop 23 |
| 120 | #define REFSEL 20 |
| 121 | #define Pseudo 18 |
| 122 | #define Short 17 |
| 123 | #define TEMP 16 |
| 124 | #define CH7 15 |
| 125 | #define CH6 14 |
| 126 | #define CH5 13 |
| 127 | #define CH4 12 |
| 128 | #define CH3 11 |
| 129 | #define CH2 10 |
| 130 | #define CH1 9 |
| 131 | #define CH0 8 |
| 132 | #define Burn 7 |
| 133 | #define REFDET 6 |
| 134 | #define BUF 4 |
| 135 | #define UnB 3 |
| 136 | #define G2 2 |
| 137 | #define G1 1 |
| 138 | #define G0 0 |
| 139 | // GPOCON Register 0x05 |
| 140 | #define BPDSW 6 |
| 141 | #define GP32EN 5 |
| 142 | #define GP10EN 4 |
| 143 | #define P3DAT 3 |
| 144 | #define P2DAT 2 |
| 145 | #define P1DAT 1 |
| 146 | #define P0DAT 0 |
| 147 | |
| 148 | /*****************************************************************************/ |
| 149 | /************************ Functions Declarations *****************************/ |
| 150 | /*****************************************************************************/ |
| 151 |