]> rtime.felk.cvut.cz Git - arc.git/blob - include/Com_Types.h
Merged in from mpc551x_mcal
[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 \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;\r
57 \r
58 #define COM_SIGNALTYPE_UNSIGNED  FALSE\r
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         COM_BIG_ENDIAN,\r
87         COM_LITTLE_ENDIAN,\r
88         COM_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 \r
121 #define SignalTypeSignedness(type) \\r
122                 (( (type == SINT8) || (type == SINT16) || (type == SINT32) ) ? \\r
123                                 COM_SIGNALTYPE_SIGNED : COM_SIGNALTYPE_UNSIGNED)\r
124 \r
125 /** Filter configuration type.\r
126  * NOT SUPPORTED\r
127  */\r
128 typedef struct {\r
129         /** The algorithm that this filter uses. */\r
130         ComFilterAlgorithm_type ComFilterAlgorithm;\r
131         /** Filter mask. */\r
132         uint32 ComFilterMask;\r
133         /** Max value for filter. */\r
134         uint32 ComFilterMax;\r
135         /** Min value for filter. */\r
136         uint32 ComFilterMin;\r
137         /** Offset for filter. */\r
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 */\r
148 typedef struct {\r
149         /** Starting position (bit) of the signal within the IPDU.\r
150          * Range 0 to 63.\r
151          */\r
152         const uint8 ComBitPosition;\r
153 \r
154         /** The size of the signal in bits.\r
155          * Range 0 to 64.\r
156          */\r
157         const uint8 ComBitSize;\r
158 \r
159         /** Identifier for the signal.\r
160          * Should be the same value as the index in the COM signal array.\r
161          */\r
162         const uint8 ComHandleId;\r
163 \r
164         /** Defines the endianess of the signal's network representation. */\r
165         const ComSignalEndianess_type ComSignalEndianess;\r
166 \r
167         /** Value used to initialize this signal. */\r
168         const void *ComSignalInitValue;\r
169 \r
170         /** Defines the type of the signal. */\r
171         const Com_SignalType ComSignalType;\r
172 \r
173 \r
174         /** Filter for this signal.\r
175          * NOT SUPPORTED\r
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.\r
182          */\r
183         //void *Com_Arc_ShadowBuffer;\r
184 \r
185         /* Callback function used when an invalid signal is received. */\r
186         // ComInvalidNotification;\r
187         //uint8 ComSignalDataInvalidValue;\r
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.\r
192          */\r
193 \r
194         //const uint8 ComIPduHandleId;\r
195         //const uint8 ComSignalUpdated;\r
196 \r
197         /** Marks the end of list for the configuration array. */\r
198         const uint8 Com_Arc_EOL;\r
199 } ComGroupSignal_type;\r
200 \r
201 \r
202 /** Configuration structure for signals and signal groups. */\r
203 typedef struct {\r
204 \r
205         /** Starting position (bit) of the signal within the IPDU.\r
206          * Range 0 to 63.\r
207          */\r
208         const uint8 ComBitPosition;\r
209 \r
210         /** The size of the signal in bits.\r
211          * Range 0 to 63.\r
212          */\r
213         const uint8 ComBitSize;\r
214 \r
215         /** Notification function for error notification. */\r
216         void (*ComErrorNotification) (void);\r
217 \r
218         /** First timeout period for deadline monitoring. */\r
219         const uint32 ComFirstTimeoutFactor;\r
220 \r
221         /** Identifier for the signal.\r
222          * Should be the same value as the index in the COM signal array.\r
223          */\r
224         const uint16 ComHandleId;\r
225 \r
226         /** Tx and Rx notification function. */\r
227         void (*ComNotification) (void);\r
228 \r
229         /** Action to be performed when a reception timeout occurs. */\r
230         const ComRxDataTimeoutAction_type ComRxDataTimeoutAction;\r
231 \r
232         /** Defines the endianess of the signal's network representation. */\r
233         const ComSignalEndianess_type ComSignalEndianess;\r
234 \r
235         /** Value used to initialized this signal. */\r
236         const void *ComSignalInitValue;\r
237 \r
238         /** The number of bytes if the signal has type UINT8_N;\r
239          * Range 1 to 8.\r
240          */\r
241         //const uint8 ComSignalLength;\r
242 \r
243         /** Defines the type of the signal. */\r
244         const Com_SignalType ComSignalType;\r
245 \r
246         /** Timeout period for deadline monitoring. */\r
247         const uint32 ComTimeoutFactor;\r
248 \r
249         /** Timeout notification function. */\r
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.\r
255          * Range 0 to 63.\r
256          * Only applicable if an update bit is used. NULL otherwise.\r
257          */\r
258         const uint8 ComUpdateBitPosition;\r
259 \r
260         /** Marks if this signal uses an update bit.\r
261          * Should be set to one if an update bit is used.\r
262          */\r
263         const uint8 ComSignalArcUseUpdateBit;\r
264 \r
265         /** Filter for this signal.\r
266          * NOT SUPPORTED.\r
267          */\r
268         //const ComFilter_type ComFilter;\r
269 \r
270         /** Marks if this signal is a signal group.\r
271          * Should be set to 1 if the signal is a signal group.\r
272          */\r
273         const uint8 Com_Arc_IsSignalGroup;\r
274 \r
275         /** Array of group signals.\r
276          * Only applicable if this signal is a signal group.\r
277          */\r
278         const ComGroupSignal_type * const *ComGroupSignal;\r
279 \r
280 \r
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.\r
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.\r
291          */\r
292 \r
293         //const uint8 ComIPduHandleId;\r
294         //const uint8 ComSignalUpdated;\r
295 \r
296         /* Callback function used when an invalid signal is received.\r
297          */\r
298         // ComInvalidNotification;\r
299 \r
300         //uint8 ComSignalDataInvalidValue;\r
301 \r
302         /* Action to be taken if an invalid signal is received.\r
303          */\r
304         // ComDataInvalidAction;\r
305 \r
306         /** Marks the end of list for the signal configuration array. */\r
307         const uint8 Com_Arc_EOL;\r
308 } ComSignal_type;\r
309 \r
310 \r
311 \r
312 /** Configuration structure for Tx-mode for I-PDUs. */\r
313 typedef struct {\r
314 \r
315         /** Transmission mode for this IPdu. */\r
316         const ComTxModeMode_type ComTxModeMode;\r
317 \r
318         /** Defines the number of times this IPdu will be sent in each IPdu cycle.\r
319          * Should be set to 0 for DIRECT transmission mode and >0 for DIRECT/N-times mode.\r
320          */\r
321         const uint8 ComTxModeNumberOfRepetitions;\r
322 \r
323         /** Defines the period of the transmissions in DIRECT/N-times and MIXED transmission modes. */\r
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. */\r
327         const uint32 ComTxModeTimeOffsetFactor;\r
328 \r
329         /** Period of cyclic transmission. */\r
330         const uint32 ComTxModeTimePeriodFactor;\r
331 } ComTxMode_type;\r
332 \r
333 /** Extra configuration structure for Tx I-PDUs. */\r
334 typedef struct {\r
335 \r
336         /** Minimum delay between successive transmissions of the IPdu. */\r
337         const uint32 ComTxIPduMinimumDelayFactor;\r
338 \r
339         /** COM will fill unused areas within an IPdu with this bit patter.\r
340          */\r
341         const uint8 ComTxIPduUnusedAreasDefault;\r
342 \r
343         /** Transmission modes for the IPdu.\r
344          * TMS is not implemented so only one static transmission mode is supported.\r
345          */\r
346         const ComTxMode_type ComTxModeTrue;\r
347 \r
348         //ComTxMode_type ComTxModeFalse;\r
349 } ComTxIPdu_type;\r
350 \r
351 \r
352 /** Configuration structure for I-PDU groups */\r
353 typedef struct ComIPduGroup_type {\r
354         /** ID of this group.\r
355          * Range 0 to 31.\r
356          */\r
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 \r
362         /** Marks the end of list for the I-PDU group configuration array. */\r
363         const uint8 Com_Arc_EOL;\r
364 } ComIPduGroup_type;\r
365 \r
366 \r
367 /** Configuration structure for an I-PDU. */\r
368 typedef struct {\r
369 \r
370         /** Callout function of this IPDU.\r
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 outgoing PDU id. For polite PDU id handling. */\r
379         const uint8 ArcIPduOutgoingId;\r
380 \r
381         /** Signal processing mode for this IPDU. */\r
382         const Com_IPduSignalProcessingMode ComIPduSignalProcessing;\r
383 \r
384         /** Size of the IPDU in bytes.\r
385          * Range 0-8 for CAN and LIN and 0-256 for FlexRay.\r
386          */\r
387         const uint8 ComIPduSize;\r
388 \r
389         /** The direction of the IPDU. Receive or Send. */\r
390         const Com_IPduDirection ComIPduDirection;\r
391 \r
392         /** Reference to the IPDU group that this IPDU belongs to. */\r
393         const uint8 ComIPduGroupRef;\r
394 \r
395         /** Container of transmission related parameters. */\r
396         const ComTxIPdu_type ComTxIPdu;\r
397 \r
398         /** References to all signals and signal groups contained in this IPDU.\r
399          * It probably makes little sense not to define at least one signal or signal group for each IPDU.\r
400          */\r
401         const ComSignal_type * const *ComIPduSignalRef;\r
402 \r
403         /*\r
404          * The following two variables are used to control the per I-PDU based Rx/Tx-deadline monitoring.\r
405          */\r
406         //const uint32 Com_Arc_DeadlineCounter;\r
407         //const uint32 Com_Arc_TimeoutFactor;\r
408 \r
409         /* Transmission related timers and parameters.\r
410          * These are internal variables and should not be configured.\r
411          */\r
412         //ComTxIPduTimer_type Com_Arc_TxIPduTimers;\r
413 \r
414         /** Marks the end of list for this configuration array. */\r
415         const uint8 Com_Arc_EOL;\r
416 \r
417 } ComIPdu_type;\r
418 \r
419 \r
420 /** Top-level configuration container for COM. Exists once per configuration. */\r
421 typedef struct {\r
422 \r
423         /** The ID of this configuration. This is returned by Com_GetConfigurationId(); */\r
424         const uint8 ComConfigurationId;\r
425 \r
426         /*\r
427          * Signal Gateway mappings.\r
428          * Not Implemented yet.\r
429         ComGwMapping_type ComGwMapping[];\r
430          */\r
431 \r
432         /** IPDU definitions */\r
433         const ComIPdu_type *ComIPdu;\r
434 \r
435         //uint16 Com_Arc_NIPdu;\r
436 \r
437         /** IPDU group definitions */\r
438         const ComIPduGroup_type *ComIPduGroup;\r
439 \r
440         /** Signal definitions */\r
441         const ComSignal_type *ComSignal;\r
442 \r
443         // Signal group definitions\r
444         //ComSignalGroup_type *ComSignalGroup;\r
445 \r
446         /** Group signal definitions */\r
447         const ComGroupSignal_type *ComGroupSignal;\r
448 \r
449 } Com_ConfigType;\r
450 \r
451 #endif /*COM_TYPES_H_*/\r
452 /** @} */\r