]> rtime.felk.cvut.cz Git - arc.git/blob - include/Com_Types.h
Added an example of CAN communication for the TMS570LS31x HDK
[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         /** Defines if a write access to this signal can trigger the transmission of the corresponding I-PDU. */\r
254         const ComTransferProperty_type ComTransferProperty;\r
255 \r
256         /** The bit position in the PDU for this signal's update bit.\r
257          * Range 0 to 2031.\r
258          * Only applicable if an update bit is used. NULL otherwise.\r
259          */\r
260         const Com_BitPositionType ComUpdateBitPosition;\r
261 \r
262         /** Marks if this signal uses an update bit.\r
263          * Should be set to one if an update bit is used.\r
264          */\r
265         const uint8 ComSignalArcUseUpdateBit;\r
266 \r
267         /** Filter for this signal.\r
268          * NOT SUPPORTED.\r
269          */\r
270         //const ComFilter_type ComFilter;\r
271 \r
272         /** Marks if this signal is a signal group.\r
273          * Should be set to 1 if the signal is a signal group.\r
274          */\r
275         const uint8 Com_Arc_IsSignalGroup;\r
276 \r
277         /** Array of group signals.\r
278          * Only applicable if this signal is a signal group.\r
279          */\r
280         const ComGroupSignal_type * const *ComGroupSignal;\r
281 \r
282 \r
283         const void *Com_Arc_ShadowBuffer;\r
284         //void *Com_Arc_IPduDataPtr;\r
285 \r
286         /* Pointer to the data storage of this signals IPDU.\r
287          * This is initialized by Com_Init() and should not be configured.\r
288          */\r
289         //const void *ComIPduDataPtr;\r
290 \r
291         /* IPDU id of the IPDU that this signal belongs to.\r
292          * This is initialized by Com_Init() and should not be configured.\r
293          */\r
294         /** The numerical value used as the ID of this I-PDU.\r
295          * TheComIPduHandleId is required by the API calls to receive I-PDUs from the PduR (ComIP-duDirection: Receive).\r
296          * For Tx-I-PDUs (ComIPduDirection: Send) this handle Id is used by the PduR to confirm the transmission of the ComIPdu\r
297          */\r
298         const uint16 ComIPduHandleId;\r
299         //const uint8 ComSignalUpdated;\r
300 \r
301         /* Callback function used when an invalid signal is received.\r
302          */\r
303         // ComInvalidNotification;\r
304 \r
305         //uint8 ComSignalDataInvalidValue;\r
306 \r
307         /* Action to be taken if an invalid signal is received.\r
308          */\r
309         // ComDataInvalidAction;\r
310 \r
311         /** Marks the end of list for the signal configuration array. */\r
312         const uint8 Com_Arc_EOL;\r
313 } ComSignal_type;\r
314 \r
315 \r
316 \r
317 /** Configuration structure for Tx-mode for I-PDUs. */\r
318 typedef struct {\r
319 \r
320         /** Transmission mode for this IPdu. */\r
321         const ComTxModeMode_type ComTxModeMode;\r
322 \r
323         /** Defines the number of times this IPdu will be sent in each IPdu cycle.\r
324          * Should be set to 0 for DIRECT transmission mode and >0 for DIRECT/N-times mode.\r
325          */\r
326         const uint8 ComTxModeNumberOfRepetitions;\r
327 \r
328         /** Defines the period of the transmissions in DIRECT/N-times and MIXED transmission modes. */\r
329         const uint32 ComTxModeRepetitionPeriodFactor;\r
330 \r
331         /** Time before first transmission of this IPDU. (i.e. between the ipdu group start and this IPDU is sent for the first time. */\r
332         const uint32 ComTxModeTimeOffsetFactor;\r
333 \r
334         /** Period of cyclic transmission. */\r
335         const uint32 ComTxModeTimePeriodFactor;\r
336 } ComTxMode_type;\r
337 \r
338 /** Extra configuration structure for Tx I-PDUs. */\r
339 typedef struct {\r
340 \r
341         /** Minimum delay between successive transmissions of the IPdu. */\r
342         const uint32 ComTxIPduMinimumDelayFactor;\r
343 \r
344         /** COM will fill unused areas within an IPdu with this bit patter.\r
345          */\r
346         const uint8 ComTxIPduUnusedAreasDefault;\r
347 \r
348         /** Transmission modes for the IPdu.\r
349          * TMS is not implemented so only one static transmission mode is supported.\r
350          */\r
351         const ComTxMode_type ComTxModeTrue;\r
352 \r
353         //ComTxMode_type ComTxModeFalse;\r
354 } ComTxIPdu_type;\r
355 \r
356 \r
357 /** Configuration structure for I-PDU groups */\r
358 typedef struct ComIPduGroup_type {\r
359         /** ID of this group.\r
360          * Range 0 to 31.\r
361          */\r
362         const uint8 ComIPduGroupHandleId;\r
363 \r
364         // reference to the group that this group possibly belongs to.\r
365         //struct ComIPduGroup_type *ComIPduGroupRef;\r
366 \r
367         /** Marks the end of list for the I-PDU group configuration array. */\r
368         const uint8 Com_Arc_EOL;\r
369 } ComIPduGroup_type;\r
370 \r
371 \r
372 /** Configuration structure for an I-PDU. */\r
373 typedef struct {\r
374 \r
375         /** Callout function of this IPDU.\r
376          * The callout function is an optional function used both on sender and receiver side.\r
377          * If configured, it determines whether an IPdu is considered for further processing. If\r
378          * the callout return false the IPdu will not be received/sent.\r
379          */\r
380         boolean (*ComIPduCallout)(PduIdType PduId, const uint8 *IPduData);\r
381 \r
382 \r
383         /** The outgoing PDU id. For polite PDU id handling. */\r
384         const uint8 ArcIPduOutgoingId;\r
385 \r
386         /** Signal processing mode for this IPDU. */\r
387         const Com_IPduSignalProcessingMode ComIPduSignalProcessing;\r
388 \r
389         /** Size of the IPDU in bytes.\r
390          * Range 0-8 for CAN and LIN and 0-256 for FlexRay.\r
391          */\r
392         const uint8 ComIPduSize;\r
393 \r
394         /** The direction of the IPDU. Receive or Send. */\r
395         const Com_IPduDirection ComIPduDirection;\r
396 \r
397         /** Reference to the IPDU group that this IPDU belongs to. */\r
398         const uint8 ComIPduGroupRef;\r
399 \r
400         /** Container of transmission related parameters. */\r
401         const ComTxIPdu_type ComTxIPdu;\r
402 \r
403         /** Reference to the actual pdu data storage */\r
404         void *const ComIPduDataPtr;\r
405         void *const ComIPduDeferredDataPtr;\r
406 \r
407         /** References to all signals and signal groups contained in this IPDU.\r
408          * It probably makes little sense not to define at least one signal or signal group for each IPDU.\r
409          */\r
410         const ComSignal_type * const *ComIPduSignalRef;\r
411 \r
412         const ComSignal_type * const ComIPduDynSignalRef;\r
413 \r
414         /*\r
415          * The following two variables are used to control the per I-PDU based Rx/Tx-deadline monitoring.\r
416          */\r
417         //const uint32 Com_Arc_DeadlineCounter;\r
418         //const uint32 Com_Arc_TimeoutFactor;\r
419 \r
420         /* Transmission related timers and parameters.\r
421          * These are internal variables and should not be configured.\r
422          */\r
423         //ComTxIPduTimer_type Com_Arc_TxIPduTimers;\r
424 \r
425         /** Marks the end of list for this configuration array. */\r
426         const uint8 Com_Arc_EOL;\r
427 \r
428 } ComIPdu_type;\r
429 \r
430 \r
431 /** Top-level configuration container for COM. Exists once per configuration. */\r
432 typedef struct {\r
433 \r
434         /** The ID of this configuration. This is returned by Com_GetConfigurationId(); */\r
435         const uint8 ComConfigurationId;\r
436 \r
437         /*\r
438          * Signal Gateway mappings.\r
439          * Not Implemented yet.\r
440         ComGwMapping_type ComGwMapping[];\r
441          */\r
442 \r
443         /** IPDU definitions */\r
444         const ComIPdu_type *ComIPdu;\r
445 \r
446         //uint16 Com_Arc_NIPdu;\r
447 \r
448         /** IPDU group definitions */\r
449         const ComIPduGroup_type *ComIPduGroup;\r
450 \r
451         /** Signal definitions */\r
452         const ComSignal_type *ComSignal;\r
453 \r
454         // Signal group definitions\r
455         //ComSignalGroup_type *ComSignalGroup;\r
456 \r
457         /** Group signal definitions */\r
458         const ComGroupSignal_type *ComGroupSignal;\r
459 \r
460 } Com_ConfigType;\r
461 \r
462 #endif /*COM_TYPES_H_*/\r
463 /** @} */\r