foxBMS  1.5.0
The foxBMS Battery Management System API Documentation
can_cbs_rx_debug.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2023, 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_cbs_rx_debug.c
44  * @author foxBMS Team
45  * @date 2021-04-20 (date of creation)
46  * @updated 2023-02-03 (date of last update)
47  * @version v1.5.0
48  * @ingroup DRIVER
49  * @prefix CANRX
50  *
51  * @brief CAN driver Rx callback implementation
52  * @details CAN Rx callback for the debug message
53  */
54 
55 /*========== Includes =======================================================*/
56 #include "can_cbs_rx.h"
60 #include "can_helper.h"
61 #include "fram.h"
62 #include "ftask.h"
63 #include "reset.h"
64 #include "rtc.h"
65 
66 #include <stdbool.h>
67 #include <stdint.h>
68 
69 /*========== Macros and Definitions =========================================*/
70 
71 #define CANRX_BIT (1u)
72 
73 /** @{
74  * multiplexer setup for the debug message
75  */
76 #define CANRX_DEBUG_MESSAGE_MUX_START_BIT (0x7u)
77 #define CANRX_DEBUG_MESSAGE_MUX_LENGTH (8u)
78 /** @} */
79 
80 /** @{
81  * supported multiplexer values
82  */
83 #define CANRX_DEBUG_MESSAGE_MUX_VALUE_VERSION_INFORMATION (0x00u)
84 #define CANRX_DEBUG_MESSAGE_MUX_VALUE_RTC (0x01u)
85 #define CANRX_DEBUG_MESSAGE_MUX_VALUE_SOFTWARE_RESET (0x02u)
86 #define CANRX_DEBUG_MESSAGE_MUX_VALUE_FRAM_INITIALIZATION (0x03u)
87 #define CANRX_DEBUG_MESSAGE_MUX_VALUE_TIME_INFO (0x04u)
88 /** @} */
89 
90 /** @{
91  * configuration of the version information signals for multiplexer
92  * 'VersionInformation' in the 'Debug message
93  */
94 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_BMS_SOFTWARE_VERSION_START_BIT (8u)
95 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_BMS_SOFTWARE_VERSION_LENGTH (CANRX_BIT)
96 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_UNIQUE_DIE_ID_START_BIT (9u)
97 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_UNIQUE_DIE_ID_LENGTH (CANRX_BIT)
98 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_LOT_NUMBER_START_BIT (10u)
99 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_LOT_NUMBER_LENGTH (CANRX_BIT)
100 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_WAFER_INFORMATION_START_BIT (11u)
101 #define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_WAFER_INFORMATION_LENGTH (CANRX_BIT)
102 /** @} */
103 
104 /** @{
105  * configuration of the RTC signals for multiplexer 'RTC' in the 'Debug'
106  * message
107  */
108 #define CANRX_MUX_RTC_SIGNAL_HUNDREDTH_OF_SECONDS_START_BIT (15u)
109 #define CANRX_MUX_RTC_SIGNAL_HUNDREDTH_OF_SECONDS_LENGTH (7u)
110 #define CANRX_MUX_RTC_SIGNAL_SECONDS_START_BIT (8u)
111 #define CANRX_MUX_RTC_SIGNAL_SECONDS_LENGTH (6u)
112 #define CANRX_MUX_RTC_SIGNAL_MINUTES_START_BIT (18u)
113 #define CANRX_MUX_RTC_SIGNAL_MINUTES_LENGTH (6u)
114 #define CANRX_MUX_RTC_SIGNAL_HOURS_START_BIT (28u)
115 #define CANRX_MUX_RTC_SIGNAL_HOURS_LENGTH (5u)
116 #define CANRX_MUX_RTC_SIGNAL_WEEKDAY_START_BIT (39u)
117 #define CANRX_MUX_RTC_SIGNAL_WEEKDAY_LENGTH (3u)
118 #define CANRX_MUX_RTC_SIGNAL_DAY_START_BIT (36u)
119 #define CANRX_MUX_RTC_SIGNAL_DAY_LENGTH (5u)
120 #define CANRX_MUX_RTC_SIGNAL_MONTH_START_BIT (47u)
121 #define CANRX_MUX_RTC_SIGNAL_MONTH_LENGTH (4u)
122 #define CANRX_MUX_RTC_SIGNAL_YEAR_START_BIT (43u)
123 #define CANRX_MUX_RTC_SIGNAL_YEAR_LENGTH (7u)
124 /** @} */
125 
126 /** @{
127  * configuration of the software reset signals for multiplexer 'SoftwareReset'
128  * in the 'Debug' message
129  */
130 #define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_SOFTWARE_RESET_START_BIT (39u)
131 #define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_SOFTWARE_RESET_LENGTH (CANRX_BIT)
132 /** @} */
133 
134 /** @{
135  * configuration of the FRAM initialization signals for multiplexer 'InitializeFram'
136  * in the 'Debug' message
137  */
138 #define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_FRAM_INITIALIZATION_START_BIT (27u)
139 #define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_FRAM_INITIALIZATION_LENGTH (CANRX_BIT)
140 /** @} */
141 
142 /** @{
143  * configuration of the time info signals for multiplexer 'TimeInfo'
144  * in the 'Debug' message
145  */
146 #define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_REQUEST_RTC_TIME_START_BIT (8u)
147 #define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_REQUEST_RTC_TIME_LENGTH (CANRX_BIT)
148 /** @} */
149 
150 /*========== Static Constant and Variable Definitions =======================*/
151 
152 /*========== Extern Constant and Variable Definitions =======================*/
153 
154 /*========== Static Function Prototypes =====================================*/
155 
156 /**
157  * @brief Parses CAN message to handle version related messages
158  * @param messageData message data of the CAN message
159  * @param endianness endianness of the message
160  */
161 static void CANRX_ProcessVersionInformationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness);
162 
163 /**
164  * @brief Parses CAN message to set the RTC clock
165  * @param messageData message data of the CAN message
166  * @param endianness endianness of the message
167  */
168 static void CANRX_ProcessRtcMux(uint64_t messageData, CAN_ENDIANNESS_e endianness);
169 
170 /**
171  * @brief Parses CAN message to handle software related requests, e.g., a
172  * software reset of the BMS
173  * @param messageData message data of the CAN message
174  * @param endianness endianness of the message
175  */
176 static void CANRX_ProcessSoftwareResetMux(uint64_t messageData, CAN_ENDIANNESS_e endianness);
177 
178 /**
179  * @brief Parses CAN message related to FRAM initialization
180  * @param messageData message data of the CAN message
181  * @param endianness endianness of the message
182  */
183 static void CANRX_ProcessFramInitializationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness);
184 
185 /**
186  * @brief Parses CAN message to handle time information requests
187  * @param messageData message data of the CAN message
188  * @param endianness endianness of the message
189  */
190 static void CANRX_ProcessTimeInfoMux(uint64_t messageData, CAN_ENDIANNESS_e endianness);
191 
192 /**
193  * @brief Parses the CAN message to retrieve the hundredth of seconds
194  * information
195  * @param messageData message data of the CAN message
196  * @param endianness endianness of the message
197  * @returns Decoded hundredth of seconds information
198  */
199 static uint8_t CANRX_GetHundredthOfSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness);
200 
201 /**
202  * @brief Parses the CAN message to retrieve the seconds information
203  * @param messageData message data of the CAN message
204  * @param endianness endianness of the message
205  * @returns Decoded seconds information
206  */
207 static uint8_t CANRX_GetSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness);
208 
209 /**
210  * @brief Parses the CAN message to retrieve the minutes information
211  * @param messageData message data of the CAN message
212  * @param endianness endianness of the message
213  * @returns Decoded minutes information
214  */
215 static uint8_t CANRX_GetMinutes(uint64_t messageData, CAN_ENDIANNESS_e endianness);
216 
217 /**
218  * @brief Parses the CAN message to retrieve the hours information
219  * @param messageData message data of the CAN message
220  * @param endianness endianness of the message
221  * @returns Decoded hours information
222  */
223 static uint8_t CANRX_GetHours(uint64_t messageData, CAN_ENDIANNESS_e endianness);
224 
225 /**
226  * @brief Parses the CAN message to retrieve the weekday information
227  * @param messageData message data of the CAN message
228  * @param endianness endianness of the message
229  * @returns Decoded weekday information
230  */
231 static uint8_t CANRX_GetWeekday(uint64_t messageData, CAN_ENDIANNESS_e endianness);
232 
233 /**
234  * @brief Parses the CAN message to retrieve the day information
235  * @param messageData message data of the CAN message
236  * @param endianness endianness of the message
237  * @returns Decoded Day information
238  */
239 static uint8_t CANRX_GetDay(uint64_t messageData, CAN_ENDIANNESS_e endianness);
240 
241 /**
242  * @brief Parses the CAN message to retrieve the month information
243  * @param messageData message data of the CAN message
244  * @param endianness endianness of the message
245 * @returns Decoded month information
246  */
247 static uint8_t CANRX_GetMonth(uint64_t messageData, CAN_ENDIANNESS_e endianness);
248 
249 /**
250  * @brief Parses the CAN message to retrieve the year information
251  * @param messageData message data of the CAN message
252  * @param endianness endianness of the message
253 * @returns Decoded year information
254  */
255 static uint8_t CANRX_GetYear(uint64_t messageData, CAN_ENDIANNESS_e endianness);
256 
257 /**
258  * @brief Check if the BMS software version information is requested
259  * @param messageData message data of the CAN message
260  * @param endianness endianness of the message
261  * @returns true if the information is requested, false otherwise
262  */
263 static bool CANRX_CheckIfBmsSoftwareVersionIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness);
264 
265 /**
266  * @brief Triggers sending of the BMS software version information message
267  */
269 
270 /**
271  * @brief Check if the MCU die ID information is requested
272  * @param messageData message data of the CAN message
273  * @param endianness endianness of the message
274  * @returns true if the information is requested, false otherwise
275  */
276 static bool CANRX_CheckIfMcuUniqueDieIdIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness);
277 
278 /**
279  * @brief Triggers sending of the MCU die ID information message
280  */
281 static void CANRX_TriggerMcuUniqueDieIdMessage(void);
282 
283 /**
284  * @brief Check if the MCU lot number information is requested
285  * @param messageData message data of the CAN message
286  * @param endianness endianness of the message
287  * @returns true if the information is requested, false otherwise
288  */
289 static bool CANRX_CheckIfMcuLotNumberIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness);
290 
291 /**
292  * @brief Triggers sending of the MCU lot number information message
293  */
294 static void CANRX_TriggerMcuLotNumberMessage(void);
295 
296 /**
297  * @brief Check if the MCU wafer information is requested
298  * @param messageData message data of the CAN message
299  * @param endianness endianness of the message
300  * @returns true if the information is requested, false otherwise
301  */
302 static bool CANRX_CheckIfMcuWaferInformationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness);
303 
304 /**
305  * @brief Triggers sending of the MCU wafer information message
306  */
308 
309 /**
310  * @brief Check if a software reset is requested
311  * @param messageData message data of the CAN message
312  * @param endianness endianness of the message
313  * @returns true if software reset is requested, false otherwise
314  */
315 static bool CANRX_CheckIfSoftwareResetIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness);
316 
317 /**
318  * @brief Check if a FRAM initialization is requested
319  * @param messageData message data of the CAN message
320  * @param endianness endianness of the message
321  * @returns true if software reset is requested, false otherwise
322  */
323 static bool CANRX_CheckIfFramInitializationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness);
324 
325 /**
326  * @brief Check if the RTC time information is requested
327  * @param messageData message data of the CAN message
328  * @param endianness endianness of the message
329  * @returns true if the information is requested, false otherwise
330  */
331 static bool CANRX_CheckIfTimeInfoIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness);
332 
333 /**
334  * @brief Triggers sending of the RTC time information message
335  */
336 static void CANRX_TriggerTimeInfoMessage(void);
337 
338 /*========== Static Function Implementations ================================*/
339 
340 static uint8_t CANRX_GetHundredthOfSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
341  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
342  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
343 
344  uint64_t signalData = 0u;
345  /* Get hundredth of seconds information form the message and return that value */
347  messageData,
350  &signalData,
351  endianness);
352  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
353  return (uint8_t)signalData;
354 }
355 
356 static uint8_t CANRX_GetSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
357  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
358  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
359 
360  uint64_t signalData = 0u;
361  /* Get seconds information form the message and return that value */
363  messageData,
366  &signalData,
367  endianness);
368 
369  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
370  return (uint8_t)signalData;
371 }
372 
373 static uint8_t CANRX_GetMinutes(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
374  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
375  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
376 
377  uint64_t signalData = 0u;
378  /* Get minutes information form the message and return that value */
380  messageData,
383  &signalData,
384  endianness);
385 
386  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
387  return (uint8_t)signalData;
388 }
389 
390 static uint8_t CANRX_GetHours(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
391  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
392  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
393 
394  uint64_t signalData = 0u;
395  /* Get hour information form the message and return that value */
397  messageData, CANRX_MUX_RTC_SIGNAL_HOURS_START_BIT, CANRX_MUX_RTC_SIGNAL_HOURS_LENGTH, &signalData, endianness);
398 
399  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
400  return (uint8_t)signalData;
401 }
402 
403 static uint8_t CANRX_GetWeekday(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
404  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
405  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
406 
407  uint64_t signalData = 0u;
408  /* Get weekday information form the message and return that value */
410  messageData,
413  &signalData,
414  endianness);
415 
416  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
417  return (uint8_t)signalData;
418 }
419 
420 static uint8_t CANRX_GetDay(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
421  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
422  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
423 
424  uint64_t signalData = 0u;
425  /* Get day information form the message and return that value */
427  messageData, CANRX_MUX_RTC_SIGNAL_DAY_START_BIT, CANRX_MUX_RTC_SIGNAL_DAY_LENGTH, &signalData, endianness);
428 
429  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
430  return (uint8_t)signalData;
431 }
432 
433 static uint8_t CANRX_GetMonth(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
434  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
435  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
436 
437  /* Get month information form the message and return that value */
438  uint64_t signalData = 0u;
440  messageData, CANRX_MUX_RTC_SIGNAL_MONTH_START_BIT, CANRX_MUX_RTC_SIGNAL_MONTH_LENGTH, &signalData, endianness);
441 
442  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
443  return (uint8_t)signalData;
444 }
445 
446 static uint8_t CANRX_GetYear(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
447  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
448  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
449 
450  /* Get year information form the message and return that value */
451  uint64_t signalData = 0u;
453  messageData, CANRX_MUX_RTC_SIGNAL_YEAR_START_BIT, CANRX_MUX_RTC_SIGNAL_YEAR_LENGTH, &signalData, endianness);
454 
455  /* AXIVION Next Codeline Style MisraC2012Directive-4.1: only first byte is of interest */
456  return (uint8_t)signalData;
457 }
458 
459 static void CANRX_ProcessRtcMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
460  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
461  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
462 
463  RTC_TIME_DATA_s time = {0};
464 
465  time.hundredthOfSeconds = CANRX_GetHundredthOfSeconds(messageData, endianness);
466  time.seconds = CANRX_GetSeconds(messageData, endianness);
467  time.minutes = CANRX_GetMinutes(messageData, endianness);
468  time.hours = CANRX_GetHours(messageData, endianness);
469  time.weekday = CANRX_GetWeekday(messageData, endianness);
470  time.day = CANRX_GetDay(messageData, endianness);
471  time.month = CANRX_GetMonth(messageData, endianness);
472  time.year = CANRX_GetYear(messageData, endianness);
473  if (OS_SendToBackOfQueue(ftsk_rtcSetTimeQueue, (void *)&time, 0u) == OS_SUCCESS) {
474  /* queue is not full */
475  }
476 }
477 
478 static bool CANRX_CheckIfBmsSoftwareVersionIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
479  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
480  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
481 
482  bool isRequested = false;
483  uint64_t signalData = 0u;
484 
485  /* get BMS software version information bit from the CAN message */
487  messageData,
490  &signalData,
491  endianness);
492  if (signalData == 1u) {
493  isRequested = true;
494  }
495  return isRequested;
496 }
497 
499  /* send the debug message containing the BMS software version information and trap if this does not work */
502  }
503 }
504 
505 static bool CANRX_CheckIfMcuUniqueDieIdIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
506  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
507  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
508 
509  bool isRequested = false;
510  uint64_t signalData = 0u;
511 
512  /* get MCU unique die id information bit from the CAN message */
514  messageData,
517  &signalData,
518  endianness);
519  if (signalData == 1u) {
520  isRequested = true;
521  }
522  return isRequested;
523 }
524 
526  /* send the debug message containing the MCU unique die id information and trap if this does not work */
529  }
530 }
531 
532 static bool CANRX_CheckIfMcuLotNumberIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
533  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
534  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
535 
536  bool isRequested = false;
537  uint64_t signalData = 0u;
538 
539  /* get MCU lot number information bit from the CAN message */
541  messageData,
544  &signalData,
545  endianness);
546  if (signalData == 1u) {
547  isRequested = true;
548  }
549  return isRequested;
550 }
551 
553  /* send the debug message containing the MCU lot number information and trap if this does not work */
556  }
557 }
558 
559 static bool CANRX_CheckIfMcuWaferInformationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
560  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
561  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
562 
563  bool isRequested = false;
564  uint64_t signalData = 0u;
565 
566  /* get MCU wafer information bit from the CAN message */
568  messageData,
571  &signalData,
572  endianness);
573  if (signalData == 1u) {
574  isRequested = true;
575  }
576  return isRequested;
577 }
578 
580  /* send the debug message containing the MCU wafer information and trap if this does not work */
583  }
584 }
585 
586 static void CANRX_ProcessVersionInformationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
587  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
588  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
589 
590  /* check if any of the version information is requested and if so transmit the information */
591  if (CANRX_CheckIfBmsSoftwareVersionIsRequested(messageData, endianness) == true) {
593  }
594  if (CANRX_CheckIfMcuUniqueDieIdIsRequested(messageData, endianness) == true) {
596  }
597  if (CANRX_CheckIfMcuLotNumberIsRequested(messageData, endianness) == true) {
599  }
600  if (CANRX_CheckIfMcuWaferInformationIsRequested(messageData, endianness) == true) {
602  }
603 }
604 
605 static bool CANRX_CheckIfSoftwareResetIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
606  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
607  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
608 
609  bool isRequested = false;
610  uint64_t signalData = 0u;
611 
612  /* get software reset bit from the CAN message */
614  messageData,
617  &signalData,
618  endianness);
619  if (signalData == 1u) {
620  isRequested = true;
621  }
622  return isRequested;
623 }
624 
625 static bool CANRX_CheckIfFramInitializationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
626  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
627  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
628 
629  bool isRequested = false;
630  uint64_t signalData = 0u;
631 
632  /* get software reset bit from the CAN message */
634  messageData,
637  &signalData,
638  endianness);
639  if (signalData == 1u) {
640  isRequested = true;
641  }
642  return isRequested;
643 }
644 
645 static void CANRX_ProcessSoftwareResetMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
646  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
647  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
648 
649  /* trigger software reset, if requested*/
650  if (CANRX_CheckIfSoftwareResetIsRequested(messageData, endianness) == true) {
652  }
653 }
654 
655 static void CANRX_ProcessFramInitializationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
656  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
657  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
658 
659  /* trigger FRAM initialization, if requested*/
660  if (CANRX_CheckIfFramInitializationIsRequested(messageData, endianness) == true) {
662  }
663 }
664 
665 static void CANRX_ProcessTimeInfoMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
666  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
667  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
668 
669  /* trigger RTC time information message, if requested*/
670  if (CANRX_CheckIfTimeInfoIsRequested(messageData, endianness) == true) {
672  }
673 }
674 
675 static bool CANRX_CheckIfTimeInfoIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
676  /* AXIVION Routine Generic-MissingParameterAssert: messageData: parameter accept whole range */
677  FAS_ASSERT(endianness == CAN_BIG_ENDIAN);
678 
679  bool isRequested = false;
680  uint64_t signalData = 0u;
681 
682  /* get RTC time information bit from the CAN message */
684  messageData,
687  &signalData,
688  endianness);
689  if (signalData == 1u) {
690  isRequested = true;
691  }
692  return isRequested;
693 }
694 
695 static void CANRX_TriggerTimeInfoMessage(void) {
696  /* send the debug message containing the RTC time information and trap if this does not work */
699  }
700 }
701 
702 /*========== Extern Function Implementations ================================*/
703 extern uint32_t CANRX_Debug(
704  CAN_MESSAGE_PROPERTIES_s message,
705  const uint8_t *const kpkCanData,
706  const CAN_SHIM_s *const kpkCanShim) {
707  FAS_ASSERT(message.id == CANRX_DEBUG_ID);
710  FAS_ASSERT(kpkCanData != NULL_PTR);
711  FAS_ASSERT(kpkCanShim != NULL_PTR);
712 
713  uint64_t messageData = 0u;
714  uint64_t muxValue = 0u;
715 
716  /* Get the message data and retrieve the multiplexer value from it*/
717  CAN_RxGetMessageDataFromCanData(&messageData, kpkCanData, message.endianness);
720 
721  /* process the respective handler function per supported multiplexer value;
722  in case of an unsupported multiplexer value, transmit that information
723  on the CAN bus. */
724  switch (muxValue) {
726  CANRX_ProcessVersionInformationMux(messageData, message.endianness);
727  break;
729  CANRX_ProcessRtcMux(messageData, message.endianness);
730  break;
732  CANRX_ProcessSoftwareResetMux(messageData, message.endianness);
733  break;
735  CANRX_ProcessFramInitializationMux(messageData, message.endianness);
736  break;
738  CANRX_ProcessTimeInfoMux(messageData, message.endianness);
739  break;
740  default:
741  CANTX_UnsupportedMultiplexerValue(message.id, (uint32_t)muxValue);
742  break;
743  }
744  return 0u;
745 }
746 
747 /*========== Externalized Static Function Implementations (Unit Test) =======*/
748 #ifdef UNITY_UNIT_TEST
749 
750 /* export RTC helper functions */
751 extern uint8_t TEST_CANRX_GetHundredthOfSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
752  return CANRX_GetHundredthOfSeconds(messageData, endianness);
753 }
754 extern uint8_t TEST_CANRX_GetSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
755  return CANRX_GetSeconds(messageData, endianness);
756 }
757 extern uint8_t TEST_CANRX_GetMinutes(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
758  return CANRX_GetMinutes(messageData, endianness);
759 }
760 extern uint8_t TEST_CANRX_GetHours(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
761  return CANRX_GetHours(messageData, endianness);
762 }
763 extern uint8_t TEST_CANRX_GetWeekday(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
764  return CANRX_GetWeekday(messageData, endianness);
765 }
766 extern uint8_t TEST_CANRX_GetDay(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
767  return CANRX_GetDay(messageData, endianness);
768 }
769 extern uint8_t TEST_CANRX_GetMonth(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
770  return CANRX_GetMonth(messageData, endianness);
771 }
772 extern uint8_t TEST_CANRX_GetYear(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
773  return CANRX_GetYear(messageData, endianness);
774 }
775 
776 /* export actions */
777 extern void TEST_CANRX_TriggerBmsSoftwareVersionMessage(void) {
779 }
780 extern void TEST_CANRX_TriggerMcuUniqueDieIdMessage(void) {
782 }
783 extern void TEST_CANRX_TriggerMcuLotNumberMessage(void) {
785 }
786 extern void TEST_CANRX_TriggerMcuWaferInformationMessage(void) {
788 }
789 extern void TEST_CANRX_TriggerTimeInfoMessage(void) {
791 }
792 
793 /* export check if functions */
794 extern bool TEST_CANRX_CheckIfBmsSoftwareVersionIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
795  return CANRX_CheckIfBmsSoftwareVersionIsRequested(messageData, endianness);
796 }
797 extern bool TEST_CANRX_CheckIfMcuUniqueDieIdIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
798  return CANRX_CheckIfMcuUniqueDieIdIsRequested(messageData, endianness);
799 }
800 extern bool TEST_CANRX_CheckIfMcuLotNumberIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
801  return CANRX_CheckIfMcuLotNumberIsRequested(messageData, endianness);
802 }
803 extern bool TEST_CANRX_CheckIfMcuWaferInformationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
804  return CANRX_CheckIfMcuWaferInformationIsRequested(messageData, endianness);
805 }
806 extern bool TEST_CANRX_CheckIfSoftwareResetIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
807  return CANRX_CheckIfSoftwareResetIsRequested(messageData, endianness);
808 }
809 extern bool TEST_CANRX_CheckIfFramInitializationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
810  return CANRX_CheckIfFramInitializationIsRequested(messageData, endianness);
811 }
812 extern bool TEST_CANRX_CheckIfTimeInfoIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
813  return CANRX_CheckIfTimeInfoIsRequested(messageData, endianness);
814 }
815 
816 /* export mux processing functions */
817 extern void TEST_CANRX_ProcessVersionInformationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
818  CANRX_ProcessVersionInformationMux(messageData, endianness);
819 }
820 extern void TEST_CANRX_ProcessRtcMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
821  CANRX_ProcessRtcMux(messageData, endianness);
822 }
823 extern void TEST_CANRX_ProcessSoftwareResetMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
824  CANRX_ProcessSoftwareResetMux(messageData, endianness);
825 }
826 extern void TEST_CANRX_ProcessFramInitializationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
827  CANRX_ProcessFramInitializationMux(messageData, endianness);
828 }
829 extern void TEST_CANRX_ProcessTimeInfoMux(uint64_t messageData, CAN_ENDIANNESS_e endianness) {
830  CANRX_ProcessTimeInfoMux(messageData, endianness);
831 }
832 
833 #endif
CAN callbacks header.
#define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_REQUEST_RTC_TIME_LENGTH
#define CANRX_DEBUG_MESSAGE_MUX_VALUE_RTC
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_BMS_SOFTWARE_VERSION_LENGTH
#define CANRX_MUX_RTC_SIGNAL_HUNDREDTH_OF_SECONDS_LENGTH
static bool CANRX_CheckIfMcuLotNumberIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Check if the MCU lot number information is requested.
#define CANRX_DEBUG_MESSAGE_MUX_VALUE_VERSION_INFORMATION
static bool CANRX_CheckIfTimeInfoIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Check if the RTC time information is requested.
static bool CANRX_CheckIfMcuWaferInformationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Check if the MCU wafer information is requested.
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_LOT_NUMBER_LENGTH
#define CANRX_MUX_RTC_SIGNAL_HOURS_LENGTH
#define CANRX_DEBUG_MESSAGE_MUX_LENGTH
static void CANRX_TriggerBmsSoftwareVersionMessage(void)
Triggers sending of the BMS software version information message.
static void CANRX_ProcessTimeInfoMux(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses CAN message to handle time information requests.
static bool CANRX_CheckIfFramInitializationIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Check if a FRAM initialization is requested.
#define CANRX_DEBUG_MESSAGE_MUX_VALUE_FRAM_INITIALIZATION
#define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_FRAM_INITIALIZATION_LENGTH
#define CANRX_MUX_RTC_SIGNAL_DAY_START_BIT
#define CANRX_MUX_RTC_SIGNAL_MINUTES_LENGTH
#define CANRX_MUX_RTC_SIGNAL_YEAR_START_BIT
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_LOT_NUMBER_START_BIT
static bool CANRX_CheckIfSoftwareResetIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Check if a software reset is requested.
#define CANRX_DEBUG_MESSAGE_MUX_VALUE_SOFTWARE_RESET
static void CANRX_TriggerMcuUniqueDieIdMessage(void)
Triggers sending of the MCU die ID information message.
#define CANRX_MUX_RTC_SIGNAL_WEEKDAY_LENGTH
#define CANRX_DEBUG_MESSAGE_MUX_VALUE_TIME_INFO
static uint8_t CANRX_GetMinutes(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the minutes information.
static void CANRX_ProcessFramInitializationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses CAN message related to FRAM initialization.
static uint8_t CANRX_GetHundredthOfSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the hundredth of seconds information.
static void CANRX_ProcessSoftwareResetMux(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses CAN message to handle software related requests, e.g., a software reset of the BMS.
static void CANRX_ProcessVersionInformationMux(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses CAN message to handle version related messages.
static uint8_t CANRX_GetMonth(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the month information.
static uint8_t CANRX_GetSeconds(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the seconds information.
#define CANRX_MUX_RTC_SIGNAL_MINUTES_START_BIT
static uint8_t CANRX_GetHours(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the hours information.
#define CANRX_MUX_RTC_SIGNAL_YEAR_LENGTH
uint32_t CANRX_Debug(CAN_MESSAGE_PROPERTIES_s message, const uint8_t *const kpkCanData, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for debug messages
#define CANRX_MUX_RTC_SIGNAL_DAY_LENGTH
static uint8_t CANRX_GetDay(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the day information.
#define CANRX_MUX_RTC_SIGNAL_WEEKDAY_START_BIT
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_UNIQUE_DIE_ID_LENGTH
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_WAFER_INFORMATION_LENGTH
#define CANRX_MUX_RTC_SIGNAL_MONTH_START_BIT
#define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_SOFTWARE_RESET_LENGTH
#define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_REQUEST_RTC_TIME_START_BIT
#define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_SOFTWARE_RESET_START_BIT
#define CANRX_MUX_RTC_SIGNAL_MONTH_LENGTH
static void CANRX_ProcessRtcMux(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses CAN message to set the RTC clock.
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_WAFER_INFORMATION_START_BIT
#define CANRX_MUX_SOFTWARE_SIGNAL_TRIGGER_FRAM_INITIALIZATION_START_BIT
#define CANRX_MUX_RTC_SIGNAL_HUNDREDTH_OF_SECONDS_START_BIT
#define CANRX_MUX_RTC_SIGNAL_HOURS_START_BIT
static uint8_t CANRX_GetYear(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the year information.
static bool CANRX_CheckIfBmsSoftwareVersionIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Check if the BMS software version information is requested.
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_MCU_UNIQUE_DIE_ID_START_BIT
static bool CANRX_CheckIfMcuUniqueDieIdIsRequested(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Check if the MCU die ID information is requested.
static void CANRX_TriggerMcuLotNumberMessage(void)
Triggers sending of the MCU lot number information message.
#define CANRX_MUX_RTC_SIGNAL_SECONDS_START_BIT
#define CANRX_DEBUG_MESSAGE_MUX_START_BIT
#define CANRX_MUX_RTC_SIGNAL_SECONDS_LENGTH
static void CANRX_TriggerMcuWaferInformationMessage(void)
Triggers sending of the MCU wafer information message.
#define CANRX_MUX_VERSION_INFO_SIGNAL_GET_BMS_SOFTWARE_VERSION_START_BIT
static uint8_t CANRX_GetWeekday(uint64_t messageData, CAN_ENDIANNESS_e endianness)
Parses the CAN message to retrieve the weekday information.
static void CANRX_TriggerTimeInfoMessage(void)
Triggers sending of the RTC time information message.
STD_RETURN_TYPE_e CANTX_DebugResponse(CANTX_DEBUG_RESPONSE_ACTIONS_e action)
Handles Debug response message.
Declarations for handling the transmit of debug response messages.
@ CANTX_DEBUG_RESPONSE_TRANSMIT_MCU_LOT_NUMBER
@ CANTX_DEBUG_RESPONSE_TRANSMIT_MCU_UNIQUE_DIE_ID
@ CANTX_DEBUG_RESPONSE_TRANSMIT_RTC_TIME
@ CANTX_DEBUG_RESPONSE_TRANSMIT_MCU_WAFER_INFORMATION
@ CANTX_DEBUG_RESPONSE_TRANSMIT_BMS_VERSION_INFO
void CANTX_UnsupportedMultiplexerValue(uint32_t messageId, uint32_t multiplexerValue)
Function to generically handle multiplexer values that are not supported in a message.
CAN_ENDIANNESS_e
Definition: can_cfg.h:156
@ CAN_BIG_ENDIAN
Definition: can_cfg.h:158
#define CAN_FOXBMS_MESSAGES_DEFAULT_DLC
Definition: can_cfg.h:106
Header for the driver for the CAN module.
#define CANRX_DEBUG_ID_TYPE
#define CANRX_DEBUG_ID
void CAN_RxGetMessageDataFromCanData(uint64_t *pMessage, const uint8_t *const kpkCanData, CAN_ENDIANNESS_e endianness)
Copy CAN data from 8 bytes to a 64-bit variable.
Definition: can_helper.c:295
void CAN_RxGetSignalDataFromMessageData(uint64_t message, uint64_t bitStart, uint8_t bitLength, uint64_t *pCanSignal, CAN_ENDIANNESS_e endianness)
Gets CAN signal data from a 64-bit variable. This function is used to get signal data from a 64-bit C...
Definition: can_helper.c:255
Headers for the helper functions for the CAN module.
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:254
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:129
STD_RETURN_TYPE_e FRAM_ReinitializeAllEntries(void)
Reinitialize all entries in the FRAM.
Definition: fram.c:116
Header for the driver for the FRAM module.
@ STD_OK
Definition: fstd_types.h:83
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:77
Header of task driver implementation.
OS_QUEUE ftsk_rtcSetTimeQueue
@ OS_SUCCESS
Definition: os.h:83
OS_STD_RETURN_e OS_SendToBackOfQueue(OS_QUEUE xQueue, const void *const pvItemToQueue, uint32_t ticksToWait)
Post an item to the back the provided queue.
Definition: os_freertos.c:261
void SYS_TriggerSoftwareReset(void)
Trigger a software reset of the BMS.
Definition: reset.c:72
Software reset driver header.
Header file of the RTC driver.
CAN_IDENTIFIER_TYPE_e idType
Definition: can_cfg.h:198
CAN_ENDIANNESS_e endianness
Definition: can_cfg.h:200
uint8_t hours
Definition: rtc.h:77
uint8_t minutes
Definition: rtc.h:76
uint8_t seconds
Definition: rtc.h:75
uint8_t month
Definition: rtc.h:80
uint8_t weekday
Definition: rtc.h:78
uint8_t hundredthOfSeconds
Definition: rtc.h:74
uint8_t year
Definition: rtc.h:81
uint8_t day
Definition: rtc.h:79