]> rtime.felk.cvut.cz Git - arc.git/blob - boards/mpc5567qrtech/config/CanIf_Cfg.c
Initial commit.
[arc.git] / boards / mpc5567qrtech / config / CanIf_Cfg.c
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 #include "CanIf.h"\r
24 #include <stdlib.h>\r
25 \r
26 // Imported structs from Can_Lcfg.c\r
27 extern const Can_ControllerConfigType CanControllerConfigData[];\r
28 extern const Can_ConfigSetType CanConfigSetData;\r
29 \r
30 \r
31 // Container that gets slamed into CanIf_InitController()\r
32 // Inits ALL controllers\r
33 // Multiplicity 1..*\r
34 const CanIf_ControllerConfigType CanIfControllerConfig[] =\r
35 {\r
36   { // This is the ConfigurationIndex in CanIf_InitController()\r
37     .WakeupSupport = CANIF_WAKEUP_SUPPORT_NO_WAKEUP,\r
38     .CanIfControllerIdRef = CAN_CTRL_A,\r
39     .CanIfDriverNameRef = "FLEXCAN",  // Not used\r
40     .CanIfInitControllerRef = &CanControllerConfigData[0],\r
41   },\r
42   {\r
43     .WakeupSupport = CANIF_WAKEUP_SUPPORT_NO_WAKEUP,\r
44     .CanIfControllerIdRef = CAN_CTRL_C,\r
45     .CanIfDriverNameRef = "FLEXCAN", // Not used\r
46     .CanIfInitControllerRef = &CanControllerConfigData[1],\r
47   }\r
48 };\r
49 \r
50 // Function callbacks for higher layers\r
51 const CanIf_DispatchConfigType CanIfDispatchConfig =\r
52 {\r
53   .CanIfBusOffNotification = NULL,\r
54   .CanIfWakeUpNotification = NULL,        // Not used\r
55   .CanIfWakeupValidNotification = NULL,   // Not used\r
56   .CanIfErrorNotificaton = NULL,\r
57 };\r
58 \r
59 //-------------------------------------------------------------------\r
60 const CanIf_HthConfigType CanIfHthConfigData[] =\r
61 {\r
62   {\r
63     .CanIfHthType = CAN_ECORE_HANDLE_TYPE_BASIC,\r
64     .CanIfCanControllerIdRef = CAN_CTRL_A,\r
65     .CanIfHthIdSymRef = CAN_HTH_A_1, // Ref to the HTH\r
66     .CanIfEcoreEOL = 0,\r
67   },\r
68   {\r
69     .CanIfHthType = CAN_ECORE_HANDLE_TYPE_BASIC,\r
70     .CanIfCanControllerIdRef = CAN_CTRL_C,\r
71     .CanIfHthIdSymRef = CAN_HTH_C_1, // Ref to the HTH\r
72     .CanIfEcoreEOL = 1,\r
73   },\r
74 };\r
75 \r
76 //-------------------------------------------------------------------\r
77 const CanIf_HrhConfigType CanIfHrhConfigData[] =\r
78 {\r
79   {\r
80     .CanIfHrhType = CAN_ECORE_HANDLE_TYPE_BASIC,\r
81     .CanIfSoftwareFilterHrh = TRUE,   // Disable software filtering\r
82     .CanIfCanControllerHrhIdRef = CAN_CTRL_A,\r
83     .CanIfHrhIdSymRef = CAN_HRH_A_1, // Ref to the HRH\r
84     .CanIfEcoreEOL = 0,\r
85   },\r
86   {\r
87     .CanIfHrhType = CAN_ECORE_HANDLE_TYPE_BASIC,\r
88     .CanIfSoftwareFilterHrh = TRUE,   // Disable software filtering\r
89     .CanIfCanControllerHrhIdRef = CAN_CTRL_C,\r
90     .CanIfHrhIdSymRef = CAN_HRH_C_1, // Ref to the HRH\r
91     .CanIfEcoreEOL = 1,\r
92   },\r
93 };\r
94 //-------------------------------------------------------------------\r
95 \r
96 /*\r
97  *  TX PDUs\r
98  */\r
99 const CanIf_TxPduConfigType CanIfTxPduConfigData[] =\r
100 {\r
101   {\r
102     .CanIfTxPduId = PDU_MSG_HARDWARE_TEST_ENGINE_STATUS, //PDU_MSG_TX789,\r
103     .CanIfCanTxPduIdCanId = 0x0000000,\r
104     .CanIfCanTxPduIdDlc = 8,\r
105     .CanIfCanTxPduType = CANIF_PDU_TYPE_STATIC,\r
106 #if ( CANIF_READTXPDU_NOTIFY_STATUS_API == STD_ON )\r
107     .CanIfReadTxPduNotifyStatus = FALSE,\r
108 #endif\r
109     .CanIfTxPduIdCanIdType = CANIF_CAN_ID_TYPE_29,\r
110     .CanIfUserTxConfirmation = PduR_CanIfTxConfirmation, //NULL,\r
111     .CanIfCanTxPduHthRef = &CanIfHthConfigData[0], // Send on controller A,\r
112     .PduIdRef = NULL,\r
113   },\r
114   {\r
115     .CanIfTxPduId = PDU_MSG_TX987,\r
116     .CanIfCanTxPduIdCanId = 0x0000100,\r
117     .CanIfCanTxPduIdDlc = 8,\r
118     .CanIfCanTxPduType = CANIF_PDU_TYPE_DYNAMIC,\r
119 #if ( CANIF_READTXPDU_NOTIFY_STATUS_API == STD_ON )\r
120     .CanIfReadTxPduNotifyStatus = FALSE,\r
121 #endif\r
122     .CanIfTxPduIdCanIdType = CANIF_CAN_ID_TYPE_29,\r
123     .CanIfUserTxConfirmation = NULL,\r
124     .CanIfCanTxPduHthRef = &CanIfHthConfigData[1], // Send on controller C,\r
125     .PduIdRef = NULL,\r
126   },\r
127   //Added by mattias\r
128         {\r
129           .CanIfTxPduId = 2, //PDU_MSG_TX789,\r
130           .CanIfCanTxPduIdCanId = 0x0000200,\r
131           .CanIfCanTxPduIdDlc = 8,\r
132           .CanIfCanTxPduType = CANIF_PDU_TYPE_STATIC,\r
133         #if ( CANIF_READTXPDU_NOTIFY_STATUS_API == STD_ON )\r
134           .CanIfReadTxPduNotifyStatus = FALSE,\r
135         #endif\r
136           .CanIfTxPduIdCanIdType = CANIF_CAN_ID_TYPE_29,\r
137           .CanIfUserTxConfirmation = PduR_CanIfTxConfirmation, // NULL\r
138           .CanIfCanTxPduHthRef = &CanIfHthConfigData[0], // Send on controller A,\r
139           .PduIdRef = NULL,\r
140         },\r
141 };\r
142 //-------------------------------------------------------------------\r
143 \r
144 /*\r
145  *  RX PDUs\r
146  */\r
147 const CanIf_RxPduConfigType CanIfRxPduConfigData[] =\r
148 {\r
149   {\r
150     .CanIfCanRxPduId = PDU_MSG_HARDWARE_TEST_ENGINE_CONTROL, //PDU_MSG_RX234,\r
151     .CanIfCanRxPduCanId = 1, // CAN ID\r
152     .CanIfCanRxPduDlc = 8, //DLC\r
153 #if ( CANIF_CANPDUID_READDATA_API == STD_ON )\r
154     .CanIfReadRxPduData = FALSE, // no buffering\r
155 #endif\r
156 #if ( CANIF_READRXPDU_NOTIF_STATUS_API == STD_ON )\r
157     .CanIfReadRxPduNotifyStatus = FALSE, // No indication\r
158 #endif\r
159     .CanIfRxPduIdCanIdType = CANIF_CAN_ID_TYPE_29,\r
160     .CanIfRxUserType = CANIF_USER_TYPE_CAN_PDUR, // CANIF_USER_TYPE_CAN_SPECIAL, // Changed by Mattias to test PDU router and Com layer.\r
161     .CanIfUserRxIndication = NULL, // No indication\r
162     .CanIfCanRxPduHrhRef = &CanIfHrhConfigData[0], // Received on controller A\r
163     .PduIdRef = NULL, // Could be used by upper layers\r
164     .CanIfSoftwareFilterType = CANIF_SOFTFILTER_TYPE_MASK, // Not enabled in HRH\r
165     .CanIfCanRxPduCanIdMask = 0xFFF,\r
166   },\r
167   {\r
168     .CanIfCanRxPduId = PDU_MSG_HARDWARE_TEST_ROUTED_MSG, //PDU_MSG_RX123,\r
169     .CanIfCanRxPduCanId = 0x02, // CAN ID\r
170     .CanIfCanRxPduDlc = 8, //DLC\r
171 #if ( CANIF_CANPDUID_READDATA_API == STD_ON )\r
172     .CanIfReadRxPduData = FALSE, // no buffering\r
173 #endif\r
174 #if ( CANIF_READRXPDU_NOTIF_STATUS_API == STD_ON )\r
175     .CanIfReadRxPduNotifyStatus = FALSE, // No indication\r
176 #endif\r
177     .CanIfRxPduIdCanIdType = CANIF_CAN_ID_TYPE_29, //\r
178     .CanIfRxUserType = CANIF_USER_TYPE_CAN_PDUR, // CANIF_USER_TYPE_CAN_SPECIAL,\r
179     .CanIfUserRxIndication = NULL, // No indication\r
180     .CanIfCanRxPduHrhRef = &CanIfHrhConfigData[0], //&CanIfHrhConfigData[1], // Received on controller C\r
181     .PduIdRef = NULL, //\r
182     .CanIfSoftwareFilterType = CANIF_SOFTFILTER_TYPE_MASK, // Not enabled in HRH\r
183     .CanIfCanRxPduCanIdMask = 0xFFF,\r
184   },\r
185 \r
186 };\r
187 \r
188 //-------------------------------------------------------------------\r
189 const CanIf_InitHohConfigType CanIfHohConfigData[] =\r
190 {\r
191   {\r
192     .CanConfigSet = &CanConfigSetData,\r
193     .CanIfHrhConfig = CanIfHrhConfigData,\r
194     .CanIfHthConfig = CanIfHthConfigData,\r
195     .CanIfEcoreEOL = 1,\r
196   },\r
197 };\r
198 \r
199 // This container contains the init parameters of the CAN\r
200 // Multiplicity 1..*\r
201 const CanIf_InitConfigType CanIfInitConfig =\r
202 {\r
203   .CanIfConfigSet = 0, // Not used\r
204   .CanIfNumberOfCanRxPduIds = sizeof(CanIfRxPduConfigData)/sizeof(CanIf_RxPduConfigType),\r
205   .CanIfNumberOfCanTXPduIds = sizeof(CanIfTxPduConfigData)/sizeof(CanIf_TxPduConfigType),\r
206   .CanIfNumberOfDynamicCanTXPduIds = 0, // Not used\r
207 \r
208   // Containers\r
209   .CanIfHohConfigPtr = CanIfHohConfigData,\r
210   .CanIfRxPduConfigPtr = CanIfRxPduConfigData,\r
211   .CanIfTxPduConfigPtr = CanIfTxPduConfigData,\r
212 };\r
213 \r
214 // This container includes all necessary configuration sub-containers\r
215 // according the CAN Interface configuration structure.\r
216 CanIf_ConfigType CanIf_Config =\r
217 {\r
218   .ControllerConfig = CanIfControllerConfig,\r
219   .DispatchConfig = &CanIfDispatchConfig,\r
220   .InitConfig = &CanIfInitConfig,\r
221   .TransceiverConfig = NULL, // Not used\r
222 };\r
223 \r