]> rtime.felk.cvut.cz Git - arc.git/blob - include/PduR.h
Correct Vendor id for all modules and upstep to AR3.1.5
[arc.git] / include / PduR.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 \r
19 \r
20 \r
21 \r
22 \r
23 #ifndef PDUR_H\r
24 #define PDUR_H\r
25 \r
26 #include "Modules.h"\r
27 \r
28 #define PDUR_VENDOR_ID             VENDOR_ID_ARCCORE\r
29 #define PDUR_AR_MAJOR_VERSION  3\r
30 #define PDUR_AR_MINOR_VERSION  1\r
31 #define PDUR_AR_PATCH_VERSION  5\r
32 #define PDUR_SW_MAJOR_VERSION  2\r
33 #define PDUR_SW_MINOR_VERSION  0\r
34 #define PDUR_SW_PATCH_VERSION  0\r
35 \r
36 \r
37 \r
38 // ERROR CODES\r
39 #define PDUR_E_CONFIG_PTR_INVALID               0x06\r
40 #define PDUR_E_INVALID_REQUEST                  0x01\r
41 #define PDUR_E_PDU_ID_INVALID                   0x02\r
42 #define PDUR_E_TP_TX_REQ_REJECTED               0x03\r
43 #define PDUR_E_DATA_PTR_INVALID                 0x05\r
44 #define PDUR_E_BUFFER_ERROR                             0x06\r
45 \r
46 #define PDUR_INSTANCE_ID        0\r
47 \r
48 #include "Modules.h"\r
49 \r
50 #include "PduR_Cfg.h"\r
51 #include "PduR_Types.h"\r
52 #include "PduR_PbCfg.h"\r
53 \r
54 #include "PduR_If.h"\r
55 \r
56 #if PDUR_COM_SUPPORT == STD_ON\r
57 #include "PduR_Com.h"\r
58 #endif\r
59 #if PDUR_CANIF_SUPPORT == STD_ON\r
60 #include "PduR_CanIf.h"\r
61 #endif\r
62 #if PDUR_LINIF_SUPPORT == STD_ON\r
63 #include "PduR_LinIf.h"\r
64 #endif\r
65 #if PDUR_CANTP_SUPPORT == STD_ON\r
66 #include "PduR_CanTp.h"\r
67 #endif\r
68 #if PDUR_J1939TP_SUPPORT == STD_ON\r
69 #include "PduR_J1939Tp.h"\r
70 #endif\r
71 #if PDUR_DCM_SUPPORT == STD_ON\r
72 #include "PduR_Dcm.h"\r
73 #endif\r
74 #if PDUR_SOAD_SUPPORT == STD_ON\r
75 #include "PduR_SoAd.h"\r
76 #endif\r
77 #if PDUR_J1939TP_SUPPORT == STD_ON\r
78 #include "PduR_J1939Tp.h"\r
79 #endif\r
80 \r
81 \r
82 /* Contain the current state of the PDU router. The router is uninitialized\r
83  * until PduR_Init has been run.\r
84  */\r
85 //PduR_StateType PduRState;\r
86 \r
87 extern const PduR_PBConfigType *PduRConfig;\r
88 \r
89 /*\r
90  * The state of the PDU router.\r
91  */\r
92 extern PduR_StateType PduRState;\r
93 \r
94 #define PduR_IsUpModule(_mod) ((_mod > ARC_PDUR_UP_MODULES) && (_mod < ARC_PDUR_LOIF_MODULES))\r
95 #define PduR_IsIfModule(_mod) ((_mod > ARC_PDUR_LOIF_MODULES) && (_mod < ARC_PDUR_LOTP_MODULES))\r
96 #define PduR_IsTpModule(_mod) ((_mod > ARC_PDUR_LOTP_MODULES) && (_mod < ARC_PDUR_END_OF_MODULES))\r
97 #define PduR_IsLoModule(_mod) (PduR_IsIfModule(_mod) || PduR_IsTpModule(_mod))\r
98 \r
99 \r
100 #if (PDUR_DEV_ERROR_DETECT == STD_ON)\r
101 \r
102 #define PDUR_DET_REPORTERROR(_x,_y,_z,_o) Det_ReportError(_x,_y,_z,_o)\r
103 \r
104 #define PDUR_VALIDATE_INITIALIZED(_api,...) \\r
105         if ((PduRState == PDUR_UNINIT) || (PduRState == PDUR_REDUCED)) { \\r
106                 Det_ReportError(MODULE_ID_PDUR, PDUR_INSTANCE_ID, _api, PDUR_E_INVALID_REQUEST); \\r
107                 return __VA_ARGS__; \\r
108         }\r
109 \r
110 #define PDUR_VALIDATE_PDUPTR(_api, _pduPtr, ...) \\r
111         if ((_pduPtr == NULL) && (PDUR_DEV_ERROR_DETECT)) { \\r
112                 Det_ReportError(MODULE_ID_PDUR, PDUR_INSTANCE_ID, _api, PDUR_E_DATA_PTR_INVALID); \\r
113                 return __VA_ARGS__; \\r
114         }\r
115 \r
116 #define PDUR_VALIDATE_PDUID(_api, _pduId, ...) \\r
117         if ((_pduId >= PduRConfig->NRoutingPaths) && PDUR_DEV_ERROR_DETECT) { \\r
118                 Det_ReportError(MODULE_ID_PDUR, PDUR_INSTANCE_ID, _api, PDUR_E_PDU_ID_INVALID); \\r
119                 return __VA_ARGS__; \\r
120         }\r
121 \r
122 \r
123 #else\r
124 #define PDUR_DET_REPORTERROR(_x,_y,_z,_o)\r
125 #define PDUR_VALIDATE_INITIALIZED(_api,...)\r
126 #define PDUR_VALIDATE_PDUPTR(_api, _pduPtr, ...)\r
127 #define PDUR_VALIDATE_PDUID(_api, _pduId, ...)\r
128 \r
129 #endif\r
130 \r
131 Std_ReturnType PduR_CancelTransmitRequest(\r
132                 PduR_CancelReasonType PduCancelReason, PduIdType PduId);\r
133 void PduR_ChangeParameterRequest(PduR_ParameterValueType PduParameterValue,\r
134                 PduIdType PduId);\r
135 \r
136 /* Zero Cost Operation function definitions\r
137  * These macros replaces the original functions if zero cost\r
138  * operation is desired. */\r
139 #if PDUR_ZERO_COST_OPERATION == STD_ON\r
140 #define PduR_Init(...)\r
141 #define PduR_GetVersionInfo(...)\r
142 #define PduR_GetConfigurationId(...) 0\r
143 \r
144 #else // Not zero cost operation\r
145 //#error fail\r
146 void PduR_Init(const PduR_PBConfigType* ConfigPtr);\r
147 void PduR_GetVersionInfo(Std_VersionInfoType* versionInfo);\r
148 uint32 PduR_GetConfigurationId(void);\r
149 \r
150 void PduR_BufferInc(PduRTxBuffer_type *Buffer, uint8 **ptr);\r
151 void PduR_BufferQueue(PduRTxBuffer_type *Buffer, const uint8 * SduPtr);\r
152 void PduR_BufferDeQueue(PduRTxBuffer_type *Buffer, uint8 *SduPtr);\r
153 void PduR_BufferFlush(PduRTxBuffer_type *Buffer);\r
154 uint8 PduR_BufferIsFull(PduRTxBuffer_type *Buffer);\r
155 void PduR_LoIfRxIndication(PduIdType PduId, const uint8* SduPtr);\r
156 void PduR_LoIfTxConfirmation(PduIdType PduId);\r
157 void PduR_LoIfTriggerTransmit(PduIdType PduId, uint8* SduPtr);\r
158 \r
159 /*\r
160  * Macros\r
161  */\r
162 #define setTxConfP(_B) (_B->TxConfP = 1)\r
163 #define clearTxConfP(_B) (_B->TxConfP = 0)\r
164 \r
165 #endif\r
166 \r
167 #endif /* PDUR_H */\r