| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC2302.h
Go to the documentation of this file.
1 /*!
2 LTC2302: 12-Bit, 1-Channel 500ksps SAR ADC with SPI Interface.
3
4 @verbatim
5
6 The LTC2302 is a single-channel 12-bit A/D converter with with serial I/O.
7 The part can be configured to operate on unipolar or bipolar modes. The
8 automatic sleep mode benefits power sensitive applications.
9
10 SPI DATA FORMAT (MSB First):
11
12 Byte #1 Byte #2
13 Data In : X OS X X UNI X X X X X X X X X X X
14 Data Out : D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
15
16 OS : ODD/Sign Bit
17 UNI : Unipolar/Bipolar Bit
18 Dx : Data Bits
19 X : Don't care
20
21 @endverbatim
22
23 http://www.linear.com/product/LTC2302
24
25 http://www.linear.com/product/LTC2302#demoboards
26
27
28 Copyright 2018(c) Analog Devices, Inc.
29
30 All rights reserved.
31
32 Redistribution and use in source and binary forms, with or without
33 modification, are permitted provided that the following conditions are met:
34 - Redistributions of source code must retain the above copyright
35 notice, this list of conditions and the following disclaimer.
36 - Redistributions in binary form must reproduce the above copyright
37 notice, this list of conditions and the following disclaimer in
38 the documentation and/or other materials provided with the
39 distribution.
40 - Neither the name of Analog Devices, Inc. nor the names of its
41 contributors may be used to endorse or promote products derived
42 from this software without specific prior written permission.
43 - The use of this software may or may not infringe the patent rights
44 of one or more patent holders. This license does not release you
45 from the requirement that you obtain separate licenses from these
46 patent holders to use this software.
47 - Use of the software either in source or binary form, must be run
48 on or directly connected to an Analog Devices Inc. component.
49
50 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
51 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
52 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
54 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
55 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
56 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
57 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
58 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
59 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60 */
61
62 /*! @file
63 @ingroup LTC2302
64 Header for LTC2302: 12-Bit, 1-Channel 500ksps SAR ADC with SPI Interface.
65 */
66
67 #ifndef LTC2302_H
68 #define LTC2302_H
69
70 //! Define the SPI CS pin
71 #ifndef LTC2302_CS
72 #define LTC2302_CS QUIKEVAL_CS
73 #endif
74
75 //! @name LTC2302 Uni/Bipolar Config bits
76 //! @{
77 // Unipolar Mode Command
78 #define LTC2302_UNIPOLAR 0xBFFF
79 // Bipolar Mode Command
80 #define LTC2302_BIPOLAR 0x0000
81 //!@}
82
83 //! Reads the ADC and returns 16-bit data
84 //! @return void
85 void LTC2302_read(uint8_t cs, //!< Chip Select Pin
86 uint16_t adc_command, //!< Channel address, config bits ORed together
87 uint16_t *adc_code //!< Returns code read from ADC (from previous conversion)
88 );
89
90 //! Calculates the LTC2302 input voltage given the data, range, and unipolar/bipolar status.
91 //! @return Floating point voltage
92 float LTC2302_code_to_voltage(uint16_t adc_code, //!< Raw ADC code
93 float vref, //!< Reference voltage
94 uint8_t uni_bipolar //!< Choice of unipolar/bipolar
95 );
96 #endif // LTC2302_H
adc_command
static uint8_t adc_command
Definition: DC2071AA.ino:111
uni_bipolar
static uint8_t uni_bipolar
Default set for unipolar mode.
Definition: DC682A.ino:121
LTC2302_code_to_voltage
float LTC2302_code_to_voltage(uint16_t adc_code, float vref, uint8_t uni_bipolar)
Calculates the LTC2302 input voltage given the data, range, and unipolar/bipolar status.
Definition: LTC2302.cpp:84
LTC2302_read
void LTC2302_read(uint8_t cs, uint16_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
Definition: LTC2302.cpp:77
vref
float vref
Definition: LTC2492_Thermocouple_Meter.ino:129
adc_code
static uint32_t adc_code
Definition: DC2071AA.ino:113