foxBMS  1.0.0
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
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
38  * ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file can.c
44  * @author foxBMS Team
45  * @date 2019-12-04 (date of creation)
46  * @updated 2021-03-29 (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 "HL_het.h"
60 
61 #include "bender_iso165c.h"
62 #include "database.h"
63 #include "diag.h"
64 #include "io.h"
65 #include "mcu.h"
66 
67 /*========== Macros and Definitions =========================================*/
68 
69 /*========== Static Constant and Variable Definitions =======================*/
70 
71 /** tracks the local state of the can module */
73  .periodicEnable = false,
74  .currentSensorPresent = false,
75  .currentSensorCCPresent = false,
76  .currentSensorECPresent = false,
77 };
78 
79 /** local buffer for receiving data from CAN */
81 
82 /** interface object for #can_rxBufferData */
84  .pRead = &can_rxBufferData[0],
85  .pWrite = &can_rxBufferData[0],
86  .length = CAN0_RX_BUFFER_LENGTH,
87 };
88 
89 /*========== Extern Constant and Variable Definitions =======================*/
90 
91 /*========== Static Function Prototypes =====================================*/
92 
93 /**
94  * @brief Called in case of CAN TX interrupt.
95  * @param pNode CAN interface on which message was sent
96  * @param messageBox message box on which message was sent
97  */
98 static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox);
99 
100 /**
101  * @brief Called in case of CAN RX interrupt.
102  * @param pNode CAN interface on which message was received
103  * @param messageBox message box on which message was received
104  */
105 static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox);
106 
107 /**
108  * @brief Handles the processing of messages that are meant to be transmitted.
109  * This function looks for the repetition times and the repetition phase of
110  * messages that are intended to be sent periodically. If a comparison with
111  * an internal counter (i.e., the counter how often this function has been called)
112  * states that a transmit is pending, the message is composed by call of CANS_ComposeMessage
113  * and transferred to the buffer of the CAN module. If a callback function
114  * is declared in configuration, this callback is called after successful transmission.
115  * @return #STD_OK if a CAN transfer was made, #STD_NOT_OK otherwise
116  */
118 
119 /**
120  * @brief Checks if the CAN messages come in the specified time window
121  * If the (current time stamp) - (previous time stamp) > 96ms and < 104ms,
122  * the check is true, false otherwise.
123  * @return true if timing is in tolerance range, false otherwise
124  */
125 static bool CAN_CheckCanTiming(void);
126 
127 #if CURRENT_SENSOR_PRESENT == true
128 /**
129  * @brief Sets flag to indicate current sensor is present.
130  *
131  * @param command true if current sensor present, otherwise false
132  * @param stringNumber string addressed
133  *
134  * @return none
135  */
136 static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber);
137 
138 /**
139  * @brief Sets flag to indicate current sensor sends C-C values.
140  *
141  * @param command true if coulomb counting message detected, otherwise false
142  * @param stringNumber string addressed
143  *
144  * @return none
145  */
146 static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber);
147 
148 /**
149  * @brief Sets flag to indicate current sensor sends C-C values.
150  *
151  * @param command true if energy counting message detected, otherwise false
152  * @param stringNumber string addressed
153  *
154  * @return none
155  */
156 static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber);
157 #endif /* CURRENT_SENSOR_PRESENT == true */
158 
159 /** initialize the SPI interface to the CAN transceiver */
160 static void CAN_InitializeTransceiver(void);
161 
162 /*========== Static Function Implementations ================================*/
163 
164 static void CAN_InitializeTransceiver(void) {
165  /* set EN and STB pins to output */
168 
169  /* first set EN and STB pins to 0 */
170  IO_PinReset((uint32_t *)&CAN_HET1_GIO->DOUT, CAN_HET1_EN_PIN);
171  IO_PinReset((uint32_t *)&CAN_HET1_GIO->DOUT, CAN_HET1_STB_PIN);
172  /* wait after pin toggle */
174 
175  /* set EN pin to 1 */
176  IO_PinSet((uint32_t *)&CAN_HET1_GIO->DOUT, CAN_HET1_EN_PIN);
177  /* wait after pin toggle */
179 
180  /* set STB pin to 1 */
181  IO_PinSet((uint32_t *)&CAN_HET1_GIO->DOUT, CAN_HET1_STB_PIN);
182  /* wait after pin toggle */
184 }
185 
186 /*========== Extern Function Implementations ================================*/
187 
188 extern void CAN_Initialize(void) {
190 }
191 
192 extern STD_RETURN_TYPE_e CAN_DataSend(canBASE_t *pNode, uint32_t id, uint8 *pData) {
193  FAS_ASSERT(pNode != NULL_PTR);
194  FAS_ASSERT(pData != NULL_PTR);
195 
196  for (uint8_t messageBox = 1u; messageBox < CAN_NR_OF_TX_MESSAGEBOX; messageBox++) {
197  if (canIsTxMessagePending(pNode, messageBox) == 0) {
198  /* id shifted by 18 to use standard frame */
199  /* standard frame: bits [28:18] */
200  /* extended frame: bits [28:0] */
201  /* bit 29 set to 1: to set direction Tx in IF2ARB register */
202  canUpdateID(pNode, messageBox, ((id << 18) | (1U << 29)));
203  canTransmit(pNode, messageBox, pData);
204  return STD_OK;
205  }
206  }
207  return STD_NOT_OK;
208 }
209 
210 extern void CAN_MainFunction(void) {
212  if (true == can_state.periodicEnable) {
214  }
215 }
216 
218  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
219  static uint32_t counterTicks = 0;
220  uint8_t data[8] = {0};
221 
222  for (uint16_t i = 0u; i < can_txLength; i++) {
223  if (((counterTicks * CAN_TICK_MS) % (can_txMessages[i].repetitionTime)) == can_txMessages[i].repetitionPhase) {
224  if (can_txMessages[i].callbackFunction != NULL_PTR) {
227  can_txMessages[i].id,
228  can_txMessages[i].dlc,
229  can_txMessages[i].byteOrder,
230  data,
231  can_txMessages[i].pMuxId);
233  CAN_DataSend(CAN0_NODE, can_txMessages[i].id, data);
234  retVal = STD_OK;
235  }
236  }
237  }
238 
239  counterTicks++;
240  return retVal;
241 }
242 
243 static bool CAN_CheckCanTiming(void) {
244  bool retVal = false;
245 
246  uint32_t current_time;
249 #if CURRENT_SENSOR_PRESENT == true
251 #endif /* CURRENT_SENSOR_PRESENT == true */
252 
253  current_time = OS_GetTickCount();
254  DATA_READ_DATA(&staterequestTab, &errorFlagsTab);
255 
256  /* Is the BMS still getting CAN messages? */
257  if ((current_time - staterequestTab.header.timestamp) <= 105) {
258  if (((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) >= 95) &&
259  ((staterequestTab.header.timestamp - staterequestTab.header.previousTimestamp) <= 105)) {
260  retVal = true;
262  } else {
263  retVal = false;
265  }
266  } else {
267  retVal = false;
269  }
270 
271 #if CURRENT_SENSOR_PRESENT == true
272  /* check time stamps of current measurements */
273  DATA_READ_DATA(&currentTab);
274 
275  for (uint8_t stringNumber = 0u; stringNumber < BS_NR_OF_STRINGS; stringNumber++) {
276  /* Current has been measured at least once */
277  if (currentTab.timestampCurrent[stringNumber] != 0u) {
278  /* Check time since last received string current data */
279  if ((current_time - currentTab.timestampCurrent[stringNumber]) >
282  } else {
284  if (can_state.currentSensorPresent[stringNumber] == false) {
285  CAN_SetCurrentSensorPresent(true, stringNumber);
286  }
287  }
288  }
289 
290  /* check time stamps of CC measurements */
291  /* if timestamp_cc != 0, this means current sensor cc message has been received at least once */
292  if (currentTab.timestampCurrentCounting[stringNumber] != 0) {
293  if ((current_time - currentTab.timestampCurrentCounting[stringNumber]) >
296  } else {
298  if (can_state.currentSensorCCPresent[stringNumber] == false) {
299  CAN_SetCurrentSensorCcPresent(true, stringNumber);
300  }
301  }
302  }
303 
304  /* check time stamps of EC measurements */
305  /* if timestamp_ec != 0, this means current sensor ec message has been received at least once */
306  if (currentTab.timestampEnergyCounting[stringNumber] != 0) {
307  if ((current_time - currentTab.timestampEnergyCounting[stringNumber]) >
310  } else {
312  if (can_state.currentSensorECPresent[stringNumber] == false) {
313  CAN_SetCurrentSensorEcPresent(true, stringNumber);
314  }
315  }
316  }
317  }
318 #endif /* CURRENT_SENSOR_PRESENT == true */
319 
320  return retVal;
321 }
322 
323 extern void CAN_ReadRxBuffer(void) {
325  for (int i = 0; i < can_rxLength; i++) {
326  if (can_rxBuffer.pRead->id == can_rxMessages[i].id) {
327  if (can_rxMessages[i].callbackFunction != NULL_PTR) {
329  can_rxMessages[i].id,
330  can_rxMessages[i].dlc,
331  can_rxMessages[i].byteOrder,
333  NULL_PTR);
334  }
335  }
336  }
340  }
341  }
342 }
343 
344 /**
345  * @brief enable/disable the periodic transmit/receive.
346  */
347 extern void CAN_EnablePeriodic(bool command) {
348  if (command == true) {
349  can_state.periodicEnable = true;
350  } else {
351  can_state.periodicEnable = false;
352  }
353 }
354 
355 #if CURRENT_SENSOR_PRESENT == true
356 static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber) {
357  if (command == true) {
359  can_state.currentSensorPresent[stringNumber] = true;
361  } else {
363  can_state.currentSensorPresent[stringNumber] = false;
365  }
366 }
367 
368 static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber) {
369  if (command == true) {
371  can_state.currentSensorCCPresent[stringNumber] = true;
373  } else {
375  can_state.currentSensorCCPresent[stringNumber] = false;
377  }
378 }
379 
380 static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber) {
381  if (command == true) {
383  can_state.currentSensorECPresent[stringNumber] = true;
385  } else {
387  can_state.currentSensorECPresent[stringNumber] = false;
389  }
390 }
391 #endif /* CURRENT_SENSOR_PRESENT == true */
392 
393 extern bool CAN_IsCurrentSensorPresent(uint8_t stringNumber) {
394  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
395  return can_state.currentSensorPresent[stringNumber];
396 }
397 
398 extern bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber) {
399  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
400  return can_state.currentSensorCCPresent[stringNumber];
401 }
402 
403 extern bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber) {
404  FAS_ASSERT(stringNumber < BS_NR_OF_STRINGS);
405  return can_state.currentSensorECPresent[stringNumber];
406 }
407 
408 static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox) {
409 }
410 
411 static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox) {
412  FAS_ASSERT(pNode != NULL_PTR);
413  uint32_t id = 0;
414  uint8_t data[8] = {0};
415  if (pNode == CAN0_NODE) {
416  canGetData(pNode, messageBox, (uint8 *)&data[0]); /* copy to RAM */
417  /* id shifted by 18 to use standard frame from IF2ARB register*/
418  /* standard frame: bits [28:18] */
419  /* extended frame: bits [28:0] */
420  id = canGetID(pNode, messageBox) >> 18;
421 
422  can_rxBuffer.pWrite->id = id;
423  can_rxBuffer.pWrite->data[0] = data[0];
424  can_rxBuffer.pWrite->data[1] = data[1];
425  can_rxBuffer.pWrite->data[2] = data[2];
426  can_rxBuffer.pWrite->data[3] = data[3];
427  can_rxBuffer.pWrite->data[4] = data[4];
428  can_rxBuffer.pWrite->data[5] = data[5];
429  can_rxBuffer.pWrite->data[6] = data[6];
430  can_rxBuffer.pWrite->data[7] = data[7];
431 
435  }
436  }
437 }
438 
439 /** called in case of CAN interrupt, defined as weak in HAL */
440 void UNIT_TEST_WEAK_IMPL canMessageNotification(canBASE_t *node, uint32 messageBox) {
441  if (messageBox <= CAN_NR_OF_TX_MESSAGEBOX) {
442  CAN_TxInterrupt(node, messageBox);
443  } else {
444  CAN_RxInterrupt(node, messageBox);
445  }
446 }
447 
448 /*========== Getter for static Variables (Unit Test) ========================*/
449 #ifdef UNITY_UNIT_TEST
450 extern CAN_STATE_s *TEST_CAN_GetCANState(void) {
451  return &can_state;
452 }
453 #endif
454 
455 /*========== Externalized Static Function Implementations (Unit Test) =======*/
CAN_PeriodicTransmit
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:217
DATA_BLOCK_CURRENT_SENSOR
Definition: database_cfg.h:209
can_rxMessages
const CAN_MSG_RX_TYPE_s can_rxMessages[]
Definition: can_cfg.c:222
DIAG_ID_CAN_EC_RESPONDING
@ DIAG_ID_CAN_EC_RESPONDING
Definition: diag_cfg.h:134
CAN0_RX_BUFFER_LENGTH
#define CAN0_RX_BUFFER_LENGTH
Definition: can.h:78
CAN_STATE::periodicEnable
bool periodicEnable
Definition: can.h:94
BS_COULOMB_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
#define BS_COULOMB_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
Definition: battery_system_cfg.h:185
DATA_BLOCK_STATEREQUEST::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:506
CAN_IsCurrentSensorCcPresent
bool CAN_IsCurrentSensorCcPresent(uint8_t stringNumber)
get flag if CC message from current sensor is received.
Definition: can.c:398
STD_RETURN_TYPE_e
enum STD_RETURN_TYPE STD_RETURN_TYPE_e
CAN_TxInterrupt
static void CAN_TxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN TX interrupt.
Definition: can.c:408
can_state
static CAN_STATE_s can_state
Definition: can.c:72
diag.h
Diagnosis driver header.
can_rxBufferData
static CAN_BUFFERELEMENT_s can_rxBufferData[CAN0_RX_BUFFER_LENGTH]
Definition: can.c:80
CAN_InitializeTransceiver
static void CAN_InitializeTransceiver(void)
Definition: can.c:164
can_rxLength
const uint8_t can_rxLength
Definition: can_cfg.c:267
CAN_STATE
Definition: can.h:93
CAN_RX_BUFFER::pRead
CAN_BUFFERELEMENT_s * pRead
Definition: can.h:87
can_txLength
const uint8_t can_txLength
Definition: can_cfg.c:266
can_txMessages
const CAN_MSG_TX_TYPE_s can_txMessages[]
Definition: can_cfg.c:180
CAN_SetCurrentSensorPresent
static void CAN_SetCurrentSensorPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor is present.
Definition: can.c:356
DIAG_EVENT_OK
@ DIAG_EVENT_OK
Definition: diag_cfg.h:201
DIAG_Handler
DIAG_RETURNTYPE_e DIAG_Handler(DIAG_ID_e diag_id, DIAG_EVENT_e event, DIAG_IMPACT_LEVEL_e impact, uint32_t data)
DIAG_Handler provides generic error handling, based on diagnosis group.
Definition: diag.c:199
CAN_MSG_RX_TYPE::id
uint32_t id
Definition: can_cfg.h:120
CAN_RX_BUFFER::pWrite
CAN_BUFFERELEMENT_s * pWrite
Definition: can.h:88
DIAG_ID_CURRENT_SENSOR_RESPONDING
@ DIAG_ID_CURRENT_SENSOR_RESPONDING
Definition: diag_cfg.h:135
CAN0_NODE
#define CAN0_NODE
Definition: can.h:70
CAN_HET1_STB_PIN
#define CAN_HET1_STB_PIN
Definition: can_cfg.h:73
FAS_ASSERT
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:237
CAN_RX_BUFFER
Definition: can.h:86
OS_ExitTaskCritical
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:178
can_rxBuffer
static CAN_RX_BUFFER_s can_rxBuffer
Definition: can.c:83
MCU_delay_us
void MCU_delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
Definition: mcu.c:80
DATA_BLOCK_CURRENT_SENSOR::timestampEnergyCounting
uint32_t timestampEnergyCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:233
OS_GetTickCount
uint32_t OS_GetTickCount(void)
Returns OS based system tick value.
Definition: os.c:182
CAN_SetCurrentSensorCcPresent
static void CAN_SetCurrentSensorCcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
Definition: can.c:368
DIAG_STRING
@ DIAG_STRING
Definition: diag_cfg.h:215
CAN_HET1_GIO
#define CAN_HET1_GIO
Definition: can_cfg.h:68
CAN_CheckCanTiming
static bool CAN_CheckCanTiming(void)
Checks if the CAN messages come in the specified time window If the (current time stamp) - (previous ...
Definition: can.c:243
mcu.h
Headers for the driver for the MCU module.
STD_OK
@ STD_OK
Definition: fstd_types.h:72
CAN_HET1_EN_PIN
#define CAN_HET1_EN_PIN
Definition: can_cfg.h:71
DIAG_SYSTEM
@ DIAG_SYSTEM
Definition: diag_cfg.h:214
CAN_Initialize
void CAN_Initialize(void)
Enables the CAN transceiver.. This function sets th pins to enable the CAN transceiver....
Definition: can.c:188
CAN_SetCurrentSensorEcPresent
static void CAN_SetCurrentSensorEcPresent(bool command, uint8_t stringNumber)
Sets flag to indicate current sensor sends C-C values.
Definition: can.c:380
CAN_MainFunction
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:210
DATA_BLOCK_CURRENT_SENSOR::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:213
OS_EnterTaskCritical
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os.c:174
DIAG_ID_CAN_CC_RESPONDING
@ DIAG_ID_CAN_CC_RESPONDING
Definition: diag_cfg.h:133
CAN_MSG_RX_TYPE::callbackFunction
can_callback_funcPtr callbackFunction
Definition: can_cfg.h:124
CAN_TICK_MS
#define CAN_TICK_MS
Definition: can.h:83
CAN_BUFFERELEMENT::id
uint32_t id
Definition: can_cfg.h:77
STD_NOT_OK
@ STD_NOT_OK
Definition: fstd_types.h:73
CAN_STATE::currentSensorCCPresent
bool currentSensorCCPresent[BS_NR_OF_STRINGS]
Definition: can.h:96
CAN_PIN_TOGGLE_DELAY_US
#define CAN_PIN_TOGGLE_DELAY_US
Definition: can_cfg.h:95
CAN_STATE::currentSensorECPresent
bool currentSensorECPresent[BS_NR_OF_STRINGS]
Definition: can.h:97
DATA_BLOCKHEADER::previousTimestamp
uint32_t previousTimestamp
Definition: database_cfg.h:111
DATA_BLOCK_CURRENT_SENSOR::timestampCurrent
uint32_t timestampCurrent[BS_NR_OF_STRINGS]
Definition: database_cfg.h:218
BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS
#define BS_CURRENT_MEASUREMENT_RESPONSE_TIMEOUT_MS
Definition: battery_system_cfg.h:182
DIAG_EVENT_NOT_OK
@ DIAG_EVENT_NOT_OK
Definition: diag_cfg.h:202
DATA_BLOCK_ID_STATEREQUEST
@ DATA_BLOCK_ID_STATEREQUEST
Definition: database_cfg.h:92
IO_PinReset
void IO_PinReset(uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Definition: io.c:79
DATA_BLOCK_ERRORSTATE::header
DATA_BLOCK_HEADER_s header
Definition: database_cfg.h:324
DATA_READ_DATA
#define DATA_READ_DATA(...)
Definition: database.h:72
CAN_IsCurrentSensorPresent
bool CAN_IsCurrentSensorPresent(uint8_t stringNumber)
set flag for presence of current sensor.
Definition: can.c:393
CAN_BUFFERELEMENT
Definition: can_cfg.h:76
DATA_BLOCK_ID_ERRORSTATE
@ DATA_BLOCK_ID_ERRORSTATE
Definition: database_cfg.h:83
DATA_BLOCK_ERRORSTATE
Definition: database_cfg.h:320
CAN_RxInterrupt
static void CAN_RxInterrupt(canBASE_t *pNode, uint32 messageBox)
Called in case of CAN RX interrupt.
Definition: can.c:411
database.h
Database module header.
NULL_PTR
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:66
DIAG_ID_CAN_TIMING
@ DIAG_ID_CAN_TIMING
Definition: diag_cfg.h:132
io.h
Header for the driver for the IO module.
BS_ENERGY_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
#define BS_ENERGY_COUNTING_MEASUREMENT_RESPONSE_TIMEOUT_MS
Definition: battery_system_cfg.h:188
DATA_BLOCK_CURRENT_SENSOR::timestampCurrentCounting
uint32_t timestampCurrentCounting[BS_NR_OF_STRINGS]
Definition: database_cfg.h:229
DATA_BLOCK_STATEREQUEST
Definition: database_cfg.h:502
can.h
Header for the driver for the CAN module.
CAN_IsCurrentSensorEcPresent
bool CAN_IsCurrentSensorEcPresent(uint8_t stringNumber)
get flag if EC message from current sensor is received
Definition: can.c:403
CAN_ReadRxBuffer
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:323
DATA_BLOCK_ID_CURRENT_SENSOR
@ DATA_BLOCK_ID_CURRENT_SENSOR
Definition: database_cfg.h:76
CAN_MSG_TX_TYPE::callbackFunction
can_callback_funcPtr callbackFunction
Definition: can_cfg.h:114
IO_PinSet
void IO_PinSet(uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Definition: io.c:72
CAN_STATE::currentSensorPresent
bool currentSensorPresent[BS_NR_OF_STRINGS]
Definition: can.h:95
UNIT_TEST_WEAK_IMPL
#define UNIT_TEST_WEAK_IMPL
Definition: general.h:104
CAN_NR_OF_TX_MESSAGEBOX
#define CAN_NR_OF_TX_MESSAGEBOX
Definition: can.h:75
BS_NR_OF_STRINGS
#define BS_NR_OF_STRINGS
Definition: battery_system_cfg.h:89
CAN_DataSend
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:192
CAN_EnablePeriodic
void CAN_EnablePeriodic(bool command)
enable/disable the periodic transmit/receive.
Definition: can.c:347
SETBIT
#define SETBIT(register, bit)
sets a bit to 1u
Definition: general.h:80
DATA_BLOCKHEADER::timestamp
uint32_t timestamp
Definition: database_cfg.h:110
CAN_BUFFERELEMENT::data
uint8_t data[8]
Definition: can_cfg.h:78
DATA_BLOCKHEADER::uniqueId
DATA_BLOCK_ID_e uniqueId
Definition: database_cfg.h:109
canMessageNotification
void UNIT_TEST_WEAK_IMPL canMessageNotification(canBASE_t *node, uint32 messageBox)
Definition: can.c:440