]> rtime.felk.cvut.cz Git - arc.git/blobdiff - communication/CanIf/CanIf.c
Merged in J1939Tp
[arc.git] / communication / CanIf / CanIf.c
index 35724281346e03876f781c385b919ae95766473a..e20a7ce877512c721ef1f9e1a1da02e025c1db3c 100644 (file)
@@ -877,7 +877,6 @@ void CanIf_RxIndication(uint8 Hrh, Can_IdType CanId, uint8 CanDlc,
             return;\r
 #endif\r
             break;\r
-\r
         case CANIF_USER_TYPE_J1939TP:\r
           // Send Can frame to CAN TP\r
 #if defined(USE_J1939TP)\r
@@ -889,9 +888,8 @@ void CanIf_RxIndication(uint8 Hrh, Can_IdType CanId, uint8 CanDlc,
             }\r
             return;\r
 #endif\r
-            break;\r
+            break;            \r
       }\r
-\r
     }\r
 \r
     entry++;\r
@@ -954,18 +952,28 @@ void CanIf_SetWakeupEvent(uint8 Controller)
 \r
 void CanIf_Arc_Error(uint8 Controller, Can_Arc_ErrorType Error)\r
 {\r
-#if  ( CANIF_DEV_ERROR_DETECT == STD_ON )\r
   // We call this a CanIf channel. Hopefully makes it easier to follow.\r
-  CanIf_Arc_ChannelIdType channel = Controller;\r
-#endif\r
+  CanIf_Arc_ChannelIdType channel = (CanIf_Arc_ChannelIdType) Controller;\r
 \r
   VALIDATE_NO_RV( CanIf_Global.initRun, CANIF_ARCERROR_ID, CANIF_E_UNINIT );\r
   VALIDATE_NO_RV( channel < CANIF_CHANNEL_CNT, CANIF_ARCERROR_ID, CANIF_E_PARAM_CONTROLLER );\r
 \r
+  /* Same handling for Arc error as for BUS_OFF even if not in AR req.\r
+   * This because we do want same handling for upper layer for restart of channel\r
+   * According to figure 35 in canif spec this should be done in\r
+   * Can driver but it is better to do it here */\r
+  CanIf_SetControllerMode(channel, CANIF_CS_STOPPED);\r
+\r
   if (CanIf_ConfigPtr->DispatchConfig->CanIfErrorNotificaton != NULL)\r
   {\r
     CanIf_ConfigPtr->DispatchConfig->CanIfErrorNotificaton(Controller, Error);\r
   }\r
+\r
+  // Special fix for restart of bus incase of general can error i.e. connection to CanSM\r
+  if (CanIf_ConfigPtr->DispatchConfig->CanIfBusOffNotification != NULL)\r
+  {\r
+    CanIf_ConfigPtr->DispatchConfig->CanIfBusOffNotification(channel);\r
+  }\r
 }\r
 \r
 uint8 CanIf_Arc_GetChannelDefaultConfIndex(CanIf_Arc_ChannelIdType Channel)