Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC3335_Config.h
Go to the documentation of this file.
1 /*!
2 LTC3335: Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter
3 
4 This header file contains the definitions that allow configuration
5 of the LTC3335 driver. The definitions belong to two groups:
6 
7  1. The first set of definitions configure the driver for the
8  IPEAK, VOUT, and battery capacity for the application. Advanced
9  features such as a battery current measurement and software correction
10  can also be enabled.
11 
12  2. The LTC3335 driver was written so that no hardware references are made
13  in the .cpp file. Instead, this file records what links to hardware
14  functions must be defined for the LTC3335 driver to operate. Change
15  these definitions to configure the LTC3335.c driver for a microprocessor
16  other than the Linduino.
17 
18 @verbatim
19 The LTC®3335 is a high efficiency, low quiescent current
20 (680nA) buck-boost DC/DC converter with an integrated
21 precision coulomb counter which monitors accumulated
22 battery discharge in long life battery powered applications.
23 The buck-boost can operate down to 1.8V on its input and
24 provides eight pin-selectable output voltages with up to
25 50mA of output current.
26 
27 The coulomb counter stores the accumulated battery discharge
28 in an internal register accessible via an I2C interface.
29 The LTC3335 features a programmable discharge alarm
30 threshold. When the threshold is reached, an interrupt is
31 generated at the IRQ pin.
32 
33 To accommodate a wide range of battery types and sizes,
34 the peak input current can be selected from as low as 5mA
35 to as high as 250mA and the full-scale coulomb counter
36 has a programmable range of 32,768:1.
37 
38 @endverbatim
39 
40 http://www.linear.com/product/LTC3335
41 
42 http://www.linear.com/product/LTC3335#demoboards
43 
44 
45 Copyright 2018(c) Analog Devices, Inc.
46 
47 All rights reserved.
48 
49 Redistribution and use in source and binary forms, with or without
50 modification, are permitted provided that the following conditions are met:
51  - Redistributions of source code must retain the above copyright
52  notice, this list of conditions and the following disclaimer.
53  - Redistributions in binary form must reproduce the above copyright
54  notice, this list of conditions and the following disclaimer in
55  the documentation and/or other materials provided with the
56  distribution.
57  - Neither the name of Analog Devices, Inc. nor the names of its
58  contributors may be used to endorse or promote products derived
59  from this software without specific prior written permission.
60  - The use of this software may or may not infringe the patent rights
61  of one or more patent holders. This license does not release you
62  from the requirement that you obtain separate licenses from these
63  patent holders to use this software.
64  - Use of the software either in source or binary form, must be run
65  on or directly connected to an Analog Devices Inc. component.
66 
67 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
68 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
69 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
70 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
71 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
72 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
73 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
74 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
75 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
76 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77 */
78 
79 /*! @file
80  @ingroup LTC3335
81  Configuration Header File for LTC3335: Nanopower Buck-Boost DC/DC with Integrated Coulomb Counter
82 */
83 
84 #ifndef LTC3335_CONFIG_H
85 #define LTC3335_CONFIG_H
86 
87 #include <Arduino.h> // provides boolean type.
88 #include "Linduino.h" // provides common macros.
89 #include "LT_I2C.h" // provides interface to i2c.
90 
91 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
92 // Configuration definitions for the LTC3335.c driver.
93 // Define this to specify the LTC3335 configuration, battery characteristics, and advanced features to be used.
94 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
95 #define LTC3335_IPEAK_CONFIGURATION LTC3335_IPEAK_CONFIGURATION_100MA //!< IPEAK setting from LTC3335_IPEAK_CONFIGURATION_TYPE in LTC3335.h
96 #define LTC3335_OUTPUT_VOLTAGE LTC3335_OUTPUT_VOLTAGE_3_3V //!< VOUT setting from LTC3335_NUM_OUTPUT_VOLTAGES in LTC3335.h
97 #define LTC3335_CAPACITY (2400) //!< in mAh, capacity of the battery
98 #define LTC3335_ALARM_CAPACITY 0.9*LTC3335_CAPACITY //!< in mAh, the capacity at which the alarm should be activated.
99 
100 #define LTC3335_USE_CURRENT_MEASUREMENT true //!< Set to true to use the /IRQ pin to measure the battery current real time.
101 
102 #define LTC3335_USE_SOFTWARE_CORRECTION false //!< Set to true to use software correction of coulomb count and current measurement.
103 #define LTC3335_VBAT_TYP 3600 //!< in mV, the nominal battery voltage expected for the majority of the battery discharge.
104 #define LTC3335_CORRECTION_FACTOR_TYP -487 //!< Value of LTC3335_Software_Correction_Table[VBAT_TO_TABLE_INDEX(LTC3335_VBAT_TYP)].
105 //!< Arduino compiler is not smart enough to lookup the value in the const table when
106 //!< optimizing and makes a lot of runtime code if you don't #define the value manually.
107 
108 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
109 // Hardware definitions for the LTC3335.c driver.
110 // Change these definitions to configure the LTC3335.c driver for a microprocessor other than the Linduino.
111 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
112 
113 //! @name Input Read Definitions
114 //! @{
115 //! Macros to read LTC3335 Inputs, defined to interface to the Arduino.
116 #define LTC3335_PGOOD_READ() digitalRead(2)
117 #define LTC3335_NIRQ_READ() digitalRead(5)
118 //! @}
119 
120 //! @name Timing Definitions
121 //! @{
122 //! Macro to get timing data from microprocessor, defined to interface to the Arduino function which uses ATMega328P Timer0.
123 //! The timer resolution is specified in timer counts per sec.
124 #define LTC3335_TIMER_GET() micros()
125 #define LTC3335_TIMER_COUNTS_PER_SEC 1000000
126 //! @}
127 
128 //! @name Counter Definitions
129 //! @{
130 //! Macro to get hardware counter data from microprocess, defined to interface to function in ATmega_Counter.h which uses ATMega328P Timer1.
131 //! The number of bits of the hardware timer is specified in number of bits.
132 #define LTC3335_COUNTER_GET() TCNT1
133 #define LTC3335_COUNTER_SIZE 16
134 //! @}
135 
136 //! @name Hardware Initialization
137 //! @{
138 //! Macro to init micro hardware that is used by LTC3335 driver.
139 #define LTC3335_MICRO_INIT() { \
140  /* Setup GPIO used by LTC3335 */ \
141  pinMode(2, INPUT); \
142  pinMode(5, INPUT); \
143  /* Setup ATMega counter counter according to Atmel datasheet 8271G, section 16.11. */ \
144  /* Turn off output compare functions for counter. */ \
145  TCCR1A = 0; \
146  /* Configure to count rising edges on T1 pin. */ \
147  TCCR1B = (1<<CS10) + (1<<CS11) + (1<<CS12); \
148  /* Start with counter cleared.*/ \
149  TCNT1 = 0; \
150  /* Enable I2C module.*/ \
151  i2c_enable(); \
152  }
153 //! @}
154 
155 #endif // LTC3335_CONFIG_H
156 
157 
158 
Header File for Linduino Libraries and Demo Code.
LT_I2C: Routines to communicate with ATmega328P&#39;s hardware I2C port.