foxBMS  1.6.0
The foxBMS Battery Management System API Documentation
can_cfg_rx-message-definitions.h
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_cfg_rx-message-definitions.h
44  * @author foxBMS Team
45  * @date 2022-07-01 (date of creation)
46  * @updated 2023-10-12 (date of last update)
47  * @version v1.6.0
48  * @ingroup DRIVERS
49  * @prefix CANRX
50  *
51  * @brief Header for the driver for the CAN module
52  *
53  */
54 
55 #ifndef FOXBMS__CAN_CFG_RX_MESSAGE_DEFINITIONS_H_
56 #define FOXBMS__CAN_CFG_RX_MESSAGE_DEFINITIONS_H_
57 
58 /*========== Includes =======================================================*/
59 #include "can_cfg.h"
60 
61 #include <stdint.h>
62 
63 /*========== Macros and Definitions =========================================*/
64 #define CANRX_NOT_PERIODIC (0u)
65 
66 /* Message IDs */
67 
68 /** CAN message properties for state request message. Required properties are:
69  * - Message ID
70  * - Identifier type (standard or extended)
71  * - Expected message period in ms or if asynchronous message
72  * - Endianness of message data @{*/
73 #define CANRX_BMS_STATE_REQUEST_ID (0x230u)
74 #define CANRX_BMS_STATE_REQUEST_ID_TYPE (CAN_STANDARD_IDENTIFIER_11_BIT)
75 #define CANRX_BMS_STATE_REQUEST_PERIOD_ms (CANRX_NOT_PERIODIC)
76 #define CANRX_BMS_STATE_REQUEST_ENDIANNESS (CAN_BIG_ENDIAN)
77 /**@} */
78 
79 /** CAN message properties for debug message. Required properties are:
80  * - Message ID
81  * - Identifier type (standard or extended)
82  * - Expected message period in ms or if asynchronous message
83  * - Endianness of message data @{*/
84 #define CANRX_DEBUG_ID (0x200u)
85 #define CANRX_DEBUG_ID_TYPE (CAN_STANDARD_IDENTIFIER_11_BIT)
86 #define CANRX_DEBUG_PERIOD_ms (CANRX_NOT_PERIODIC)
87 #define CANRX_DEBUG_ENDIANNESS (CAN_BIG_ENDIAN)
88 /**@}*/
89 
90 /** CAN message properties for aerosol sensor. Required properties are:
91  * - Message ID
92  * - Identifier type (standard or extended)
93  * - Expected message period in ms or if asynchronous message
94  * - Endianness of message data @{*/
95 #define CANRX_AEROSOL_SENSOR_ID (0x3C4u)
96 #define CANRX_AEROSOL_SENSOR_ID_TYPE (CAN_STANDARD_IDENTIFIER_11_BIT)
97 #define CANRX_AEROSOL_SENSOR_PERIOD_ms (1000u)
98 #define CANRX_AEROSOL_SENSOR_ENDIANNESS (CAN_BIG_ENDIAN)
99 /**@}*/
100 
101 /**
102  * -------------------------CAUTION-------------------------
103  * The following defines are used by the insulation monitoring device (IMD).
104  * If they are changed, the IMD will not work anymore
105  * -------------------------CAUTION-------------------------
106  */
107 /** CAN message ID for info message from iso165c */
108 #define CANRX_IMD_INFO_ID (0x37u)
109 /** CAN message ID for response message from iso165c */
110 #define CANRX_IMD_RESPONSE_ID (0x23u)
111 /** CAN message identifier type */
112 #define CANRX_IMD_ID_TYPE (CAN_STANDARD_IDENTIFIER_11_BIT)
113 
114 /** CAN message properties for Isabellenhuette current sensor messages. Properties are:
115  * - Data length of current sensor CAN messages
116  * - Identifier type (standard or extended)
117  * - Endianness of message data @{*/
118 #define CANRX_CURRENT_SENSOR_MESSAGES_DLC (6u)
119 #define CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE (CAN_STANDARD_IDENTIFIER_11_BIT)
120 #define CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS (CAN_BIG_ENDIAN)
121 /**@} */
122 
123 /** CAN message properties for string 0 current sensor messages. Properties for each message are:
124  * - Message ID
125  * - Expected message period in ms or if asynchronous message @{*/
126 #define CANRX_STRING0_CURRENT_ID (0x521u)
127 #define CANRX_STRING0_CURRENT_PERIOD_ms (CANRX_NOT_PERIODIC)
128 #define CANRX_STRING0_VOLTAGE1_ID (0x522u)
129 #define CANRX_STRING0_VOLTAGE1_PERIOD_ms (CANRX_NOT_PERIODIC)
130 #define CANRX_STRING0_VOLTAGE2_ID (0x523u)
131 #define CANRX_STRING0_VOLTAGE2_PERIOD_ms (CANRX_NOT_PERIODIC)
132 #define CANRX_STRING0_VOLTAGE3_ID (0x524u)
133 #define CANRX_STRING0_VOLTAGE3_PERIOD_ms (CANRX_NOT_PERIODIC)
134 #define CANRX_STRING0_TEMPERATURE_ID (0x525u)
135 #define CANRX_STRING0_TEMPERATURE_PERIOD_ms (CANRX_NOT_PERIODIC)
136 #define CANRX_STRING0_POWER_ID (0x526u)
137 #define CANRX_STRING0_POWER_PERIOD_ms (CANRX_NOT_PERIODIC)
138 #define CANRX_STRING0_CURRENT_COUNTER_ID (0x527u)
139 #define CANRX_STRING0_CURRENT_COUNTER_PERIOD_ms (CANRX_NOT_PERIODIC)
140 #define CANRX_STRING0_ENERGY_COUNTER_ID (0x528u)
141 #define CANRX_STRING0_ENERGY_COUNTER_PERIOD_ms (CANRX_NOT_PERIODIC)
142 /**@} */
143 
144 /* composed Rx messages */
145 
146 /* AXIVION Disable Style Generic-NoUnsafeMacro: These macros MUST only be used
147  to populate the 'can_rxMessages' array. The type of this array expects data
148  exactly as it is provided here and therefore these macros are good (for this
149  and only for this purpose!).*/
150 
151 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
152  timing check not implemented for RX messages!
153  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
154 */
155 
156 #define CANRX_DEBUG_MESSAGE \
157  { \
158  .id = CANRX_DEBUG_ID, \
159  .idType = CANRX_DEBUG_ID_TYPE, \
160  .dlc = CAN_DEFAULT_DLC, \
161  .endianness = CANRX_DEBUG_ENDIANNESS, \
162  }, \
163  { \
164  .period = CANRX_DEBUG_PERIOD_ms \
165  }
166 
167 #define CANRX_AEROSOL_SENSOR_MESSAGE \
168  { \
169  .id = CANRX_AEROSOL_SENSOR_ID, \
170  .idType = CANRX_AEROSOL_SENSOR_ID_TYPE, \
171  .dlc = CAN_DEFAULT_DLC, \
172  .endianness = CANRX_AEROSOL_SENSOR_ENDIANNESS, \
173  }, \
174  { \
175  .period = CANRX_AEROSOL_SENSOR_PERIOD_ms \
176  }
177 
178 #define CANRX_IMD_INFO_MESSAGE \
179  { \
180  .id = CANRX_IMD_INFO_ID, \
181  .idType = CANRX_IMD_ID_TYPE, \
182  .dlc = CAN_DEFAULT_DLC, \
183  .endianness = CAN_LITTLE_ENDIAN, \
184  }, \
185  { \
186  .period = CANRX_NOT_PERIODIC \
187  }
188 
189 #define CANRX_IMD_RESPONSE_MESSAGE \
190  { \
191  .id = CANRX_IMD_RESPONSE_ID, \
192  .idType = CANRX_IMD_ID_TYPE, \
193  .dlc = CAN_DEFAULT_DLC, \
194  .endianness = CAN_LITTLE_ENDIAN, \
195  }, \
196  { \
197  .period = CANRX_NOT_PERIODIC \
198  }
199 
200 #define CANRX_BMS_STATE_REQUEST_MESSAGE \
201  { \
202  .id = CANRX_BMS_STATE_REQUEST_ID, \
203  .idType = CANRX_BMS_STATE_REQUEST_ID_TYPE, \
204  .dlc = CAN_DEFAULT_DLC, \
205  .endianness = CANRX_BMS_STATE_REQUEST_ENDIANNESS, \
206  }, \
207  { \
208  .period = CANRX_BMS_STATE_REQUEST_PERIOD_ms \
209  }
210 
211 #define CANRX_STRING0_CURRENT_MESSAGE \
212  { \
213  .id = CANRX_STRING0_CURRENT_ID, \
214  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
215  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
216  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
217  }, \
218  { \
219  .period = CANRX_STRING0_CURRENT_PERIOD_ms \
220  }
221 
222 #define CANRX_STRING0_VOLTAGE1_MESSAGE \
223  { \
224  .id = CANRX_STRING0_VOLTAGE1_ID, \
225  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
226  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
227  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
228  }, \
229  { \
230  .period = CANRX_STRING0_VOLTAGE1_PERIOD_ms \
231  }
232 
233 #define CANRX_STRING0_VOLTAGE2_MESSAGE \
234  { \
235  .id = CANRX_STRING0_VOLTAGE2_ID, \
236  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
237  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
238  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
239  }, \
240  { \
241  .period = CANRX_STRING0_VOLTAGE2_PERIOD_ms \
242  }
243 
244 #define CANRX_STRING0_VOLTAGE3_MESSAGE \
245  { \
246  .id = CANRX_STRING0_VOLTAGE3_ID, \
247  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
248  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
249  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
250  }, \
251  { \
252  .period = CANRX_STRING0_VOLTAGE3_PERIOD_ms \
253  }
254 
255 #define CANRX_STRING0_TEMPERATURE_MESSAGE \
256  { \
257  .id = CANRX_STRING0_TEMPERATURE_ID, \
258  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
259  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
260  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
261  }, \
262  { \
263  .period = CANRX_STRING0_TEMPERATURE_PERIOD_ms \
264  }
265 
266 #define CANRX_STRING0_POWER_MESSAGE \
267  { \
268  .id = CANRX_STRING0_POWER_ID, \
269  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
270  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
271  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
272  }, \
273  { \
274  .period = CANRX_STRING0_POWER_PERIOD_ms \
275  }
276 
277 #define CANRX_STRING0_CURRENT_COUNTER_MESSAGE \
278  { \
279  .id = CANRX_STRING0_CURRENT_COUNTER_ID, \
280  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
281  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
282  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
283  }, \
284  { \
285  .period = CANRX_STRING0_CURRENT_COUNTER_PERIOD_ms \
286  }
287 
288 #define CANRX_STRING0_ENERGY_COUNTER_MESSAGE \
289  { \
290  .id = CANRX_STRING0_ENERGY_COUNTER_ID, \
291  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
292  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
293  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
294  }, \
295  { \
296  .period = CANRX_STRING0_ENERGY_COUNTER_PERIOD_ms \
297  }
298 /* AXIVION Enable Style Generic-NoUnsafeMacro */
299 
300 /*========== Extern Constant and Variable Declarations ======================*/
301 
302 /*========== Extern Function Prototypes =====================================*/
303 
304 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
305 #ifdef UNITY_UNIT_TEST
306 #endif
307 
308 #endif /* FOXBMS__CAN_CFG_RX_MESSAGE_DEFINITIONS_H_ */
Headers for the configuration for the CAN module.