foxBMS  1.1.2
The foxBMS Battery Management System 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-07-23 (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 "io.h"
71 #include "mcu.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 /*========== Static Constant and Variable Definitions =======================*/
99 
100 /** tracks the local state of the can module */
102  .periodicEnable = false,
103  .currentSensorPresent = {REPEAT_U(false, STRIP(BS_NR_OF_STRINGS))},
104  .currentSensorCCPresent = {REPEAT_U(false, STRIP(BS_NR_OF_STRINGS))},
105  .currentSensorECPresent = {REPEAT_U(false, STRIP(BS_NR_OF_STRINGS))},
106 };
107 
108 /*========== Extern Constant and Variable Definitions =======================*/
109 
110 /*========== Static Function Prototypes =====================================*/
111 
112 /**
113  * @brief Called in case of CAN TX interrupt.
114  * @param pNode CAN interface on which message was sent
115  * @param messageBox message box on which message was sent
116  */
117 static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox);
118 
119 /**
120  * @brief Called in case of CAN RX interrupt.
121  * @param pNode CAN interface on which message was received
122  * @param messageBox message box on which message was received
123  */
124 static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox);
125 
126 /**
127  * @brief Handles the processing of messages that are meant to be transmitted.
128  * This function looks for the repetition times and the repetition phase of
129  * messages that are intended to be sent periodically. If a comparison with
130  * an internal counter (i.e., the counter how often this function has been called)
131  * states that a transmit is pending, the message is composed by call of CANS_ComposeMessage
132  * and transferred to the buffer of the CAN module. If a callback function
133  * is declared in configuration, this callback is called after successful transmission.
134  * @return #STD_OK if a CAN transfer was made, #STD_NOT_OK otherwise
135  */
137 
138 /**
139  * @brief Checks if the CAN messages come in the specified time window
140  * If the (current time stamp) - (previous time stamp) > 96ms and < 104ms,
141  * the check is true, false otherwise. The result is reported via flags
142  * in the DIAG module.
143  */
144 static void CAN_CheckCanTiming(void);
145 
146 #if CURRENT_SENSOR_PRESENT == true
147 /**
148  * @brief Sets flag to indicate current sensor is present.
149  *
150  * @param command true if current sensor present, otherwise false
151  * @param stringNumber string addressed
152  *
153  * @return none
154  */
155 static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber);
156 
157 /**
158  * @brief Sets flag to indicate current sensor sends C-C values.
159  *
160  * @param command true if coulomb counting message detected, otherwise false
161  * @param stringNumber string addressed
162  *
163  * @return none
164  */
165 static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber);
166 
167 /**
168  * @brief Sets flag to indicate current sensor sends C-C values.
169  *
170  * @param command true if energy counting message detected, otherwise false
171  * @param stringNumber string addressed
172  *
173  * @return none
174  */
175 static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber);
176 #endif /* CURRENT_SENSOR_PRESENT == true */
177 
178 /** initialize the SPI interface to the CAN transceiver */
179 static void CAN_InitializeTransceiver(void);
180 
181 /*========== Static Function Implementations ================================*/
182 
183 static void CAN_InitializeTransceiver(void) {
184  /* set EN and STB pins to output */
187 
188  /* first set EN and STB pins to 0 */
191  /* wait after pin toggle */
193 
194  /* set EN pin to 1 */
196  /* wait after pin toggle */
198 
199  /* set STB pin to 1 */
201  /* wait after pin toggle */
203 }
204 
205 /*========== Extern Function Implementations ================================*/
206 
207 extern void CAN_Initialize(void) {
209 }
210 
211 extern STD_RETURN_TYPE_e CAN_DataSend(canBASE_t *pNode, uint32_t id, uint8 *pData) {
212  FAS_ASSERT(pNode != NULL_PTR);
213  FAS_ASSERT(pData != NULL_PTR);
214 
215  STD_RETURN_TYPE_e result = STD_NOT_OK;
216 
217  /**
218  * Parse all TX message boxes until we find a free one,
219  * then use it to send the CAN message.
220  * In the HAL, message box numbers start from 1, not 0.
221  */
222  for (uint8_t messageBox = 1u; messageBox <= CAN_NR_OF_TX_MESSAGE_BOX; messageBox++) {
223  if (canIsTxMessagePending(pNode, messageBox) == 0u) {
224  /* id shifted by 18 to use standard frame */
225  /* standard frame: bits [28:18] */
226  /* extended frame: bits [28:0] */
227  /* bit 29 set to 1: to set direction Tx in IF2ARB register */
228  canUpdateID(pNode, messageBox, ((id << 18) | (1U << 29)));
229  canTransmit(pNode, messageBox, pData);
230  result = STD_OK;
231  break;
232  }
233  }
234  return result;
235 }
236 
237 extern void CAN_MainFunction(void) {
239  if (true == can_state.periodicEnable) {
241  }
242 }
243 
245  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
246  static uint32_t counterTicks = 0;
247  uint8_t data[8] = {0};
248 
249  for (uint16_t i = 0u; i < can_txLength; i++) {
250  if (((counterTicks * CAN_TICK_MS) % (can_txMessages[i].repetitionTime)) == can_txMessages[i].repetitionPhase) {
251  if (can_txMessages[i].callbackFunction != NULL_PTR) {
254  can_txMessages[i].id,
255  can_txMessages[i].dlc,
256  can_txMessages[i].endianness,
257  data,
258  can_txMessages[i].pMuxId,
259  &can_kShim);
261  /* CAN messages are currently discarded if all message boxes
262  * are full. They will not be retransmitted within the next
263  * call of CAN_PeriodicTransmit() */
264  CAN_DataSend(CAN0_NODE, can_txMessages[i].id, data);
265  retVal = STD_OK;
266  }
267  }
268  }
269 
270  counterTicks++;
271  return retVal;
272 }
273 
274 static void CAN_CheckCanTiming(void) {
275  uint32_t current_time;
278 #if CURRENT_SENSOR_PRESENT == true
280 #endif /* CURRENT_SENSOR_PRESENT == true */
281 
282  current_time = OS_GetTickCount();
283  DATA_READ_DATA(&staterequestTab, &errorFlagsTab);
284 
285  /* Is the BMS still getting CAN messages? */
286  if ((current_time - staterequestTab.header.timestamp) <= CAN_TIMING_UPPER_LIMIT_COUNTS) {
287  if (((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) >=
289  ((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) <=
292  } else {
294  }
295  } else {
297  }
298 
299 #if CURRENT_SENSOR_PRESENT == true
300  /* check time stamps of current measurements */
301  DATA_READ_DATA(&currentTab);
302 
303  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
304  /* Current has been measured at least once */
305  if (currentTab.timestampCurrent[stringNumber] != 0u) {
306  /* Check time since last received string current data */
307  if ((current_time - currentTab.timestampCurrent[stringNumber]) >
310  } else {
312  if (can_state.currentSensorPresent[stringNumber] == false) {
313  CAN_SetCurrentSensorPresent(true, stringNumber);
314  }
315  }
316  }
317 
318  /* check time stamps of CC measurements */
319  /* if timestamp_cc != 0, this means current sensor cc message has been received at least once */
320  if (currentTab.timestampCurrentCounting[stringNumber] != 0) {
321  if ((current_time - currentTab.timestampCurrentCounting[stringNumber]) >
324  } else {
326  if (can_state.currentSensorCCPresent[stringNumber] == false) {
327  CAN_SetCurrentSensorCcPresent(true, stringNumber);
328  }
329  }
330  }
331 
332  /* check time stamps of EC measurements */
333  /* if timestamp_ec != 0, this means current sensor ec message has been received at least once */
334  if (currentTab.timestampEnergyCounting[stringNumber] != 0) {
335  if ((current_time - currentTab.timestampEnergyCounting[stringNumber]) >
338  } else {
340  if (can_state.currentSensorECPresent[stringNumber] == false) {
341  CAN_SetCurrentSensorEcPresent(true, stringNumber);
342  }
343  }
344  }
345  }
346 #endif /* CURRENT_SENSOR_PRESENT == true */
347 }
348 
349 extern void CAN_ReadRxBuffer(void) {
350  CAN_BUFFERELEMENT_s can_rxBuffer = {0};
351  if (ftsk_allQueuesCreated == true) {
352  while (pdPASS == xQueueReceive(ftsk_canRxQueue, (void *)&can_rxBuffer, 0u)) {
353  /* data queue was no empty */
354  for (uint16_t i = 0u; i < can_rxLength; i++) {
355  if (can_rxBuffer.id == can_rxMessages[i].id) {
356  if (can_rxMessages[i].callbackFunction != NULL_PTR) {
358  can_rxMessages[i].id,
359  can_rxMessages[i].dlc,
360  can_rxMessages[i].endianness,
361  can_rxBuffer.data,
362  NULL_PTR,
363  &can_kShim);
364  }
365  }
366  }
367  }
368  }
369 }
370 
371 /**
372  * @brief enable/disable the periodic transmit/receive.
373  */
374 extern void CAN_EnablePeriodic(bool command) {
375  if (command == true) {
376  can_state.periodicEnable = true;
377  } else {
378  can_state.periodicEnable = false;
379  }
380 }
381 
382 #if CURRENT_SENSOR_PRESENT == true
383 static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber) {
384  if (command == true) {
386  can_state.currentSensorPresent[stringNumber] = true;
388  } else {
390  can_state.currentSensorPresent[stringNumber] = false;
392  }
393 }
394 
395 static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber) {
396  if (command == true) {
398  can_state.currentSensorCCPresent[stringNumber] = true;
400  } else {
402  can_state.currentSensorCCPresent[stringNumber] = false;
404  }
405 }
406 
407 static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber) {
408  if (command == true) {
410  can_state.currentSensorECPresent[stringNumber] = true;
412  } else {
414  can_state.currentSensorECPresent[stringNumber] = false;
416  }
417 }
418 #endif /* CURRENT_SENSOR_PRESENT == true */
419 
420 extern bool CAN_IsCurrentSensorPresent(uint8_t stringNumber) {
421  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
422  return can_state.currentSensorPresent[stringNumber];
423 }
424 
425 extern bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber) {
426  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
427  return can_state.currentSensorCCPresent[stringNumber];
428 }
429 
430 extern bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber) {
431  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
432  return can_state.currentSensorECPresent[stringNumber];
433 }
434 
435 static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox) {
436 }
437 
438 static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) {
439  FAS_ASSERT(pNode != NULL_PTR);
440  CAN_BUFFERELEMENT_s can_rxBuffer = {0};
441  uint8_t data[8] = {0};
442  /* Read even if queues are not created, otherwise message boxes get full */
443  canGetData(pNode, messageBox, (uint8 *)&data[0]); /* copy to RAM */
444 
445  /* Check that CAN RX queue is started before using it */
446  if (ftsk_allQueuesCreated == true) {
447  if (pNode == CAN0_NODE) {
448  /* id shifted by 18 to use standard frame from IF2ARB register*/
449  /* standard frame: bits [28:18] */
450  /* extended frame: bits [28:0] */
451  uint32_t id = canGetID(pNode, messageBox) >> 18;
452  can_rxBuffer.id = id;
453  can_rxBuffer.data[0] = data[0];
454  can_rxBuffer.data[1] = data[1];
455  can_rxBuffer.data[2] = data[2];
456  can_rxBuffer.data[3] = data[3];
457  can_rxBuffer.data[4] = data[4];
458  can_rxBuffer.data[5] = data[5];
459  can_rxBuffer.data[6] = data[6];
460  can_rxBuffer.data[7] = data[7];
461  if (pdPASS == xQueueSendToBackFromISR(ftsk_canRxQueue, (void *)&can_rxBuffer, NULL)) {
462  /* queue is not full */
464  } else {
465  /* queue is full */
467  }
468  }
469  }
470 }
471 
472 /** called in case of CAN interrupt, defined as weak in HAL */
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
531 extern CAN_STATE_s *TEST_CAN_GetCANState(void) {
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:438
bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber)
get flag if CC message from current sensor is received.
Definition: can.c:425
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:237
static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
Definition: can.c:395
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:244
#define CAN_BOOT_MESSAGE_BYTE_3_BIT_DISTANCE_OVERFLOW_FLAG
Definition: can.c:93
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:274
#define CAN_TIMING_LOWER_LIMIT_COUNTS
Definition: can.c:75
static void CAN_InitializeTransceiver(void)
Definition: can.c:183
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:430
static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN TX interrupt.
Definition: can.c:435
#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:211
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:349
bool CAN_IsCurrentSensorPresent(uint8_t stringNumber)
set flag for presence of current sensor.
Definition: can.c:420
static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
Definition: can.c:407
STD_RETURN_TYPE_e CAN_TransmitBootMessage(void)
Transmit startup boot message.
Definition: can.c:481
#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:383
#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:207
static CAN_STATE_s can_state
Definition: can.c:101
void CAN_EnablePeriodic(bool command)
enable/disable the periodic transmit/receive.
Definition: can.c:374
#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:75
#define CAN0_NODE
Definition: can.h:70
#define CAN_TICK_MS
Definition: can.h:83
const CAN_MSG_RX_TYPE_s can_rxMessages[]
Definition: can_cfg.c:180
const uint8_t can_txLength
Definition: can_cfg.c:251
const CAN_MSG_TX_TYPE_s can_txMessages[]
Definition: can_cfg.c:87
const CAN_SHIM_s can_kShim
Definition: can_cfg.c:274
const uint8_t can_rxLength
Definition: can_cfg.c:252
#define CAN_HET1_GIO
Definition: can_cfg.h:224
#define CAN_PIN_TOGGLE_DELAY_US
Definition: can_cfg.h:242
#define CAN_HET1_EN_PIN
Definition: can_cfg.h:227
#define CAN_MAX_DLC
Definition: can_cfg.h:70
#define CAN_HET1_STB_PIN
Definition: can_cfg.h:229
#define CAN_ID_BOOT_MESSAGE
Definition: can_cfg.h:167
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:247
@ DIAG_STRING
Definition: diag_cfg.h:248
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:235
@ DIAG_EVENT_OK
Definition: diag_cfg.h:234
@ 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:237
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:268
#define SETBIT(register, bit)
sets a bit to 1u
Definition: general.h:80
#define REPEAT_U(x, n)
Macro that helps to generate a series of literals (for array initializers).
Definition: general.h:256
#define UNIT_TEST_WEAK_IMPL
Definition: general.h:104
void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Definition: io.c:70
void IO_PinReset(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Definition: io.c:77
Header for the driver for the IO module.
void MCU_delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
Definition: mcu.c:80
Headers for the driver for the MCU module.
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
uint8_t data[CAN_MAX_DLC]
Definition: can_cfg.h:234
uint32_t id
Definition: can_cfg.h:233
uint32_t id
Definition: can_cfg.h:335
can_callback_funcPtr callbackFunction
Definition: can_cfg.h:338
can_callback_funcPtr callbackFunction
Definition: can_cfg.h:328
Definition: can.h:93
bool currentSensorECPresent[BS_NR_OF_STRINGS]
Definition: can.h:97
bool periodicEnable
Definition: can.h:94
bool currentSensorCCPresent[BS_NR_OF_STRINGS]
Definition: can.h:96
bool currentSensorPresent[BS_NR_OF_STRINGS]
Definition: can.h:95
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:110
uint32_t timestamp
Definition: database_cfg.h:111
uint32_t previousTimestamp
Definition: database_cfg.h:112
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:215
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:220
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:235
uint32_t timestampCurrentCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:231
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:327
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:510
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