]> rtime.felk.cvut.cz Git - arc.git/blob - include/Com.h
Initial commit.
[arc.git] / include / Com.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_H_\r
24 #define COM_H_\r
25 \r
26 #include "Std_Types.h"\r
27 #include "Com_Types.h"\r
28 #include "Com_EcoreTypes.h"\r
29 \r
30 \r
31 #ifdef COM_DEV_ERROR_DETECT\r
32 #include "Det.h"\r
33 #endif\r
34 \r
35 #include "Com_Cfg.h"\r
36 #include "Com_PbCfg.h"\r
37 #include "Com_Com.h"\r
38 #include "Com_Sched.h"\r
39 \r
40 const Com_ConfigType * ComConfig;\r
41 \r
42 ComEcoreConfig_type ComEcoreConfig;\r
43 \r
44 \r
45 \r
46 #ifdef COM_DEV_ERROR_DETECT\r
47 \r
48 #undef DET_REPORTERROR\r
49 #define DET_REPORTERROR(_x,_y,_z,_q) Det_ReportError(_x,_y,_z,_q)\r
50 \r
51 \r
52 // Define macro for parameter check.\r
53 #define PduIdCheck(PduId,ApiId,...) \\r
54         if (PduId >= ComEcoreConfig.ComNIPdu) { \\r
55                 DET_REPORTERROR(COM_MODULE_ID, COM_INSTANCE_ID, ApiId, COM_INVALID_PDU_ID); \\r
56                 return __VA_ARGS__; \\r
57         } \\r
58 \r
59 #define COM_VALIDATE_SIGNAL(SignalId, ApiId, ...) \\r
60         if (ComConfig->ComSignal[SignalId].ComEcoreIsSignalGroup) { \\r
61                 DET_REPORTERROR(COM_MODULE_ID, COM_INSTANCE_ID, ApiId, COM_ERROR_SIGNAL_IS_SIGNALGROUP); \\r
62                 return __VA_ARGS__; \\r
63         } \\r
64 \r
65 \r
66 #else\r
67 \r
68 #undef DET_REPORTERROR\r
69 #define DET_REPORTERROR(_x,_y,_z,_q)\r
70 \r
71 #define PduIdCheck(PduId,ApiId,...)\r
72 #define COM_VALIDATE_SIGNAL(PduId, ApiId, ...)\r
73 #endif\r
74 \r
75 \r
76 #define testBit(source,bit) (*((uint8 *)source + (bit / 8)) & (1 << (bit % 8)))\r
77 #define setBit(dest,bit) *((uint8 *)dest + (bit / 8)) |= (1 << (bit % 8))\r
78 #define clearBit(dest,bit) *((uint8 *)dest + (bit / 8)) &= ~(1 << (bit % 8))\r
79 \r
80 #define ComGetSignal(SignalId) \\r
81         const ComSignal_type * Signal = &ComConfig->ComSignal[SignalId]\\r
82 \r
83 #define ComGetEcoreSignal(SignalId) \\r
84         ComEcoreSignal_type * EcoreSignal = &ComEcoreConfig.ComSignal[SignalId]\\r
85 \r
86 #define ComGetIPdu(IPduId) \\r
87         const ComIPdu_type *IPdu = &ComConfig->ComIPdu[IPduId]\\r
88 \r
89 #define ComGetEcoreIPdu(IPduId) \\r
90         ComEcoreIPdu_type *EcoreIPdu = &ComEcoreConfig.ComIPdu[IPduId]\\r
91 \r
92 #define ComGetGroupSignal(GroupSignalId) \\r
93         const ComGroupSignal_type *GroupSignal = &ComConfig->ComGroupSignal[GroupSignalId]\\r
94 \r
95 #define ComGetEcoreGroupSignal(GroupSignalId) \\r
96         ComEcoreGroupSignal_type *EcoreGroupSignal = &ComEcoreConfig.ComGroupSignal[GroupSignalId]\\r
97 \r
98 //-------------------------------------------------------------------\r
99 // From OSEK_VDX spec...\r
100 //\r
101 //typedef uint32 MessageIdentifier;\r
102 // TODO: Have no idea here..\r
103 //typedef void * ApplicationDataRef;\r
104 \r
105 \r
106 \r
107 \r
108 \r
109 \r
110 //-------------------------------------------------------------------\r
111 \r
112 // From OSEK_VDX\r
113 \r
114 /* The service SendMessage updates the message object identified by\r
115  * <Message> with the application message referenced by the\r
116  * <DataRef> parameter.\r
117  *\r
118  * Internal communication:\r
119  * The message <Message> is routed to the receiving part of the IL.\r
120   */\r
121 // Update 2008-10-30, SendMessage and ReceiveMessage should not be required. ensured by RTE. COM013\r
122 //StatusType SendMessage(MessageIdentifier , ApplicationDataRef );\r
123 \r
124 // The service  ReceiveMessage updates the application message\r
125 // referenced by <DataRef> with the data in the message object\r
126 // identified by <Message>. It resets all flags (Notification classes 1 and\r
127 // 3) associated with <Message>.\r
128 //StatusType ReceiveMessage ( MessageIdentifier , ApplicationDataRef );\r
129 \r
130 \r
131 // From Autosar\r
132 void Com_Init( const Com_ConfigType * ConfigPtr);\r
133 void Com_DeInit( void );\r
134 \r
135 void Com_IpduGroupStart(Com_PduGroupIdType IpduGroupId, boolean Initialize);\r
136 void Com_IpduGroupStop(Com_PduGroupIdType IpduGroupId);\r
137 \r
138 \r
139 #endif /*COM_H_*/\r