DC2100A  1.2.0
Bi-Directional Cell Balancer Using the LTC3300-1 and the LTC6804-2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
LTC1380.c
Go to the documentation of this file.
1 /*
2  Linear Technology DC2100A Demonstration Board.
3  Driver File for LTC1380 Single-Ended 8-Channel/Differential 4-Channel Analog Multiplexer with SMBus Interface.
4  All datasheet references in this file refer to Linear Technology document 138093f.pdf.
5 
6  @verbatim
7  The LTC1380/LTC1393 are CMOS analog multiplexers with
8  SMBus compatible digital interfaces. The LTC1380 is a
9  single-ended 8-channel multiplexer, while the LTC1393 is a
10  differential 4-channel multiplexer. The SMBus digital interface
11  requires only two wires (SCL and SDA). Both the
12  LTC1380 and the LTC1393 have four hard-wired SMBus
13  addresses, selectable with two external address pins. This
14  allows four devices, each with a unique SMBus address, to
15  coexist on one system and for four devices to be synchronized
16  with one stop bit.
17  The supply current is typically 10mA. Both digital interface
18  pins are SMBus compatible over the full operating supply
19  voltage range. The LTC1380 analog switches feature a
20  typical RON of 35W (±5V supplies), typical switch leakage of
21  20pA and guaranteed break-before-make operation. Charge
22  injection is ±1pC typical.
23  The LTC1380/LTC1393 are available in 16-lead SO and GN
24  packages. Operation is fully specified over the commercial
25  and industrial temperature ranges.
26  @endverbatim
27 
28  http://www.linear.com/product/LTC1380
29 
30  REVISION HISTORY
31  $Revision: 608 $
32  $Date: 2014-08-20 14:34:15 -0400 (Wed, 20 Aug 2014) $
33 
34  Copyright (c) 2013, Linear Technology Corp.(LTC)
35  All rights reserved.
36 
37  Redistribution and use in source and binary forms, with or without
38  modification, are permitted provided that the following conditions are met:
39 
40  1. Redistributions of source code must retain the above copyright notice, this
41  list of conditions and the following disclaimer.
42  2. Redistributions in binary form must reproduce the above copyright notice,
43  this list of conditions and the following disclaimer in the documentation
44  and/or other materials provided with the distribution.
45 
46  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
47  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
48  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
49  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
50  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
51  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
52  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
55  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 
57  The views and conclusions contained in the software and documentation are those
58  of the authors and should not be interpreted as representing official policies,
59  either expressed or implied, of Linear Technology Corp.
60 
61 */
62 
63 //! @defgroup LTC1380 LTC1380 Single-Ended 8-Channel/Differential 4-Channel Analog Multiplexer with SMBus Interface.
64 
65 /*! @file
66  @ingroup LTC1380
67  Driver File for LTC1380 Single-Ended 8-Channel/Differential 4-Channel Analog Multiplexer with SMBus Interface.
68 */
69 
70 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
71 // Includes
72 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
73 #include "Typedefs.h"
74 #include "LTC1380.h"
75 #include "LTC1380_Config.h"
76 
77 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
78 // Definitions
79 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
80 
81 // I2C address and format from datasheet page 8
82 #define LTC1380_BASE_ADDRESS 0x48
83 
84 typedef struct
85 {
86  int8 address_byte;
87  int8 command_byte;
89 
90 // command byte format from datasheet table 2
91 #define LTC1380_EN_BIT 0x08
92 #define LTC1380_CHANNEL_MASK 0x07
93 
94 // Timing characteristics from datasheet page 3
95 #define LTC1380_TON 2 // in us, max value
96 
97 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
98 // Global Data
99 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
100 
101 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
102 // Local Data
103 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
104 
105 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
106 // Local Prototypes
107 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
108 
109 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
110 // Global Functions
111 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
112 
113 // Commands an LTC1380 mux to connect one channel to its output
114 void LTC1380_Set_Channel(int8 board_num, int8 mux_num, int8 channel_num)
115 {
116  LTC1380_COMMAND_TYPE command;
117 
118  if((LTC1380_CONFIG_NUM_ICS_PER_ADDRESS <= mux_num) ||
119  (LTC1380_NUM_CHANNELS <= channel_num))
120  {
121  return;
122  }
123 
124  // Build command to control the mux
125  command.address_byte = (LTC1380_BASE_ADDRESS | mux_num) << 1;
126  command.command_byte = LTC1380_EN_BIT | channel_num;
127 
128  // Send command to control the mux
129  LTC1380_CONFIG_I2C_WRITE(board_num, &command, sizeof(command), LTC1380_BAUD_RATE);
130 
131  // Wait for the channel to connect
132  delay_us(LTC1380_TON);
133 
134  return;
135 }
136 
137 // Commands an LTC1380 mux to disconnect all channels from its output
138 void LTC1380_All_Off(int8 board_num, int8 mux_num)
139 {
140  LTC1380_COMMAND_TYPE command;
141 
142  if(LTC1380_NUM_CHANNELS <= mux_num)
143  {
144  return;
145  }
146 
147  // Build command to control the mux
148  command.address_byte = (LTC1380_BASE_ADDRESS | mux_num) << 1;
149  command.command_byte = ~LTC1380_EN_BIT;
150 
151  // Send command to control the mux
152  LTC1380_CONFIG_I2C_WRITE(board_num, &command, sizeof(command), LTC1380_BAUD_RATE);
153 
154  return;
155 }
156 
157 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
158 // Local Functions
159 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#define LTC1380_CONFIG_NUM_ICS_PER_ADDRESS
Configures the number of LTC1380 ICs at each logical address.
#define LTC1380_CONFIG_I2C_WRITE(address, data_ptr, num_bytes, baud_khz)
Configures interface through which LTC1380 driver module sends I2C bytes to an LTC1380 IC...
API Header File for LTC1380 Single-Ended 8-Channel/Differential 4-Channel Analog Multiplexer with SMB...
Driver Configuration Header File for LTC1380 Single-Ended 8-Channel/Differential 4-Channel Analog Mul...
void LTC1380_All_Off(int8 board_num, int8 mux_num)
Commands an LTC1380 mux to disconnect all channels from its output.
Definition: LTC1380.c:138
void LTC1380_Set_Channel(int8 board_num, int8 mux_num, int8 channel_num)
Commands an LTC1380 mux to connect one channel to its output.
Definition: LTC1380.c:114