Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC4245.h
Go to the documentation of this file.
1 /*!
2 LTC4245: Hot Swap Controller with I2C Compatible Monitoring
3 
4 @verbatim
5 
6 The LTC4245 Hot Swap controller allows a board to be safely inserted and removed
7 from a live backplane. Using an external N-channel pass transistor, board supply
8 voltage and inrush current are ramped up at an adjustable rate. An I2C interface
9 and onboard ADC allow for monitoring of load current, voltage and fault status.
10 
11 I2C DATA FORMAT (MSB FIRST):
12 
13 Data Out:
14 Byte #1 Byte #2 Byte #3
15 
16 START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK C7 C6 C5 C4 C3 C2 C1 C0 SACK D7 D6 D5 D4 D3 D2 D1 D0 SACK STOP
17 
18 Data In:
19 Byte #1 Byte #2 Byte #3
20 
21 START SA6 SA5 SA4 SA3 SA2 SA1 SA0 W SACK C7 C6 C5 C4 C3 C2 C1 C0 SACK Repeat Start SA6 SA5 SA4 SA3 SA2 SA1 SA0 R SACK
22 
23 Byte #4 Byte #5
24 MSB LSB
25 D15 D14 D13 D12 D11 D10 D9 D8 MACK D7 D6 D5 D4 D3 D2 D1 D0 MNACK STOP
26 
27 START : I2C Start
28 Repeat Start: I2C Repeat Start
29 STOP : I2C Stop
30 SAx : I2C Address
31 SACK : I2C Slave Generated Acknowledge (Active Low)
32 MACK : I2C Master Generated Acknowledge (Active Low)
33 MNACK : I2C Master Generated Not Acknowledge
34 W : I2C Write (0)
35 R : I2C Read (1)
36 Cx : Command Code
37 Dx : Data Bits
38 X : Don't care
39 
40 
41 Example Code:
42 
43  float adin_lsb = (1.23/255); // ADIN Voltage Data is 8-Bit Data with 4.82mV LSB and 1.23V Full Scale
44  float adin_resisive_ratio = (155.4/12.4); // Resistor divider circuit at ADIN pin.
45  ack |= LTC4245_read(LTC4245_I2C_ADDRESS, LTC4245_ADIN_REG, &adin_code); // Read ADIN Register
46  adin_voltage = LTC4245_code_to_voltage(adin_code, adin_lsb, adin_resisive_ratio); // Calculate ADIN Voltage from ADIN Register data
47 
48 @endverbatim
49 
50 http://www.linear.com/product/LTC4245
51 
52 http://www.linear.com/product/LTC4245#demoboards
53 
54 
55 Copyright 2018(c) Analog Devices, Inc.
56 
57 All rights reserved.
58 
59 Redistribution and use in source and binary forms, with or without
60 modification, are permitted provided that the following conditions are met:
61  - Redistributions of source code must retain the above copyright
62  notice, this list of conditions and the following disclaimer.
63  - Redistributions in binary form must reproduce the above copyright
64  notice, this list of conditions and the following disclaimer in
65  the documentation and/or other materials provided with the
66  distribution.
67  - Neither the name of Analog Devices, Inc. nor the names of its
68  contributors may be used to endorse or promote products derived
69  from this software without specific prior written permission.
70  - The use of this software may or may not infringe the patent rights
71  of one or more patent holders. This license does not release you
72  from the requirement that you obtain separate licenses from these
73  patent holders to use this software.
74  - Use of the software either in source or binary form, must be run
75  on or directly connected to an Analog Devices Inc. component.
76 
77 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
78 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
79 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
80 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
81 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
82 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
83 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
84 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
85 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
86 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
87 */
88 
89 /*! @file
90  @ingroup LTC4245
91  Header for LTC4245: Hot Swap Controller with I2C Compatible Monitoring
92 */
93 
94 #ifndef LTC4245_H
95 #define LTC4245_H
96 
97 //! @name LTC4261 Address Assignment
98 //! @{
99 #define LTC4245_I2C_ADDRESS 0x20 //ADDR2 = L, ADDR1 = L, ADDR0 = L
100 #define LTC4245_I2C_ALERT_RESPONSE 0x0C
101 #define LTC4245_I2C_MASS_WRITE 0x17
102 //!@}
103 
104 //! @name LTC4245 Register addresses
105 //! @{
106 // Register Addresses
107 #define LTC4245_STATUS_REG 0x00
108 #define LTC4245_ALERT_REG 0x01
109 #define LTC4245_CONTROL_REG 0x02
110 #define LTC4245_ON_REG 0x03
111 #define LTC4245_FAULT1_REG 0x04
112 #define LTC4245_FAULT2_REG 0x05
113 #define LTC4245_GPIO_REG 0x06
114 #define LTC4245_ADCADR_REG 0x07
115 //!@}
116 
117 //! @name LTC4245 ADC Data Register addresses
118 //! @{
119 // Register Addresses
120 #define LTC4245_12VIN_REG 0x10
121 #define LTC4245_12VSENSE_REG 0x11
122 #define LTC4245_12VOUT_REG 0x12
123 #define LTC4245_5VIN_REG 0x13
124 #define LTC4245_5VSENSE_REG 0x14
125 #define LTC4245_5VOUT_REG 0x15
126 #define LTC4245_3_3VIN_REG 0x16
127 #define LTC4245_3_3VSENSE_REG 0x17
128 #define LTC4245_3_3VOUT_REG 0x18
129 #define LTC4245_VEEIN_REG 0x19
130 #define LTC4245_VEESENSE_REG 0x1A
131 #define LTC4245_VEEOUT_REG 0x1B
132 #define LTC4245_GPIOADC1_REG 0x1C
133 #define LTC4245_GPIOADC2_REG 0x1D
134 #define LTC4245_GPIOADC3_REG 0x1E
135 #define LTC4245_GPIOADC4_REG 0x1F
136 //!@}
137 
138 //! @name LTC4245 Status Register Bits
139 //! @{
140 // Alert Register Bit Positions
141 #define LTC4245_GPIO1_STATE_CHANGE_ENABLE 0x80
142 #define LTC4245_GPIO1_STATE_CHANGE_DISABLE 0x7F
143 #define LTC4245_BD_SEL_STATE_CHANGE_ENABLE 0x40
144 #define LTC4245_BD_SEL_STATE_CHANGE_DISABLE 0xBF
145 #define LTC4245_FET_SHORT_ENABLE 0x20
146 #define LTC4245_FET_SHORT_DISABLE 0xDF
147 #define LTC4245_PGI_FAULT_ENABLE 0x10
148 #define LTC4245_PGI_FAULT_DISABLE 0xEF
149 #define LTC4245_ALERT_PRESENT_ENABLE 0x08
150 #define LTC4245_ALERT_PRESENT_DISABLE 0xF7
151 #define LTC4245_POWER_BAD_ENABLE 0x04
152 #define LTC4245_POWER_BAD_DISABLE 0xFB
153 #define LTC4245_OVERCURRENT_ENABLE 0x02
154 #define LTC4245_OVERCURRENT_DISABLE 0xFD
155 #define LTC4245_UNDERVOLTAGE_ENABLE 0x01
156 #define LTC4245_UNDERVOLTAGE_DISABLE 0xFE
157 //!@}
158 
159 //! @name LTC4245 Control Register Bits
160 //! @{
161 // Control Register Bit Positions
162 #define LTC4245_ADC_FREE_RUN_DISABLE 0x80
163 #define LTC4245_ADC_FREE_RUN_ENABLE 0x7F
164 
165 #define LTC4245_SEQUENCING_ENABLE 0x40
166 #define LTC4245_SEQUENCING_DISABLE 0xBF
167 
168 #define LTC4245_MASS_WRITE_ENABLE 0x20
169 #define LTC4245_MASS_WRITE_DISABLE 0xDF
170 
171 #define LTC4245_PGI_FAULT_AUTO_RETRY_ENABLE 0x10
172 #define LTC4245_PGI_FAULT_AUTO_RETRY_DISABLE 0xEF
173 
174 #define LTC4245_PGI_DISABLE 0x08
175 #define LTC4245_PGI_ENABLE 0xF7
176 
177 #define LTC4245_OVERCURRENT_AUTO_RETRY_ENABLE 0x02
178 #define LTC4245_OVERCURRENT_AUTO_RETRY_DISABLE 0xFD
179 
180 #define LTC4245_UNDERVOLTAGE_AUTO_RETRY_ENABLE 0x01
181 #define LTC4245_UNDERVOLTAGE_AUTO_RETRY_DISABLE 0xFE
182 //!@}
183 
184 
185 
186 //! @name LTC4245 Fault Register Bits
187 //! @{
188 // Fault Register Bit Positions
189 #define LTC4245_NEG12V_OVERCURRENT_FAULT 0x80
190 #define LTC4245_3_3V_OVERCURRENT_FAULT 0x40
191 #define LTC4245_5V_OVERCURRENT_FAULT 0x20
192 #define LTC4245_12V_OVERCURRENT_FAULT 0x10
193 #define LTC4245_NEG12V_UNDERVOLTAGE_FAULT 0x08
194 #define LTC4245_3_3V_UNDERVOLTAGE_FAULT 0x04
195 #define LTC4245_5V_UNDERVOLTAGE_FAULT 0x02
196 #define LTC4245_12V_UNDERVOLTAGE_FAULT 0x01
197 
198 #define LTC4245_GPIO1_STATE_CHANGE 0x80
199 #define LTC4245_BD_SEL_STATE_CHANGE 0x40
200 #define LTC4245_FET_SHORT_FAULT 0x20
201 #define LTC4245_PGI_FAULT 0x10
202 #define LTC4245_NEG12V_POWER_BAD_FAULT 0x08
203 #define LTC4245_3_3V_POWER_BAD_FAULT 0x04
204 #define LTC4245_5V_POWER_BAD_FAULT 0x02
205 #define LTC4245_12V_POWER_BAD_FAULT 0x01
206 //!@}
207 
208 
209 
210 //! Calculates voltage from register code data
211 //! @return The function returns valtage calculated from register data
212 float LTC4245_code_to_voltage(uint8_t register_code, //! Data from registers
213  float full_scale_voltage //! Full scale voltage
214  );
215 
216 //! SMBus Alert ResponseProtocol: Sends an alert response command and releases /ALERT pin. LTC4245 responds with its address
217 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge
218 int8_t LTC4245_ARA(uint8_t alert_response_address, //!< the Alert Response Address on the I2C bus
219  uint8_t *i2c_address //!< the address of the alert source
220  );
221 
222 //! Write an 8-bit code to the LTC4245
223 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
224 int8_t LTC4245_write(uint8_t i2c_address, //! LTC4245 I2C ADDRESS
225  uint8_t command, //! Register address to be written into
226  uint8_t code //! Data to be written into the register
227  );
228 
229 
230 //! Reads an 8-bit adc_code from LTC4245
231 //! @return The function returns the state of the acknowledge bit after the I2C address write. 0=acknowledge, 1=no acknowledge.
232 int8_t LTC4245_read(uint8_t i2c_address, //! LTC4245 I2C ADDRESS
233  uint8_t command, //! Register address to read from
234  uint8_t *code //! Contents of the requested register
235  );
236 
237 #endif
int8_t LTC4245_write(uint8_t i2c_address, uint8_t command, uint8_t code)
Write an 8-bit code to the LTC4245.
Definition: LTC4245.cpp:90
uint8_t i2c_address
float LTC4245_code_to_voltage(uint8_t register_code, float full_scale_voltage)
Calculates voltage from register code data.
Definition: LTC4245.cpp:73
int8_t LTC4245_read(uint8_t i2c_address, uint8_t command, uint8_t *code)
Reads an 8-bit adc_code from LTC4245.
Definition: LTC4245.cpp:98
int8_t LTC4245_ARA(uint8_t alert_response_address, uint8_t *i2c_address)
SMBus Alert ResponseProtocol: Sends an alert response command and releases /ALERT pin...
Definition: LTC4245.cpp:82