foxBMS - Unit Tests  1.5.0
The foxBMS Unit Tests 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-02-03 (date of last update)
47  * @version v1.5.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 /**
91  * -------------------------CAUTION-------------------------
92  * The following defines are used by the insulation monitoring device (IMD).
93  * If they are changed, the IMD will not work anymore
94  * -------------------------CAUTION-------------------------
95  */
96 /** CAN message ID for info message from iso165c */
97 #define CANRX_IMD_INFO_ID (0x37u)
98 /** CAN message ID for response message from iso165c */
99 #define CANRX_IMD_RESPONSE_ID (0x23u)
100 /** CAN message identifier type */
101 #define CANRX_IMD_ID_TYPE (CAN_STANDARD_IDENTIFIER_11_BIT)
102 
103 /** CAN message properties for Isabellenhuette current sensor messages. Properties are:
104  * - Data length of current sensor CAN messages
105  * - Identifier type (standard or extended)
106  * - Endianness of message data @{*/
107 #define CANRX_CURRENT_SENSOR_MESSAGES_DLC (6u)
108 #define CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE (CAN_STANDARD_IDENTIFIER_11_BIT)
109 #define CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS (CAN_BIG_ENDIAN)
110 /**@} */
111 
112 /** CAN message properties for string 0 current sensor messages. Properties for each message are:
113  * - Message ID
114  * - Expected message period in ms or if asynchronous message @{*/
115 #define CANRX_STRING0_CURRENT_ID (0x521u)
116 #define CANRX_STRING0_CURRENT_PERIOD_ms (CANRX_NOT_PERIODIC)
117 #define CANRX_STRING0_VOLTAGE1_ID (0x522u)
118 #define CANRX_STRING0_VOLTAGE1_PERIOD_ms (CANRX_NOT_PERIODIC)
119 #define CANRX_STRING0_VOLTAGE2_ID (0x523u)
120 #define CANRX_STRING0_VOLTAGE2_PERIOD_ms (CANRX_NOT_PERIODIC)
121 #define CANRX_STRING0_VOLTAGE3_ID (0x524u)
122 #define CANRX_STRING0_VOLTAGE3_PERIOD_ms (CANRX_NOT_PERIODIC)
123 #define CANRX_STRING0_TEMPERATURE_ID (0x525u)
124 #define CANRX_STRING0_TEMPERATURE_PERIOD_ms (CANRX_NOT_PERIODIC)
125 #define CANRX_STRING0_POWER_ID (0x526u)
126 #define CANRX_STRING0_POWER_PERIOD_ms (CANRX_NOT_PERIODIC)
127 #define CANRX_STRING0_CURRENT_COUNTER_ID (0x527u)
128 #define CANRX_STRING0_CURRENT_COUNTER_PERIOD_ms (CANRX_NOT_PERIODIC)
129 #define CANRX_STRING0_ENERGY_COUNTER_ID (0x528u)
130 #define CANRX_STRING0_ENERGY_COUNTER_PERIOD_ms (CANRX_NOT_PERIODIC)
131 /**@} */
132 
133 /* composed Rx messages */
134 
135 /* AXIVION Disable Style Generic-NoUnsafeMacro: These macros MUST only be used
136  to populate the 'can_rxMessages' array. The type of this array expects data
137  exactly as it is provided here and therefore these macros are good (for this
138  and only for this purpose!).*/
139 
140 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
141  timing check not implemented for RX messages!
142  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
143 */
144 
145 #define CANRX_DEBUG_MESSAGE \
146  { \
147  .id = CANRX_DEBUG_ID, \
148  .idType = CANRX_DEBUG_ID_TYPE, \
149  .dlc = CAN_DEFAULT_DLC, \
150  .endianness = CANRX_DEBUG_ENDIANNESS, \
151  }, \
152  { \
153  .period = CANRX_DEBUG_PERIOD_ms \
154  }
155 
156 #define CANRX_IMD_INFO_MESSAGE \
157  { \
158  .id = CANRX_IMD_INFO_ID, \
159  .idType = CANRX_IMD_ID_TYPE, \
160  .dlc = CAN_DEFAULT_DLC, \
161  .endianness = CAN_LITTLE_ENDIAN, \
162  }, \
163  { \
164  .period = CANRX_NOT_PERIODIC \
165  }
166 
167 #define CANRX_IMD_RESPONSE_MESSAGE \
168  { \
169  .id = CANRX_IMD_RESPONSE_ID, \
170  .idType = CANRX_IMD_ID_TYPE, \
171  .dlc = CAN_DEFAULT_DLC, \
172  .endianness = CAN_LITTLE_ENDIAN, \
173  }, \
174  { \
175  .period = CANRX_NOT_PERIODIC \
176  }
177 
178 #define CANRX_BMS_STATE_REQUEST_MESSAGE \
179  { \
180  .id = CANRX_BMS_STATE_REQUEST_ID, \
181  .idType = CANRX_BMS_STATE_REQUEST_ID_TYPE, \
182  .dlc = CAN_DEFAULT_DLC, \
183  .endianness = CANRX_BMS_STATE_REQUEST_ENDIANNESS, \
184  }, \
185  { \
186  .period = CANRX_BMS_STATE_REQUEST_PERIOD_ms \
187  }
188 
189 #define CANRX_STRING0_CURRENT_MESSAGE \
190  { \
191  .id = CANRX_STRING0_CURRENT_ID, \
192  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
193  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
194  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
195  }, \
196  { \
197  .period = CANRX_STRING0_CURRENT_PERIOD_ms \
198  }
199 
200 #define CANRX_STRING0_VOLTAGE1_MESSAGE \
201  { \
202  .id = CANRX_STRING0_VOLTAGE1_ID, \
203  .idType = CANRX_CURRENT_SENSOR_MESSAGES_ID_TYPE, \
204  .dlc = CANRX_CURRENT_SENSOR_MESSAGES_DLC, \
205  .endianness = CANRX_CURRENT_SENSOR_MESSAGES_ENDIANNESS, \
206  }, \
207  { \
208  .period = CANRX_STRING0_VOLTAGE1_PERIOD_ms \
209  }
210 
211 #define CANRX_STRING0_VOLTAGE2_MESSAGE \
212  { \
213  .id = CANRX_STRING0_VOLTAGE2_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_VOLTAGE2_PERIOD_ms \
220  }
221 
222 #define CANRX_STRING0_VOLTAGE3_MESSAGE \
223  { \
224  .id = CANRX_STRING0_VOLTAGE3_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_VOLTAGE3_PERIOD_ms \
231  }
232 
233 #define CANRX_STRING0_TEMPERATURE_MESSAGE \
234  { \
235  .id = CANRX_STRING0_TEMPERATURE_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_TEMPERATURE_PERIOD_ms \
242  }
243 
244 #define CANRX_STRING0_POWER_MESSAGE \
245  { \
246  .id = CANRX_STRING0_POWER_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_POWER_PERIOD_ms \
253  }
254 
255 #define CANRX_STRING0_CURRENT_COUNTER_MESSAGE \
256  { \
257  .id = CANRX_STRING0_CURRENT_COUNTER_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_CURRENT_COUNTER_PERIOD_ms \
264  }
265 
266 #define CANRX_STRING0_ENERGY_COUNTER_MESSAGE \
267  { \
268  .id = CANRX_STRING0_ENERGY_COUNTER_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_ENERGY_COUNTER_PERIOD_ms \
275  }
276 /* AXIVION Enable Style Generic-NoUnsafeMacro */
277 
278 /*========== Extern Constant and Variable Declarations ======================*/
279 
280 /*========== Extern Function Prototypes =====================================*/
281 
282 /*========== Externalized Static Functions Prototypes (Unit Test) ===========*/
283 #ifdef UNITY_UNIT_TEST
284 #endif
285 
286 #endif /* FOXBMS__CAN_CFG_RX_MESSAGE_DEFINITIONS_H_ */
Headers for the configuration for the CAN module.