]> rtime.felk.cvut.cz Git - arc.git/blob - include/PduR.h
Lint fixes on PduR and CanIf
[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  1\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_Com.h"\r
52 #include "PduR_CanIf.h"\r
53 #include "PduR_LinIf.h"\r
54 #include "PduR_CanTp.h"\r
55 #include "PduR_Dcm.h"\r
56 \r
57 \r
58 \r
59 /* Contain the current state of the PDU router. The router is uninitialized\r
60  * until PduR_Init has been run.\r
61  */\r
62 PduR_StateType PduRState; // 960, 31 LINT: Borde åtgärdas\r
63 \r
64 extern const PduR_PBConfigType *PduRConfig;\r
65 \r
66 \r
67 #if (PDUR_DEV_ERROR_DETECT == STD_ON)\r
68 \r
69 #define PDUR_DET_REPORTERROR(_x,_y,_z,_q) Det_ReportError(_x,_y,_z,_q)\r
70 \r
71 // Define macro for state, parameter and data pointer checks.\r
72 // TODO Implement data range check if needed.\r
73 #define PduR_DevCheck(PduId,PduPtr,ApiId,...) \\r
74         if ((PduRState == PDUR_UNINIT) || (PduRState == PDUR_REDUCED)) { \\r
75                 PDUR_DET_REPORTERROR(MODULE_ID_PDUR, PDUR_INSTANCE_ID, ApiId, PDUR_E_INVALID_REQUEST); \\r
76                 return __VA_ARGS__; \\r
77         } \\r
78         if ((PduPtr == 0) && (PDUR_DEV_ERROR_DETECT)) { \\r
79                 PDUR_DET_REPORTERROR(MODULE_ID_PDUR, PDUR_INSTANCE_ID, ApiId, PDUR_E_DATA_PTR_INVALID); \\r
80                 return __VA_ARGS__; \\r
81         } \\r
82         if ((PduId >= PduRConfig->PduRRoutingTable->NRoutingPaths) && PDUR_DEV_ERROR_DETECT) { \\r
83                 PDUR_DET_REPORTERROR(MODULE_ID_PDUR, PDUR_INSTANCE_ID, ApiId, PDUR_E_PDU_ID_INVALID); \\r
84                 return __VA_ARGS__; \\r
85         }\r
86 \r
87 \r
88 #else\r
89 #define PDUR_DET_REPORTERROR(_x,_y,_z,_q)\r
90 #define PduR_DevCheck(...)\r
91 \r
92 #endif\r
93 \r
94 Std_ReturnType PduR_CancelTransmitRequest(\r
95                 PduR_CancelReasonType PduCancelReason, PduIdType PduId);\r
96 void PduR_ChangeParameterRequest(PduR_ParameterValueType PduParameterValue,\r
97                 PduIdType PduId);\r
98 \r
99 /* Zero Cost Operation function definitions\r
100  * These macros replaces the original functions if zero cost\r
101  * operation is desired. */\r
102 #if PDUR_ZERO_COST_OPERATION == STD_ON\r
103 #define PduR_Init(...)\r
104 #define PduR_GetVersionInfo(...)\r
105 #define PduR_GetConfigurationId(...) 0\r
106 \r
107 #else // Not zero cost operation\r
108 //#error fail\r
109 void PduR_Init(const PduR_PBConfigType* ConfigPtr);\r
110 void PduR_GetVersionInfo(Std_VersionInfoType* versionInfo);\r
111 uint32 PduR_GetConfigurationId(void);\r
112 \r
113 void PduR_BufferInc(PduRTxBuffer_type *Buffer, uint8 **ptr);\r
114 void PduR_BufferQueue(PduRTxBuffer_type *Buffer, const uint8 * SduPtr);\r
115 void PduR_BufferDeQueue(PduRTxBuffer_type *Buffer, uint8 *SduPtr);\r
116 void PduR_BufferFlush(PduRTxBuffer_type *Buffer);\r
117 uint8 PduR_BufferIsFull(PduRTxBuffer_type *Buffer);\r
118 void PduR_LoIfRxIndication(PduIdType PduId, const uint8* SduPtr);\r
119 void PduR_LoIfTxConfirmation(PduIdType PduId);\r
120 void PduR_LoIfTriggerTransmit(PduIdType PduId, uint8* SduPtr);\r
121 \r
122 /*\r
123  * Macros\r
124  */\r
125 #define setTxConfP(R) R->PduRDestPdu.TxBufferRef->TxConfP = 1\r
126 #define clearTxConfP(R) R->PduRDestPdu.TxBufferRef->TxConfP = 0\r
127 \r
128 #endif\r
129 \r
130 extern PduR_FctPtrType PduR_StdCanFctPtrs;\r
131 extern PduR_FctPtrType PduR_StdLinFctPtrs;\r
132 \r
133 #endif /* _PDUR_H_ */\r