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