foxBMS - Unit Tests  1.2.0
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-10-12 (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) {
249  can_txMessages[i].id,
250  can_txMessages[i].dlc,
251  can_txMessages[i].endianness,
252  data,
253  can_txMessages[i].pMuxId,
254  &can_kShim);
256  /* CAN messages are currently discarded if all message boxes
257  * are full. They will not be retransmitted within the next
258  * call of CAN_PeriodicTransmit() */
259  CAN_DataSend(can_txMessages[i].canNode, can_txMessages[i].id, data);
260  retVal = STD_OK;
261  }
262  }
263  }
264 
265  counterTicks++;
266  return retVal;
267 }
268 
269 static void CAN_CheckCanTiming(void) {
270  uint32_t current_time;
273 #if CURRENT_SENSOR_PRESENT == true
275 #endif /* CURRENT_SENSOR_PRESENT == true */
276 
277  current_time = OS_GetTickCount();
278  DATA_READ_DATA(&staterequestTab, &errorFlagsTab);
279 
280  /* Is the BMS still getting CAN messages? */
281  if ((current_time - staterequestTab.header.timestamp) <= CAN_TIMING_UPPER_LIMIT_COUNTS) {
282  if (((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) >=
284  ((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) <=
287  } else {
289  }
290  } else {
292  }
293 
294 #if CURRENT_SENSOR_PRESENT == true
295  /* check time stamps of current measurements */
296  DATA_READ_DATA(&currentTab);
297 
298  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
299  /* Current has been measured at least once */
300  if (currentTab.timestampCurrent[stringNumber] != 0u) {
301  /* Check time since last received string current data */
302  if ((current_time - currentTab.timestampCurrent[stringNumber]) >
305  } else {
307  if (can_state.currentSensorPresent[stringNumber] == false) {
308  CAN_SetCurrentSensorPresent(true, stringNumber);
309  }
310  }
311  }
312 
313  /* check time stamps of CC measurements */
314  /* if timestamp_cc != 0, this means current sensor cc message has been received at least once */
315  if (currentTab.timestampCurrentCounting[stringNumber] != 0) {
316  if ((current_time - currentTab.timestampCurrentCounting[stringNumber]) >
319  } else {
321  if (can_state.currentSensorCCPresent[stringNumber] == false) {
322  CAN_SetCurrentSensorCcPresent(true, stringNumber);
323  }
324  }
325  }
326 
327  /* check time stamps of EC measurements */
328  /* if timestamp_ec != 0, this means current sensor ec message has been received at least once */
329  if (currentTab.timestampEnergyCounting[stringNumber] != 0) {
330  if ((current_time - currentTab.timestampEnergyCounting[stringNumber]) >
333  } else {
335  if (can_state.currentSensorECPresent[stringNumber] == false) {
336  CAN_SetCurrentSensorEcPresent(true, stringNumber);
337  }
338  }
339  }
340  }
341 #endif /* CURRENT_SENSOR_PRESENT == true */
342 }
343 
344 extern void CAN_ReadRxBuffer(void) {
345  CAN_BUFFERELEMENT_s can_rxBuffer = {0};
346  if (ftsk_allQueuesCreated == true) {
347  while (pdPASS == xQueueReceive(ftsk_canRxQueue, (void *)&can_rxBuffer, 0u)) {
348  /* data queue was no empty */
349  for (uint16_t i = 0u; i < can_rxLength; i++) {
350  if ((can_rxBuffer.canNode == can_rxMessages[i].canNode) && (can_rxBuffer.id == can_rxMessages[i].id)) {
351  if (can_rxMessages[i].callbackFunction != NULL_PTR) {
353  can_rxMessages[i].id,
354  can_rxMessages[i].dlc,
355  can_rxMessages[i].endianness,
356  can_rxBuffer.data,
357  NULL_PTR,
358  &can_kShim);
359  }
360  }
361  }
362  }
363  }
364 }
365 
366 /**
367  * @brief enable/disable the periodic transmit/receive.
368  */
369 extern void CAN_EnablePeriodic(bool command) {
370  if (command == true) {
371  can_state.periodicEnable = true;
372  } else {
373  can_state.periodicEnable = false;
374  }
375 }
376 
377 #if CURRENT_SENSOR_PRESENT == true
378 static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber) {
379  if (command == true) {
381  can_state.currentSensorPresent[stringNumber] = true;
383  } else {
385  can_state.currentSensorPresent[stringNumber] = false;
387  }
388 }
389 
390 static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber) {
391  if (command == true) {
393  can_state.currentSensorCCPresent[stringNumber] = true;
395  } else {
397  can_state.currentSensorCCPresent[stringNumber] = false;
399  }
400 }
401 
402 static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber) {
403  if (command == true) {
405  can_state.currentSensorECPresent[stringNumber] = true;
407  } else {
409  can_state.currentSensorECPresent[stringNumber] = false;
411  }
412 }
413 #endif /* CURRENT_SENSOR_PRESENT == true */
414 
415 extern bool CAN_IsCurrentSensorPresent(uint8_t stringNumber) {
416  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
417  return can_state.currentSensorPresent[stringNumber];
418 }
419 
420 extern bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber) {
421  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
422  return can_state.currentSensorCCPresent[stringNumber];
423 }
424 
425 extern bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber) {
426  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
427  return can_state.currentSensorECPresent[stringNumber];
428 }
429 
430 static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox) {
431 }
432 
433 static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) {
434  FAS_ASSERT(pNode != NULL_PTR);
435  CAN_BUFFERELEMENT_s can_rxBuffer = {0u};
436  uint8_t messageData[CAN_DLC] = {0u};
437  /**
438  * Read even if queues are not created, otherwise message boxes get full.
439  * Possible return values:
440  * - 0: no new data
441  * - 1: no data lost
442  * - 3: data lost */
443  uint32_t retval = canGetData(pNode, messageBox, (uint8 *)&messageData[0]); /* copy to RAM */
444 
445  /* Check that CAN RX queue is started before using it and data is valid */
446  if ((ftsk_allQueuesCreated == true) && (CAN_HAL_RETVAL_NO_DATA_LOST == retval)) {
447  /* id shifted by 18 to use standard frame from IF2ARB register*/
448  /* standard frame: bits [28:18] */
449  /* extended frame: bits [28:0] */
450  uint32_t id = canGetID(pNode, messageBox) >> 18u;
451 
452  can_rxBuffer.canNode = pNode;
453  can_rxBuffer.id = id;
454  can_rxBuffer.data[0] = messageData[0];
455  can_rxBuffer.data[1] = messageData[1];
456  can_rxBuffer.data[2] = messageData[2];
457  can_rxBuffer.data[3] = messageData[3];
458  can_rxBuffer.data[4] = messageData[4];
459  can_rxBuffer.data[5] = messageData[5];
460  can_rxBuffer.data[6] = messageData[6];
461  can_rxBuffer.data[7] = messageData[7];
462 
463  if (pdPASS == xQueueSendToBackFromISR(ftsk_canRxQueue, (void *)&can_rxBuffer, NULL)) {
464  /* queue is not full */
466  } else {
467  /* queue is full */
469  }
470  }
471 }
472 
473 /** called in case of CAN interrupt, defined as weak in HAL */
474 void UNIT_TEST_WEAK_IMPL canMessageNotification(canBASE_t *node, uint32 messageBox) {
475  if (messageBox <= CAN_NR_OF_TX_MESSAGE_BOX) {
476  CAN_TxInterrupt(node, messageBox);
477  } else {
478  CAN_RxInterrupt(node, messageBox);
479  }
480 }
481 
483  uint8_t data[] = {REPEAT_U(0u, STRIP(CAN_MAX_DLC))};
484 
485  /* Set major number */
487  /* Set minor number */
489  /* Set patch number */
491 
492  /* intermediate variable for message byte 3 */
493  uint8_t versionControlByte = 0u;
494 
495  /* Set version control flags */
497  versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_VERSION_CONTROL);
498  }
499  if (true == foxbmsVersionInfo.isDirty) {
500  versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_DIRTY_FLAG);
501  }
502  /* Set overflow flag (if release distance is larger than 31) */
504  /* we need to set the overflow flag */
505  versionControlByte |= (0x01u << CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG);
506  }
507 
508  /* Set release distance (capped to maximum value) */
509  const uint8_t distanceCapped = (uint8_t)MATH_MinimumOfTwoUint16_t(
511  versionControlByte |= (distanceCapped << CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_COUNTER);
512 
513  /* assign assembled byte to databyte */
514  data[CAN_BYTE_3_POSITION] = versionControlByte;
515 
516  /* Read out device register with unique ID */
517  uint32_t deviceRegister = systemREG1->DEVID;
518 
519  /* Set unique ID */
520  data[CAN_BYTE_4_POSITION] = (uint8_t)((deviceRegister >> 24u) & 0xFFu);
521  data[CAN_BYTE_5_POSITION] = (uint8_t)((deviceRegister >> 16u) & 0xFFu);
522  data[CAN_BYTE_6_POSITION] = (uint8_t)((deviceRegister >> 8u) & 0xFFu);
523  data[CAN_BYTE_7_POSITION] = (uint8_t)(deviceRegister & 0xFFu);
524 
526 
527  return retval;
528 }
529 
530 /*========== Getter for static Variables (Unit Test) ========================*/
531 #ifdef UNITY_UNIT_TEST
533  return &can_state;
534 }
535 #endif
536 
537 /*========== 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:433
bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber)
get flag if CC message from current sensor is received.
Definition: can.c:420
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:390
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:532
#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:269
#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:474
bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber)
get flag if EC message from current sensor is received
Definition: can.c:425
static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN TX interrupt.
Definition: can.c:430
#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:344
bool CAN_IsCurrentSensorPresent(uint8_t stringNumber)
set flag for presence of current sensor.
Definition: can.c:415
static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
Definition: can.c:402
STD_RETURN_TYPE_e CAN_TransmitBootMessage(void)
Transmit startup boot message.
Definition: can.c:482
#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:378
#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:369
#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:233
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:73
@ STD_OK
Definition: fstd_types.h:72
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:66
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
volatile bool ftsk_allQueuesCreated
Definition: ftask.c:166
QueueHandle_t ftsk_canRxQueue
Definition: ftask.c:173
Header of task driver implementation.
#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
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:178
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:174
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
Definition: os.c:182
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