| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

LTC68032.h
Go to the documentation of this file.
1 /*!
2 LTC6803-2 Multicell Battery Monitor
3
4 http://www.linear.com/product/LTC6803-2
5
6 http://www.linear.com/product/LTC6803-2#demoboards
7
8
9 Copyright 2018(c) Analog Devices, Inc.
10
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 - Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 - Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in
19 the documentation and/or other materials provided with the
20 distribution.
21 - Neither the name of Analog Devices, Inc. nor the names of its
22 contributors may be used to endorse or promote products derived
23 from this software without specific prior written permission.
24 - The use of this software may or may not infringe the patent rights
25 of one or more patent holders. This license does not release you
26 from the requirement that you obtain separate licenses from these
27 patent holders to use this software.
28 - Use of the software either in source or binary form, must be run
29 on or directly connected to an Analog Devices Inc. component.
30
31 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
32 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
33 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
34 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
35 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
37 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
42 Copyright 2015 Linear Technology Corp. (LTC)
43 */
44
45 /*! @file
46 @ingroup LTC68032
47 Library Header File for LTC6803-2 Multicell Battery Monitor
48 */
49
50 #ifndef LTC68032_H
51 #define LTC68032_H
52
53
54 #ifndef LTC6803_CS
55 #define LTC6803_CS QUIKEVAL_CS
56 #endif
57
58 #define PEC_POLY 7
59
60 //!Initializes the SPI port
61 //! @return void
62 void LTC6803_initialize();
63
64 //! Function to start Cell Voltage measurement
65 //! @return void
66 void LTC6803_stcvad();
67
68 //! Function to start Temp channel voltage measurement
69 //! @return void
70 void LTC6803_sttmpad();
71
72 //! Function that reads Cell Voltage registers
73 //! @returns This function will return a 0 if there is no PEC error and will return -1 if there is a PEC error
74 uint8_t LTC6803_rdcv(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
75 uint16_t cell_codes[][12] //!< The Function will put the parsed measured cell voltages into this array
76 );
77
78 //! Function that reads Temp Voltage registers
79 //! @returns This function will return a 0 if there is no PEC error and will return -1 if there is a PEC error
80 int8_t LTC6803_rdtmp(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
81 uint16_t temp_codes[][3] //!< The Function will put the parsed measured Temp voltages into this array
82 );
83
84 //! Function that writes configuration of LTC6803-2/-4
85 //! @return void
86 void LTC6803_wrcfg(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
87 uint8_t config[][6] //!< The function will write the 6803 CFGR register with data in the config array
88 );
89
90 //! Function that reads configuration of LTC6803-2/-4
91 //! @returns This function will return a 0 if there is no PEC error and will return -1 if there is a PEC error
92 int8_t LTC6803_rdcfg(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
93 uint8_t r_config[][7] //!< The Function will put the read config register data into this array
94 );
95 //! Function that calculates PEC byte
96 //! @returns The calculated CRC8
97 uint8_t pec8_calc(uint8_t len, //!< the length of the data array
98 uint8_t *data //!< data array
99 );
100
101 //! Writes an array of bytes out of the SPI port
102 //! @return void
103 void spi_write_array(uint8_t length, //!< length of the data array being written on the SPI port
104 uint8_t *data //!< the data array to be written on the SPI port
105 );
106
107 //! Writes and read a set number of bytes using the SPI port.
108 //! @return void
109 void spi_write_read(uint8_t *TxData, //!< array of data to be written on the SPI port
110 uint8_t TXlen, //!< length of the tx_data array
111 uint8_t *rx_data, //!< array that read data will be written too.
112 uint8_t RXlen //!< number of bytes to be read from the SPI port.
113 );
114
115 #endif
LTC6803_rdcv
uint8_t LTC6803_rdcv(uint8_t total_ic, uint16_t cell_codes[][12])
Function that reads Cell Voltage registers.
Definition: LTC68031.cpp:246
LTC6803_wrcfg
void LTC6803_wrcfg(uint8_t total_ic, uint8_t config[][6])
Function that writes configuration of LTC6803-2/-4.
Definition: LTC68031.cpp:90
LTC6803_initialize
void LTC6803_initialize()
Initializes the SPI port.
Definition: LTC68031.cpp:79
spi_write_read
void spi_write_read(uint8_t *TxData, uint8_t TXlen, uint8_t *rx_data, uint8_t RXlen)
Writes and read a set number of bytes using the SPI port.
data
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
temp_codes
static uint16_t temp_codes[TOTAL_IC][3]
The Temp codes will be stored in the temp_codes[][3] array in the following format: ...
Definition: DC1651A.ino:117
spi_write_array
void spi_write_array(uint8_t length, uint8_t *data)
Writes an array of bytes out of the SPI port.
LTC6803_sttmpad
void LTC6803_sttmpad()
Function to start Temp channel voltage measurement.
Definition: LTC68031.cpp:184
LTC6803_stcvad
void LTC6803_stcvad()
Function to start Cell Voltage measurement.
Definition: LTC68031.cpp:174
LTC6803_rdcfg
int8_t LTC6803_rdcfg(uint8_t total_ic, uint8_t r_config[][7])
Function that reads configuration of LTC6803-2/-4.
Definition: LTC68031.cpp:126
LTC6803_rdtmp
int8_t LTC6803_rdtmp(uint8_t total_ic, uint16_t temp_codes[][3])
Function that reads Temp Voltage registers.
Definition: LTC68031.cpp:195
cell_codes
static uint16_t cell_codes[TOTAL_IC][12]
The cell codes will be stored in the cell_codes[][12] array in the following format: ...
Definition: DC1651A.ino:108
pec8_calc
uint8_t pec8_calc(uint8_t len, uint8_t *data)
Function that calculates PEC byte.
Definition: LTC68031.cpp:305