Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTM2893.h
Go to the documentation of this file.
1 /*!
2 LTM2893-1: 100MHz ADC SPI Isolator
3 
4 @verbatim
5 
6 Example Code:
7 
8 Read ADC input.
9 
10  LTM2893_read(LTM2893_CS, &adc_code); // Throws out last reading
11  LTM2893_read(LTM2893_CS, &adc_code); // Obtains the current reading and stores to adc_code variable
12 
13  // Convert adc_code to voltage
14  adc_voltage = LTM2893_code_to_voltage(adc_code, vref);
15 
16 @endverbatim
17 
18 http://www.linear.com/product/LTM2893
19 
20 http://www.linear.com/product/LTM2893#demoboards
21 
22 
23 Copyright 2018(c) Analog Devices, Inc.
24 
25 All rights reserved.
26 
27 Redistribution and use in source and binary forms, with or without
28 modification, are permitted provided that the following conditions are met:
29  - Redistributions of source code must retain the above copyright
30  notice, this list of conditions and the following disclaimer.
31  - Redistributions in binary form must reproduce the above copyright
32  notice, this list of conditions and the following disclaimer in
33  the documentation and/or other materials provided with the
34  distribution.
35  - Neither the name of Analog Devices, Inc. nor the names of its
36  contributors may be used to endorse or promote products derived
37  from this software without specific prior written permission.
38  - The use of this software may or may not infringe the patent rights
39  of one or more patent holders. This license does not release you
40  from the requirement that you obtain separate licenses from these
41  patent holders to use this software.
42  - Use of the software either in source or binary form, must be run
43  on or directly connected to an Analog Devices Inc. component.
44 
45 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
46 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
47 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
49 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
50 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
51 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56 
57 /*! @file
58  @ingroup LTM2893
59  Header for LTM2893: Interface LTC2328 16/18-bit 1Msps ADC
60 */
61 
62 #ifndef LTM2893_H
63 #define LTM2893_H
64 
65 #include <SPI.h>
66 
67 //! Define the SPI CS pin
68 #ifndef LTM2893_CS
69 #define LTM2893_CS QUIKEVAL_CS
70 #endif
71 
72 #define LTM2893_CSC_PIN QUIKEVAL_GPIO
73 
74 //! @name LTM2893 Channel Address
75 //! @{
76 // Channel Address
77 //#define LTM2893_ADDRESS 0x00
78 //!@}
79 
80 // UserConfig 0 Register
81 #define LTM2893_UC0_SA_DIR_ISO2LOGIC (1 << 0)
82 #define LTM2893_UC0_SB_DIR_ISO2LOGIC (1 << 1)
83 #define LTM2893_UC0_SC_DIR_ISO2LOGIC (1 << 2)
84 #define LTM2893_UC0_CRC (1 << 3)
85 //- OSCDIV
86 #define LTM2893_UC0_OSCDIV_100 (0 << 4)
87 #define LTM2893_UC0_OSCDIV_66 (1 << 4)
88 #define LTM2893_UC0_OSCDIV_50 (2 << 4)
89 #define LTM2893_UC0_OSCDIV_40 (3 << 4)
90 #define LTM2893_UC0_OSCDIV_33 (4 << 4)
91 #define LTM2893_UC0_OSCDIV_25 (5 << 4)
92 #define LTM2893_UC0_OSCDIV_12 (6 << 4)
93 #define LTM2893_UC0_OSCDIV_6 (7 << 4)
94 
95 // UserConfig 1 Register
96 //- OSCDIV
97 #define LTM2893_UC1_WORDL_8 ((0 << 0) | (1 << 7))
98 #define LTM2893_UC1_WORDL_12 ((1 << 0) | (1 << 7))
99 #define LTM2893_UC1_WORDL_14 ((2 << 0) | (1 << 7))
100 #define LTM2893_UC1_WORDL_16 ((3 << 0) | (1 << 7))
101 #define LTM2893_UC1_WORDL_18 ((4 << 0) | (1 << 7))
102 #define LTM2893_UC1_WORDL_20 ((5 << 0) | (1 << 7))
103 #define LTM2893_UC1_WORDL_24 ((6 << 0) | (1 << 7))
104 #define LTM2893_UC1_WORDL_32 ((7 << 0) | (1 << 7))
105 //- DEVCNT
106 #define LTM2893_UC1_DEVCNT_1 ((0 << 3) | (1 << 7))
107 #define LTM2893_UC1_DEVCNT_2 ((1 << 3) | (1 << 7))
108 #define LTM2893_UC1_DEVCNT_3 ((2 << 3) | (1 << 7))
109 #define LTM2893_UC1_DEVCNT_4 ((3 << 3) | (1 << 7))
110 
111 //! Reads the LTM2893 and returns 32-bit data in 2's complement format
112 //! @return void
113 void LTM2893_read(uint8_t cs, //!< Chip Select Pin
114  int32_t *ptr_adc_code //!< Returns code read from ADC (from previous conversion)
115  );
116 
117 
118 //! Calculates the LTM2893 input voltage given the binary data and lsb weight.
119 //! @return Floating point voltage
120 float LTM2893_code_to_voltage(int32_t adc_code, //!< Raw ADC code
121  float vref //!< Reference voltage
122  );
123 
124 void LTM2893_config(uint8_t user_config);
125 
126 #endif // LTM2893_H
127 
128 
void LTM2893_read(uint8_t cs, int32_t *ptr_adc_code)
Reads the LTM2893 and returns 32-bit data in 2&#39;s complement format.
Definition: LTM2893.cpp:67
void LTM2893_config(uint8_t user_config)
Definition: LTM2893.cpp:87
float LTM2893_code_to_voltage(int32_t adc_code, float vref)
Calculates the LTM2893 input voltage given the binary data and lsb weight.
Definition: LTM2893.cpp:112
static uint32_t adc_code
Definition: DC2071AA.ino:113