| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC4155.h
Go to the documentation of this file.
1 /*!
2 LTC4155: Dual-Input Power Manager / 3.5A Li-Ion Battery Charger with I²C Control and USB OTG
3
4 @verbatim
5 The LTC®4155 is a 15 watt I²C controlled power manager with PowerPath™ instant-
6 on operation, high efficiency switching battery charging and USB compatibility.
7 The LTC4155 seamlessly manages power distribution from two 5V sources, such as a
8 USB port and a wall adapter, to a single-cell rechargeable Lithium-Ion/Polymer
9 battery and a system load.
10 @endverbatim
11
12 http://www.linear.com/product/LTC4155
13
14 http://www.linear.com/product/LTC4155#demoboards
15
16
17 Copyright 2018(c) Analog Devices, Inc.
18
19 All rights reserved.
20
21 Redistribution and use in source and binary forms, with or without
22 modification, are permitted provided that the following conditions are met:
23 - Redistributions of source code must retain the above copyright
24 notice, this list of conditions and the following disclaimer.
25 - Redistributions in binary form must reproduce the above copyright
26 notice, this list of conditions and the following disclaimer in
27 the documentation and/or other materials provided with the
28 distribution.
29 - Neither the name of Analog Devices, Inc. nor the names of its
30 contributors may be used to endorse or promote products derived
31 from this software without specific prior written permission.
32 - The use of this software may or may not infringe the patent rights
33 of one or more patent holders. This license does not release you
34 from the requirement that you obtain separate licenses from these
35 patent holders to use this software.
36 - Use of the software either in source or binary form, must be run
37 on or directly connected to an Analog Devices Inc. component.
38
39 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
40 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
41 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
43 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
45 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
46 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
48 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
50 Generated on: 2016-01-19
51 */
52
53
54 /*! @file
55 * @ingroup LTC4155
56 * @brief LTC4155 communication library core header file defining
57 * prototypes, data structures and constants used by LTC4155.c
58 *
59 * Functions matching the prototypes of @ref smbus_write_register and @ref
60 * smbus_read_register must be provided to this API. They will implement the
61 * SMBus read and write transactions on your hardware. If the register size of
62 * the LTC4155 is 8 bits, functions should be provided that implement SMBus
63 * read byte and write byte. If the register size of the LTC4155 is 16 bits,
64 * functions should be provided that implement SMBus read word and write word.
65 * smbus_read_register needs to store the value read from the LTC4155 into
66 * the variable data. Both functions should return 0 on success and a non-0
67 * error code on failure. The API functions will return your error codes on
68 * failure and a 0 on success.
69 */
70
71 #ifndef LTC4155_H_
72 #define LTC4155_H_
73
74 #ifdef __cplusplus
75 extern "C" {
76 #endif
77
78 #include "LTC4155_reg_defs.h"
79 #include "LTC4155_formats.h"
80 #include <stdint.h>
81 #include <stddef.h>
82
83 // Type declarations
84 /*! Hardware port information. Modify as needed for local hardware
85 requirements. Available to user supplied read and write functions. */
86 typedef struct
87 {
88 int file_descriptor; //!< Linux SMBus file handle
89 } port_configuration_t;
90 /*! Prototype of user supplied SMBus write_byte or write_word function. Should return 0 on success and a non-0 error code on failure. */
91 typedef int (*smbus_write_register)(uint8_t addr, //!< Target IC's SMBus address
92 uint8_t command_code, //!< Command code to be written to
93 uint8_t data, //!< Data to be written
94 port_configuration_t *port_configuration //!< Pointer to a user supplied port_configuration struct
95 );
96 /*! Prototype of user supplied SMBus read_byte or read_word function. Should return 0 on success and a non-0 error code on failure. */
97 typedef int (*smbus_read_register)(uint8_t addr, //!< Target IC's SMBus address
98 uint8_t command_code, //!< command code to be read from
99 uint8_t *data, //!< Pointer to data destination
100 port_configuration_t *port_configuration //!< Pointer to a user supplied port_configuration struct
101 );
102 typedef void *LTC4155;
103 /*! Information required to access hardware SMBus port */
104 typedef struct
105 {
106 uint8_t addr; //!< Target IC's SMBus address
107 smbus_read_register read_register; //!< Pointer to a user supplied smbus_read_register function
108 smbus_write_register write_register; //!< Pointer to a user supplied smbus_write_register function
109 port_configuration_t *port_configuration; //!< Pointer to a user supplied port_configuration struct
110 } LTC4155_chip_cfg_t;
111
112 // function declarations
113 /*! Returns a pointer to a LTC4155 structure used by LTC4155_write_register and LTC4155_read_register */
114 LTC4155 LTC4155_init(LTC4155_chip_cfg_t *cfg //!< Information required to access hardware SMBus port
115 );
116 /*! Function to modify a bit field within a register while preserving the unaddressed bit fields */
117 int LTC4155_write_register(LTC4155 chip_handle, //!< Struct returned by LTC4155_init
118 uint16_t registerinfo, //!< Bit field name from LTC4155_regdefs.h
119 uint8_t data //!< Data to be written
120 );
121 /*! Retrieves a bit field data into *data. Right shifts the addressed portion down to the 0 position */
122 int LTC4155_read_register(LTC4155 chip_handle, //!< Struct returned by LTC4155_init
123 uint16_t registerinfo, //!< Register name from LTC4155_regdefs.h
124 uint8_t *data //!< Pointer to the data destination
125 );
126 /*! Multiple LTC4155 use.
127 Multiple LTC4155s can be used with this API. Each one must be initialized.
128 The LTC4155_init requires some memory for each LTC4155. This memory can
129 be statically allocated by defining MAX_NUM_LTC4155_INSTANCES to the
130 number of LTC4155s required. Alternatively it can be dynamically allocated
131 by defining LTC4155_USE_MALLOC. The default is to not use malloc and
132 statically allocate one LTC4155.
133 */
134 #ifndef MAX_NUM_LTC4155_INSTANCES
135 #define MAX_NUM_LTC4155_INSTANCES 1
136 #endif
137 #ifdef __cplusplus
138 }
139 #endif
140 #endif /* LTC4155_H_ */
LTC4155_formats.h
LTC4155: Dual-Input Power Manager / 3.5A Li-Ion Battery Charger with I²C Control and USB OTG...
LTC4155_chip_cfg_t::addr
uint8_t addr
Target IC&#39;s SMBus address.
Definition: LTC4155.h:106
LTC4155
void * LTC4155
Definition: LTC4155.h:102
smbus_read_register
int(* smbus_read_register)(uint8_t addr, uint8_t command_code, uint8_t *data, port_configuration_t *port_configuration)
Prototype of user supplied SMBus read_byte or read_word function.
Definition: LTC4155.h:97
LTC4155_chip_cfg_t::read_register
smbus_read_register read_register
Pointer to a user supplied smbus_read_register function.
Definition: LTC4155.h:107
LTC4155_init
LTC4155 LTC4155_init(LTC4155_chip_cfg_t *cfg)
Returns a pointer to a LTC4155 structure used by LTC4155_write_register and LTC4155_read_register.
Definition: LTC4155.c:112
LTC4155_chip_cfg_t
Information required to access hardware SMBus port.
Definition: LTC4155.h:104
smbus_write_register
int(* smbus_write_register)(uint8_t addr, uint8_t command_code, uint8_t data, port_configuration_t *port_configuration)
Prototype of user supplied SMBus write_byte or write_word function.
Definition: LTC4155.h:91
port_configuration_t::file_descriptor
int file_descriptor
Linux SMBus file handle.
Definition: LTC4155.h:88
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
cfg
LTC4155_chip_cfg_t cfg
Definition: DC1674A.ino:79
LTC4155_chip_cfg_t::port_configuration
port_configuration_t * port_configuration
Pointer to a user supplied port_configuration struct.
Definition: LTC4155.h:109
LTC4155_reg_defs.h
LTC4155: Dual-Input Power Manager / 3.5A Li-Ion Battery Charger with I²C Control and USB OTG...
LTC4155_read_register
int LTC4155_read_register(LTC4155 chip_handle, uint16_t registerinfo, uint8_t *data)
Retrieves a bit field data into *data.
Definition: LTC4155.c:164
LTC4155_chip_cfg_t::write_register
smbus_write_register write_register
Pointer to a user supplied smbus_write_register function.
Definition: LTC4155.h:108
port_configuration_t
Hardware port information.
Definition: LTC4155.h:86
LTC4155_write_register
int LTC4155_write_register(LTC4155 chip_handle, uint16_t registerinfo, uint8_t data)
Function to modify a bit field within a register while preserving the unaddressed bit fields...
Definition: LTC4155.c:147