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