]> rtime.felk.cvut.cz Git - arc.git/blob - communication/Com/Com_Internal.h
147ab348be7a030686665a00ee3814af4ab84356
[arc.git] / communication / Com / Com_Internal.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  * NB! This file is for COM internal use only and may only be included from COM C-files!\r
18  */\r
19 \r
20 \r
21 \r
22 #ifndef COM_INTERNAL_H_\r
23 #define COM_INTERNAL_H_\r
24 \r
25 #include "Com_Arc_Types.h"\r
26 \r
27 extern const Com_ConfigType *ComConfig;\r
28 extern Com_Arc_Config_type Com_Arc_Config;\r
29 \r
30 \r
31 \r
32 #if COM_DEV_ERROR_DETECT == STD_ON\r
33 #include "Det.h"\r
34 \r
35 #define DET_REPORTERROR(_x,_y,_z,_q) Det_ReportError(_x,_y,_z,_q)\r
36 \r
37 \r
38 // Define macro for parameter check.\r
39 #define PDU_ID_CHECK(PduId,ApiId,...) \\r
40         if (PduId >= COM_N_IPDUS) { \\r
41                 DET_REPORTERROR(COM_MODULE_ID, COM_INSTANCE_ID, ApiId, COM_INVALID_PDU_ID); \\r
42                 return __VA_ARGS__; \\r
43         } \\r
44 \r
45 #define VALIDATE_SIGNAL(SignalId, ApiId, ...) \\r
46         if (SignalId >= COM_N_SIGNALS) { \\r
47                 DET_REPORTERROR(COM_MODULE_ID, COM_INSTANCE_ID, ApiId, COM_INVALID_SIGNAL_ID); \\r
48                 return __VA_ARGS__; \\r
49         } \\r
50 \r
51 \r
52 #else\r
53 \r
54 #define DET_REPORTERROR(_x,_y,_z,_q)\r
55 \r
56 #define PDU_ID_CHECK(PduId,ApiId,...)\r
57 #define VALIDATE_SIGNAL(PduId, ApiId, ...)\r
58 #endif\r
59 \r
60 \r
61 #define TESTBIT(source,bit)     ( *( (uint8 *)source  + (bit / 8) ) &  (uint8)(1u << (bit % 8)) )\r
62 #define SETBIT(dest,bit)        ( *( (uint8 *)dest    + (bit / 8) ) |= (uint8)(1u << (bit % 8)) )\r
63 #define CLEARBIT(dest,bit)      ( *( (uint8 *)dest    + (bit / 8) ) &= (uint8)~(uint8)(1u << (bit % 8)) )\r
64 \r
65 \r
66 #define GET_Signal(SignalId) \\r
67         (&ComConfig->ComSignal[SignalId])\r
68 \r
69 #define GET_ArcSignal(SignalId) \\r
70         (&Com_Arc_Config.ComSignal[SignalId])\r
71 \r
72 #define GET_IPdu(IPduId) \\r
73         (&ComConfig->ComIPdu[IPduId])\r
74 \r
75 #define GET_ArcIPdu(IPduId) \\r
76         (&Com_Arc_Config.ComIPdu[IPduId])\r
77 \r
78 #define GET_GroupSignal(GroupSignalId) \\r
79         (&ComConfig->ComGroupSignal[GroupSignalId])\r
80 \r
81 #define GET_ArcGroupSignal(GroupSignalId) \\r
82         (&Com_Arc_Config.ComGroupSignal[GroupSignalId])\r
83 \r
84 \r
85 \r
86 #endif /* COM_INTERNAL_H_ */\r