Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC4215.cpp
Go to the documentation of this file.
1 /*!
2 LTC4215: Hot Swap Controller with I2C Compatible Monitoring
3 
4 @verbatim
5 
6 The LTC4215 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 @endverbatim
12 
13 http://www.linear.com/product/LTC4215
14 
15 http://www.linear.com/product/LTC4215#demoboards
16 
17 
18 Copyright 2018(c) Analog Devices, Inc.
19 
20 All rights reserved.
21 
22 Redistribution and use in source and binary forms, with or without
23 modification, are permitted provided that the following conditions are met:
24  - Redistributions of source code must retain the above copyright
25  notice, this list of conditions and the following disclaimer.
26  - Redistributions in binary form must reproduce the above copyright
27  notice, this list of conditions and the following disclaimer in
28  the documentation and/or other materials provided with the
29  distribution.
30  - Neither the name of Analog Devices, Inc. nor the names of its
31  contributors may be used to endorse or promote products derived
32  from this software without specific prior written permission.
33  - The use of this software may or may not infringe the patent rights
34  of one or more patent holders. This license does not release you
35  from the requirement that you obtain separate licenses from these
36  patent holders to use this software.
37  - Use of the software either in source or binary form, must be run
38  on or directly connected to an Analog Devices Inc. component.
39 
40 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
41 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
42 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
43 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
44 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
46 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
47 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 */
51 
52 //! @ingroup Hot_Swap
53 //! @{
54 //! @defgroup LTC4215 LTC4215: Hot Swap Controller with I2C Compatible Monitoring
55 //! @}
56 
57 /*! @file
58  @ingroup LTC4215
59  Library for LTC4215 Hot Swap Controller with I2C Compatible Monitoring
60 */
61 #include <Arduino.h>
62 #include <stdint.h>
63 #include "LT_I2C.h"
64 #include "LT_SPI.h"
65 #include "UserInterface.h"
66 #include "QuikEval_EEPROM.h"
67 #include <Wire.h>
68 #include <SPI.h>
69 #include "LTC4215.h"
70 
71 // Calculates voltage from register code data
72 float LTC4215_code_to_voltage(uint8_t register_code, float LSB, float resistor_divider_ratio)
73 {
74  float voltage;
75  voltage = (float)register_code * LSB; //! 1) Calculate voltage from code and ADIN lsb
76  return(voltage * resistor_divider_ratio);
77 }
78 
79 
80 // SMBus Alert ResponseProtocol: Sends an alert response command and releases /ALERT pin. LTC4215 responds with its address
81 int8_t LTC4215_ARA(uint8_t alert_response_address, uint8_t *i2c_address)
82 {
83  int8_t ack;
84  ack = i2c_read_byte(alert_response_address, i2c_address);
85  return ack;
86 }
87 
88 // Write an 8-bit code to the LTC4215
89 int8_t LTC4215_write(uint8_t i2c_address, uint8_t command, uint8_t code)
90 {
91  int8_t ack;
92  ack = i2c_write_byte_data(i2c_address,command,code);
93  return ack;
94 }
95 
96 // Reads an 8-bit adc_code from LTC4215
97 int8_t LTC4215_read(uint8_t i2c_address, uint8_t command, uint8_t *code)
98 {
99  int8_t ack;
100  ack = i2c_read_byte_data(i2c_address,command,code);
101  return ack;
102 }
uint8_t i2c_address
int8_t i2c_read_byte_data(uint8_t address, uint8_t command, uint8_t *value)
Read a byte of data at register specified by "command", store in "value".
Definition: LT_I2C.cpp:124
int8_t LTC4215_write(uint8_t i2c_address, uint8_t command, uint8_t code)
Write an 8-bit code to the LTC4215.
Definition: LTC4215.cpp:89
float LTC4215_code_to_voltage(uint8_t register_code, float LSB, float resistor_divider_ratio)
Calculates voltage from register code data.
Definition: LTC4215.cpp:72
int8_t i2c_write_byte_data(uint8_t address, uint8_t command, uint8_t value)
Write a byte of data to register specified by "command".
Definition: LT_I2C.cpp:155
QuikEval EEPROM Library.
#define LSB
Location of Least Signficant Byte when Word is accessed as Byte Array.
Definition: Linduino.h:90
LT_SPI: Routines to communicate with ATmega328P&#39;s hardware SPI port.
int8_t LTC4215_ARA(uint8_t alert_response_address, uint8_t *i2c_address)
SMBus Alert ResponseProtocol: Sends an alert response command and releases /ALERT pin...
Definition: LTC4215.cpp:81
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.
int8_t LTC4215_read(uint8_t i2c_address, uint8_t command, uint8_t *code)
Reads an 8-bit adc_code from LTC4215.
Definition: LTC4215.cpp:97
static float voltage
Definition: DC2289AA.ino:71
LTC4215: Hot Swap Controller with I2C Compatible Monitoring.
int8_t i2c_read_byte(uint8_t address, uint8_t *value)
Read a byte, store in "value".
Definition: LT_I2C.cpp:93