]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Fixed problem with tx warnings generating interrupts that wasn't cleared and some...
authorjcar <devnull@localhost>
Mon, 23 Apr 2012 20:09:06 +0000 (22:09 +0200)
committerjcar <devnull@localhost>
Mon, 23 Apr 2012 20:09:06 +0000 (22:09 +0200)
arch/ppc/mpc55xx/drivers/Can.c
communication/CanIf/CanIf.c

index 6ccba1646c7f37e571bbf2c6f0f7021f49df43d0..d749bca8dc49416b38c85355524aa604ea2f7b20 100644 (file)
@@ -394,13 +394,7 @@ static void Can_Err(int unit)
         GET_CALLBACKS()->Arc_Error(unit, err);\r
     }\r
 \r
-    /* TODO: To avoid flooding the CPU with errors some intelligent\r
-     * decisions have to be made here. CanSM should handle this.\r
-     * (not implemented)\r
-     *\r
-     * So, turn the interrupts OFF.\r
-     */\r
-    canHw->CR.B.ERRMSK = 0;\r
+    Can_SetControllerMode(unit, CAN_T_STOP); // CANIF272 Same handling as for busoff\r
 \r
     // Clear ERRINT\r
     canHw->ESR.R = esrWrite.R;\r
@@ -414,41 +408,37 @@ static void Can_Err(int unit)
 // Uses 25.4.5.1 Transmission Abort Mechanism\r
 static void Can_AbortTx(flexcan_t *canHw, Can_UnitType *canUnit)\r
 {\r
   uint32 mbMask;\r
uint64_t mbMask;\r
     uint8 mbNr;\r
-\r
     // Find our Tx boxes.\r
     mbMask = canUnit->Can_Arc_TxMbMask;\r
-\r
     // Loop over the Mb's set to abort\r
-    for (; mbMask; mbMask &= ~(1 << mbNr)) {\r
-        mbNr = ilog2(mbMask);\r
-\r
+    for (; mbMask; mbMask &= ~(1ull << mbNr)) {\r
+        mbNr = ilog2_64(mbMask);\r
         canHw->BUF[mbNr].CS.B.CODE = MB_ABORT;\r
-\r
         // Did it take\r
         if (canHw->BUF[mbNr].CS.B.CODE != MB_ABORT) {\r
             // nope..\r
-\r
             /* it's not sent... or being sent.\r
              * Just wait for it\r
-             *\r
-             * TODO: Add 64 box support\r
              */\r
             int i = 0;\r
-            while (canHw->IFRL.R == (1 << mbNr)) {\r
+            while (*(uint64_t *) (&canHw->IFRH.R) & (1ull << mbNr)) {\r
                 i++;\r
-                if (i > 1000)\r
+                if (i > 1000) {\r
                     break;\r
+                }\r
             }\r
         }\r
-    }\r
 \r
-    // Ack tx interrupts, TODO: Add 64bit support\r
-    canHw->IFRL.R = canUnit->Can_Arc_TxMbMask;\r
+        // Clear interrupt\r
+        clearMbFlag(canHw,mbNr);\r
+        canUnit->mbTxFree |= (1ull << mbNr);\r
+    }\r
 }\r
 \r
 \r
+\r
 /**\r
  * BusOff ISR for CAN\r
  *\r
@@ -475,12 +465,6 @@ static void Can_BusOff(int unit)
     }\r
 #endif\r
 \r
-    if (err.R != 0) {\r
-        if (GET_CALLBACKS()->Arc_Error != NULL) {\r
-            GET_CALLBACKS()->Arc_Error(unit, err);\r
-        }\r
-    }\r
-\r
     if (canHw->ESR.B.BOFFINT) {\r
 #if (USE_CAN_STATISTICS == STD_ON)\r
         canUnit->stats.boffCnt++;\r
@@ -1179,8 +1163,11 @@ void Can_EnableControllerInterrupts(uint8 controller)
 \r
         canHw->CR.B.ERRMSK = 1; /* Enable error interrupt */\r
         canHw->CR.B.BOFFMSK = 1; /* Enable bus-off interrupt */\r
+\r
+#if (USE_CAN_STATISTICS == STD_ON)\r
         canHw->CR.B.TWRNMSK = 1; /* Enable Tx warning */\r
         canHw->CR.B.RWRNMSK = 1; /* Enable Rx warning */\r
+#endif\r
     }\r
 \r
     return;\r
index 91992780b3946c5a56e2c93aad26d8c05498ed58..14bc8d2031683e026e3aec50999e66f6c0593d4e 100644 (file)
@@ -978,12 +978,6 @@ void CanIf_Arc_Error(uint8 Controller, Can_Arc_ErrorType Error)
 \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