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