]> rtime.felk.cvut.cz Git - arc.git/blob - include/Com_Types.h
Continuing dem-dev branch
[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
19
20
21
22
23 #ifndef COM_TYPES_H_\r
24 #define COM_TYPES_H_\r
25 \r
26 #include "ComStack_Types.h"\r
27 #include "Com_Cfg.h"\r
28 \r
29 typedef uint8 Com_PduGroupIdType;\r
30 typedef uint16 Com_SignalIdType;\r
31 typedef uint8 Com_SignalGroupIdType;\r
32 \r
33 typedef enum {\r
34         IMMEDIATE,\r
35         DEFERRED,\r
36 } Com_IPduSignalProcessingMode;\r
37 \r
38 typedef enum {\r
39         RECEIVE,\r
40         SEND\r
41 } Com_IPduDirection;\r
42 \r
43 typedef enum {\r
44         BOOLEAN,\r
45         UINT8,\r
46         UINT16,\r
47         UINT32,\r
48         UINT8_N,\r
49         SINT8,\r
50         SINT16,\r
51         SINT32\r
52 } Com_SignalType;\r
53 \r
54 typedef enum {\r
55         PENDING,\r
56         TRIGGERED,\r
57 } ComTransferProperty_type;\r
58 \r
59 typedef enum {\r
60         DIRECT,\r
61         MIXED,\r
62         NONE,\r
63         PERIODIC,\r
64 } ComTxModeMode_type;\r
65 \r
66 \r
67 typedef enum {\r
68         ALWAYS,\r
69         MASKED_NEW_DIFFERS_MASKED_OLD,\r
70         MASKED_NEW_DIFFERS_X,\r
71         MASKED_NEW_EQUALS_X,\r
72         NEVER,\r
73         NEW_IS_OUTSIDE,\r
74         NEW_IS_WITHIN,\r
75         ONE_EVERY_N,\r
76 } ComFilterAlgorithm_type;\r
77 \r
78 typedef enum {\r
79         BIG_ENDIAN,\r
80         LITTLE_ENDIAN,\r
81         OPAQUE,\r
82 } ComSignalEndianess_type;\r
83 \r
84 typedef enum {\r
85         COM_TIMEOUT_DATA_ACTION_NONE,\r
86         COM_TIMEOUT_DATA_ACTION_REPLACE\r
87 } ComRxDataTimeoutAction_type;\r
88 \r
89 /*\r
90 typedef enum {\r
91 \r
92 } ComTransmissionMode_type;\r
93 */\r
94 \r
95 // Shortcut macros\r
96 #define M_BOOLEAN boolean\r
97 #define M_UINT8 uint8\r
98 #define M_UINT16 uint16\r
99 #define M_UINT32 uint32\r
100 #define M_UINT8_N uint8\r
101 #define M_SINT8 sint8\r
102 #define M_SINT16 sint16\r
103 #define M_SINT32 sint32\r
104 \r
105 #define SignalTypeToSize(type,length) \\r
106         (type == UINT8   ? sizeof(uint8) : \\r
107         type == UINT16  ? sizeof(uint16) : \\r
108         type == UINT32  ? sizeof(uint32) : \\r
109         type == UINT8_N  ? sizeof(uint8) * length : \\r
110         type == SINT8   ? sizeof(sint8) : \\r
111         type == SINT16  ? sizeof(sint16) : \\r
112         type == SINT32  ? sizeof(sint32) : sizeof(boolean)) \\r
113 \r
114 \r
115 typedef struct {\r
116         ComFilterAlgorithm_type ComFilterAlgorithm;\r
117         uint32 ComFilterMask;\r
118         uint32 ComFilterMax;\r
119         uint32 ComFilterMin;\r
120         uint32 ComFilterOffset;\r
121         uint32 ComFilterPeriodFactor;\r
122         uint32 ComFilterX;\r
123 \r
124 \r
125         uint32 ComFilterArcN;\r
126         uint32 ComFilterArcNewValue;\r
127         uint32 ComFilterArcOldValue;\r
128 \r
129 } ComFilter_type;\r
130 \r
131 \r
132 typedef struct {\r
133         /* Starting position (bit) of the signal within the IPDU.\r
134          *\r
135          * Context:\r
136          *   - Send and receive.\r
137          *   - Required.\r
138          *\r
139          * Comment: Range 0 to 63.\r
140          */\r
141         const uint8 ComBitPosition;\r
142 \r
143         /* The size of the signal in bits.\r
144          *\r
145          * Context:\r
146          *   - Send and receive.\r
147          *   - Required.\r
148          *\r
149          * Comment: Range 0 to 64.\r
150          */\r
151         const uint8 ComBitSize;\r
152 \r
153         /* Identifier for the signal.\r
154          *\r
155          * Context:\r
156          *   - Send and receive.\r
157          *   - Required.\r
158          *\r
159          * Comment: Should be the same value as the index in the COM signal array.\r
160          */\r
161         const uint8 ComHandleId;\r
162 \r
163         /* Callback function used when an invalid signal is received.\r
164          *\r
165          * Context:\r
166          *   - Receive.\r
167          *   - Not required.\r
168          */\r
169         // ComInvalidNotification;\r
170 \r
171         /*\r
172          *\r
173          * Context:\r
174          *   - Send and receive.\r
175          *   - Not required.\r
176          */\r
177         //uint8 ComSignalDataInvalidValue;\r
178 \r
179         /* Defines the endianess of the signal's network representation.\r
180          *\r
181          * Context:\r
182          *   - Send and receive.\r
183          *   - Required.\r
184          */\r
185         const ComSignalEndianess_type ComSignalEndianess;\r
186 \r
187         /*\r
188          * Value used to initialized this signal.\r
189          *\r
190          * Context:\r
191          *   - Send\r
192          *   - Required\r
193          */\r
194         const uint32 ComSignalInitValue;\r
195 \r
196         /* The number of bytes if the signal has type UINT8_N;\r
197          *\r
198          * Context:\r
199          *   - Send and receive.\r
200          *   - Required if type of signal is UINT8_N\r
201          *\r
202          * Comment: Range 1 to 8.\r
203          */\r
204         const uint8 ComSignalLength;\r
205 \r
206         /* Defines the type of the signal\r
207          *\r
208          * Context:\r
209          *   - Send and receive.\r
210          *   - Required.\r
211          */\r
212         const Com_SignalType ComSignalType;\r
213 \r
214 \r
215         /* Filter for this signal\r
216          *\r
217          * Context:\r
218          *   - Send.\r
219          *   - Required.\r
220          */\r
221         const ComFilter_type ComFilter;\r
222 \r
223         /* Pointer to the shadow buffer of the signal group that this group signal is contained in.\r
224          *\r
225          * Comment: This is initialized by Com_Init() and should not be configured.\r
226          */\r
227         //void *Com_Arc_ShadowBuffer;\r
228 \r
229 \r
230         /* IPDU id of the IPDU that this signal belongs to.\r
231          *\r
232          * Comment: This is initialized by Com_Init() and should not be configured.\r
233          */\r
234 \r
235         //const uint8 ComIPduHandleId;\r
236         //const uint8 ComSignalUpdated;\r
237 \r
238         const uint8 Com_Arc_EOL;\r
239 } ComGroupSignal_type;\r
240 \r
241 typedef struct {\r
242 \r
243         /* Starting position (bit) of the signal within the IPDU.\r
244          *\r
245          * Context:\r
246          *   - Send and receive.\r
247          *   - Required.\r
248          *\r
249          * Comment: Range 0 to 63.
250          */\r
251         const uint8 ComBitPosition;\r
252 \r
253         /* The size of the signal in bits.\r
254          *\r
255          * Context:\r
256          *   - Send and receive.\r
257          *   - Required.\r
258          *\r
259          * Comment: Range 0 to 64.
260          */\r
261         const uint8 ComBitSize;\r
262 \r
263 \r
264         /* Action to be taken if an invalid signal is received.\r
265          *\r
266          * Context:\r
267          *   -
268          */\r
269         // ComDataInvalidAction;\r
270 \r
271         /* Notification function for error notification.\r
272          *\r
273          * Context:\r
274          *   - Send.\r
275          *   - Not required.\r
276          *
277          */\r
278         void (*ComErrorNotification) (void);\r
279 \r
280         /* First timeout period for deadline monitoring.\r
281          *\r
282          * Context:\r
283          *   - Receive\r
284          *   - Not required.
285          */\r
286         const uint32 ComFirstTimeoutFactor;\r
287 \r
288         /* Identifier for the signal.\r
289          *\r
290          * Context:\r
291          *   - Send and receive.\r
292          *   - Required.\r
293          *\r
294          * Comment: Should be the same value as the index in the COM signal array.
295          */\r
296         const uint8 ComHandleId;\r
297 \r
298         /* Callback function used when an invalid signal is received.\r
299          *\r
300          * Context:\r
301          *   - Receive.\r
302          *   - Not required.
303          */\r
304         // ComInvalidNotification;\r
305 \r
306         /* Tx and Rx notification function.\r
307          *\r
308          * Context:\r
309          *   - Send and receive.\r
310          *   - Not required.
311          */\r
312         void (*ComNotification) (void);\r
313 \r
314         /* Action to be performed when a reception timeout occurs.\r
315          *\r
316          * Context:\r
317          *   - Receive.\r
318          *   - Required.
319          */\r
320         const ComRxDataTimeoutAction_type ComRxDataTimeoutAction;\r
321 \r
322         /*\r
323          *\r
324          * Context:\r
325          *   - Send and receive.\r
326          *   - Not required.
327          */\r
328         //uint8 ComSignalDataInvalidValue;\r
329 \r
330         /* Defines the endianess of the signal's network representation.\r
331          *\r
332          * Context:\r
333          *   - Send and receive.\r
334          *   - Required.
335          */\r
336         const ComSignalEndianess_type ComSignalEndianess;\r
337 \r
338         /*\r
339          * Value used to initialized this signal.\r
340          *\r
341          * Context:\r
342          *   - Send\r
343          *   - Required
344          */\r
345         const uint32 ComSignalInitValue;\r
346 \r
347         /* The number of bytes if the signal has type UINT8_N;\r
348          *\r
349          * Context:\r
350          *   - Send and receive.\r
351          *   - Required if type of signal is UINT8_N\r
352          *\r
353          * Comment: Range 1 to 8.
354          */\r
355         const uint8 ComSignalLength;\r
356 \r
357         /* Defines the type of the signal\r
358          *\r
359          * Context:\r
360          *   - Send and receive.\r
361          *   - Required.
362          */\r
363         const Com_SignalType ComSignalType;\r
364 \r
365         /* Timeout period for deadline monitoring.\r
366          *\r
367          * Context:\r
368          *   - Receive\r
369          *   - Not required.\r
370          */\r
371         //const uint32 Com_Arc_DeadlineCounter;\r
372         const uint32 ComTimeoutFactor;\r
373 \r
374         /* Timeout notification function\r
375          *\r
376          * Context:\r
377          *   - Receive and send\r
378          *   - Not required.\r
379          */\r
380         void (*ComTimeoutNotification) (void);\r
381 \r
382         const ComTransferProperty_type ComTransferProperty;\r
383 \r
384         /*\r
385          * The bit position in the PDU for this signals update bit.\r
386          *\r
387          * Context:\r
388          *   - Send and receive.\r
389          *   - Not required.\r
390          *\r
391          * Comment: Range 0 to 63. If update bit is used for this signal, then the corresponding parameter ComSignalArcUseUpdateBit\r
392          *          needs to be set to one.
393          */\r
394         const uint8 ComUpdateBitPosition;\r
395         const uint8 ComSignalArcUseUpdateBit;\r
396 \r
397         /* Filter for this signal\r
398          *\r
399          * Context:\r
400          *   - Send.\r
401          *   - Required.
402          */\r
403         const ComFilter_type ComFilter;\r
404 \r
405 \r
406         /**** SIGNAL GROUP DATA ****/\r
407         const uint8 Com_Arc_IsSignalGroup;\r
408         const ComGroupSignal_type *ComGroupSignal[COM_MAX_NR_SIGNALS_PER_SIGNAL_GROUP];\r
409         //void *Com_Arc_ShadowBuffer;\r
410         //void *Com_Arc_IPduDataPtr;\r
411 \r
412 \r
413         /* Pointer to the data storage of this signals IPDU.\r
414          *\r
415          * Comment: This is initialized by Com_Init() and should not be configured.
416          */\r
417         //const void *ComIPduDataPtr;\r
418 \r
419         /* IPDU id of the IPDU that this signal belongs to.\r
420          *\r
421          * Comment: This is initialized by Com_Init() and should not be configured.\r
422          */\r
423 \r
424         //const uint8 ComIPduHandleId;\r
425         //const uint8 ComSignalUpdated;\r
426 \r
427 \r
428         const uint8 Com_Arc_EOL;\r
429 } ComSignal_type;\r
430 \r
431 \r
432 typedef struct {\r
433         /* Transmission mode for this IPdu.\r
434          *\r
435          * Context:\r
436          *   - Send.\r
437          *   - Required.
438          */\r
439         const ComTxModeMode_type ComTxModeMode;\r
440 \r
441         /* Defines the number of times this IPdu will be sent in each IPdu cycle.\r
442          *\r
443          * Context:\r
444          *   - Send.\r
445          *   - Required for transmission modes DIRECT/N-times and MIXED.\r
446          *\r
447          * Comment: Should be set to 0 for DIRECT transmission mode and >0 for DIRECT/N-times mode.
448          */\r
449         const uint8 ComTxModeNumberOfRepetitions;\r
450 \r
451         /* Defines the period of the transmissions in DIRECT/N-times and MIXED\r
452          * transmission modes.\r
453          *\r
454          * Context:\r
455          *   - Send.\r
456          *   - Required for DIRECT/N-times and MIXED transmission modes.
457          */\r
458         const uint32 ComTxModeRepetitionPeriodFactor;\r
459 \r
460         /* Time before first transmission of this IPDU. (i.e. between the ipdu group start\r
461          * and this IPDU is sent for the first time.\r
462          *\r
463          * Context:\r
464          *   - Send.\r
465          *   - Required for all transmission modes except NONE.
466          */\r
467         const uint32 ComTxModeTimeOffsetFactor;\r
468 \r
469         /* Period of cyclic transmission.\r
470          *\r
471          * Context:\r
472          *   - Send.\r
473          *   - Required for CYCLIC and MIXED transmission mode.
474          */\r
475         const uint32 ComTxModeTimePeriodFactor;\r
476 } ComTxMode_type;\r
477 \r
478 \r
479 typedef struct {\r
480 \r
481         /* Minimum delay between successive transmissions of the IPdu.\r
482          *\r
483          * Context:\r
484          *   - Send.\r
485          *   - Not required.
486          */\r
487         const uint32 ComTxIPduMinimumDelayFactor;\r
488 \r
489         /* COM will fill unused areas within an IPdu with this bit patter.\r
490          *\r
491          * Context:\r
492          *   - Send.\r
493          *   - Required.
494          */\r
495         const uint8 ComTxIPduUnusedAreasDefault;\r
496 \r
497         /* Transmission modes for this IPdu.\r
498          *\r
499          * Context:\r
500          *   - Send.\r
501          *   - Not required.\r
502          *\r
503          * Comment: TMS is not implemented so only one static transmission\r
504          *          mode is supported.
505          */\r
506         const ComTxMode_type ComTxModeTrue;\r
507         //ComTxMode_type ComTxModeFalse;\r
508 \r
509 } ComTxIPdu_type;\r
510 \r
511 /*\r
512 typedef struct {\r
513         uint8  ComTxIPduNumberOfRepetitionsLeft;\r
514         uint32 ComTxModeRepetitionPeriodTimer;\r
515         uint32 ComTxIPduMinimumDelayTimer;\r
516         uint32 ComTxModeTimePeriodTimer;\r
517 } ComTxIPduTimer_type;\r
518 */\r
519 \r
520 typedef struct ComIPduGroup_type {\r
521         // ID of this group. 0-31.\r
522         const uint8 ComIPduGroupHandleId;\r
523 \r
524         // reference to the group that this group possibly belongs to.\r
525         //struct ComIPduGroup_type *ComIPduGroupRef;\r
526 \r
527         const uint8 Com_Arc_EOL;\r
528 } ComIPduGroup_type;\r
529 \r
530 \r
531 typedef struct {\r
532 \r
533         /* Callout function of this IPDU.\r
534          * The callout function is an optional function used both on sender and receiver side.\r
535          * If configured, it determines whether an IPdu is considered for further processing. If\r
536          * the callout return false the IPdu will not be received/sent.\r
537          *\r
538          * Context:\r
539          *   - Send and receive.\r
540          *   - Not required.
541          */\r
542         boolean (*ComIPduCallout)(PduIdType PduId, const uint8 *IPduData);\r
543 \r
544 \r
545         /* The ID of this IPDU.\r
546          *\r
547          * Context:\r
548          *   - Send and receive.\r
549          *   - Required.\r
550          *\r
551          * Comment:
552          */\r
553         const uint8 ComIPduRxHandleId;\r
554 \r
555         /* Signal processing mode for this IPDU.\r
556          *\r
557          * Context:\r
558          *   - Receive.\r
559          *   - Required.
560          */\r
561         const Com_IPduSignalProcessingMode ComIPduSignalProcessing;\r
562 \r
563         /* Size of the IPDU in bytes. 0-8 for CAN and LIN and 0-256 for FlexRay.\r
564          *\r
565          * Context:\r
566          *   - Send and receive.\r
567          *   - Required.
568          */\r
569         const uint8 ComIPduSize;\r
570 \r
571         /* The direction of the IPDU. Receive or Send.\r
572          *\r
573          * Context:\r
574          *   - Receive or send.\r
575          *   - Required.
576          */\r
577         const Com_IPduDirection ComIPduDirection;\r
578 \r
579         /* Reference to the IPDU group that this IPDU belongs to.\r
580          *\r
581          * Context:\r
582          *   - Send and receive.\r
583          *   - Required.
584          */\r
585         const uint8 ComIPduGroupRef;\r
586 \r
587         /* Reference to global PDU structure. ???\r
588          *\r
589          * No global PDU structure defined so this variable is left out.
590          */\r
591         // PduIdRef\r
592 \r
593         /* Container of transmission related parameters.\r
594          *\r
595          * Context:\r
596          *       - Send\r
597          *   - Required.
598          */\r
599         const ComTxIPdu_type ComTxIPdu;\r
600 \r
601         /* Transmission related timers and parameters.\r
602          *\r
603          * Context:\r
604          *   - Send\r
605          *   - Not required.\r
606          *   - Not part of the AUTOSAR standard.\r
607          *\r
608          * Comment: These are internal variables and should not be configured.
609          */\r
610         //ComTxIPduTimer_type Com_Arc_TxIPduTimers;\r
611 \r
612         /* Pointer to data storage of this IPDU.\r
613          *\r
614          * Context:\r
615          *   - Send and receive.\r
616          *\r
617          * Comment: this memory will be initialized dynamically in Com_Init();
618          */\r
619         //void *ComIPduDataPtr;\r
620 \r
621         /* References to all signals contained in this IPDU.\r
622          *\r
623          * Context:\r
624          *   - Send and receive.\r
625          *   - Not required.\r
626          *\r
627          * Comment: It probably makes little sense not to define at least one signal for each IPDU.\r
628          */\r
629         //const uint8 Com_Arc_NIPduSignalGroupRef;\r
630         const ComSignal_type *ComIPduSignalGroupRef[COM_MAX_NR_SIGNALS_PER_IPDU];\r
631 \r
632 \r
633         /* References to all signals contained in this IPDU.\r
634          *\r
635          * Context:\r
636          *   - Send and receive.\r
637          *   - Not required.\r
638          *\r
639          * Comment: It probably makes little sense not to define at least one signal for each IPDU.\r
640          */\r
641         //const uint8 NComIPduSignalRef;\r
642         const ComSignal_type *ComIPduSignalRef[COM_MAX_NR_SIGNALS_PER_IPDU];\r
643 \r
644         /*\r
645          * The following two variables are used to control the per I-PDU based Rx/Tx-deadline monitoring.\r
646          */\r
647         //const uint32 Com_Arc_DeadlineCounter;\r
648         //const uint32 Com_Arc_TimeoutFactor;\r
649 \r
650         const uint8 Com_Arc_EOL;\r
651 \r
652 } ComIPdu_type;\r
653 \r
654 \r
655 // Contains configuration specific configuration parameters. Exists once per configuration.\r
656 typedef struct {\r
657 \r
658         // The ID of this configuration. This is returned by Com_GetConfigurationId();\r
659         const uint8 ComConfigurationId;\r
660 \r
661         /*\r
662          * Signal Gateway mappings.\r
663          * Not Implemented yet.\r
664         ComGwMapping_type ComGwMapping[];\r
665          */\r
666 \r
667         // IPDU definitions. At least one\r
668         const ComIPdu_type *ComIPdu;\r
669 \r
670         //uint16 Com_Arc_NIPdu;\r
671 \r
672         // IPDU group definitions\r
673         const ComIPduGroup_type *ComIPduGroup;\r
674 \r
675         // Signal definitions\r
676         const ComSignal_type *ComSignal;\r
677 \r
678         // Signal group definitions\r
679         //ComSignalGroup_type *ComSignalGroup;\r
680 \r
681         // Group signal definitions\r
682         const ComGroupSignal_type *ComGroupSignal;\r
683 \r
684 } Com_ConfigType;\r
685 \r
686 #endif /*COM_TYPES_H_*/\r