foxBMS - Unit Tests  1.4.0
The foxBMS Unit Tests API Documentation
can.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, 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 can.c
44  * @author foxBMS Team
45  * @date 2019-12-04 (date of creation)
46  * @updated 2022-07-28 (date of last update)
47  * @version v1.4.0
48  * @ingroup DRIVERS
49  * @prefix CAN
50  *
51  * @brief Driver for the CAN module
52  *
53  * @details Implementation of the CAN Interrupts, initialization, buffers,
54  * receive and transmit interfaces.
55  */
56 
57 /*========== Includes =======================================================*/
58 #include "can.h"
59 
60 #include "version_cfg.h"
61 
62 #include "HL_het.h"
63 #include "HL_reg_system.h"
64 
65 #include "bender_iso165c.h"
66 #include "can_helper.h"
67 #include "database.h"
68 #include "diag.h"
69 #include "foxmath.h"
70 #include "ftask.h"
71 #include "pex.h"
72 
73 /*========== Macros and Definitions =========================================*/
74 /** lower limit of timestamp counts for a valid CAN timing */
75 #define CAN_TIMING_LOWER_LIMIT_COUNTS (95u)
76 
77 /** upper limit of timestamp counts for a valid CAN timing */
78 #define CAN_TIMING_UPPER_LIMIT_COUNTS (105u)
79 
80 /** maximum distance from release that can be encoded in the boot message */
81 #define CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE (31u)
82 #if CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE > UINT8_MAX
83 #error "This code assumes that the define is smaller or equal to UINT8_MAX")
84 #endif
85 
86 /** bit position of boot message byte 3 version control flag */
87 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL (0u)
88 
89 /** bit position of boot message byte 3 dirty flag */
90 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG (1u)
91 
92 /** bit position of boot message byte 3 release distance overflow flag */
93 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG (2u)
94 
95 /** bit position of boot message byte 3 release distance counter */
96 #define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER (3u)
97 
98 /** return value of function canGetData if no data was lost during reception */
99 #define CAN_HAL_RETVAL_NO_DATA_LOST (1u)
100 
101 /*========== Static Constant and Variable Definitions =======================*/
102 
103 /** tracks the local state of the can module */
105  .periodicEnable = false,
106  .currentSensorPresent = {GEN_REPEAT_U(false, GEN_STRIP(BS_NR_OF_STRINGS))},
107  .currentSensorCCPresent = {GEN_REPEAT_U(false, GEN_STRIP(BS_NR_OF_STRINGS))},
108  .currentSensorECPresent = {GEN_REPEAT_U(false, GEN_STRIP(BS_NR_OF_STRINGS))},
109 };
110 
111 /*========== Extern Constant and Variable Definitions =======================*/
112 
113 /*========== Static Function Prototypes =====================================*/
114 
115 /**
116  * @brief Called in case of CAN TX interrupt.
117  * @param pNode CAN interface on which message was sent
118  * @param messageBox message box on which message was sent
119  */
120 static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox);
121 
122 /**
123  * @brief Called in case of CAN RX interrupt.
124  * @param pNode CAN interface on which message was received
125  * @param messageBox message box on which message was received
126  */
127 static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox);
128 
129 /**
130  * @brief Handles the processing of messages that are meant to be transmitted.
131  * This function looks for the repetition times and the repetition phase of
132  * messages that are intended to be sent periodically. If a comparison with
133  * an internal counter (i.e., the counter how often this function has been called)
134  * states that a transmit is pending, the message is composed by call of CANS_ComposeMessage
135  * and transferred to the buffer of the CAN module. If a callback function
136  * is declared in configuration, this callback is called after successful transmission.
137  * @return #STD_OK if a CAN transfer was made, #STD_NOT_OK otherwise
138  */
140 
141 /**
142  * @brief Checks if the CAN messages come in the specified time window
143  * If the (current time stamp) - (previous time stamp) > 96ms and < 104ms,
144  * the check is true, false otherwise. The result is reported via flags
145  * in the DIAG module.
146  */
147 static void CAN_CheckCanTiming(void);
148 
149 #if CURRENT_SENSOR_PRESENT == true
150 /**
151  * @brief Sets flag to indicate current sensor is present.
152  *
153  * @param command true if current sensor present, otherwise false
154  * @param stringNumber string addressed
155  *
156  * @return none
157  */
158 static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber);
159 
160 /**
161  * @brief Sets flag to indicate current sensor sends C-C values.
162  *
163  * @param command true if coulomb counting message detected, otherwise false
164  * @param stringNumber string addressed
165  *
166  * @return none
167  */
168 static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber);
169 
170 /**
171  * @brief Sets flag to indicate current sensor sends C-C values.
172  *
173  * @param command true if energy counting message detected, otherwise false
174  * @param stringNumber string addressed
175  *
176  * @return none
177  */
178 static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber);
179 #endif /* CURRENT_SENSOR_PRESENT == true */
180 
181 /** initialize the SPI interface to the CAN transceiver */
182 static void CAN_InitializeTransceiver(void);
183 
184 /** checks that the configured message period for Tx messages is valid */
185 static void CAN_ValidateConfiguredTxMessagePeriod(void);
186 
187 /*========== Static Function Implementations ================================*/
188 
189 static void CAN_InitializeTransceiver(void) {
190  /** Initialize transceiver for CAN1 */
195 
196  /** Initialize transceiver for CAN2 */
201 }
202 
204  for (uint16_t i = 0u; i < can_txLength; i++) {
205  if (can_txMessages[i].repetitionTime == 0u) {
207  }
208  }
209 }
210 
211 /*========== Extern Function Implementations ================================*/
212 
213 extern void CAN_Initialize(void) {
216 }
217 
218 extern STD_RETURN_TYPE_e CAN_DataSend(canBASE_t *pNode, uint32_t id, uint8 *pData) {
219  FAS_ASSERT(pNode != NULL_PTR);
220  FAS_ASSERT(pData != NULL_PTR);
221  FAS_ASSERT((pNode == CAN1_NODE) || (pNode == CAN2_NODE));
222  /* AXIVION Routine Generic-MissingParameterAssert: id: parameter accepts whole range */
223 
224  STD_RETURN_TYPE_e result = STD_NOT_OK;
225 
226  /**
227  * Parse all TX message boxes until we find a free one,
228  * then use it to send the CAN message.
229  * In the HAL, message box numbers start from 1, not 0.
230  */
231  for (uint8_t messageBox = 1u; messageBox <= CAN_NR_OF_TX_MESSAGE_BOX; messageBox++) {
232  if (canIsTxMessagePending(pNode, messageBox) == 0u) {
233  /* id shifted by 18 to use standard frame */
234  /* standard frame: bits [28:18] */
235  /* extended frame: bits [28:0] */
236  /* bit 29 set to 1: to set direction Tx in IF2ARB register */
237  canUpdateID(pNode, messageBox, ((id << 18u) | (1u << 29u)));
238  canTransmit(pNode, messageBox, pData);
239  result = STD_OK;
240  break;
241  }
242  }
243  return result;
244 }
245 
246 extern void CAN_MainFunction(void) {
248  if (can_state.periodicEnable == true) {
250  }
251 }
252 
254  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
255  static uint32_t counterTicks = 0;
256  uint8_t data[8] = {0};
257 
258  for (uint16_t i = 0u; i < can_txLength; i++) {
259  if (((counterTicks * CAN_TICK_ms) % (can_txMessages[i].repetitionTime)) == can_txMessages[i].repetitionPhase) {
260  if (can_txMessages[i].callbackFunction != NULL_PTR) {
262  can_txMessages[i].id,
263  can_txMessages[i].dlc,
264  can_txMessages[i].endianness,
265  data,
266  can_txMessages[i].pMuxId,
267  &can_kShim);
268  /* CAN messages are currently discarded if all message boxes
269  * are full. They will not be retransmitted within the next
270  * call of CAN_PeriodicTransmit() */
271  CAN_DataSend(can_txMessages[i].canNode, can_txMessages[i].id, data);
272  retVal = STD_OK;
273  }
274  }
275  }
276 
277  counterTicks++;
278  return retVal;
279 }
280 
281 static void CAN_CheckCanTiming(void) {
282  uint32_t current_time;
285 #if CURRENT_SENSOR_PRESENT == true
287 #endif /* CURRENT_SENSOR_PRESENT == true */
288 
289  current_time = OS_GetTickCount();
290  DATA_READ_DATA(&staterequestTab, &errorFlagsTab);
291 
292  /* Is the BMS still getting CAN messages? */
293  if ((current_time - staterequestTab.header.timestamp) <= CAN_TIMING_UPPER_LIMIT_COUNTS) {
294  if (((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) >=
296  ((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) <=
299  } else {
301  }
302  } else {
304  }
305 
306 #if CURRENT_SENSOR_PRESENT == true
307  /* check time stamps of current measurements */
308  DATA_READ_DATA(&currentTab);
309 
310  for (uint8_t s = 0u; s < BS_NR_OF_STRINGS; s++) {
311  /* Current has been measured at least once */
312  if (currentTab.timestampCurrent[s] != 0u) {
313  /* Check time since last received string current data */
314  if ((current_time - currentTab.timestampCurrent[s]) > BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS) {
316  } else {
318  if (can_state.currentSensorPresent[s] == false) {
320  }
321  }
322  }
323 
324  /* check time stamps of CC measurements */
325  /* if timestamp_cc != 0, this means current sensor cc message has been received at least once */
326  if (currentTab.timestampCurrentCounting[s] != 0) {
327  if ((current_time - currentTab.timestampCurrentCounting[s]) >
330  } else {
332  if (can_state.currentSensorCCPresent[s] == false) {
334  }
335  }
336  }
337 
338  /* check time stamps of EC measurements */
339  /* if timestamp_ec != 0, this means current sensor ec message has been received at least once */
340  if (currentTab.timestampEnergyCounting[s] != 0) {
341  if ((current_time - currentTab.timestampEnergyCounting[s]) >
344  } else {
346  if (can_state.currentSensorECPresent[s] == false) {
348  }
349  }
350  }
351  }
352 #endif /* CURRENT_SENSOR_PRESENT == true */
353 }
354 
355 extern void CAN_ReadRxBuffer(void) {
356  CAN_BUFFERELEMENT_s can_rxBuffer = {0};
357  if (ftsk_allQueuesCreated == true) {
358  while (OS_ReceiveFromQueue(ftsk_canRxQueue, (void *)&can_rxBuffer, 0u) == OS_SUCCESS) {
359  /* data queue was not empty */
360  for (uint16_t i = 0u; i < can_rxLength; i++) {
361  if ((can_rxBuffer.canNode == can_rxMessages[i].canNode) && (can_rxBuffer.id == can_rxMessages[i].id)) {
362  if (can_rxMessages[i].callbackFunction != NULL_PTR) {
364  can_rxMessages[i].id,
365  can_rxMessages[i].dlc,
366  can_rxMessages[i].endianness,
367  can_rxBuffer.data,
368  &can_kShim);
369  }
370  }
371  }
372  }
373  }
374 }
375 
376 /**
377  * @brief enable/disable the periodic transmit/receive.
378  */
379 extern void CAN_EnablePeriodic(bool command) {
380  if (command == true) {
381  can_state.periodicEnable = true;
382  } else {
383  can_state.periodicEnable = false;
384  }
385 }
386 
387 #if CURRENT_SENSOR_PRESENT == true
388 static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber) {
389  if (command == true) {
391  can_state.currentSensorPresent[stringNumber] = true;
393  } else {
395  can_state.currentSensorPresent[stringNumber] = false;
397  }
398 }
399 
400 static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber) {
401  if (command == true) {
403  can_state.currentSensorCCPresent[stringNumber] = true;
405  } else {
407  can_state.currentSensorCCPresent[stringNumber] = false;
409  }
410 }
411 
412 static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber) {
413  if (command == true) {
415  can_state.currentSensorECPresent[stringNumber] = true;
417  } else {
419  can_state.currentSensorECPresent[stringNumber] = false;
421  }
422 }
423 #endif /* CURRENT_SENSOR_PRESENT == true */
424 
425 extern bool CAN_IsCurrentSensorPresent(uint8_t stringNumber) {
426  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
427  return can_state.currentSensorPresent[stringNumber];
428 }
429 
430 extern bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber) {
431  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
432  return can_state.currentSensorCCPresent[stringNumber];
433 }
434 
435 extern bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber) {
436  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
437  return can_state.currentSensorECPresent[stringNumber];
438 }
439 
440 static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox) {
441  /* AXIVION Routine Generic-MissingParameterAssert: pNode: unused parameter */
442  /* AXIVION Routine Generic-MissingParameterAssert: messageBox: unused parameter */
443  (void)pNode;
444  (void)messageBox;
445 }
446 
447 static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) {
448  FAS_ASSERT(pNode != NULL_PTR);
449 
450  CAN_BUFFERELEMENT_s can_rxBuffer = {0u};
451  uint8_t messageData[CAN_DLC] = {0u};
452  /**
453  * Read even if queues are not created, otherwise message boxes get full.
454  * Possible return values:
455  * - 0: no new data
456  * - 1: no data lost
457  * - 3: data lost */
458  uint32_t retval = canGetData(pNode, messageBox, (uint8 *)&messageData[0]); /* copy to RAM */
459 
460  /* Check that CAN RX queue is started before using it and data is valid */
461  if ((ftsk_allQueuesCreated == true) && (retval == CAN_HAL_RETVAL_NO_DATA_LOST)) {
462  /* id shifted by 18 to use standard frame from IF2ARB register*/
463  /* standard frame: bits [28:18] */
464  /* extended frame: bits [28:0] */
465  uint32_t id = canGetID(pNode, messageBox) >> 18u;
466 
467  can_rxBuffer.canNode = pNode;
468  can_rxBuffer.id = id;
469  can_rxBuffer.data[0] = messageData[0];
470  can_rxBuffer.data[1] = messageData[1];
471  can_rxBuffer.data[2] = messageData[2];
472  can_rxBuffer.data[3] = messageData[3];
473  can_rxBuffer.data[4] = messageData[4];
474  can_rxBuffer.data[5] = messageData[5];
475  can_rxBuffer.data[6] = messageData[6];
476  can_rxBuffer.data[7] = messageData[7];
477 
478  if (OS_SendToBackOfQueueFromIsr(ftsk_canRxQueue, (void *)&can_rxBuffer, NULL_PTR) == OS_SUCCESS) {
479  /* queue is not full */
481  } else {
482  /* queue is full */
484  }
485  }
486 }
487 
488 /** called in case of CAN interrupt, defined as weak in HAL */
489 /* AXIVION Next Codeline Style Linker-Multiple_Definition: TI HAL only provides a weak implementation */
490 void UNIT_TEST_WEAK_IMPL canMessageNotification(canBASE_t *node, uint32 messageBox) {
491  /* AXIVION Routine Generic-MissingParameterAssert: node: unchecked in interrupt */
492  /* AXIVION Routine Generic-MissingParameterAssert: messageBox: unchecked in interrupt */
493 
494  if (messageBox <= CAN_NR_OF_TX_MESSAGE_BOX) {
495  CAN_TxInterrupt(node, messageBox);
496  } else {
497  CAN_RxInterrupt(node, messageBox);
498  }
499 }
500 
502  uint8_t data[] = {GEN_REPEAT_U(0u, GEN_STRIP(CAN_MAX_DLC))};
503 
504  /* Set major number */
506  /* Set minor number */
508  /* Set patch number */
510 
511  /* intermediate variable for message byte 3 */
512  uint8_t versionControlByte = 0u;
513 
514  /* Set version control flags */
516  versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL);
517  }
519  versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG);
520  }
521  /* Set overflow flag (if release distance is larger than 31) */
523  /* we need to set the overflow flag */
524  versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG);
525  }
526 
527  /* Set release distance (capped to maximum value) */
528  const uint8_t distanceCapped = (uint8_t)MATH_MinimumOfTwoUint16_t(
530  versionControlByte |= (distanceCapped << CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER);
531 
532  /* assign assembled byte to databyte */
533  data[CAN_BYTE_3_POSITION] = versionControlByte;
534 
535  /* Read out device register with unique ID */
536  const uint32_t deviceRegister = systemREG1->DEVID;
537 
538  /* Set unique ID */
539  data[CAN_BYTE_4_POSITION] = (uint8_t)((deviceRegister >> 24u) & 0xFFu);
540  data[CAN_BYTE_5_POSITION] = (uint8_t)((deviceRegister >> 16u) & 0xFFu);
541  data[CAN_BYTE_6_POSITION] = (uint8_t)((deviceRegister >> 8u) & 0xFFu);
542  data[CAN_BYTE_7_POSITION] = (uint8_t)(deviceRegister & 0xFFu);
543 
545 
546  return retval;
547 }
548 
550  uint8_t data[] = {GEN_REPEAT_U(0u, GEN_STRIP(CAN_MAX_DLC))};
551 
552  /* Read out device register with die ID low and high */
553  const uint32_t dieIdLow = systemREG1->DIEIDL;
554  const uint32_t dieIdHigh = systemREG1->DIEIDH;
555 
556  /* set die ID */
557  /* AXIVION Disable Style Generic-NoMagicNumbers: The magic numbers are used to divide down the registers into the CAN message */
558  data[CAN_BYTE_0_POSITION] = (uint8_t)((dieIdHigh >> 24u) & 0xFFu);
559  data[CAN_BYTE_1_POSITION] = (uint8_t)((dieIdHigh >> 16u) & 0xFFu);
560  data[CAN_BYTE_2_POSITION] = (uint8_t)((dieIdHigh >> 8u) & 0xFFu);
561  data[CAN_BYTE_3_POSITION] = (uint8_t)(dieIdHigh & 0xFFu);
562  data[CAN_BYTE_4_POSITION] = (uint8_t)((dieIdLow >> 24u) & 0xFFu);
563  data[CAN_BYTE_5_POSITION] = (uint8_t)((dieIdLow >> 16u) & 0xFFu);
564  data[CAN_BYTE_6_POSITION] = (uint8_t)((dieIdLow >> 8u) & 0xFFu);
565  data[CAN_BYTE_7_POSITION] = (uint8_t)(dieIdLow & 0xFFu);
566  /* AXIVION Enable Style Generic-NoMagicNumbers: */
567 
569 
570  return retval;
571 }
572 
573 /*========== Getter for static Variables (Unit Test) ========================*/
574 #ifdef UNITY_UNIT_TEST
576  return &can_state;
577 }
578 #endif
579 
580 /*========== Externalized Static Function Implementations (Unit Test) =======*/
#define BS_COULOMB_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
#define BS_ENERGY_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
#define BS_NR_OF_STRINGS
Number of parallel strings in the battery pack.
#define BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS
Headers for the driver for the insulation monitoring.
static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN RX interrupt.
Definition: can.c:447
bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber)
get flag if CC message from current sensor is received.
Definition: can.c:430
void CAN_MainFunction(void)
Calls the functions to drive the CAN interface. Makes the CAN timing checks and sends the periodic me...
Definition: can.c:246
static void CAN_ValidateConfiguredTxMessagePeriod(void)
Definition: can.c:203
static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
Definition: can.c:400
static STD_RETURN_TYPE_e CAN_PeriodicTransmit(void)
Handles the processing of messages that are meant to be transmitted. This function looks for the repe...
Definition: can.c:253
CAN_STATE_s * TEST_CAN_GetCANState(void)
Definition: can.c:575
STD_RETURN_TYPE_e CAN_TransmitDieId(void)
Transmit chip id.
Definition: can.c:549
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG
Definition: can.c:93
#define CAN_HAL_RETVAL_NO_DATA_LOST
Definition: can.c:99
static void CAN_CheckCanTiming(void)
Checks if the CAN messages come in the specified time window If the (current time stamp) - (previous ...
Definition: can.c:281
#define CAN_TIMING_LOWER_LIMIT_COUNTS
Definition: can.c:75
static void CAN_InitializeTransceiver(void)
Definition: can.c:189
void UNIT_TEST_WEAK_IMPL canMessageNotification(canBASE_t *node, uint32 messageBox)
Definition: can.c:490
bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber)
get flag if EC message from current sensor is received
Definition: can.c:435
static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN TX interrupt.
Definition: can.c:440
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER
Definition: can.c:96
STD_RETURN_TYPE_e CAN_DataSend(canBASE_t *pNode, uint32_t id, uint8 *pData)
Sends over CAN the data passed in parameters. This function goes over the messageboxes and marks the ...
Definition: can.c:218
void CAN_ReadRxBuffer(void)
Checks the data received per CAN. A receive buffer is used because CAN frames are received in an inte...
Definition: can.c:355
bool CAN_IsCurrentSensorPresent(uint8_t stringNumber)
set flag for presence of current sensor.
Definition: can.c:425
static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
Definition: can.c:412
STD_RETURN_TYPE_e CAN_TransmitBootMessage(void)
Transmit startup boot message.
Definition: can.c:501
#define CAN_TIMING_UPPER_LIMIT_COUNTS
Definition: can.c:78
#define CAN_BOOT_MESSAGE_MAXIMUM_RELEASE_DISTANCE
Definition: can.c:81
static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor is present.
Definition: can.c:388
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG
Definition: can.c:90
void CAN_Initialize(void)
Enables the CAN transceiver.. This function sets th pins to enable the CAN transceiver....
Definition: can.c:213
static CAN_STATE_s can_state
Definition: can.c:104
void CAN_EnablePeriodic(bool command)
enable/disable the periodic transmit/receive.
Definition: can.c:379
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL
Definition: can.c:87
Header for the driver for the CAN module.
#define CAN_NR_OF_TX_MESSAGE_BOX
Definition: can.h:71
#define CAN_TICK_ms
Definition: can.h:76
const CAN_MSG_RX_TYPE_s can_rxMessages[]
Definition: can_cfg.c:201
const uint8_t can_txLength
Definition: can_cfg.c:345
const CAN_MSG_TX_TYPE_s can_txMessages[]
Definition: can_cfg.c:89
const CAN_SHIM_s can_kShim
Definition: can_cfg.c:368
const uint8_t can_rxLength
Definition: can_cfg.c:346
#define CAN2_ENABLE_PIN
Definition: can_cfg.h:81
#define CAN1_STANDBY_PIN
Definition: can_cfg.h:80
#define CAN2_NODE
Definition: can_cfg.h:72
#define CAN1_ENABLE_PIN
Definition: can_cfg.h:79
#define CAN2_STANDBY_PIN
Definition: can_cfg.h:82
#define CAN_DLC
Definition: can_cfg.h:91
#define CAN_ID_DIE_ID
Definition: can_cfg.h:98
#define CAN1_NODE
Definition: can_cfg.h:71
#define CAN_MAX_DLC
Definition: can_cfg.h:88
#define CAN_ID_BOOT_MESSAGE
Definition: can_cfg.h:96
Headers for the helper functions for the CAN module.
#define CAN_BYTE_2_POSITION
Definition: can_helper.h:71
#define CAN_BYTE_4_POSITION
Definition: can_helper.h:73
#define CAN_BYTE_0_POSITION
Definition: can_helper.h:69
#define CAN_BYTE_6_POSITION
Definition: can_helper.h:75
#define CAN_BYTE_7_POSITION
Definition: can_helper.h:76
#define CAN_BYTE_3_POSITION
Definition: can_helper.h:72
#define CAN_BYTE_5_POSITION
Definition: can_helper.h:74
#define CAN_BYTE_1_POSITION
Definition: can_helper.h:70
Database module header.
#define DATA_READ_DATA(...)
Definition: database.h:83
@ DATA_BLOCK_ID_CURRENT_SENSOR
Definition: database_cfg.h:79
@ DATA_BLOCK_ID_ERRORSTATE
Definition: database_cfg.h:86
@ DATA_BLOCK_ID_STATEREQUEST
Definition: database_cfg.h:95
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diagId, 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:231
Diagnosis driver header.
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:239
@ DIAG_EVENT_OK
Definition: diag_cfg.h:238
@ DIAG_SYSTEM
Definition: diag_cfg.h:251
@ DIAG_STRING
Definition: diag_cfg.h:252
@ DIAG_ID_CAN_CC_RESPONDING
Definition: diag_cfg.h:167
@ DIAG_ID_CAN_TIMING
Definition: diag_cfg.h:165
@ DIAG_ID_CURRENT_SENSOR_RESPONDING
Definition: diag_cfg.h:169
@ DIAG_ID_CAN_RX_QUEUE_FULL
Definition: diag_cfg.h:166
@ DIAG_ID_CAN_EC_RESPONDING
Definition: diag_cfg.h:168
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:248
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:126
uint16_t MATH_MinimumOfTwoUint16_t(const uint16_t value1, const uint16_t value2)
Returns the minimum of the passed uint16_t values.
Definition: foxmath.c:146
math library for often used math functions
STD_RETURN_TYPE_e
Definition: fstd_types.h:81
@ STD_NOT_OK
Definition: fstd_types.h:83
@ STD_OK
Definition: fstd_types.h:82
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76
Header of task driver implementation.
volatile bool ftsk_allQueuesCreated
QueueHandle_t ftsk_canRxQueue
#define GEN_REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
Definition: general.h:250
#define GEN_STRIP(x)
Definition: general.h:261
#define UNIT_TEST_WEAK_IMPL
Definition: general.h:95
@ OS_SUCCESS
Definition: os.h:78
OS_STD_RETURN_e OS_ReceiveFromQueue(OS_QUEUE xQueue, void *const pvBuffer, uint32_t ticksToWait)
Receive an item from a queue.
Definition: os_freertos.c:157
OS_STD_RETURN_e OS_SendToBackOfQueueFromIsr(OS_QUEUE xQueue, const void *const pvItemToQueue, long *const pxHigherPriorityTaskWoken)
Post an item to the back the provided queue during an ISR.
Definition: os_freertos.c:182
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:135
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:131
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
Definition: os_freertos.c:139
void PEX_SetPin(uint8_t portExpander, uint8_t pin)
sets pin to high.
Definition: pex.c:321
void PEX_SetPinDirectionOutput(uint8_t portExpander, uint8_t pin)
sets pin to input.
Definition: pex.c:394
Header for the driver for the NXP PCA9539 port expander module.
#define PEX_PORT_EXPANDER2
Definition: pex_cfg.h:75
uint8_t data[CAN_MAX_DLC]
Definition: can_cfg.h:307
canBASE_t * canNode
Definition: can_cfg.h:305
CAN_RxCallbackFunction_f callbackFunction
Definition: can_cfg.h:365
canBASE_t * canNode
Definition: can_cfg.h:361
uint32_t id
Definition: can_cfg.h:362
CAN_TxCallbackFunction_f callbackFunction
Definition: can_cfg.h:354
bool currentSensorCCPresent[BS_NR_OF_STRINGS]
Definition: can.h:82
bool currentSensorECPresent[BS_NR_OF_STRINGS]
Definition: can.h:83
bool currentSensorPresent[BS_NR_OF_STRINGS]
Definition: can.h:81
bool periodicEnable
Definition: can.h:80
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:216
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:211
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:231
uint32_t timestampCurrentCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:227
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:329
uint32_t previousTimestamp
Definition: database_cfg.h:121
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:119
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:532
const bool isDirty
Definition: version_cfg.h:80
const uint8_t major
Definition: version_cfg.h:81
const bool underVersionControl
Definition: version_cfg.h:79
const uint8_t minor
Definition: version_cfg.h:82
const uint8_t patch
Definition: version_cfg.h:83
const uint16_t distanceFromLastRelease
Definition: version_cfg.h:84
Header file for the version information that is generated by the toolchain.
const VER_VERSION_s ver_foxbmsVersionInformation
Definition: test_can.c:78