]> rtime.felk.cvut.cz Git - arc.git/blob - include/Com_Types.h
EcuM: Added more on the statemachine
[arc.git] / include / Com_Types.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 \r
18 /** @addtogroup Com COM module\r
19  *  @{ */\r
20 \r
21 /** @file Com_Types.h\r
22  * Definitions of configuration types and parameters for the COM module.\r
23  */\r
24 \r
25 \r
26 \r
27 #ifndef COM_TYPES_H_\r
28 #define COM_TYPES_H_\r
29 \r
30 \r
31 #include "ComStack_Types.h"\r
32 \r
33 typedef uint8 Com_PduGroupIdType;\r
34 typedef uint16 Com_SignalIdType;\r
35 typedef uint8 Com_SignalGroupIdType;\r
36 typedef uint16 Com_BitPositionType;\r
37 typedef enum {\r
38         IMMEDIATE,\r
39         DEFERRED\r
40 } Com_IPduSignalProcessingMode;\r
41 \r
42 typedef enum {\r
43         RECEIVE,\r
44         SEND\r
45 } Com_IPduDirection;\r
46 \r
47 typedef enum {\r
48         BOOLEAN,\r
49         UINT8,\r
50         UINT16,\r
51         UINT32,\r
52         UINT8_N,\r
53         UINT8_DYN,\r
54         SINT8,\r
55         SINT16,\r
56         SINT32\r
57 } Com_SignalType;\r
58 \r
59 #define COM_SIGNALTYPE_UNSIGNED  FALSE\r
60 #define COM_SIGNALTYPE_SIGNED    TRUE\r
61 \r
62 typedef enum {\r
63         PENDING,\r
64         TRIGGERED\r
65 } ComTransferProperty_type;\r
66 \r
67 typedef enum {\r
68         DIRECT,\r
69         MIXED,\r
70         NONE,\r
71         PERIODIC\r
72 } ComTxModeMode_type;\r
73 \r
74 \r
75 typedef enum {\r
76         ALWAYS,\r
77         MASKED_NEW_DIFFERS_MASKED_OLD,\r
78         MASKED_NEW_DIFFERS_X,\r
79         MASKED_NEW_EQUALS_X,\r
80         NEVER,\r
81         NEW_IS_OUTSIDE,\r
82         NEW_IS_WITHIN,\r
83         ONE_EVERY_N\r
84 } ComFilterAlgorithm_type;\r
85 \r
86 typedef enum {\r
87         COM_BIG_ENDIAN,\r
88         COM_LITTLE_ENDIAN,\r
89         COM_OPAQUE\r
90 } ComSignalEndianess_type;\r
91 \r
92 typedef enum {\r
93         COM_TIMEOUT_DATA_ACTION_NONE,\r
94         COM_TIMEOUT_DATA_ACTION_REPLACE\r
95 } ComRxDataTimeoutAction_type;\r
96 \r
97 /*\r
98 typedef enum {\r
99 \r
100 } ComTransmissionMode_type;\r
101 */\r
102 \r
103 // Shortcut macros\r
104 #define M_BOOLEAN boolean\r
105 #define M_UINT8 uint8\r
106 #define M_UINT16 uint16\r
107 #define M_UINT32 uint32\r
108 #define M_UINT8_N uint8\r
109 #define M_SINT8 sint8\r
110 #define M_SINT16 sint16\r
111 #define M_SINT32 sint32\r
112 \r
113 #define SignalTypeToSize(type,length) \\r
114         (type == UINT8   ? sizeof(uint8) : \\r
115         type == UINT16  ? sizeof(uint16) : \\r
116         type == UINT32  ? sizeof(uint32) : \\r
117         type == UINT8_N  ? sizeof(uint8) * length : \\r
118         type == SINT8   ? sizeof(sint8) : \\r
119         type == SINT16  ? sizeof(sint16) : \\r
120         type == SINT32  ? sizeof(sint32) : sizeof(boolean)) \\r
121 \r
122 #define SignalTypeSignedness(type) \\r
123                 (( (type == SINT8) || (type == SINT16) || (type == SINT32) ) ? \\r
124                                 COM_SIGNALTYPE_SIGNED : COM_SIGNALTYPE_UNSIGNED)\r
125 \r
126 /** Filter configuration type.\r
127  * NOT SUPPORTED\r
128  */\r
129 typedef struct {\r
130         /** The algorithm that this filter uses. */\r
131         ComFilterAlgorithm_type ComFilterAlgorithm;\r
132         /** Filter mask. */\r
133         uint32 ComFilterMask;\r
134         /** Max value for filter. */\r
135         uint32 ComFilterMax;\r
136         /** Min value for filter. */\r
137         uint32 ComFilterMin;\r
138         /** Offset for filter. */\r
139         uint32 ComFilterOffset;\r
140         uint32 ComFilterPeriodFactor;\r
141         uint32 ComFilterX;\r
142         uint32 ComFilterArcN;\r
143         uint32 ComFilterArcNewValue;\r
144         uint32 ComFilterArcOldValue;\r
145 \r
146 } ComFilter_type;\r
147 \r
148 /** Configuration structure for group signals */\r
149 typedef struct {\r
150         /** Starting position (bit) of the signal within the IPDU.\r
151          * Range 0 to 63.\r
152          */\r
153         const Com_BitPositionType ComBitPosition;\r
154 \r
155         /** The size of the signal in bits.\r
156          * Range 0 to 64.\r
157          */\r
158         const uint8 ComBitSize;\r
159 \r
160         /** Identifier for the signal.\r
161          * Should be the same value as the index in the COM signal array.\r
162          */\r
163         const uint8 ComHandleId;\r
164 \r
165         /** Defines the endianess of the signal's network representation. */\r
166         const ComSignalEndianess_type ComSignalEndianess;\r
167 \r
168         /** Value used to initialize this signal. */\r
169         const void *ComSignalInitValue;\r
170 \r
171         /** Defines the type of the signal. */\r
172         const Com_SignalType ComSignalType;\r
173 \r
174 \r
175         /** Filter for this signal.\r
176          * NOT SUPPORTED\r
177          */\r
178         //const ComFilter_type ComFilter;\r
179 \r
180         /* Pointer to the shadow buffer of the signal group that this group signal is contained in.\r
181          *\r
182          * This is initialized by Com_Init() and should not be configured.\r
183          */\r
184         //void *Com_Arc_ShadowBuffer;\r
185 \r
186         /* Callback function used when an invalid signal is received. */\r
187         // ComInvalidNotification;\r
188         //uint8 ComSignalDataInvalidValue;\r
189 \r
190         /* IPDU id of the IPDU that this signal belongs to.\r
191          *\r
192          * This is initialized by Com_Init() and should not be configured.\r
193          */\r
194 \r
195         //const uint8 ComIPduHandleId;\r
196         //const uint8 ComSignalUpdated;\r
197 \r
198         /** Marks the end of list for the configuration array. */\r
199         const uint8 Com_Arc_EOL;\r
200 } ComGroupSignal_type;\r
201 \r
202 \r
203 /** Configuration structure for signals and signal groups. */\r
204 typedef struct {\r
205 \r
206         /** Starting position (bit) of the signal within the IPDU.\r
207          * Range 0 to 2031.\r
208          */\r
209         const Com_BitPositionType ComBitPosition;\r
210 \r
211         /** The size of the signal in bits.\r
212          * Range 0 to 63.\r
213          */\r
214         const uint8 ComBitSize;\r
215 \r
216         /** Notification function for error notification. */\r
217         void (*ComErrorNotification) (void);\r
218 \r
219         /** First timeout period for deadline monitoring. */\r
220         const uint32 ComFirstTimeoutFactor;\r
221 \r
222         /** Identifier for the signal.\r
223          * Should be the same value as the index in the COM signal array.\r
224          */\r
225         const uint16 ComHandleId;\r
226 \r
227         /** Tx and Rx notification function. */\r
228         void (*ComNotification) (void);\r
229 \r
230         /** Action to be performed when a reception timeout occurs. */\r
231         const ComRxDataTimeoutAction_type ComRxDataTimeoutAction;\r
232 \r
233         /** Defines the endianess of the signal's network representation. */\r
234         const ComSignalEndianess_type ComSignalEndianess;\r
235 \r
236         /** Value used to initialized this signal. */\r
237         const void *ComSignalInitValue;\r
238 \r
239         /** The number of bytes if the signal has type UINT8_N;\r
240          * Range 1 to 8.\r
241          */\r
242         //const uint8 ComSignalLength;\r
243 \r
244         /** Defines the type of the signal. */\r
245         const Com_SignalType ComSignalType;\r
246 \r
247         /** Timeout period for deadline monitoring. */\r
248         const uint32 ComTimeoutFactor;\r
249 \r
250         /** Timeout notification function. */\r
251         void (*ComTimeoutNotification) (void);\r
252 \r
253         const ComTransferProperty_type ComTransferProperty;\r
254 \r
255         /** The bit position in the PDU for this signal's update bit.\r
256          * Range 0 to 2031.\r
257          * Only applicable if an update bit is used. NULL otherwise.\r
258          */\r
259         const Com_BitPositionType ComUpdateBitPosition;\r
260 \r
261         /** Marks if this signal uses an update bit.\r
262          * Should be set to one if an update bit is used.\r
263          */\r
264         const uint8 ComSignalArcUseUpdateBit;\r
265 \r
266         /** Filter for this signal.\r
267          * NOT SUPPORTED.\r
268          */\r
269         //const ComFilter_type ComFilter;\r
270 \r
271         /** Marks if this signal is a signal group.\r
272          * Should be set to 1 if the signal is a signal group.\r
273          */\r
274         const uint8 Com_Arc_IsSignalGroup;\r
275 \r
276         /** Array of group signals.\r
277          * Only applicable if this signal is a signal group.\r
278          */\r
279         const ComGroupSignal_type * const *ComGroupSignal;\r
280 \r
281 \r
282         const void *Com_Arc_ShadowBuffer;\r
283         //void *Com_Arc_IPduDataPtr;\r
284 \r
285         /* Pointer to the data storage of this signals IPDU.\r
286          * This is initialized by Com_Init() and should not be configured.\r
287          */\r
288         //const void *ComIPduDataPtr;\r
289 \r
290         /* IPDU id of the IPDU that this signal belongs to.\r
291          * This is initialized by Com_Init() and should not be configured.\r
292          */\r
293 \r
294         const uint16 ComIPduHandleId;\r
295         //const uint8 ComSignalUpdated;\r
296 \r
297         /* Callback function used when an invalid signal is received.\r
298          */\r
299         // ComInvalidNotification;\r
300 \r
301         //uint8 ComSignalDataInvalidValue;\r
302 \r
303         /* Action to be taken if an invalid signal is received.\r
304          */\r
305         // ComDataInvalidAction;\r
306 \r
307         /** Marks the end of list for the signal configuration array. */\r
308         const uint8 Com_Arc_EOL;\r
309 } ComSignal_type;\r
310 \r
311 \r
312 \r
313 /** Configuration structure for Tx-mode for I-PDUs. */\r
314 typedef struct {\r
315 \r
316         /** Transmission mode for this IPdu. */\r
317         const ComTxModeMode_type ComTxModeMode;\r
318 \r
319         /** Defines the number of times this IPdu will be sent in each IPdu cycle.\r
320          * Should be set to 0 for DIRECT transmission mode and >0 for DIRECT/N-times mode.\r
321          */\r
322         const uint8 ComTxModeNumberOfRepetitions;\r
323 \r
324         /** Defines the period of the transmissions in DIRECT/N-times and MIXED transmission modes. */\r
325         const uint32 ComTxModeRepetitionPeriodFactor;\r
326 \r
327         /** Time before first transmission of this IPDU. (i.e. between the ipdu group start and this IPDU is sent for the first time. */\r
328         const uint32 ComTxModeTimeOffsetFactor;\r
329 \r
330         /** Period of cyclic transmission. */\r
331         const uint32 ComTxModeTimePeriodFactor;\r
332 } ComTxMode_type;\r
333 \r
334 /** Extra configuration structure for Tx I-PDUs. */\r
335 typedef struct {\r
336 \r
337         /** Minimum delay between successive transmissions of the IPdu. */\r
338         const uint32 ComTxIPduMinimumDelayFactor;\r
339 \r
340         /** COM will fill unused areas within an IPdu with this bit patter.\r
341          */\r
342         const uint8 ComTxIPduUnusedAreasDefault;\r
343 \r
344         /** Transmission modes for the IPdu.\r
345          * TMS is not implemented so only one static transmission mode is supported.\r
346          */\r
347         const ComTxMode_type ComTxModeTrue;\r
348 \r
349         //ComTxMode_type ComTxModeFalse;\r
350 } ComTxIPdu_type;\r
351 \r
352 \r
353 /** Configuration structure for I-PDU groups */\r
354 typedef struct ComIPduGroup_type {\r
355         /** ID of this group.\r
356          * Range 0 to 31.\r
357          */\r
358         const uint8 ComIPduGroupHandleId;\r
359 \r
360         // reference to the group that this group possibly belongs to.\r
361         //struct ComIPduGroup_type *ComIPduGroupRef;\r
362 \r
363         /** Marks the end of list for the I-PDU group configuration array. */\r
364         const uint8 Com_Arc_EOL;\r
365 } ComIPduGroup_type;\r
366 \r
367 \r
368 /** Configuration structure for an I-PDU. */\r
369 typedef struct {\r
370 \r
371         /** Callout function of this IPDU.\r
372          * The callout function is an optional function used both on sender and receiver side.\r
373          * If configured, it determines whether an IPdu is considered for further processing. If\r
374          * the callout return false the IPdu will not be received/sent.\r
375          */\r
376         boolean (*ComIPduCallout)(PduIdType PduId, const uint8 *IPduData);\r
377 \r
378 \r
379         /** The outgoing PDU id. For polite PDU id handling. */\r
380         const uint8 ArcIPduOutgoingId;\r
381 \r
382         /** Signal processing mode for this IPDU. */\r
383         const Com_IPduSignalProcessingMode ComIPduSignalProcessing;\r
384 \r
385         /** Size of the IPDU in bytes.\r
386          * Range 0-8 for CAN and LIN and 0-256 for FlexRay.\r
387          */\r
388         const uint8 ComIPduSize;\r
389 \r
390         /** The direction of the IPDU. Receive or Send. */\r
391         const Com_IPduDirection ComIPduDirection;\r
392 \r
393         /** Reference to the IPDU group that this IPDU belongs to. */\r
394         const uint8 ComIPduGroupRef;\r
395 \r
396         /** Container of transmission related parameters. */\r
397         const ComTxIPdu_type ComTxIPdu;\r
398 \r
399         /** Reference to the actual pdu data storage */\r
400         void *const ComIPduDataPtr;\r
401         void *const ComIPduDeferredDataPtr;\r
402 \r
403         /** References to all signals and signal groups contained in this IPDU.\r
404          * It probably makes little sense not to define at least one signal or signal group for each IPDU.\r
405          */\r
406         const ComSignal_type * const *ComIPduSignalRef;\r
407 \r
408         const ComSignal_type * const ComIPduDynSignalRef;\r
409 \r
410         /*\r
411          * The following two variables are used to control the per I-PDU based Rx/Tx-deadline monitoring.\r
412          */\r
413         //const uint32 Com_Arc_DeadlineCounter;\r
414         //const uint32 Com_Arc_TimeoutFactor;\r
415 \r
416         /* Transmission related timers and parameters.\r
417          * These are internal variables and should not be configured.\r
418          */\r
419         //ComTxIPduTimer_type Com_Arc_TxIPduTimers;\r
420 \r
421         /** Marks the end of list for this configuration array. */\r
422         const uint8 Com_Arc_EOL;\r
423 \r
424 } ComIPdu_type;\r
425 \r
426 \r
427 /** Top-level configuration container for COM. Exists once per configuration. */\r
428 typedef struct {\r
429 \r
430         /** The ID of this configuration. This is returned by Com_GetConfigurationId(); */\r
431         const uint8 ComConfigurationId;\r
432 \r
433         /*\r
434          * Signal Gateway mappings.\r
435          * Not Implemented yet.\r
436         ComGwMapping_type ComGwMapping[];\r
437          */\r
438 \r
439         /** IPDU definitions */\r
440         const ComIPdu_type *ComIPdu;\r
441 \r
442         //uint16 Com_Arc_NIPdu;\r
443 \r
444         /** IPDU group definitions */\r
445         const ComIPduGroup_type *ComIPduGroup;\r
446 \r
447         /** Signal definitions */\r
448         const ComSignal_type *ComSignal;\r
449 \r
450         // Signal group definitions\r
451         //ComSignalGroup_type *ComSignalGroup;\r
452 \r
453         /** Group signal definitions */\r
454         const ComGroupSignal_type *ComGroupSignal;\r
455 \r
456 } Com_ConfigType;\r
457 \r
458 #endif /*COM_TYPES_H_*/\r
459 /** @} */\r