Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
LTC68031.h
Go to the documentation of this file.
1 /*!
2 LTC6803-1 Multicell Battery Monitor
3 
4 http://www.linear.com/product/LTC6803-1
5 
6 http://www.linear.com/product/LTC6803-1#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 LTC68031
47  Library Header File for LTC6803-1 Multicell Battery Monitor
48 */
49 
50 #ifndef LTC68031_H
51 #define LTC68031_H
52 
53 
54 #ifndef LTC6803_CS
55 #define LTC6803_CS QUIKEVAL_CS
56 #endif
57 
58 #define PEC_POLY 7
59 //!Initializes the SPI port
60 //! @return void
61 void LTC6803_initialize();
62 
63 //! Function to start Cell Voltage measurement
64 //! @return void
65 void LTC6803_stcvad();
66 
67 //! Function to start Temp channel voltage measurement
68 //! @return void
69 void LTC6803_sttmpad();
70 
71 //! Function that reads Cell Voltage registers
72 //! @returns This function will return a 0 if there is no PEC error and will return -1 if there is a PEC error
73 uint8_t LTC6803_rdcv(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
74  uint16_t cell_codes[][12] //!< The Function will put the parsed measured cell voltages into this array
75  );
76 
77 //! Function that reads Temp Voltage registers
78 //! @returns This function will return a 0 if there is no PEC error and will return -1 if there is a PEC error
79 int8_t LTC6803_rdtmp(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
80  uint16_t temp_codes[][3] //!< The Function will put the parsed measured Temp voltages into this array
81  );
82 
83 //! Function that writes configuration of LTC6803-1/-3
84 //! @return void
85 void LTC6803_wrcfg(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
86  uint8_t config[][6] //!< The function will write the 6803 CFGR register with data in the config array
87  );
88 
89 //! Function that reads configuration of LTC6803-1/-3
90 //! @returns This function will return a 0 if there is no PEC error and will return -1 if there is a PEC error
91 int8_t LTC6803_rdcfg(uint8_t total_ic, //!< total_ic number of LTC6803 ICs in stack
92  uint8_t r_config[][7] //!< The Function will put the read config register data into this array
93  );
94 //! Function that calculates PEC byte
95 //! @returns The calculated CRC8
96 uint8_t pec8_calc(uint8_t len, //!< the length of the data array
97  uint8_t *data //!< data array
98  );
99 
100 //! Writes an array of bytes out of the SPI port
101 //! @return void
102 void spi_write_array(uint8_t length, //!< length of the data array being written on the SPI port
103  uint8_t *data //!< the data array to be written on the SPI port
104  );
105 
106 //! Writes and read a set number of bytes using the SPI port.
107 //! @return void
108 void spi_write_read(uint8_t *TxData, //!< array of data to be written on the SPI port
109  uint8_t TXlen, //!< length of the tx_data array
110  uint8_t *rx_data, //!< array that read data will be written too.
111  uint8_t RXlen //!< number of bytes to be read from the SPI port.
112  );
113 
114 #endif
int8_t LTC6803_rdcfg(uint8_t total_ic, uint8_t r_config[][7])
Function that reads configuration of LTC6803-1/-3.
Definition: LTC68031.cpp:126
uint8_t LTC6803_rdcv(uint8_t total_ic, uint16_t cell_codes[][12])
Function that reads Cell Voltage registers.
Definition: LTC68031.cpp:246
void spi_write_array(uint8_t length, uint8_t *data)
Writes an array of bytes out of the SPI port.
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.
void LTC6803_wrcfg(uint8_t total_ic, uint8_t config[][6])
Function that writes configuration of LTC6803-1/-3.
Definition: LTC68031.cpp:90
union LT_union_int32_4bytes data
Definition: DC2094A.ino:138
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
void LTC6803_initialize()
Initializes the SPI port.
Definition: LTC68031.cpp:79
void LTC6803_stcvad()
Function to start Cell Voltage measurement.
Definition: LTC68031.cpp:174
int8_t LTC6803_rdtmp(uint8_t total_ic, uint16_t temp_codes[][3])
Function that reads Temp Voltage registers.
Definition: LTC68031.cpp:195
void LTC6803_sttmpad()
Function to start Temp channel voltage measurement.
Definition: LTC68031.cpp:184
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
uint8_t pec8_calc(uint8_t len, uint8_t *data)
Function that calculates PEC byte.
Definition: LTC68031.cpp:305