foxBMS - Unit Tests  1.2.1
The foxBMS Unit Tests API Documentation
can_cbs.h
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_cbs.h
44  * @author foxBMS Team
45  * @date 2021-04-20 (date of creation)
46  * @updated 2021-07-29 (date of last update)
47  * @ingroup DRIVER
48  * @prefix CAN
49  *
50  * @brief CAN callbacks header
51  *
52  */
53 
54 #ifndef FOXBMS__CAN_CBS_H_
55 #define FOXBMS__CAN_CBS_H_
56 
57 /*========== Includes =======================================================*/
58 #include "general.h"
59 
60 #include "can_cfg.h"
61 
62 /*========== Macros and Definitions =========================================*/
63 
64 /*========== Extern Constant and Variable Declarations ======================*/
65 
66 /*========== Extern Function Prototypes =====================================*/
67 /** TX callback functions @{ */
68 /**
69  * @brief can tx callback function for state
70  * @param[in] id CAN ID
71  * @param[in] dlc CAN Data Length Code
72  * @param[in] endianness big or little endian
73  * @param[in] pCanData payload of can frame
74  * @param[in] pMuxId multiplexer for multiplexed CAN messages
75  * @param[in] kpkCanShim shim to the database entries
76  */
77 extern uint32_t CAN_TxState(
78  uint32_t id,
79  uint8_t dlc,
80  CAN_ENDIANNESS_e endianness,
81  uint8_t *pCanData,
82  uint8_t *pMuxId,
83  const CAN_SHIM_s *const kpkCanShim);
84 /**
85  * @brief can tx callback function for cell voltages
86  * @param[in] id CAN ID
87  * @param[in] dlc CAN Data Length Code
88  * @param[in] endianness big or little endian
89  * @param[in] pCanData payload of can frame
90  * @param[in] pMuxId multiplexer for multiplexed CAN messages
91  * @param[in] kpkCanShim shim to the database entries
92  */
93 extern uint32_t CAN_TxVoltage(
94  uint32_t id,
95  uint8_t dlc,
96  CAN_ENDIANNESS_e endianness,
97  uint8_t *pCanData,
98  uint8_t *pMuxId,
99  const CAN_SHIM_s *const kpkCanShim);
100 /**
101  * @brief can tx callback function for cell temperatures
102  * @param[in] id CAN ID
103  * @param[in] dlc CAN Data Length Code
104  * @param[in] endianness big or little endian
105  * @param[in] pCanData payload of can frame
106  * @param[in] pMuxId multiplexer for multiplexed CAN messages
107  * @param[in] kpkCanShim shim to the database entries
108  */
109 extern uint32_t CAN_TxCellTemperature(
110  uint32_t id,
111  uint8_t dlc,
112  CAN_ENDIANNESS_e endianness,
113  uint8_t *pCanData,
114  uint8_t *pMuxId,
115  const CAN_SHIM_s *const kpkCanShim);
116 /**
117  * @brief can tx callback function for limit values
118  * @param[in] id CAN ID
119  * @param[in] dlc CAN Data Length Code
120  * @param[in] endianness big or little endian
121  * @param[in] pCanData payload of can frame
122  * @param[in] pMuxId multiplexer for multiplexed CAN messages
123  * @param[in] kpkCanShim shim to the database entries
124  */
125 extern uint32_t CAN_TxLimitValues(
126  uint32_t id,
127  uint8_t dlc,
128  CAN_ENDIANNESS_e endianness,
129  uint8_t *pCanData,
130  uint8_t *pMuxId,
131  const CAN_SHIM_s *const kpkCanShim);
132 /**
133  * @brief can tx callback function for min/max values
134  * @param[in] id CAN ID
135  * @param[in] dlc CAN Data Length Code
136  * @param[in] endianness big or little endian
137  * @param[in] pCanData payload of can frame
138  * @param[in] pMuxId multiplexer for multiplexed CAN messages
139  * @param[in] kpkCanShim shim to the database entries
140  */
141 extern uint32_t CAN_TxMinimumMaximumValues(
142  uint32_t id,
143  uint8_t dlc,
144  CAN_ENDIANNESS_e endianness,
145  uint8_t *pCanData,
146  uint8_t *pMuxId,
147  const CAN_SHIM_s *const kpkCanShim);
148 /**
149  * @brief can tx callback function for state estimation values
150  * @param[in] id CAN ID
151  * @param[in] dlc CAN Data Length Code
152  * @param[in] endianness big or little endian
153  * @param[in] pCanData payload of can frame
154  * @param[in] pMuxId multiplexer for multiplexed CAN messages
155  * @param[in] kpkCanShim shim to the database entries
156  */
157 extern uint32_t CAN_TxStateEstimation(
158  uint32_t id,
159  uint8_t dlc,
160  CAN_ENDIANNESS_e endianness,
161  uint8_t *pCanData,
162  uint8_t *pMuxId,
163  const CAN_SHIM_s *const kpkCanShim);
164 /**
165  * @brief can tx callback function for pack values values
166  * @param[in] id CAN ID
167  * @param[in] dlc CAN Data Length Code
168  * @param[in] endianness big or little endian
169  * @param[in] pCanData payload of can frame
170  * @param[in] pMuxId multiplexer for multiplexed CAN messages
171  * @param[in] kpkCanShim shim to the database entries
172  */
173 extern uint32_t CAN_TxPackValues(
174  uint32_t id,
175  uint8_t dlc,
176  CAN_ENDIANNESS_e endianness,
177  uint8_t *pCanData,
178  uint8_t *pMuxId,
179  const CAN_SHIM_s *const kpkCanShim);
180 /**
181  * @brief can tx callback function for string state values
182  * @param[in] id CAN ID
183  * @param[in] dlc CAN Data Length Code
184  * @param[in] endianness big or little endian
185  * @param[in] pCanData payload of can frame
186  * @param[in] pMuxId multiplexer for multiplexed CAN messages
187  * @param[in] kpkCanShim shim to the database entries
188  */
189 extern uint32_t CAN_TxStringState(
190  uint32_t id,
191  uint8_t dlc,
192  CAN_ENDIANNESS_e endianness,
193  uint8_t *pCanData,
194  uint8_t *pMuxId,
195  const CAN_SHIM_s *const kpkCanShim);
196 /**
197  * @brief can tx callback function for string values
198  * @param[in] id CAN ID
199  * @param[in] dlc CAN Data Length Code
200  * @param[in] endianness big or little endian
201  * @param[in] pCanData payload of can frame
202  * @param[in] pMuxId multiplexer for multiplexed CAN messages
203  * @param[in] kpkCanShim shim to the database entries
204  */
205 extern uint32_t CAN_TxStringValues(
206  uint32_t id,
207  uint8_t dlc,
208  CAN_ENDIANNESS_e endianness,
209  uint8_t *pCanData,
210  uint8_t *pMuxId,
211  const CAN_SHIM_s *const kpkCanShim);
212 /**
213  * @brief can tx callback function for string minimum and maximum values
214  * @param[in] id CAN ID
215  * @param[in] dlc CAN Data Length Code
216  * @param[in] endianness big or little endian
217  * @param[in] pCanData payload of can frame
218  * @param[in] pMuxId multiplexer for multiplexed CAN messages
219  * @param[in] kpkCanShim shim to the database entries
220  */
221 extern uint32_t CAN_TxStringMinimumMaximumValues(
222  uint32_t id,
223  uint8_t dlc,
224  CAN_ENDIANNESS_e endianness,
225  uint8_t *pCanData,
226  uint8_t *pMuxId,
227  const CAN_SHIM_s *const kpkCanShim);
228 /**
229  * @brief can tx callback function for string state estimation
230  * @param[in] id CAN ID
231  * @param[in] dlc CAN Data Length Code
232  * @param[in] endianness big or little endian
233  * @param[in] pCanData payload of can frame
234  * @param[in] pMuxId multiplexer for multiplexed CAN messages
235  * @param[in] kpkCanShim shim to the database entries
236  */
237 extern uint32_t CAN_TxStringStateEstimation(
238  uint32_t id,
239  uint8_t dlc,
240  CAN_ENDIANNESS_e endianness,
241  uint8_t *pCanData,
242  uint8_t *pMuxId,
243  const CAN_SHIM_s *const kpkCanShim);
244 /**
245  * @brief can tx callback function for string values 2
246  * @param[in] id CAN ID
247  * @param[in] dlc CAN Data Length Code
248  * @param[in] endianness big or little endian
249  * @param[in] pCanData payload of can frame
250  * @param[in] pMuxId multiplexer for multiplexed CAN messages
251  * @param[in] kpkCanShim shim to the database entries
252  */
253 extern uint32_t CAN_TxStringValues2(
254  uint32_t id,
255  uint8_t dlc,
256  CAN_ENDIANNESS_e endianness,
257  uint8_t *pCanData,
258  uint8_t *pMuxId,
259  const CAN_SHIM_s *const kpkCanShim);
260 /** @} */
261 
262 /** RX callback functions @{ */
263 /**
264  * @brief can rx callback function for IMD info messages
265  * @param[in] id CAN ID
266  * @param[in] dlc CAN Data Length Code
267  * @param[in] endianness big or little endian
268  * @param[in] pCanData payload of can frame
269  * @param[in] pMuxId multiplexer for multiplexed CAN messages
270  * @param[in] kpkCanShim shim to the database entries
271  */
272 extern uint32_t CAN_RxImdInfo(
273  uint32_t id,
274  uint8_t dlc,
275  CAN_ENDIANNESS_e endianness,
276  uint8_t *pCanData,
277  uint8_t *pMuxId,
278  const CAN_SHIM_s *const kpkCanShim);
279 /**
280  * @brief can rx callback function for IMD response messages
281  * @param[in] id CAN ID
282  * @param[in] dlc CAN Data Length Code
283  * @param[in] endianness big or little endian
284  * @param[in] pCanData payload of can frame
285  * @param[in] pMuxId multiplexer for multiplexed CAN messages
286  * @param[in] kpkCanShim shim to the database entries
287  */
288 extern uint32_t CAN_RxImdResponse(
289  uint32_t id,
290  uint8_t dlc,
291  CAN_ENDIANNESS_e endianness,
292  uint8_t *pCanData,
293  uint8_t *pMuxId,
294  const CAN_SHIM_s *const kpkCanShim);
295 /**
296  * @brief can rx callback function for state requests
297  * @param[in] id CAN ID
298  * @param[in] dlc CAN Data Length Code
299  * @param[in] endianness big or little endian
300  * @param[in] pCanData payload of can frame
301  * @param[in] pMuxId multiplexer for multiplexed CAN messages
302  * @param[in] kpkCanShim shim to the database entries
303  */
304 extern uint32_t CAN_RxRequest(
305  uint32_t id,
306  uint8_t dlc,
307  CAN_ENDIANNESS_e endianness,
308  uint8_t *pCanData,
309  uint8_t *pMuxId,
310  const CAN_SHIM_s *const kpkCanShim);
311 /**
312  * @brief can rx callback function for SW reset
313  * @param[in] id CAN ID
314  * @param[in] dlc CAN Data Length Code
315  * @param[in] endianness big or little endian
316  * @param[in] pCanData payload of can frame
317  * @param[in] pMuxId multiplexer for multiplexed CAN messages
318  * @param[in] kpkCanShim shim to the database entries
319  */
320 extern uint32_t CAN_RxSwReset(
321  uint32_t id,
322  uint8_t dlc,
323  CAN_ENDIANNESS_e endianness,
324  uint8_t *pCanData,
325  uint8_t *pMuxId,
326  const CAN_SHIM_s *const kpkCanShim);
327 /**
328  * @brief can rx callback function for current sensor measurements
329  * @param[in] id CAN ID
330  * @param[in] dlc CAN Data Length Code
331  * @param[in] endianness big or little endian
332  * @param[in] pCanData payload of can frame
333  * @param[in] pMuxId multiplexer for multiplexed CAN messages
334  * @param[in] kpkCanShim shim to the database entries
335  */
336 extern uint32_t CAN_RxCurrentSensor(
337  uint32_t id,
338  uint8_t dlc,
339  CAN_ENDIANNESS_e endianness,
340  uint8_t *pCanData,
341  uint8_t *pMuxId,
342  const CAN_SHIM_s *const kpkCanShim);
343 /**
344  * @brief can rx callback function for debug messages
345  * @param[in] id CAN ID
346  * @param[in] dlc CAN Data Length Code
347  * @param[in] endianness big or little endian
348  * @param[in] pCanData payload of can frame
349  * @param[in] pMuxId multiplexer for multiplexed CAN messages
350  * @param[in] kpkCanShim shim to the database entries
351  */
352 extern uint32_t CAN_RxDebug(
353  uint32_t id,
354  uint8_t dlc,
355  CAN_ENDIANNESS_e endianness,
356  uint8_t *pCanData,
357  uint8_t *pMuxId,
358  const CAN_SHIM_s *const kpkCanShim);
359 /**
360  * @brief can rx callback function for SW version
361  * @param[in] id CAN ID
362  * @param[in] dlc CAN Data Length Code
363  * @param[in] endianness big or little endian
364  * @param[in] pCanData payload of can frame
365  * @param[in] pMuxId multiplexer for multiplexed CAN messages
366  * @param[in] kpkCanShim shim to the database entries
367  */
368 extern uint32_t CAN_RxSwVersion(
369  uint32_t id,
370  uint8_t dlc,
371  CAN_ENDIANNESS_e endianness,
372  uint8_t *pCanData,
373  uint8_t *pMuxId,
374  const CAN_SHIM_s *const kpkCanShim);
375 /** @} */
376 
377 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
378 #ifdef UNITY_UNIT_TEST
379 
380 #endif
381 
382 #endif /* FOXBMS__CAN_CBS_H_ */
uint32_t CAN_TxStateEstimation(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for state estimation values
uint32_t CAN_RxSwVersion(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for SW version
uint32_t CAN_RxSwReset(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for SW reset
uint32_t CAN_RxDebug(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for debug messages
uint32_t CAN_RxImdInfo(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for IMD info messages
uint32_t CAN_TxStringValues2(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for string values 2
uint32_t CAN_RxCurrentSensor(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for current sensor measurements
uint32_t CAN_TxMinimumMaximumValues(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for min/max values
uint32_t CAN_TxCellTemperature(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for cell temperatures
uint32_t CAN_TxPackValues(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for pack values values
uint32_t CAN_TxVoltage(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for cell voltages
uint32_t CAN_TxStringState(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for string state values
uint32_t CAN_TxStringMinimumMaximumValues(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for string minimum and maximum values
uint32_t CAN_TxStringValues(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for string values
uint32_t CAN_RxRequest(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for state requests
uint32_t CAN_RxImdResponse(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can rx callback function for IMD response messages
uint32_t CAN_TxLimitValues(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for limit values
uint32_t CAN_TxStringStateEstimation(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for string state estimation
uint32_t CAN_TxState(uint32_t id, uint8_t dlc, CAN_ENDIANNESS_e endianness, uint8_t *pCanData, uint8_t *pMuxId, const CAN_SHIM_s *const kpkCanShim)
can tx callback function for state
Headers for the configuration for the CAN module.
enum CAN_ENDIANNESS CAN_ENDIANNESS_e
General macros and definitions for the whole platform.