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
// 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
}\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
\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
\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