]> rtime.felk.cvut.cz Git - arc.git/blob - boards/mpc5516it/config/Can_Cfg.h
Initial commit.
[arc.git] / boards / mpc5516it / config / Can_Cfg.h
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
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>.
9  *
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
13  * for more details.
14  * -------------------------------- Arctic Core ------------------------------*/
15
16
17
18
19
20
21
22
23 #ifndef CAN_CFG_H_\r
24 #define CAN_CFG_H_\r
25 \r
26 // Number of controller configs\r
27 #define CAN_ECORE_CTRL_CONFIG_CNT   2\r
28 \r
29 #define CAN_DEV_ERROR_DETECT          STD_ON\r
30 #define CAN_VERSION_INFO_API          STD_ON\r
31 #define CAN_MULTIPLEXED_TRANSMISSION  STD_ON    // Makes no differens in the code\r
32 #define CAN_WAKEUP_SUPPORT            STD_OFF   // Not supported\r
33 #define CAN_HW_TRANSMIT_CANCELLATION   STD_OFF  // Not supported\r
34 \r
35 // loop cnt.. very strange timeout\r
36 #define CAN_TIMEOUT_DURATION          100\r
37 \r
38 #define INTERRUPT               0\r
39 #define POLLING                 1\r
40 \r
41 // Can controller\r
42 #define CAN_BUSOFF_PROCESSING         INTERRUPT  // INTERRUPT/POLLING\r
43 #define CAN_CONTROLLER_ACTIVATION     OFF\r
44 #define CAN_CONTROLLER_BAUD_RATE      125000\r
45 #define CAN_DRIVER_CONTROLLER_ID      0\r
46 #define CAN_CONTROLLER_PROP_SEG       4\r
47 #define CAN_CONTROLLER_PHASE1_SEG     4\r
48 #define CAN_CONTROLLER_PHASE2_SEG     4\r
49 #define CAN_CONTROLLER_TIME_QUANTA    4\r
50 #define CAN_RX_PROCESSING             INTERRUPT\r
51 #define CAN_TX_PROCESSING             INTERRUPT\r
52 #define CAN_WAKEUP_PROCESSING         INTERRUPT\r
53 \r
54 typedef enum {\r
55   CAN_CTRL_A = 0,\r
56   CAN_CTRL_B,\r
57   CAN_CTRL_C,\r
58   CAN_CTRL_D,\r
59   CAN_CTRL_E,\r
60   CAN_CTRL_F,\r
61   CAN_CONTROLLER_CNT  \r
62 }CanControllerIdType;\r
63 \r
64 typedef enum {\r
65   CAN_ID_TYPE_EXTENDED,\r
66   CAN_ID_TYPE_MIXED,\r
67   CAN_ID_TYPE_STANDARD,\r
68 } Can_IdTypeType;\r
69 \r
70 typedef enum {\r
71   CAN_OBJECT_TYPE_RECEIVE,\r
72   CAN_OBJECT_TYPE_TRANSMIT,\r
73 } Can_ObjectTypeType;\r
74 \r
75 typedef enum {\r
76   CAN_ECORE_HANDLE_TYPE_BASIC,\r
77   CAN_ECORE_HANDLE_TYPE_FULL\r
78 } Can_EcoreHohType;\r
79 \r
80 // HTH definitions\r
81 // Due to effiency: Start with index 0 and don't use any holes in the enumeration\r
82 typedef enum {\r
83   CAN_HTH_A_1 = 0,\r
84   CAN_HTH_C_1,\r
85   NUM_OF_HTHS\r
86 } Can_EcoreHTHType;\r
87 \r
88 // HRH definitions\r
89 // Due to effiency: Start with index 0 and don't use any holes in the enumeration\r
90 typedef enum {\r
91   CAN_HRH_A_1 = 0,\r
92   CAN_HRH_C_1,\r
93   NUM_OF_HRHS\r
94 } Can_EcoreHRHType;\r
95 \r
96 // Non-standard type\r
97 typedef struct {\r
98   void (*CancelTxConfirmation)( const Can_PduType *);\r
99   void (*RxIndication)( uint8 ,Can_IdType ,uint8 , const uint8 * );\r
100   void (*ControllerBusOff)(uint8);\r
101   void (*TxConfirmation)(PduIdType);\r
102   void (*ControllerWakeup)(uint8);\r
103   void (*EcoreError)(uint8,Can_EcoreErrorType);\r
104 } Can_CallbackType;\r
105 \r
106 /*\r
107  * CanGeneral Container\r
108  */\r
109 \r
110 // This container contains the parameters related each CAN Driver Unit.\r
111 typedef struct {\r
112   //  Specifies the InstanceId of this module instance. If only one instance is\r
113   //  present it shall have the Id 0\r
114   int CanIndex;\r
115 \r
116 #if 0 // This is only used by the config tool\r
117   //  This parameter describes the period for cyclic call to\r
118   //  Can_MainFunction_Busoff. Unit is seconds.\r
119   float CanMainFunctionBusoffPeriod;\r
120   //  This parameter describes the period for cyclic call to\r
121   //  Can_MainFunction_Read. Unit is seconds.\r
122   float CanMainFunctionReadPeriod;\r
123   // This parameter describes the period for cyclic call to\r
124   // Can_MainFunction_Wakeup. Unit is seconds.\r
125   float CanMainFunctionWakeupPeriod;\r
126   //  This parameter describes the period for cyclic call to\r
127   //  Can_MainFunction_Write. Unit is seconds.\r
128   float CanMainFunctionWritePeriod;\r
129 #endif\r
130 \r
131 \r
132 #if ( CAN_TIMEOUT_DURATION == STD_ON )\r
133   //  Specifies the maximum number of loops for blocking function until a\r
134   //  timeout is raised in short term wait loops.\r
135   uint32 CanTimeoutDurationFactor;\r
136 #endif\r
137 \r
138 } Can_GeneralType;\r
139 \r
140 \r
141 /*\r
142  * CanFilterMask container\r
143  */\r
144 typedef uint32 Can_FilterMaskType;\r
145 \r
146 /*\r
147  * CanHardwareObject container\r
148  */\r
149 \r
150 //This container contains the configuration (parameters) of CAN Hardware\r
151 //Objects.\r
152 typedef struct Can_HardwareObjectStruct {\r
153   // Specifies the type (Full-CAN or Basic-CAN) of a hardware object.\r
154   Can_EcoreHohType CanHandleType;\r
155 \r
156   // Specifies whether the IdValue is of type - standard identifier - extended\r
157   // identifier - mixed mode ImplementationType: Can_IdType\r
158   Can_IdTypeType CanIdType;\r
159 \r
160   //  Specifies (together with the filter mask) the identifiers range that passes\r
161   //  the hardware filter.\r
162   uint32 CanIdValue;\r
163 \r
164   //  Holds the handle ID of HRH or HTH. The value of this parameter is unique\r
165   //  in a given CAN Driver, and it should start with 0 and continue without any\r
166   //  gaps. The HRH and HTH Ids are defined under two different name-spaces.\r
167   //  Example: HRH0-0, HRH1-1, HTH0-2, HTH1-3\r
168   uint32 CanObjectId;\r
169 \r
170   // Specifies if the HardwareObject is used as Transmit or as Receive object\r
171   Can_ObjectTypeType CanObjectType;\r
172 \r
173   // Reference to the filter mask that is used for hardware filtering togerther\r
174   // with the CAN_ID_VALUE\r
175   Can_FilterMaskType *CanFilterMaskRef;\r
176 \r
177   // A "1" in this mask tells the driver that that HW Message Box should be\r
178   // occupied by this Hoh. A "1" in bit 31(ppc) occupies Mb 0 in HW.\r
179   uint32 CanEcoreMbMask;\r
180 \r
181   // End Of List. Set to TRUE is this is the last object in the list.\r
182   boolean CanEcoreEOL;\r
183 \r
184 } Can_HardwareObjectType;\r
185 \r
186 \r
187 /*\r
188  * CanController container\r
189  */\r
190 typedef enum {\r
191   CAN_ECORE_PROCESS_TYPE_INTERRUPT,\r
192   CAN_ECORE_PROCESS_TYPE_POLLING,\r
193 } Can_EcoreProcessType;\r
194 \r
195 typedef struct {\r
196 \r
197   //  Enables / disables API Can_MainFunction_BusOff() for handling busoff\r
198   //  events in polling mode.\r
199   // INTERRUPT or POLLING\r
200   Can_EcoreProcessType CanBusOffProcessing;\r
201 \r
202   // Defines if a CAN controller is used in the configuration.\r
203   boolean CanControllerActivation;\r
204 \r
205   // Specifies the buadrate of the controller in kbps.\r
206   uint32 CanControllerBaudRate;\r
207 \r
208   //  This parameter provides the controller ID which is unique in a given CAN\r
209   //  Driver. The value for this parameter starts with 0 and continue without any\r
210   //  gaps.\r
211   CanControllerIdType CanControllerId;\r
212 \r
213   // Specifies propagation delay in time quantas.\r
214   uint32 CanControllerPropSeg;\r
215 \r
216   // Specifies phase segment 1 in time quantas.\r
217   uint32 CanControllerSeg1;\r
218 \r
219   // Specifies phase segment 2 in time quantas.\r
220   uint32 CanControllerSeg2;\r
221 \r
222   //  Specifies the time quanta for the controller. The calculation of the resulting\r
223   //  prescaler value depending on module clocking and time quanta shall be\r
224   //  done offline Hardware specific.\r
225   uint32 CanControllerTimeQuanta;\r
226 \r
227   //  Enables / disables API Can_MainFunction_Read() for handling PDU\r
228   //  reception events in polling mode.\r
229   Can_EcoreProcessType CanRxProcessing;\r
230 \r
231   //  Enables / disables API Can_MainFunction_Write() for handling PDU\r
232   //  transmission events in polling mode.\r
233   Can_EcoreProcessType CanTxProcessing;\r
234 \r
235   //  Enables / disables API Can_MainFunction_Wakeup() for handling wakeup\r
236   //  events in polling mode.\r
237   Can_EcoreProcessType CanWakeupProcessing;\r
238 \r
239   //  Reference to the CPU clock configuration, which is set in the MCU driver\r
240   //  configuration\r
241   uint32 CanCpuClockRef;\r
242 \r
243   //  This parameter contains a reference to the Wakeup Source for this\r
244   //  controller as defined in the ECU State Manager. Implementation Type:\r
245   //  reference to EcuM_WakeupSourceType\r
246   uint32 CanWakeupSourceRef;\r
247 \r
248   //\r
249   // Ecore stuff\r
250   //\r
251 \r
252   // List of Hoh id's that belong to this controller\r
253   const Can_HardwareObjectType  *CanEcoreHoh;\r
254 \r
255   boolean CanEcoreLoopback;\r
256 \r
257   // Set this to use the fifo\r
258   boolean CanEcoreFifo;\r
259 \r
260 } Can_ControllerConfigType;\r
261 \r
262 \r
263 \r
264 /*\r
265  * CanConfigSet container\r
266  */\r
267 typedef struct {\r
268   const Can_ControllerConfigType *CanController;\r
269   \r
270   // Callbacks( Extension )\r
271   const Can_CallbackType *CanCallbacks;\r
272 } Can_ConfigSetType;\r
273 \r
274 \r
275 typedef struct {\r
276   // This is the multiple configuration set container for CAN Driver\r
277   // Multiplicity 1..*\r
278   const Can_ConfigSetType   *CanConfigSet;\r
279   // This container contains the parameters related each CAN\r
280   // Driver Unit.\r
281   // Multiplicity 1..*\r
282   const Can_GeneralType   *CanGeneral;\r
283 \r
284 \r
285 } Can_ConfigType;\r
286 \r
287 \r
288 extern const Can_ConfigType CanConfigData;\r
289 extern const Can_ControllerConfigType CanControllerConfigData[];\r
290 extern const Can_ConfigSetType Can_ConfigSet;\r
291 \r
292 \r
293 #endif /*CAN_CFG_H_*/\r