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