foxBMS - Unit Tests  1.1.0
The foxBMS Unit Tests API Documentation
ltc.h
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file ltc.h
44  * @author foxBMS Team
45  * @date 2015-09-01 (date of creation)
46  * @updated 2015-09-01 (date of last update)
47  * @ingroup DRIVERS
48  * @prefix LTC
49  *
50  * @brief Headers for the driver for the LTC monitoring chip.
51  *
52  */
53 
54 #ifndef FOXBMS__LTC_H_
55 #define FOXBMS__LTC_H_
56 
57 /*========== Includes =======================================================*/
58 #include "ltc_defs.h"
59 
60 /*========== Macros and Definitions =========================================*/
61 
62 /*========== Extern Constant and Variable Declarations ======================*/
63 
64 /**
65  * This variable contains the internal state of the LTC state machine.
66  */
68 
69 /*========== Extern Function Prototypes =====================================*/
70 
71 /**
72  * @brief trigger function for the LTC driver state machine.
73  *
74  * This function contains the sequence of events in the LTC state machine.
75  * It must be called time-triggered, every 1ms.
76  */
77 extern void LTC_Trigger(LTC_STATE_s *ltc_state);
78 
79 /**
80  * @brief sets the current state request of the state variable ltc_state.
81  *
82  * This function is used to make a state request to the state machine,e.g, start voltage measurement,
83  * read result of voltage measurement, re-initialization
84  * It calls LTC_CheckStateRequest() to check if the request is valid.
85  * The state request is rejected if is not valid.
86  * The result of the check is returned immediately, so that the requester can act in case
87  * it made a non-valid state request.
88  *
89  * @param ltc_state state of the ltc state machine
90  * @param statereq state request to set
91  *
92  * @return current state request, taken from LTC_STATE_REQUEST_e
93  */
95 
96 /**
97  * @brief gets the measurement initialization status.
98  *
99  * @param ltc_state state of the ltc state machine
100  *
101  * @return true if a first measurement cycle was made, false otherwise
102  *
103  */
104 extern bool LTC_IsFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state);
105 
106 /**
107  * @brief stores the measured voltages in the database.
108  *
109  * This function loops through the data of all modules in the LTC daisy-chain that are
110  * stored in the LTC_CellVoltages buffer and writes them in the database.
111  * At each write iteration, the variable named "state" and related to voltages in the
112  * database is incremented.
113  *
114  * @param ltc_state state of the ltc state machine
115  *
116  * @param stringNumber string addressed
117  *
118  */
119 extern void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber);
120 
121 /**
122  * @brief stores the measured temperatures and the measured multiplexer feedbacks in the database.
123  *
124  * This function loops through the temperature and multiplexer feedback data of all modules
125  * in the LTC daisy-chain that are stored in the LTC_MultiplexerVoltages buffer and writes
126  * them in the database.
127  * At each write iteration, the variables named "state" and related to temperatures and multiplexer feedbacks
128  * in the database are incremented.
129  *
130  * @param ltc_state state of the ltc state machine
131  * @param stringNumber string addressed
132  *
133  */
134 extern void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber);
135 
136 /**
137  * @brief stores the measured GPIOs in the database.
138  *
139  * This function loops through the data of all modules in the LTC daisy-chain that are
140  * stored in the ltc_allgpiovoltage buffer and writes them in the database.
141  * At each write iteration, the variable named "state" and related to voltages in the
142  * database is incremented.
143  *
144  * @param ltc_state: state of the ltc state machine
145  *
146  */
147 extern void LTC_SaveAllGPIOMeasurement(LTC_STATE_s *ltc_state);
148 
149 /**
150  * @brief gets the current state request.
151  *
152  * This function is used in the functioning of the LTC state machine.
153  *
154  * @param ltc_state: state of the ltc state machine
155  *
156  * @return retval current state request, taken from LTC_STATE_REQUEST_e
157  */
159 
160 /**
161  * @brief gets the current state.
162  *
163  * This function is used in the functioning of the LTC state machine.
164  *
165  * @param ltc_state: state of the ltc state machine
166  *
167  * @return current state, taken from LTC_STATEMACH_e
168  */
169 extern LTC_STATEMACH_e LTC_GetState(LTC_STATE_s *ltc_state);
170 
171 /**
172  * @brief Sets the transceiver pins to enable LTC6820 IC.
173  *
174  */
175 extern void LTC_monitoringPinInit(void);
176 
177 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
178 #ifdef UNITY_UNIT_TEST
179 extern uint8_t TEST_LTC_CheckReEntrance();
181 
182 /** this define is used for creating the declaration of a function for variable extraction
183  * deviate from style guide in order to make the variable name better recognizable
184  */
185 #define TEST_LTC_DECLARE_GET(VARIABLE) extern void TEST_LTC_Get_##VARIABLE(uint8_t data[4])
237 #endif
238 
239 #endif /* FOXBMS__LTC_H_ */
#define TEST_LTC_DECLARE_GET(VARIABLE)
Definition: ltc.h:185
LTC_STATEMACH_e LTC_GetState(LTC_STATE_s *ltc_state)
gets the current state.
Definition: ltc_6806.c:572
bool LTC_IsFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state)
gets the measurement initialization status.
Definition: ltc_6806.c:1733
void LTC_SaveAllGPIOMeasurement(LTC_STATE_s *ltc_state)
stores the measured GPIOs in the database.
Definition: ltc_6806.c:511
LTC_RETURN_TYPE_e LTC_SetStateRequest(LTC_STATE_s *ltc_state, LTC_REQUEST_s statereq)
sets the current state request of the state variable ltc_state.
Definition: ltc_6806.c:610
void LTC_SaveTemperatures(LTC_STATE_s *ltc_state, uint8_t stringNumber)
stores the measured temperatures and the measured multiplexer feedbacks in the database.
Definition: ltc_6806.c:463
LTC_REQUEST_s LTC_GetStateRequest(LTC_STATE_s *ltc_state)
gets the current state request.
Definition: ltc_6806.c:552
void LTC_SaveVoltages(LTC_STATE_s *ltc_state, uint8_t stringNumber)
stores the measured voltages in the database.
Definition: ltc_6806.c:402
LTC_STATE_s ltc_stateBase
Definition: ltc_6806.c:147
void LTC_Trigger(LTC_STATE_s *ltc_state)
trigger function for the LTC driver state machine.
Definition: ltc_6806.c:625
void LTC_monitoringPinInit(void)
Sets the transceiver pins to enable LTC6820 IC.
Definition: ltc_6806.c:1752
void TEST_LTC_SetFirstMeasurementCycleFinished(LTC_STATE_s *ltc_state)
Definition: ltc_6806.c:1776
uint8_t TEST_LTC_CheckReEntrance()
static uint16_t ltc_cmdRDCVI_Fuelcell[4]
Definition: ltc_6806.c:210
static uint16_t ltc_cmdRDCVA_Fuelcell[4]
Definition: ltc_6806.c:202
static uint16_t ltc_cmdRDCVD_Fuelcell[4]
Definition: ltc_6806.c:205
static uint16_t ltc_cmdRDCVG_Fuelcell[4]
Definition: ltc_6806.c:208
static uint16_t ltc_cmdRDCVH_Fuelcell[4]
Definition: ltc_6806.c:209
static uint16_t ltc_cmdRDCVE_Fuelcell[4]
Definition: ltc_6806.c:206
static uint16_t ltc_cmdRDCFG[4]
Definition: ltc_6806.c:195
static uint16_t ltc_cmdRDCVF_Fuelcell[4]
Definition: ltc_6806.c:207
static uint16_t ltc_cmdRDCVB_Fuelcell[4]
Definition: ltc_6806.c:203
static uint16_t ltc_BC_cmdADOW_PDOWN_100ms_fuelcell[4]
Definition: ltc_6806.c:241
static uint16_t ltc_cmdWRCFG[4]
Definition: ltc_6806.c:194
static uint16_t ltc_BC_cmdADOW_PUP_100ms_fuelcell[4]
Definition: ltc_6806.c:239
static uint16_t ltc_cmdRDCVC_Fuelcell[4]
Definition: ltc_6806.c:204
static uint16_t ltc_cmdADCV_normal_Fuelcell[4]
Definition: ltc_6806.c:215
static uint16_t ltc_cmdADAX_fast_GPIO3[4]
Definition: ltc_6813-1.c:261
static uint16_t ltc_cmdRDCVC[4]
Definition: ltc_6813-1.c:205
static uint16_t ltc_cmdRDAUXB[4]
Definition: ltc_6813-1.c:213
static uint16_t ltc_cmdRDCVA[4]
Definition: ltc_6813-1.c:203
static uint16_t ltc_cmdWRCOMM[4]
Definition: ltc_6813-1.c:209
static uint16_t ltc_cmdADAX_normal_GPIO1[4]
Definition: ltc_6813-1.c:253
static uint16_t ltc_cmdRDAUXA[4]
Definition: ltc_6813-1.c:212
static uint16_t ltc_cmdRDCVB[4]
Definition: ltc_6813-1.c:204
static uint16_t ltc_cmdADCV_fast_DCP1[4]
Definition: ltc_6813-1.c:247
static uint16_t ltc_cmdWRCFG2[4]
Definition: ltc_6813-1.c:200
static uint16_t ltc_cmdRDAUXC[4]
Definition: ltc_6813-1.c:214
static uint16_t ltc_cmdADAX_fast_GPIO2[4]
Definition: ltc_6813-1.c:258
static uint16_t ltc_cmdADAX_normal_ALLGPIOS[4]
Definition: ltc_6813-1.c:268
static uint16_t ltc_cmdADAX_filtered_GPIO3[4]
Definition: ltc_6813-1.c:260
static uint16_t ltc_cmdADAX_filtered_GPIO2[4]
Definition: ltc_6813-1.c:257
static uint16_t ltc_cmdRDCVD[4]
Definition: ltc_6813-1.c:206
static uint16_t ltc_cmdADAX_fast_ALLGPIOS[4]
Definition: ltc_6813-1.c:271
static uint16_t ltc_cmdADAX_normal_GPIO2[4]
Definition: ltc_6813-1.c:256
static uint16_t ltc_BC_cmdADOW_PDOWN_filtered_DCP0[4]
Definition: ltc_6813-1.c:289
static uint16_t ltc_cmdADAX_filtered_ALLGPIOS[4]
Definition: ltc_6813-1.c:269
static uint16_t ltc_cmdADCV_fast_DCP0[4]
Definition: ltc_6813-1.c:245
static uint16_t ltc_cmdADCV_filtered_DCP0[4]
Definition: ltc_6813-1.c:241
static uint16_t ltc_cmdADAX_normal_GPIO3[4]
Definition: ltc_6813-1.c:259
static uint16_t ltc_cmdADCV_normal_DCP1[4]
Definition: ltc_6813-1.c:239
static uint16_t ltc_cmdRDCVE[4]
Definition: ltc_6813-1.c:207
static uint16_t ltc_cmdRDAUXD[4]
Definition: ltc_6813-1.c:215
static uint16_t ltc_cmdADCV_normal_DCP0[4]
Definition: ltc_6813-1.c:237
static uint16_t ltc_BC_cmdADOW_PDOWN_normal_DCP0[4]
Definition: ltc_6813-1.c:279
static uint16_t ltc_cmdADCV_fast_DCP0_twocells[4]
Definition: ltc_6813-1.c:249
static uint16_t ltc_cmdRDCVF[4]
Definition: ltc_6813-1.c:208
static uint16_t ltc_BC_cmdADOW_PUP_normal_DCP0[4]
Definition: ltc_6813-1.c:274
static uint16_t ltc_cmdRDCOMM[4]
Definition: ltc_6813-1.c:211
static uint16_t ltc_cmdSTCOMM[4]
Definition: ltc_6813-1.c:210
static uint16_t ltc_cmdADAX_filtered_GPIO1[4]
Definition: ltc_6813-1.c:254
static uint16_t ltc_BC_cmdADOW_PUP_filtered_DCP0[4]
Definition: ltc_6813-1.c:284
static uint16_t ltc_cmdADCV_filtered_DCP1[4]
Definition: ltc_6813-1.c:243
static uint16_t ltc_cmdADAX_fast_GPIO1[4]
Definition: ltc_6813-1.c:255
Headers for the driver for the LTC monitoring chip.
LTC_STATEMACH_e
Definition: ltc_defs.h:116
LTC_RETURN_TYPE_e
Definition: ltc_defs.h:395