1 /* -------------------------------- Arctic Core ------------------------------
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
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>.
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
14 * -------------------------------- Arctic Core ------------------------------*/
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 3
\r
31 #define PDUR_SW_MINOR_VERSION 0
\r
32 #define PDUR_SW_PATCH_VERSION 2
\r
34 #include "PduR_Cfg.h"
\r
35 #include "PduR_Types.h"
\r
37 #ifndef PDUR_ZERO_COST_OPERATION
\r
38 #include "PduR_PbCfg.h"
\r
41 #include "PduR_Com.h"
\r
42 #include "PduR_CanIf.h"
\r
43 #include "PduR_LinIf.h"
\r
45 /* Contain the current state of the PDU router. The router is uninitialized
\r
46 * until PduR_Init has been run.
\r
48 PduR_StateType PduRState;
\r
50 extern const PduR_PBConfigType *PduRConfig;
\r
52 #ifdef PDUR_PRINT_DEBUG_STATEMENTS
\r
53 /* A simple debug macro to be used instead of printf(). This way all print
\r
54 * statements are turned off if PDUR_PRINT_DEBUG_STATEMENTS is undefined.
\r
56 //#include <stdio.h>
\r
57 #define debug(...) simple_printf(__VA_ARGS__)
\r
64 #ifdef PDUR_REENTRANCY_CHECK
\r
66 * The macros Enter and Exit performs the ReEntrancy check of the PDU router functions.
\r
67 * Enter shall be called at the beginning of the function with the current PduId and the wanted
\r
68 * return value (possibly nothing for void methods).
\r
69 * Exit should be called at the end of the function where reentrancy is desirable.
\r
71 #define Enter(PduId,...) \
\r
72 static uint8 entered;\
\r
73 static PduIdType enteredId;\
\r
74 if (entered && enteredId == PduId) { \
\r
75 debug("Function already entered. EnteredId: %d, CurrentId: %d. Exiting.\n", enteredId, PduId); \
\r
76 return __VA_ARGS__; \
\r
79 enteredId = PduId; \
\r
91 #ifdef PDUR_DEV_ERROR_DETECT
\r
93 #undef DET_REPORTERROR
\r
94 #define DET_REPORTERROR(_x,_y,_z,_q) Det_ReportError(_x,_y,_z,_q)
\r
96 // Define macro for state, parameter and data pointer checks.
\r
97 // TODO Implement data range check if needed.
\r
98 #define DevCheck(PduId,PduPtr,ApiId,...) \
\r
99 if (PduRState == PDUR_UNINIT || PduRState == PDUR_REDUCED) { \
\r
100 DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, ApiId, PDUR_E_INVALID_REQUEST); \
\r
101 DEBUG(DEBUG_LOW,"PDU Router not initialized. Routing request ignored.\n"); \
\r
103 return __VA_ARGS__; \
\r
105 if (PduPtr == 0 && PDUR_DEV_ERROR_DETECT) { \
\r
106 DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, ApiId, PDUR_E_DATA_PTR_INVALID); \
\r
108 return __VA_ARGS__; \
\r
110 if ((PduId >= PduRConfig->PduRRoutingTable->NRoutingPaths) && PDUR_DEV_ERROR_DETECT) { \
\r
111 DET_REPORTERROR(PDUR_MODULE_ID, PDUR_INSTANCE_ID, ApiId, PDUR_E_PDU_ID_INVALID); \
\r
113 return __VA_ARGS__; \
\r
118 #undef DET_REPORTERROR
\r
119 #define DET_REPORTERROR(_x,_y,_z,_q)
\r
120 #define DevCheck(...)
\r
124 Std_ReturnType PduR_CancelTransmitRequest(
\r
125 PduR_CancelReasonType PduCancelReason, PduIdType PduId);
\r
126 void PduR_ChangeParameterRequest(PduR_ParameterValueType PduParameterValue,
\r
129 /* Zero Cost Operation function definitions
\r
130 * These macros replaces the original functions if zero cost
\r
131 * operation is desired. */
\r
132 #ifdef PDUR_ZERO_COST_OPERATION
\r
134 #define PduR_Init(...)
\r
135 #define PduR_GetVersionInfo(...)
\r
136 #define PduR_GetConfigurationId(...) 0
\r
138 #else // Not zero cost operation
\r
139 void PduR_Init(const PduR_PBConfigType* ConfigPtr);
\r
140 void PduR_GetVersionInfo(Std_VersionInfoType* versionInfo);
\r
141 uint32 PduR_GetConfigurationId();
\r
143 void PduR_BufferQueue(PduRTxBuffer_type *Buffer, const uint8 * SduPtr);
\r
144 void PduR_BufferDeQueue(PduRTxBuffer_type *Buffer, uint8 *SduPtr);
\r
145 void PduR_BufferFlush(PduRTxBuffer_type *Buffer);
\r
146 uint8 PduR_BufferIsFull(PduRTxBuffer_type *Buffer);
\r
151 #define setTxConfP(R) R->PduRDestPdu.TxBufferRef->TxConfP = 1
\r
152 #define clearTxConfP(R) R->PduRDestPdu.TxBufferRef->TxConfP = 0
\r
156 extern PduR_FctPtrType PduR_StdCanFctPtrs;
\r
157 extern PduR_FctPtrType PduR_StdLinFctPtrs;
\r
159 #endif /* _PDUR_H_ */
\r