Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC2642.h
Go to the documentation of this file.
1 /*!
2 LTC2642: 16-/14-/12-Bit VOUT DAC with SPI Interface
3 LTC2641: 16-/14-/12-Bit VOUT DAC with SPI Interface
4 
5 @verbatim
6 
7 The LTC2641/LTC2642 are families of 16-,14 and 12-bit unbuffered voltage output
8 DACs. These DACs operate from 2.7V to 5.5V supply and are monotonic over
9 temperature.
10 
11 They communicate via SPI interface. 16 bits of data are loaded through DIN
12 after a high-to-low transition of CS (MSB first). After 16 data bits have
13 been loaded into the serial input register, a low-to-high transition on CS
14 transfers the data to the 16-bit DAC latch, updating the DAC output.
15 
16 For the 14-bit DACs, (LTC2641-14/LTC2642-14), the MSB remains in the same
17 (left-justified) position in the input 16-bit data word. Therefore, two
18 “don’t-care” bits must be loaded after the LSB, to make up the required
19 16 data bits. Similarly, for the 12-bit family members(LTC2641-12/LTC2642-12)
20 four “don’t-care” bits must follow the LSB.
21 
22 @endverbatim
23 
24 http://www.linear.com/product/LTC2642
25 http://www.linear.com/product/LTC2641
26 
27 http://www.linear.com/product/LTC2642#demoboards
28 http://www.linear.com/product/LTC2641#demoboards
29 
30 Copyright 2018(c) Analog Devices, Inc.
31 
32 All rights reserved.
33 
34 Redistribution and use in source and binary forms, with or without
35 modification, are permitted provided that the following conditions are met:
36  - Redistributions of source code must retain the above copyright
37  notice, this list of conditions and the following disclaimer.
38  - Redistributions in binary form must reproduce the above copyright
39  notice, this list of conditions and the following disclaimer in
40  the documentation and/or other materials provided with the
41  distribution.
42  - Neither the name of Analog Devices, Inc. nor the names of its
43  contributors may be used to endorse or promote products derived
44  from this software without specific prior written permission.
45  - The use of this software may or may not infringe the patent rights
46  of one or more patent holders. This license does not release you
47  from the requirement that you obtain separate licenses from these
48  patent holders to use this software.
49  - Use of the software either in source or binary form, must be run
50  on or directly connected to an Analog Devices Inc. component.
51 
52 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
53 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
54 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
55 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
56 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
58 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
59 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
60 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62 */
63 
64 /*! @file
65  @ingroup LTC2642
66  Header for LTC2642: 16-/14-/12-Bit VOUT DAC with SPI Interface
67 */
68 
69 #ifndef LTC2642_H
70 #define LTC2642_H
71 
72 //! Define the SPI CS pin
73 #ifndef LTC2642_CS
74 #define LTC2642_CS QUIKEVAL_CS
75 #endif
76 
77 #define UNIPOLAR 1
78 #define BIPOLAR 2
79 
80 //! Writes the 16-bit data into the DAC
81 //! @return void
82 void LTC2642_write(uint8_t cs, //!< Chip Select Pin
83  uint16_t data //!< 16-bit digital input data
84  );
85 //! Calculates the output voltage from the given digital code and reference voltage
86 //! @return Floating point voltage
87 float LTC2642_code_to_voltage(uint16_t data, //!< 16-bit digital input data
88  float reference_voltage, //!< Reference voltage
89  uint8_t range //!< Unipolar/Bipolar
90  );
91 //! Calculates the 16 bit data code from voltage
92 //! @return 16-bit code
93 uint16_t LTC2642_voltage_to_code(float voltage, //!< Analog voltage to be converted into code
94  float reference_voltage, //!< Reference Voltage
95  uint8_t range //!< Unipolar/Bipolar
96  );
97 #endif //LTC2642_H
float LTC2642_code_to_voltage(uint16_t data, float reference_voltage, uint8_t range)
Calculates the output voltage from the given digital code and reference voltage.
Definition: LTC2642.cpp:107
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
static uint8_t range
Definition: DC1096B.ino:111
void LTC2642_write(uint8_t cs, uint16_t data)
Writes the 16-bit data into the DAC.
Definition: LTC2642.cpp:85
static float reference_voltage
The reference voltage range, set to 5v through JP2 and JP3 by default.
uint16_t LTC2642_voltage_to_code(float voltage, float reference_voltage, uint8_t range)
Calculates the 16 bit data code from voltage.
Definition: LTC2642.cpp:92
static float voltage
Definition: DC2289AA.ino:71