foxBMS  1.0.0
The foxBMS Battery Management System API Documentation
can_cfg.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
38  * ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file can_cfg.c
44  * @author foxBMS Team
45  * @date 2019-12-04 (date of creation)
46  * @updated 2021-03-24 (date of last update)
47  * @ingroup DRIVERS_CONFIGURATION
48  * @prefix CAN
49  *
50  * @brief Configuration for the CAN module
51  *
52  * The CAN bus settings and the received messages and their
53  * reception handling are to be specified here.
54  *
55  *
56  */
57 
58 /*========== Includes =======================================================*/
59 #include "can_cfg.h"
60 
61 #include "database.h"
62 #include "diag.h"
63 #include "foxmath.h"
64 #include "imd.h"
65 
66 /*========== Macros and Definitions =========================================*/
67 
68 /*========== Static Function Prototypes =====================================*/
69 
70 /**
71  * @brief Puts CAN signal data in a 64-bit variable.
72  * This function is used to compose a 64-bit CAN message.
73  * It takes signal data, signal bit start, signal bit length
74  * and puts the data in the 64-bit variable.
75  * @param pMessage 64-bit variable containing the CAN data
76  * @param bitStart starting bit were the signal data must be put
77  * @param bitLength length of the signal data to be put in CAN message
78  * @param signal signal data to be put in message
79  * @param byteOrder big or little endianess of data
80  */
82  uint64_t *pMessage,
83  uint64_t bitStart,
84  uint8_t bitLength,
85  uint64_t signal,
86  CAN_byteOrder_e byteOrder);
87 
88 /**
89  * @brief Copy CAN data from a 64-bit variable to 8 bytes.
90  * This function is used to copy a 64-bit CAN message to 8 bytes.
91  * @param pMessage 64-bit variable containing the CAN data
92  * @param pCanData 8 bytes where the data is copied
93  */
94 static void CAN_TxSetCanDataWithMessageData(uint64_t *pMessage, uint8_t *pCanData);
95 
96 /**
97  * @brief Gets CAN signal data from a 64-bit variable.
98  * This function is used to get signal data from a 64-bit
99  * CAN message.
100  * It takes signal bit start, signal bit length and extract
101  * signal data from the the 64-bit variable.
102  * @param message 64-bit variable containing the CAN data
103  * @param bitStart starting bit were the signal data must be put
104  * @param bitLength length of the signal data to be put in CAN message
105  * @param pSignal signal data to be retrieved from message
106  * @param byteOrder big or little endianess of data
107  */
109  uint64_t message,
110  uint64_t bitStart,
111  uint8_t bitLength,
112  uint64_t *pSignal,
113  CAN_byteOrder_e byteOrder);
114 
115 /**
116  * @brief Copy CAN data from 8 bytes to a 64-bit variable.
117  * @details This function is used to copy data from a 64-bit variable to 8
118  * bytes.
119  * @param pCanData 8 bytes containing the data
120  * @param pMessage 64-bit where the data is copied
121  */
122 static void CAN_RxGetMessageDataFromCanData(uint8_t *pCanData, uint64_t *pMessage);
123 
124 /** TX callback functions @{ */
125 static uint32_t CAN_TxVoltage(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId);
126 static uint32_t CAN_TxPcbTemperature(
127  uint32_t id,
128  uint8_t dlc,
129  CAN_byteOrder_e byteOrder,
130  uint8_t *canData,
131  uint32_t *pMuxId);
132 static uint32_t CAN_TxExternalTemperature(
133  uint32_t id,
134  uint8_t dlc,
135  CAN_byteOrder_e byteOrder,
136  uint8_t *canData,
137  uint32_t *pMuxId);
138 static uint32_t CAN_TxVoltageMinMax(
139  uint32_t id,
140  uint8_t dlc,
141  CAN_byteOrder_e byteOrder,
142  uint8_t *canData,
143  uint32_t *pMuxId);
144 /** @} */
145 
146 /** RX callback functions @{ */
147 static uint32_t CAN_RxImdInfo(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId);
148 static uint32_t CAN_RxImdResponse(
149  uint32_t id,
150  uint8_t dlc,
151  CAN_byteOrder_e byteOrder,
152  uint8_t *canData,
153  uint32_t *pMuxId);
154 static uint32_t CAN_RxRequest(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId);
155 static uint32_t CAN_RxSwReset(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId);
156 static uint32_t CAN_RxCurrentSensor(
157  uint32_t id,
158  uint8_t dlc,
159  CAN_byteOrder_e byteOrder,
160  uint8_t *canData,
161  uint32_t *pMuxId);
162 static uint32_t CAN_RxDebug(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId);
163 static uint32_t CAN_RxSwVersion(
164  uint32_t id,
165  uint8_t dlc,
166  CAN_byteOrder_e byteOrder,
167  uint8_t *canData,
168  uint32_t *pMuxId);
169 /** @} */
170 
171 /*========== Static Constant and Variable Definitions =======================*/
172 
173 /*========== Extern Constant and Variable Definitions =======================*/
174 
175 /* ***************************************
176  * Configure TX messages here
177  ****************************************/
178 
179 /** registry of CAN TX messages */
181  {0x100, 8, 100, 0, littleEndian, &CAN_TxVoltageMinMax, NULL_PTR}, /*!< Min/Max voltages */
182  {0x101, 8, 1000, 0, littleEndian, &CAN_TxPcbTemperature, NULL_PTR}, /*!< PCB temperature and open wire channels */
183  {0x102, 8, 100, 0, littleEndian, &CAN_TxExternalTemperature, NULL_PTR}, /*!< External temperature */
184 
185  {0x110, 8, 100, 0, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 0-5*/
186  {0x111, 8, 100, 0, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 6-11*/
187  {0x112, 8, 100, 0, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 12-17*/
188  {0x113, 8, 100, 10, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 18-23*/
189  {0x114, 8, 100, 10, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 24-29*/
190  {0x115, 8, 100, 10, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 30-35*/
191  {0x116, 8, 100, 20, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 36-41*/
192  {0x117, 8, 100, 20, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 42-47*/
193  {0x118, 8, 100, 20, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 48-53*/
194  {0x119, 8, 100, 30, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 54-59*/
195  {0x11A, 8, 100, 30, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 60-65*/
196  {0x11B, 8, 100, 30, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 66-71*/
197  {0x11C, 8, 100, 40, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 72-77*/
198  {0x11D, 8, 100, 40, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 78-83*/
199  {0x11E, 8, 100, 40, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 84-89*/
200  {0x11F, 8, 100, 50, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 90-95*/
201  {0x120, 8, 100, 50, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 96-101*/
202  {0x121, 8, 100, 50, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 102-107*/
203  {0x122, 8, 100, 60, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 108-113*/
204  {0x123, 8, 100, 60, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 114-119*/
205  {0x124, 8, 100, 60, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 120-125*/
206  {0x125, 8, 100, 70, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 126-131*/
207  {0x126, 8, 100, 70, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 132-137*/
208  {0x127, 8, 100, 70, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 138-143*/
209  {0x128, 8, 100, 80, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 144-149*/
210  {0x129, 8, 100, 80, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 150-155*/
211  {0x12A, 8, 100, 80, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 156-161*/
212  {0x12B, 8, 100, 90, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 162-167*/
213  {0x12C, 8, 100, 90, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 168-173*/
214  {0x12D, 8, 100, 90, littleEndian, &CAN_TxVoltage, NULL_PTR}, /*!< Cell voltages 174-179*/
215 };
216 
217 /* ***************************************
218  * Configure RX messages here
219  ****************************************/
220 
221 /** registry of CAN RX messages */
223  {0x37, 8, 0, littleEndian, &CAN_RxImdInfo}, /*!< request SW version */
224  {0x23, 8, 0, littleEndian, &CAN_RxImdResponse}, /*!< request SW version */
225 
226  {0x120, 8, 0, littleEndian, &CAN_RxRequest}, /*!< state request */
227  {CAN_ID_SOFTWARE_RESET_MSG, 8, 0, littleEndian, &CAN_RxSwReset}, /*!< software reset */
228 
229  {0x521u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */
230  {0x522u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */
231  {0x523u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */
232  {0x524u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */
233  {0x525u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */
234  {0x526u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */
235  {0x527u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor C-C in cyclic mode */
236  {0x528u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor E-C in cyclic mode */
237 
238 #if BS_NR_OF_STRINGS > 1u
239  {0x621u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */
240  {0x622u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */
241  {0x623u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */
242  {0x624u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */
243  {0x625u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */
244  {0x626u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */
245  {0x627u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor C-C in cyclic mode */
246  {0x628u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor E-C in cyclic mode */
247 
248 #if BS_NR_OF_STRINGS > 2u
249  {0x721u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor I in cyclic mode */
250  {0x722u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U1 in cyclic mode */
251  {0x723u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U2 in cyclic mode */
252  {0x724u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor U3 in cyclic mode */
253  {0x725u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor T in cyclic mode */
254  {0x726u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor Power in cyclic mode */
255  {0x727u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor C-C in cyclic mode */
256  {0x728u, 8, 0, bigEndian, &CAN_RxCurrentSensor}, /*!< current sensor E-C in cyclic mode */
257 
258 #endif /* BS_NR_OF_STRINGS > 1 */
259 #endif /* BS_NR_OF_STRINGS > 2 */
260 
261  {0x100, 8, 0, littleEndian, &CAN_RxDebug}, /*!< debug message */
262  {0x777, 8, 0, littleEndian, &CAN_RxSwVersion}, /*!< request SW version */
263 };
264 
265 /** length of CAN message arrays @{*/
266 const uint8_t can_txLength = sizeof(can_txMessages) / sizeof(can_txMessages[0]);
267 const uint8_t can_rxLength = sizeof(can_rxMessages) / sizeof(can_rxMessages[0]);
268 /**@}*/
269 
270 /** local copies of database tables */
271 /**@{*/
278 /**@}*/
279 
280 /*========== Static Function Prototypes =====================================*/
281 
282 /*========== Static Function Implementations ================================*/
283 #pragma diag_push
284 #pragma diag_suppress 880
285 static uint32_t CAN_TxVoltage(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId) {
286  FAS_ASSERT(canData != NULL_PTR);
287  uint32_t index = 0;
288  uint64_t message = 0;
289  float tmpVal = 0.0f;
290  float offset = 0.0f;
291  float factor = 0.0f;
292  uint64_t bitStart = 0;
293  uint8_t bitLength = 0;
294 
295  /* first signal to transmit cell voltages */
296  if (id == 0x110u) {
298  }
299 
300  index = id - 0x110u;
301  bitLength = 10;
302  /* each voltage frame contains 6 voltages */
303  for (uint8_t i = 0u; i < 6u; i++) {
304  /* conversion from mV to V */
305  tmpVal = (can_tableCellVoltages.cellVoltage_mV[0][(index * 6u) + i]) /
306  1000.0; /* TODO: string index to be added */
307  /* apply offset and factor */
308  offset = 2.5f;
309  factor = 200.0f;
310  tmpVal = (tmpVal + offset) * factor;
311  /* set data in CAN frame */
312  bitStart = 10u * i;
313  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
314  }
315 
316  /* now copy data in the buffer that will be use to send data */
317  CAN_TxSetCanDataWithMessageData(&message, canData);
318 
319  return 0;
320 }
321 #pragma diag_pop
322 
323 #pragma diag_push
324 #pragma diag_suppress 880
325 uint32_t CAN_TxPcbTemperature(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId) {
326  FAS_ASSERT(canData != NULL_PTR);
327  uint64_t message = 0;
328  float tmpVal = 0.0f;
329  float offset = 0.0f;
330  float factor = 0.0f;
331  uint64_t bitStart = 0;
332  uint8_t bitLength = 0;
333 
335 
336  /* Three PCB temperatures to send */
337  bitLength = 16;
338  for (int i = 0; i < 3; i++) {
339  /* apply offset and factor */
341  offset = 0.0f;
342  factor = 0.1f;
343  tmpVal = (tmpVal + offset) * factor;
344  /* set data in CAN frame */
345  bitStart = 16 * i;
346  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
347  }
348 
349  /* Number of open wires */
350  bitLength = 16;
351  bitStart = 48;
352  tmpVal = (float)can_tableOpenWire.nrOpenWires[0]; /* TODO: string index to be added */
353  offset = 0.0f;
354  factor = 1.0f;
355  tmpVal = (tmpVal + offset) * factor;
356  /* set data in CAN frame */
357  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
358 
359  /* now copy data in the buffer that will be use to send data */
360  CAN_TxSetCanDataWithMessageData(&message, canData);
361 
362  return 0;
363 }
364 #pragma diag_pop
365 
366 #pragma diag_push
367 #pragma diag_suppress 880
369  uint32_t id,
370  uint8_t dlc,
371  CAN_byteOrder_e byteOrder,
372  uint8_t *canData,
373  uint32_t *pMuxId) {
374  FAS_ASSERT(canData != NULL_PTR);
375  uint64_t message = 0;
376  float tmpVal = 0.0f;
377  float offset = 0.0f;
378  float factor = 0.0f;
379  uint64_t bitStart = 0;
380  uint8_t bitLength = 0;
381 
383 
384  /* Three external temperatures to send */
385  bitLength = 16;
386  for (int i = 0; i < 3; i++) {
387  /* apply offset and factor */
389  offset = 0.0f;
390  factor = 0.1f;
391  tmpVal = (tmpVal + offset) * factor;
392  /* set data in CAN frame */
393  bitStart = 16 * i;
394  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
395  }
396 
397  /* current measurement */
398  bitLength = 16;
399  bitStart = 48;
400  tmpVal = (float)can_tableCurrentSensor.current_mA[0]; /* TODO: string index to be added */
401  offset = 0.0f;
402  factor = 1.0f;
403  tmpVal = (tmpVal + offset) * factor;
404  /* set data in CAN frame */
405  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
406 
407  /* now copy data in the buffer that will be use to send data */
408  CAN_TxSetCanDataWithMessageData(&message, canData);
409 
410  return 0;
411 }
412 #pragma diag_pop
413 
414 #pragma diag_push
415 #pragma diag_suppress 880
416 static uint32_t CAN_TxVoltageMinMax(
417  uint32_t id,
418  uint8_t dlc,
419  CAN_byteOrder_e byteOrder,
420  uint8_t *canData,
421  uint32_t *pMuxId) {
422  FAS_ASSERT(canData != NULL_PTR);
423  uint64_t message = 0;
424  float tmpVal = 0.0f;
425  float offset = 0.0f;
426  float factor = 0.0f;
427  uint64_t bitStart = 0;
428  uint8_t bitLength = 0;
429 
431 
432  /* min voltage */
433  bitStart = 0;
434  bitLength = 16;
435  tmpVal = (float)can_tableMinimumMaximumValues.minimumCellVoltage_mV[0]; /* TODO: string index to be added */
436  offset = 0.0f;
437  factor = 1.0f;
438  tmpVal = (tmpVal + offset) * factor;
439  /* set data in CAN frame */
440  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
441 
442  /* apply offset and factor */
443  bitStart = 16;
444  bitLength = 8;
445  tmpVal = (float)can_tableMinimumMaximumValues.nrCellMinimumCellVoltage[0]; /* TODO: string index to be added */
446  offset = 0.0f;
447  factor = 1.0f;
448  tmpVal = (tmpVal + offset) * factor;
449  /* set data in CAN frame */
450  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
451 
452  /* apply offset and factor */
453  bitStart = 24;
454  bitLength = 16;
455  tmpVal = (float)can_tableMinimumMaximumValues.maximumCellVoltage_mV[0]; /* TODO: string index to be added */
456  offset = 0.0f;
457  factor = 1.0f;
458  tmpVal = (tmpVal + offset) * factor;
459  /* set data in CAN frame */
460  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
461 
462  /* apply offset and factor */
463  bitStart = 40;
464  bitLength = 8;
465  tmpVal = (float)can_tableMinimumMaximumValues.nrCellMaximumCellVoltage[0]; /* TODO: string index to be added */
466  offset = 0.0f;
467  factor = 1.0f;
468  tmpVal = (tmpVal + offset) * factor;
469  /* set data in CAN frame */
470  CAN_TxSetMessageDataWithSignalData(&message, bitStart, bitLength, (uint32_t)tmpVal, byteOrder);
471 
472  /* now copy data in the buffer that will be use to send data */
473  CAN_TxSetCanDataWithMessageData(&message, canData);
474 
475  return 0;
476 }
477 
478 #pragma diag_pop
479 
480 #pragma diag_push
481 #pragma diag_suppress 880
482 static uint32_t CAN_RxImdInfo(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId) {
483  FAS_ASSERT(canData != NULL_PTR);
484  CAN_BUFFERELEMENT_s canMessage = {0u};
485  uint32_t retVal = 1u;
486 
487  canMessage.id = id;
488  for (uint8_t i = 0; i < dlc; i++) {
489  canMessage.data[i] = canData[i];
490  }
491  if (pdPASS == xQueueSend(imd_canDataQueue, (void *)&canMessage, 0u)) {
492  retVal = 0u;
493  }
494  return retVal;
495 }
496 
497 #pragma diag_pop
498 
499 #pragma diag_push
500 #pragma diag_suppress 880
501 static uint32_t CAN_RxImdResponse(
502  uint32_t id,
503  uint8_t dlc,
504  CAN_byteOrder_e byteOrder,
505  uint8_t *canData,
506  uint32_t *pMuxId) {
507  FAS_ASSERT(canData != NULL_PTR);
508  CAN_BUFFERELEMENT_s canMessage = {0u};
509  uint32_t retVal = 1u;
510 
511  canMessage.id = id;
512  for (uint8_t i = 0; i < dlc; i++) {
513  canMessage.data[i] = canData[i];
514  }
515  if (pdPASS == xQueueSend(imd_canDataQueue, (void *)&canMessage, 0u)) {
516  retVal = 0u;
517  }
518  return retVal;
519 }
520 
521 #pragma diag_pop
522 
523 #pragma diag_push
524 #pragma diag_suppress 880
525 static uint32_t CAN_RxRequest(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId) {
526  FAS_ASSERT(canData != NULL_PTR);
527  uint64_t message = 0;
528  uint64_t signal = 0;
529  uint64_t bitStart = 0;
530  uint8_t bitLength = 0;
531  uint8_t stateRequest = 0;
532 
534 
535  bitStart = 8;
536  bitLength = 8;
537  CAN_RxGetMessageDataFromCanData(canData, &message);
538  CAN_RxGetSignalDataFromMessageData(message, bitStart, bitLength, &signal, byteOrder);
539 
540  stateRequest = (uint8_t)signal;
546  }
548 
550 
551  return 0;
552 }
553 
554 #pragma diag_pop
555 
556 #pragma diag_push
557 #pragma diag_suppress 880
558 static uint32_t CAN_RxSwReset(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId) {
559  FAS_ASSERT(canData != NULL_PTR);
560  return 0;
561 }
562 
563 #pragma diag_pop
564 
565 #pragma diag_push
566 #pragma diag_suppress 880
567 static uint32_t CAN_RxCurrentSensor(
568  uint32_t id,
569  uint8_t dlc,
570  CAN_byteOrder_e byteOrder,
571  uint8_t *canData,
572  uint32_t *pMuxId) {
573  FAS_ASSERT(canData != NULL_PTR);
574  uint64_t message = 0u;
575  uint64_t signal = 0u;
576  uint64_t bitStart = 0u;
577  uint8_t bitLength = 0u;
578 
579  int32_t tempValue = 0;
580  uint8_t dummy = 0u;
581  uint8_t stringNumber = 0;
582 
583  /* IDs are used as follows:
584  - String 0: 0x521 - 0x528
585  - String 1: 0x621 - 0x628
586  - String 2: 0x721 - 0x728 */
587  if (id <= 0x528u) {
588  stringNumber = 0u;
589  } else if (id <= 0x628u) {
590  stringNumber = 1u;
591  } else {
592  stringNumber = 2u;
593  }
594 
595  CAN_RxGetMessageDataFromCanData(canData, &message);
596 
597  /* Get status*/
598  bitStart = 0;
599  bitLength = 8;
600  CAN_RxGetSignalDataFromMessageData(message, bitStart, bitLength, &signal, byteOrder);
601 
602  dummy = (uint32_t)signal;
603  dummy &= 0xF0u; /* only high nibble contains diag info */
604  if ((dummy & 0x10u) == 0x10u) {
605  /* Overcurrent detected. This feature is currently not supported. */
606  }
607  if ((dummy & 0x20u) == 0x20u) {
608  switch (id) {
609  case 0x521u: /* Current status */
611  break;
612  case 0x522u: /* Voltage status */
614  break;
615  case 0x523u:
617  break;
618  case 0x524u:
620  break;
621  case 0x525u: /* Temperature status */
623  break;
624  case 0x526u: /* Power status */
626  break;
627  case 0x527u: /* CC status */
629  break;
630  case 0x528u: /* EC status */
632  break;
633  default:
634  break;
635  }
636  } else {
645  }
646 
647  if (((dummy & 0x40u) == 0x40u) || ((dummy & 0x80u) == 0x80u)) {
656  }
657 
658  /* Get measurement */
659  bitStart = 16;
660  bitLength = 32;
661  CAN_RxGetSignalDataFromMessageData(message, bitStart, bitLength, &signal, byteOrder);
662  switch (id) {
663  /* Current measurement */
664  case 0x521u:
665  case 0x621u:
666  case 0x721u:
667  tempValue = (int32_t)signal;
668  can_tableCurrentSensor.current_mA[stringNumber] = tempValue;
673  break;
674  /* Voltage measurement U1 */
675  case 0x522u:
676  case 0x622u:
677  case 0x722u:
678  tempValue = (int32_t)signal;
679  can_tableCurrentSensor.highVoltage_mV[stringNumber][0] = tempValue;
683  break;
684  /* Voltage measurement U2 */
685  case 0x523u:
686  case 0x623u:
687  case 0x723u:
688  tempValue = (int32_t)signal;
689  can_tableCurrentSensor.highVoltage_mV[stringNumber][1] = tempValue;
693  break;
694  /* Voltage measurement U3 */
695  case 0x524u:
696  case 0x624u:
697  case 0x724u:
698  tempValue = (int32_t)signal;
699  can_tableCurrentSensor.highVoltage_mV[stringNumber][2] = tempValue;
703  break;
704  /* Temperature measurement */
705  case 0x525u:
706  case 0x625u:
707  case 0x725u:
708  tempValue = (int32_t)signal;
709  can_tableCurrentSensor.sensorTemperature_ddegC[stringNumber] = tempValue;
710  break;
711  /* Power measurement */
712  case 0x526u:
713  case 0x626u:
714  case 0x726u:
715  tempValue = (int32_t)signal;
716  can_tableCurrentSensor.power_W[stringNumber] = tempValue;
721  break;
722  /* CC measurement */
723  case 0x527u:
724  case 0x627u:
725  case 0x727u:
726  tempValue = (int32_t)signal;
730  can_tableCurrentSensor.currentCounter_As[stringNumber] = tempValue;
731  break;
732  /* EC measurement */
733  case 0x528u:
734  case 0x628u:
735  case 0x728u:
736  tempValue = (int32_t)signal;
737  can_tableCurrentSensor.energyCounter_Wh[stringNumber] = tempValue;
741  break;
742 
743  default:
745  break;
746  }
747 
749  return 0;
750 }
751 #pragma diag_pop
752 
753 #pragma diag_push
754 #pragma diag_suppress 880
755 static uint32_t CAN_RxDebug(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId) {
756  FAS_ASSERT(canData != NULL_PTR);
757 
758  uint64_t message = 0;
759  uint64_t signal = 0;
760  uint64_t bitStart = 0;
761  uint8_t bitLength = 0;
762 
763  CAN_RxGetMessageDataFromCanData(canData, &message);
764 
765  bitStart = 0;
766  bitLength = 8;
767  CAN_RxGetSignalDataFromMessageData(message, bitStart, bitLength, &signal, byteOrder);
768 
769  switch ((uint8_t)signal) {
770  case 0xAA:
771  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
773  }
774  break;
775 
776  default:
777  break;
778  }
779  return 0;
780 }
781 #pragma diag_pop
782 
783 #pragma diag_push
784 #pragma diag_suppress 880
785 static uint32_t CAN_RxSwVersion(
786  uint32_t id,
787  uint8_t dlc,
788  CAN_byteOrder_e byteOrder,
789  uint8_t *canData,
790  uint32_t *pMuxId) {
791  FAS_ASSERT(canData != NULL_PTR);
792  return 0;
793 }
794 #pragma diag_pop
795 
797  uint64_t *pMessage,
798  uint64_t bitStart,
799  uint8_t bitLength,
800  uint64_t signal,
801  CAN_byteOrder_e byteOrder) {
802  FAS_ASSERT(pMessage != NULL_PTR);
803  uint64_t mask = 0xFFFFFFFFFFFFFFFFu;
804 
805  /* Swap byte order if necessary */
806  if (byteOrder == littleEndian) {
807  /* No need to switch byte order as native MCU endianness is little-endian (intel) */
808  } else if (byteOrder == bigEndian) {
809  if (bitLength <= 8u) {
810  /* No need to switch byte order as signal length is smaller than one byte */
811  } else if (bitLength <= 16u) {
812  /* Swap byte order */
813  signal = (uint64_t)MATH_swapBytes_uint16_t((uint16_t)signal);
814  } else if (bitLength <= 32u) {
815  /* Swap byte order */
816  signal = (uint64_t)MATH_swapBytes_uint32_t((uint32_t)signal);
817  } else { /* (signal.bit_length <= 64) */
818  /* Swap byte order */
819  signal = MATH_swapBytes_uint64_t(signal);
820  }
821  }
822 
823  if ((bitLength < 64u) && (bitStart < 64u)) {
824  mask <<= bitLength;
825  mask = ~mask;
826 
827  *pMessage |= (signal & mask) << bitStart;
828  } else {
829  /* unexpectedly large bit-shift */
831  }
832 }
833 
834 static void CAN_TxSetCanDataWithMessageData(uint64_t *pMessage, uint8_t *pCanData) {
835  FAS_ASSERT(pMessage != NULL_PTR);
836  FAS_ASSERT(pCanData != NULL_PTR);
837  pCanData[0] = (uint8_t)(((*pMessage) >> 0u) & 0xFFu);
838  pCanData[1] = (uint8_t)(((*pMessage) >> 8u) & 0xFFu);
839  pCanData[2] = (uint8_t)(((*pMessage) >> 16u) & 0xFFu);
840  pCanData[3] = (uint8_t)(((*pMessage) >> 24u) & 0xFFu);
841  pCanData[4] = (uint8_t)(((*pMessage) >> 32u) & 0xFFu);
842  pCanData[5] = (uint8_t)(((*pMessage) >> 40u) & 0xFFu);
843  pCanData[6] = (uint8_t)(((*pMessage) >> 48u) & 0xFFu);
844  pCanData[7] = (uint8_t)(((*pMessage) >> 56u) & 0xFFu);
845 }
846 
848  uint64_t message,
849  uint64_t bitStart,
850  uint8_t bitLength,
851  uint64_t *pSignal,
852  CAN_byteOrder_e byteOrder) {
853  FAS_ASSERT(pSignal != NULL_PTR);
854  uint64_t mask = 0xFFFFFFFFFFFFFFFFu;
855 
856  if ((bitLength < 64u) && (bitStart < 64u)) {
857  mask <<= bitLength;
858  mask = ~mask;
859 
860  *pSignal = (message >> bitStart) & mask;
861  } else {
862  /* unexpectedly large bit-shift */
864  }
865 
866  /* Swap byte order if necessary */
867  if (byteOrder == littleEndian) {
868  /* No need to switch byte order as native MCU endianness is little-endian (intel) */
869  } else if (byteOrder == bigEndian) {
870  if (bitLength <= 8u) {
871  /* No need to switch byte order as signal length is smaller than one byte */
872  } else if (bitLength <= 16u) {
873  /* Swap byte order */
874  *pSignal = (uint64_t)MATH_swapBytes_uint16_t((uint16_t)*pSignal);
875  } else if (bitLength <= 32u) {
876  /* Swap byte order */
877  *pSignal = (uint64_t)MATH_swapBytes_uint32_t((uint32_t)*pSignal);
878  } else { /* (signal.bit_length <= 64) */
879  /* Swap byte order */
880  *pSignal = MATH_swapBytes_uint64_t(*pSignal);
881  }
882  }
883 }
884 
885 static void CAN_RxGetMessageDataFromCanData(uint8_t *pCanData, uint64_t *pMessage) {
886  FAS_ASSERT(pMessage != NULL_PTR);
887  FAS_ASSERT(pCanData != NULL_PTR);
888  *pMessage = ((((uint64_t)pCanData[0]) & 0xFFu) << 0u) | ((((uint64_t)pCanData[1]) & 0xFFu) << 8u) |
889  ((((uint64_t)pCanData[2]) & 0xFFu) << 16u) | ((((uint64_t)pCanData[3]) & 0xFFu) << 24u) |
890  ((((uint64_t)pCanData[4]) & 0xFFu) << 32u) | ((((uint64_t)pCanData[5]) & 0xFFu) << 40u) |
891  ((((uint64_t)pCanData[6]) & 0xFFu) << 48u) | ((((uint64_t)pCanData[7]) & 0xFFu) << 56u);
892 }
893 
894 /*========== Extern Function Implementations ================================*/
895 
896 /*========== Externalized Static Function Implementations (Unit Test) =======*/
897 #ifdef UNITY_UNIT_TEST
898 extern DATA_BLOCK_CELL_VOLTAGE_s *TEST_CAN_GetCellvoltageTab(void) {
899  return &can_tableCellVoltages;
900 }
901 
902 /* TX callback functions */
903 extern uint32_t TEST_CAN_TxVoltage(
904  uint32_t id,
905  uint8_t dlc,
906  CAN_byteOrder_e byteOrder,
907  uint8_t *pCanData,
908  uint32_t *pMuxId) {
909  return CAN_TxVoltage(id, dlc, byteOrder, pCanData, pMuxId);
910 }
911 extern uint32_t TEST_CAN_TxPcbTemperature(
912  uint32_t id,
913  uint8_t dlc,
914  CAN_byteOrder_e byteOrder,
915  uint8_t *pCanData,
916  uint32_t *pMuxId) {
917  return CAN_TxPcbTemperature(id, dlc, byteOrder, pCanData, pMuxId);
918 }
919 extern uint32_t TEST_CAN_TxExternalTemperature(
920  uint32_t id,
921  uint8_t dlc,
922  CAN_byteOrder_e byteOrder,
923  uint8_t *pCanData,
924  uint32_t *pMuxId) {
925  return CAN_TxExternalTemperature(id, dlc, byteOrder, pCanData, pMuxId);
926 }
927 extern uint32_t TEST_CAN_TxVoltageMinMax(
928  uint32_t id,
929  uint8_t dlc,
930  CAN_byteOrder_e byteOrder,
931  uint8_t *pCanData,
932  uint32_t *pMuxId) {
933  return CAN_TxVoltageMinMax(id, dlc, byteOrder, pCanData, pMuxId);
934 }
935 
936 /* RX callback functions */
937 extern uint32_t TEST_CAN_RxRequest(
938  uint32_t id,
939  uint8_t dlc,
940  CAN_byteOrder_e byteOrder,
941  uint8_t *pCanData,
942  uint32_t *pMuxId) {
943  return CAN_RxRequest(id, dlc, byteOrder, pCanData, pMuxId);
944 }
945 extern uint32_t TEST_CAN_RxSwReset(
946  uint32_t id,
947  uint8_t dlc,
948  CAN_byteOrder_e byteOrder,
949  uint8_t *pCanData,
950  uint32_t *pMuxId) {
951  return CAN_RxSwReset(id, dlc, byteOrder, pCanData, pMuxId);
952 }
953 extern uint32_t TEST_CAN_RxCurrentSensor(
954  uint32_t id,
955  uint8_t dlc,
956  CAN_byteOrder_e byteOrder,
957  uint8_t *pCanData,
958  uint32_t *pMuxId) {
959  return CAN_RxCurrentSensor(id, dlc, byteOrder, pCanData, pMuxId);
960 }
961 extern uint32_t TEST_CAN_RxDebug(
962  uint32_t id,
963  uint8_t dlc,
964  CAN_byteOrder_e byteOrder,
965  uint8_t *pCanData,
966  uint32_t *pMuxId) {
967  return CAN_RxDebug(id, dlc, byteOrder, pCanData, pMuxId);
968 }
969 extern uint32_t TEST_CAN_RxSwVersion(
970  uint32_t id,
971  uint8_t dlc,
972  CAN_byteOrder_e byteOrder,
973  uint8_t *pCanData,
974  uint32_t *pMuxId) {
975  return CAN_RxSwVersion(id, dlc, byteOrder, pCanData, pMuxId);
976 }
977 #endif
DATA_BLOCK_ADC_TEMPERATURE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:148
can_tableStateRequest
static DATA_BLOCK_STATEREQUEST_s can_tableStateRequest
Definition: can_cfg.c:277
can_tableMinimumMaximumValues
static DATA_BLOCK_MIN_MAX_s can_tableMinimumMaximumValues
Definition: can_cfg.c:274
DATA_BLOCK_CURRENT_SENSOR
Definition: database_cfg.h:209
DATA_BLOCK_OPENWIRE
Definition: database_cfg.h:296
CAN_TxPcbTemperature
static uint32_t CAN_TxPcbTemperature(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:325
can_rxMessages
const CAN_MSG_RX_TYPE_s can_rxMessages[]
Definition: can_cfg.c:222
CAN_TxVoltageMinMax
static uint32_t CAN_TxVoltageMinMax(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:416
CAN_RxSwVersion
static uint32_t CAN_RxSwVersion(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:785
CAN_MSG_RX_TYPE
Definition: can_cfg.h:119
DATA_BLOCK_STATEREQUEST::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:506
DATA_BLOCK_MIN_MAX::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:162
DATA_BLOCK_ID_OPEN_WIRE_BASE
@ DATA_BLOCK_ID_OPEN_WIRE_BASE
Definition: database_cfg.h:81
DATA_BLOCK_CURRENT_SENSOR::invalidCurrentCountingMeasurement
uint8_t invalidCurrentCountingMeasurement[BS_NR_OF_STRINGS]
Definition: database_cfg.h:227
DATA_BLOCK_ADC_TEMPERATURE::temperatureAdc0_ddegC
int16_t temperatureAdc0_ddegC[BS_NR_OF_TEMP_SENSORS_ON_ADC0]
Definition: database_cfg.h:149
DATA_BLOCK_CURRENT_SENSOR::invalidPowerMeasurement
uint8_t invalidPowerMeasurement[BS_NR_OF_STRINGS]
Definition: database_cfg.h:222
littleEndian
@ littleEndian
Definition: can_cfg.h:99
can_tableCellVoltages
static DATA_BLOCK_CELL_VOLTAGE_s can_tableCellVoltages
Definition: can_cfg.c:272
DATA_BLOCK_MIN_MAX::nrCellMinimumCellVoltage
uint16_t nrCellMinimumCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:171
diag.h
Diagnosis driver header.
can_tableCurrentSensor
static DATA_BLOCK_CURRENT_SENSOR_s can_tableCurrentSensor
Definition: can_cfg.c:275
DATA_BLOCK_STATEREQUEST::stateRequestViaCan
uint8_t stateRequestViaCan
Definition: database_cfg.h:507
DATA_BLOCK_CURRENT_SENSOR::previousTimestampEnergyCounting
uint32_t previousTimestampEnergyCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:232
CAN_MSG_TX_TYPE
Definition: can_cfg.h:108
DATA_BLOCK_ADC_TEMPERATURE
Definition: database_cfg.h:144
DATA_WRITE_DATA
#define DATA_WRITE_DATA(...)
Definition: database.h:82
can_rxLength
const uint8_t can_rxLength
Definition: can_cfg.c:267
MATH_swapBytes_uint32_t
uint32_t MATH_swapBytes_uint32_t(uint32_t val)
Swap bytes of uint32_t value.
Definition: foxmath.c:90
DATA_BLOCK_CURRENT_SENSOR::previousTimestampCurrentCounting
uint32_t previousTimestampCurrentCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:228
DATA_BLOCK_CURRENT_SENSOR::invalidEnergyCountingMeasurement
uint8_t invalidEnergyCountingMeasurement[BS_NR_OF_STRINGS]
Definition: database_cfg.h:231
DATA_BLOCK_CURRENT_SENSOR::invalidSensorTemperatureMeasurement
uint8_t invalidSensorTemperatureMeasurement[BS_NR_OF_STRINGS]
Definition: database_cfg.h:220
DATA_BLOCK_CURRENT_SENSOR::previousTimestampHighVoltage
uint32_t previousTimestampHighVoltage[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:239
can_txLength
const uint8_t can_txLength
Definition: can_cfg.c:266
CAN_RxCurrentSensor
static uint32_t CAN_RxCurrentSensor(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:567
can_txMessages
const CAN_MSG_TX_TYPE_s can_txMessages[]
Definition: can_cfg.c:180
can_tableOpenWire
static DATA_BLOCK_OPEN_WIRE_s can_tableOpenWire
Definition: can_cfg.c:276
DIAG_EVENT_OK
@ DIAG_EVENT_OK
Definition: diag_cfg.h:201
DIAG_Handler
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diag_id, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
Definition: diag.c:199
DATA_BLOCK_STATEREQUEST::state
uint8_t state
Definition: database_cfg.h:510
can_cfg.h
Headers for the configuration for the CAN module.
CAN_RxGetMessageDataFromCanData
static void CAN_RxGetMessageDataFromCanData(uint8_t *pCanData, uint64_t *pMessage)
Copy CAN data from 8 bytes to a 64-bit variable.
Definition: can_cfg.c:885
DATA_BLOCK_CURRENT_SENSOR::energyCounter_Wh
int32_t energyCounter_Wh[BS_NR_OF_STRINGS]
Definition: database_cfg.h:230
DATA_BLOCK_CURRENT_SENSOR::current_mA
int32_t current_mA[BS_NR_OF_STRINGS]
Definition: database_cfg.h:214
FAS_ASSERT
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:237
CAN_TxSetCanDataWithMessageData
static void CAN_TxSetCanDataWithMessageData(uint64_t *pMessage, uint8_t *pCanData)
Copy CAN data from a 64-bit variable to 8 bytes. This function is used to copy a 64-bit CAN message t...
Definition: can_cfg.c:834
DATA_BLOCK_CURRENT_SENSOR::invalidCurrentMeasurement
uint8_t invalidCurrentMeasurement[BS_NR_OF_STRINGS]
Definition: database_cfg.h:215
CAN_RxDebug
static uint32_t CAN_RxDebug(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:755
MATH_swapBytes_uint16_t
uint16_t MATH_swapBytes_uint16_t(uint16_t val)
Swap bytes of uint16_t value.
Definition: foxmath.c:86
DATA_BLOCK_CURRENT_SENSOR::timestampEnergyCounting
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:233
OS_GetTickCount
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
Definition: os.c:182
CAN_TxExternalTemperature
static uint32_t CAN_TxExternalTemperature(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:368
DATA_BLOCK_ID_MIN_MAX
@ DATA_BLOCK_ID_MIN_MAX
Definition: database_cfg.h:75
DIAG_STRING
@ DIAG_STRING
Definition: diag_cfg.h:215
foxmath.h
math library for often used math functions
DATA_BLOCK_ID_ADC_TEMPERATURE
@ DATA_BLOCK_ID_ADC_TEMPERATURE
Definition: database_cfg.h:101
CAN_TxVoltage
static uint32_t CAN_TxVoltage(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:285
CAN_ID_SOFTWARE_RESET_MSG
#define CAN_ID_SOFTWARE_RESET_MSG
Definition: can_cfg.h:92
CAN_RxImdInfo
static uint32_t CAN_RxImdInfo(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:482
DATA_BLOCK_CURRENT_SENSOR::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:213
DATA_BLOCK_CURRENT_SENSOR::sensorTemperature_ddegC
int32_t sensorTemperature_ddegC[BS_NR_OF_STRINGS]
Definition: database_cfg.h:219
CAN_BUFFERELEMENT::id
uint32_t id
Definition: can_cfg.h:77
DATA_BLOCK_CELL_VOLTAGE::cellVoltage_mV
int16_t cellVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_BAT_CELLS]
Definition: database_cfg.h:122
DATA_BLOCK_OPENWIRE::nrOpenWires
uint16_t nrOpenWires[BS_NR_OF_STRINGS]
Definition: database_cfg.h:302
DATA_BLOCK_STATEREQUEST::previousStateRequestViaCan
uint8_t previousStateRequestViaCan
Definition: database_cfg.h:508
DATA_BLOCK_CURRENT_SENSOR::timestampHighVoltage
uint32_t timestampHighVoltage[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:241
DATA_BLOCK_CURRENT_SENSOR::timestampCurrent
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:218
DATA_BLOCK_STATEREQUEST::stateRequestViaCanPending
uint8_t stateRequestViaCanPending
Definition: database_cfg.h:509
DATA_BLOCK_MIN_MAX::maximumCellVoltage_mV
int16_t maximumCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:167
CAN_TxSetMessageDataWithSignalData
static void CAN_TxSetMessageDataWithSignalData(uint64_t *pMessage, uint64_t bitStart, uint8_t bitLength, uint64_t signal, CAN_byteOrder_e byteOrder)
Puts CAN signal data in a 64-bit variable. This function is used to compose a 64-bit CAN message....
Definition: can_cfg.c:796
DATA_BLOCK_ID_STATEREQUEST
@ DATA_BLOCK_ID_STATEREQUEST
Definition: database_cfg.h:92
DATA_BLOCK_CELL_VOLTAGE
Definition: database_cfg.h:115
CAN_RxRequest
static uint32_t CAN_RxRequest(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:525
DATA_BLOCK_MIN_MAX
Definition: database_cfg.h:158
DATA_READ_DATA
#define DATA_READ_DATA(...)
Definition: database.h:72
CAN_BUFFERELEMENT
Definition: can_cfg.h:76
DATA_BLOCK_CURRENT_SENSOR::previousTimestampCurrent
uint32_t previousTimestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:217
DATA_BLOCK_CURRENT_SENSOR::highVoltage_mV
int32_t highVoltage_mV[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:236
can_tableAdcTemperatures
static DATA_BLOCK_ADC_TEMPERATURE_s can_tableAdcTemperatures
Definition: can_cfg.c:273
CAN_RxImdResponse
static uint32_t CAN_RxImdResponse(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:501
DATA_BLOCK_CURRENT_SENSOR::newCurrent
uint8_t newCurrent
Definition: database_cfg.h:216
DATA_BLOCK_CURRENT_SENSOR::currentCounter_As
int32_t currentCounter_As[BS_NR_OF_STRINGS]
Definition: database_cfg.h:226
database.h
Database module header.
NULL_PTR
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:66
MATH_swapBytes_uint64_t
uint64_t MATH_swapBytes_uint64_t(uint64_t val)
Swap bytes of uint64_t value.
Definition: foxmath.c:95
CAN_byteOrder_e
CAN_byteOrder_e
Definition: can_cfg.h:98
imd.h
API header for the insulation monitoring device.
DATA_BLOCK_CURRENT_SENSOR::previousTimestampPower
uint32_t previousTimestampPower[BS_NR_OF_STRINGS]
Definition: database_cfg.h:224
DATA_BLOCK_CURRENT_SENSOR::invalidHighVoltageMeasurement
uint8_t invalidHighVoltageMeasurement[BS_NR_OF_STRINGS][BS_NR_OF_VOLTAGES_FROM_CURRENT_SENSOR]
Definition: database_cfg.h:235
DATA_BLOCK_CURRENT_SENSOR::timestampCurrentCounting
uint32_t timestampCurrentCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:229
DATA_BLOCK_ID_CELL_VOLTAGE
@ DATA_BLOCK_ID_CELL_VOLTAGE
Definition: database_cfg.h:73
DATA_BLOCK_CURRENT_SENSOR::power_W
int32_t power_W[BS_NR_OF_STRINGS]
Definition: database_cfg.h:221
DATA_BLOCK_STATEREQUEST
Definition: database_cfg.h:502
DATA_BLOCK_MIN_MAX::nrCellMaximumCellVoltage
uint16_t nrCellMaximumCellVoltage[BS_NR_OF_STRINGS]
Definition: database_cfg.h:173
DATA_BLOCK_MIN_MAX::minimumCellVoltage_mV
int16_t minimumCellVoltage_mV[BS_NR_OF_STRINGS]
Definition: database_cfg.h:165
CAN_RxSwReset
static uint32_t CAN_RxSwReset(uint32_t id, uint8_t dlc, CAN_byteOrder_e byteOrder, uint8_t *canData, uint32_t *pMuxId)
Definition: can_cfg.c:558
DATA_BLOCK_ADC_TEMPERATURE::temperatureAdc1_ddegC
int16_t temperatureAdc1_ddegC[BS_NR_OF_TEMP_SENSORS_ON_ADC1]
Definition: database_cfg.h:150
imd_canDataQueue
QueueHandle_t imd_canDataQueue
Definition: no-imd.c:69
DATA_BLOCK_ID_CURRENT_SENSOR
@ DATA_BLOCK_ID_CURRENT_SENSOR
Definition: database_cfg.h:76
bigEndian
@ bigEndian
Definition: can_cfg.h:100
FAS_TRAP
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:108
DATA_BLOCK_OPENWIRE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:300
DATA_BLOCK_CELL_VOLTAGE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:119
DIAG_ID_DEEP_DISCHARGE_DETECTED
@ DIAG_ID_DEEP_DISCHARGE_DETECTED
Definition: diag_cfg.h:175
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89
CAN_RxGetSignalDataFromMessageData
static void CAN_RxGetSignalDataFromMessageData(uint64_t message, uint64_t bitStart, uint8_t bitLength, uint64_t *pSignal, CAN_byteOrder_e byteOrder)
Gets CAN signal data from a 64-bit variable. This function is used to get signal data from a 64-bit C...
Definition: can_cfg.c:847
DATA_BLOCKHEADER::timestamp
uint32_t timestamp
Definition: database_cfg.h:110
DATA_BLOCK_CURRENT_SENSOR::newPower
uint8_t newPower
Definition: database_cfg.h:223
CAN_BUFFERELEMENT::data
uint8_t data[8]
Definition: can_cfg.h:78
DATA_BLOCKHEADER::uniqueId
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:109
DATA_BLOCK_CURRENT_SENSOR::timestampPower
uint32_t timestampPower[BS_NR_OF_STRINGS]
Definition: database_cfg.h:225