]> rtime.felk.cvut.cz Git - arc.git/commitdiff
More work on CAN driver. Cleanup of files in cortex R4 port.
authormaek <devnull@localhost>
Fri, 12 Nov 2010 10:41:20 +0000 (11:41 +0100)
committermaek <devnull@localhost>
Fri, 12 Nov 2010 10:41:20 +0000 (11:41 +0100)
12 files changed:
arch/arm/arm_cr4/drivers/Can.c
arch/arm/arm_cr4/drivers/Can_cortexr4.h [deleted file]
arch/arm/arm_cr4/drivers/Mcu.c
arch/arm/arm_cr4/kernel/arch_krn.sx
arch/arm/arm_cr4/kernel/core_cr4.h
arch/arm/arm_cr4/kernel/irq.c
arch/arm/arm_cr4/kernel/irq_types.h
arch/arm/arm_cr4/kernel/stack.h
arch/arm/arm_cr4/kernel/startup_cr4.s
boards/ti_tms570ls/memory.ldf
include/Mcu.h
system/kernel/isr.c

index 6695a6fc8406f93c305b806a73bf7f36de30af1e..3ab545642cc5edd0bab5bd02be88ff074c8ead51 100644 (file)
@@ -1,8 +1,17 @@
-\r
-\r
-/*----------------------------------------------------------------------------*/\r
-/* Include Files                                                              */\r
-\r
+/* -------------------------------- Arctic Core ------------------------------\r
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
+ *\r
+ * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
+ *\r
+ * This source code is free software; you can redistribute it and/or modify it\r
+ * under the terms of the GNU General Public License version 2 as published by the\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ *\r
+ * This program is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
+ * for more details.\r
+ * -------------------------------- Arctic Core ------------------------------*/\r
 \r
 \r
 #include "Can.h"\r
 #include "Dem.h"\r
 #endif\r
 #include "Det.h"\r
-//#include "Spi.h"\r
-//#include "EcuM_Cbk.h"\r
 #include "CanIf_Cbk.h"\r
-//#include "MemMap.h"\r
 #include "Os.h"\r
 #include "irq.h"\r
+#include "Mcu.h"\r
+\r
+#define DCAN1_MAX_MESSAGEBOXES 64\r
+#define DCAN2_MAX_MESSAGEBOXES 64\r
+#define DCAN3_MAX_MESSAGEBOXES 32\r
 \r
+#define CAN_TIMEOUT_DURATION   0xFFFFFFFF\r
+#define CAN_INSTANCE           0\r
 \r
 \r
 #if !defined(USE_DEM)\r
 /*----------------------------------------------------------------------------*/\r
 /* Variable Definition                                                        */\r
 \r
+// Array for easy access to DCAN register definitions.\r
 static Can_RegisterType* CanBase[]=\r
 {\r
-    Can0_Base,\r
-#ifdef Can1_Base\r
-    Can1_Base\r
-#endif\r
+       DCAN1_Base,\r
+       DCAN2_Base,\r
+       DCAN3_Base\r
 };\r
 \r
 typedef enum\r
@@ -42,23 +55,11 @@ typedef enum
     CAN_READY\r
 } Can_StateType;\r
 \r
-typedef enum\r
-{\r
-    INTERRUPT = 0x00000400,\r
-    POLLING   = 0x00000000\r
-} OpMode;\r
 \r
 typedef struct\r
 {\r
-    OpMode       BusOff;\r
-    OpMode       RxProc;\r
-    OpMode       TxProc;\r
-    OpMode       WakeupProc;\r
-    uint16       MessageBoxCount;\r
     uint16       MaxBoxes;\r
-    uint8        FirstHandle;\r
     uint32       WakeupSrc;\r
-    uint32      *MaskRefPtr;\r
     Can_PduType *PduPtr;\r
     uint8       *CancelPtr;\r
     uint8       *TxPtr;    \r
@@ -69,7 +70,8 @@ typedef struct
 /* Module is in uninitialized state */\r
 static Can_StateType            ModuleState = CAN_UNINIT;\r
 #endif\r
-static CanIf_ControllerModeType ControllerMode[CAN_CONTROLLER_COUNT];\r
+\r
+static CanIf_ControllerModeType ControllerMode[CAN_ARC_CTRL_CONFIG_CNT];\r
 \r
 /* Used to switch between IF1 and IF2 of DCAN */\r
 static uint8 IfRegId = 0;\r
@@ -81,73 +83,98 @@ static const uint8 ElementIndex[] = {3, 2, 1, 0, 7, 6, 5, 4};
 static const Can_ConfigType *CurConfig;\r
 \r
 /* To save the PduData of transmission objects */\r
-static Can_PduType PduInfoArray_0[MAX_MESSAGEBOXES_0];\r
+static Can_PduType PduInfoArray_1[DCAN1_MAX_MESSAGEBOXES];\r
 /* To save pending Cancel Requests of transmission objects */\r
-static uint8 CancelRqstArray_0[MAX_MESSAGEBOXES_0];\r
+static uint8 CancelRqstArray_1[DCAN1_MAX_MESSAGEBOXES];\r
 /* To save pending Transmit Requests of transmission objects */\r
-static uint8 TxRqstArray_0[MAX_MESSAGEBOXES_0];\r
-/* Array to save Filtermask references of MessageObjects */\r
-static uint32 FilterMaskRef_0[MESSAGEBOX_COUNT_0];\r
-\r
-#ifdef CanController_1\r
-static Can_PduType PduInfoArray_1[MAX_MESSAGEBOXES_1];\r
-static uint8 CancelRqstArray_1[MAX_MESSAGEBOXES_1];\r
-static uint8 TxRqstArray_1[MAX_MESSAGEBOXES_1];\r
-static uint32 FilterMaskRef_1[MESSAGEBOX_COUNT_1];\r
-#endif\r
+static uint8 TxRqstArray_1[DCAN1_MAX_MESSAGEBOXES];\r
+\r
+static Can_PduType PduInfoArray_2[DCAN2_MAX_MESSAGEBOXES];\r
+static uint8 CancelRqstArray_2[DCAN2_MAX_MESSAGEBOXES];\r
+static uint8 TxRqstArray_2[DCAN2_MAX_MESSAGEBOXES];\r
+\r
+static Can_PduType PduInfoArray_3[DCAN3_MAX_MESSAGEBOXES];\r
+static uint8 CancelRqstArray_3[DCAN3_MAX_MESSAGEBOXES];\r
+static uint8 TxRqstArray_3[DCAN3_MAX_MESSAGEBOXES];\r
+\r
 \r
 /* Holds the Controller specific configuration */ \r
 static Controller_PreConfigType ControllerConfig[] =\r
 {\r
-    {\r
-        BUSOFF_PROCESSING_0,\r
-        RX_PROCESSING_0,\r
-        TX_PROCESSING_0,\r
-        WAKEUP_PROCESSING_0,\r
-        MESSAGEBOX_COUNT_0,\r
-        MAX_MESSAGEBOXES_0,\r
-        FIRST_HANDLE_0,\r
-        WAKEUP_SRC_REF_0,\r
-        FilterMaskRef_0,\r
-        PduInfoArray_0,\r
-        CancelRqstArray_0,\r
-        TxRqstArray_0\r
+    { // DCAN1\r
+        .MaxBoxes = DCAN1_MAX_MESSAGEBOXES,\r
+        .WakeupSrc = 0,\r
+        .PduPtr = PduInfoArray_1,\r
+        .CancelPtr = CancelRqstArray_1,\r
+        .TxPtr = TxRqstArray_1\r
     },\r
-#ifdef CanController_1\r
-    {\r
-        BUSOFF_PROCESSING_1,\r
-        RX_PROCESSING_1,\r
-        TX_PROCESSING_1,\r
-        WAKEUP_PROCESSING_1,\r
-        MESSAGEBOX_COUNT_1,\r
-        MAX_MESSAGEBOXES_1,\r
-        FIRST_HANDLE_1,\r
-        WAKEUP_SRC_REF_1,\r
-        FilterMaskRef_1,\r
-        PduInfoArray_1,\r
-        CancelRqstArray_1,\r
-        TxRqstArray_1\r
-    }\r
-#endif\r
+    { // DCAN2\r
+        .MaxBoxes = DCAN2_MAX_MESSAGEBOXES,\r
+        .WakeupSrc = 1,\r
+        .PduPtr = PduInfoArray_2,\r
+        .CancelPtr = CancelRqstArray_2,\r
+        .TxPtr = TxRqstArray_2\r
+    },\r
+    { // DCAN3\r
+               .MaxBoxes = DCAN3_MAX_MESSAGEBOXES,\r
+               .WakeupSrc = 1,\r
+               .PduPtr = PduInfoArray_3,\r
+               .CancelPtr = CancelRqstArray_3,\r
+               .TxPtr = TxRqstArray_3\r
+       }\r
+\r
 };\r
 \r
 /* Shadow Buffer is used for buffering of received data */ \r
-static uint8 RxShadowBuf[8];\r
+static uint8 RxShadowBuf[CAN_ARC_CTRL_CONFIG_CNT][8];\r
 \r
 /* Driver must know how often Can_DisableControllerInterrupts() has been called */\r
-static uint32 IntDisableCount[CAN_CONTROLLER_COUNT];\r
+static uint32 IntDisableCount[CAN_ARC_CTRL_CONFIG_CNT];\r
+\r
+\r
+static inline const Can_HardwareObjectType * Can_FindTxHoh(Can_Arc_HTHType hth) {\r
+       for (int i = 0; i < CAN_ARC_CTRL_CONFIG_CNT; i++) {\r
+               const Can_HardwareObjectType * hoh = CanControllerConfigData[i].Can_Arc_Hoh;\r
+               hoh--;\r
+               do {\r
+                       hoh++;\r
+                       if (hoh->CanObjectType == CAN_OBJECT_TYPE_TRANSMIT && hoh->CanObjectId == hth) {\r
+                               return hoh;\r
+                       }\r
+               } while (!hoh->Can_Arc_EOL);\r
+       }\r
+       return 0;\r
+}\r
 \r
+static inline uint8 Can_FindControllerId(Can_Arc_HTHType hth) {\r
+       for (int i = 0; i < CAN_ARC_CTRL_CONFIG_CNT; i++) {\r
+               const Can_HardwareObjectType * hoh = CanControllerConfigData[i].Can_Arc_Hoh;\r
+               hoh--;\r
+               do {\r
+                       hoh++;\r
+                       if (hoh->CanObjectType == CAN_OBJECT_TYPE_TRANSMIT && hoh->CanObjectId == hth) {\r
+                               return i;\r
+                       }\r
+               } while (!hoh->Can_Arc_EOL);\r
+       }\r
+       return 0;\r
+}\r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can1_InterruptHandler_0                                     */\r
-/* Description:   CAN Node 1 Level 0 Interrupt Service Routine                */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
+static inline const Can_HardwareObjectType * Can_FindRxHoh(CanControllerIdType Controller, uint8 msgNr) {\r
+       const Can_HardwareObjectType * hoh = CanControllerConfigData[Controller].Can_Arc_Hoh;\r
+       hoh--;\r
+       do {\r
+               hoh++;\r
+               if (hoh->CanObjectType == CAN_OBJECT_TYPE_RECEIVE\r
+                               && (hoh->Can_Arc_MbMask & (1 << (msgNr - 1))) ) {\r
+                       return hoh;\r
+               }\r
+       } while (!hoh->Can_Arc_EOL);\r
+       return 0;\r
+}\r
 \r
-//#pragma INTERRUPT(CAN1_INTERRUPTHANDLER_0,IRQ)\r
 \r
-void CAN1_INTERRUPTHANDLER_0()\r
+void Can_InterruptHandler(CanControllerIdType controller)\r
 {\r
     uint32  ErrCounter;\r
     uint32  MsgNr;\r
@@ -160,21 +187,21 @@ void CAN1_INTERRUPTHANDLER_0()
 \r
     ErrCounter = CAN_TIMEOUT_DURATION;\r
 \r
-    uint32 ir = CanBase[0]->IR;\r
+    uint32 ir = CanBase[controller]->IR;\r
 \r
     if(ir == 0x8000)\r
     {\r
-       uint32 sr = CanBase[0]->SR;\r
+       uint32 sr = CanBase[controller]->SR;\r
         /* WakeUp Pending */\r
         if(sr & 0x00000200) {\r
             /* Set Init Bit, so that Controller is in Stop state */\r
-            CanBase[0]->CTL |= 0x1;\r
+            CanBase[controller]->CTL |= 0x1;\r
            // EcuM_CheckWakeUp(ControllerConfig[0].WakeupSrc);\r
 \r
         }\r
         /* Bus Off */\r
         if(sr & 0x00000080) {\r
-               Can_SetControllerMode(0, CAN_T_STOP); // CANIF272\r
+               Can_SetControllerMode(controller, CAN_T_STOP); // CANIF272\r
             //CanIf_ControllerBusOff(0); // Not implemented in Arctic Core\r
 \r
         }\r
@@ -184,10 +211,10 @@ void CAN1_INTERRUPTHANDLER_0()
         MsgNr = ir;\r
 \r
         /* Read Arbitration, Control and Data Bits and clear IntPnd and NewDat*/\r
-        CanBase[0]->IFx[IfRegId].COM = 0x003F0000 | MsgNr;\r
+        CanBase[controller]->IFx[IfRegId].COM = 0x003F0000 | MsgNr;\r
 \r
         /* Wait until Busy Flag is 0 */\r
-        while(CanBase[0]->IFx[IfRegId].COM & 0x8000)\r
+        while(CanBase[controller]->IFx[IfRegId].COM & 0x8000)\r
         {\r
             ErrCounter--;\r
             if(ErrCounter == 0)\r
@@ -199,69 +226,81 @@ void CAN1_INTERRUPTHANDLER_0()
         }\r
 \r
         /* Transmit Object */\r
-        if(CanBase[0]->IFx[IfRegId].ARB & 0x20000000)\r
+        if(CanBase[controller]->IFx[IfRegId].ARB & 0x20000000)\r
         {\r
             /* Reset TxRqst-Array Element */\r
-            TxRqstArray_0[MsgNr - 1] = 0;\r
+               ControllerConfig[controller].TxPtr[MsgNr - 1] = 0;\r
             /* A Message was successfully transmitted */\r
-            CanIf_TxConfirmation(PduInfoArray_0[MsgNr - 1].swPduHandle);\r
+            CanIf_TxConfirmation(ControllerConfig[controller].PduPtr[MsgNr - 1].swPduHandle);\r
         }\r
         /* Receive Object */\r
         else\r
         {\r
             /* Extended Id */\r
-            if(CanBase[0]->IFx[IfRegId].ARB & 0x40000000)\r
+            if(CanBase[controller]->IFx[IfRegId].ARB & 0x40000000)\r
             {\r
                 /* Bring Id to standardized format (MSB marks extended Id) */\r
-                MsgId = (CanBase[0]->IFx[IfRegId].ARB & 0x1FFFFFFF) | 0x80000000;\r
+                MsgId = (CanBase[controller]->IFx[IfRegId].ARB & 0x1FFFFFFF) | 0x80000000;\r
             }\r
             /* Standard Id */\r
             else\r
             {\r
                 /* Bring Id to standardized format (MSB marks extended Id) */\r
-                MsgId = (CanBase[0]->IFx[IfRegId].ARB & 0x1FFC0000) >> 18;\r
+                MsgId = (CanBase[controller]->IFx[IfRegId].ARB & 0x1FFC0000) >> 18;\r
             }\r
             /* DLC (Max 8) */\r
-            MsgDlc = CanBase[0]->IFx[IfRegId].MC & 0x000F;\r
+            MsgDlc = CanBase[controller]->IFx[IfRegId].MC & 0x000F;\r
             if(MsgDlc > 8)\r
             {\r
                 MsgDlc = 8;\r
             }\r
             /* Let SduPtr point to Shadow Buffer */\r
-            SduPtr = RxShadowBuf;\r
+            SduPtr = RxShadowBuf[controller];\r
 \r
             /* Copy Message Data to Shadow Buffer */\r
             for(DataByteIndex = 0; DataByteIndex < MsgDlc; DataByteIndex++)\r
             {\r
-                RxShadowBuf[DataByteIndex] = CanBase[0]->IFx[IfRegId].DATx[ElementIndex[DataByteIndex]];\r
+               SduPtr[DataByteIndex] = CanBase[controller]->IFx[IfRegId].DATx[ElementIndex[DataByteIndex]];\r
             }\r
             /* Indicate successful Reception */\r
-            CanIf_RxIndication(CurConfig->MessageBoxPtr[MsgNr - 1].ObjectId, MsgId, MsgDlc, SduPtr);\r
+            const Can_HardwareObjectType *hoh = Can_FindRxHoh(controller, MsgNr);\r
+            CanIf_RxIndication(hoh->CanObjectId, MsgId, MsgDlc, SduPtr);\r
+\r
         }\r
     }\r
     //Can_EnableControllerInterrupts(0);\r
 }\r
 \r
+void Can1_InterruptHandler() {\r
+       Can_InterruptHandler(DCAN1);\r
+}\r
 \r
+void Can2_InterruptHandler() {\r
+       Can_InterruptHandler(DCAN2);\r
+}\r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_Init                                                    */\r
-/* Service Id:    0x00                                                        */\r
-/* Execution:     Synchronous                                                 */\r
-/* Re-entrant:    No                                                          */\r
-/* Description:   Initialize Can Driver                                       */\r
-/* ConfigPtr:     Pointer to initialization data                              */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:                                                                   */\r
-/*                                                                            */\r
-void CAN_INIT(const Can_ConfigType *Config)\r
+void Can3_InterruptHandler() {\r
+       Can_InterruptHandler(DCAN3);\r
+}\r
+\r
+uint32 Can_CalculateBTR(uint8 Controller) {\r
+\r
+       uint32 clock = McuE_GetPeripheralClock(PERIPHERAL_CLOCK_CAN);\r
+       uint32 tq1 = CanControllerConfigData[Controller].CanControllerPropSeg + CanControllerConfigData[Controller].CanControllerSeg1;\r
+       uint32 tq2 = CanControllerConfigData[Controller].CanControllerSeg2;\r
+       uint32 ntq = tq1 + tq2 + 1 + 1 + 1;\r
+       uint32 brp = clock / (CanControllerConfigData[Controller].CanControllerBaudRate * 1000 * ntq) - 1;\r
+\r
+       uint32 retVal = (brp | (tq1 << 8) | (tq2 << 12));\r
+       return retVal;\r
+}\r
+\r
+\r
+void Can_Init(const Can_ConfigType *Config)\r
 {\r
     uint32                    Controller;\r
     uint8                     MsgNr;\r
     uint32                    ErrCounter;\r
-    Can_ControllerConfigType *CurControllerPtr;\r
-    Can_MessageObjectType    *MsgBoxPtr;\r
-    uint32                   *CurFilterMaskPtr;\r
     uint32                    Eob;\r
 \r
 /* DET Error Check */\r
@@ -278,21 +317,18 @@ void CAN_INIT(const Can_ConfigType *Config)
     }\r
 #endif \r
      \r
+    // TODO This should be used instead of other variables in the Can_Lcfg file.\r
     CurConfig        = Config;\r
-    /* Set Pointer to ControllerConfig */\r
-    CurControllerPtr = Config->ControllerConfigPtr;    \r
-    /* Set Pointer to MessageObjects */\r
-    MsgBoxPtr        = CurConfig->MessageBoxPtr;\r
 \r
-    for(Controller = 0; Controller < CAN_CONTROLLER_COUNT; Controller++)\r
+    for(Controller = 0; Controller < CAN_ARC_CTRL_CONFIG_CNT; Controller++)\r
     {\r
         ErrCounter = CAN_TIMEOUT_DURATION;\r
 \r
         /* Init, IE, AutomaticRetransmission, ConfChangeEnable, ABO Off,Parity On, SIE and EIE depending on ControllerConfig */\r
 #if(CAN_WAKEUP_SUPPORT == STD_ON)\r
-        CanBase[Controller]->CTL = 0x02001643 | (ControllerConfig[Controller].WakeupProc >> 8) | (ControllerConfig[Controller].BusOff >> 7);\r
+        CanBase[Controller]->CTL = 0x02001643;// | (CanControllerConfigData[Controller].CanWakeupProcessing >> 8) | (CanControllerConfigData[Controller].CanBusOffProcessing >> 7);\r
 #else\r
-        CanBase[Controller]->CTL = 0x00001643 | (ControllerConfig[Controller].WakeupProc >> 8) | (ControllerConfig[Controller].BusOff >> 7);\r
+        CanBase[Controller]->CTL = 0x00001643;// | (CanControllerConfigData[Controller].CanWakeupProcessing >> 8) | (CanControllerConfigData[Controller].CanBusOffProcessing >> 7);\r
 #endif        \r
         /* LEC 7, TxOk, RxOk, PER */\r
         CanBase[Controller]->SR  = 0x0000011F;\r
@@ -301,14 +337,13 @@ void CAN_INIT(const Can_ConfigType *Config)
         //CanBase[Controller]->CTL |= 0x00000080;\r
         //CanBase[Controller]->TR   = 0x00000018;\r
             \r
-        for(MsgNr = 0; MsgNr < ControllerConfig[Controller].MaxBoxes; MsgNr++)\r
-        {\r
+\r
+        // Basic message object initialization\r
+        for(MsgNr = 0; MsgNr < ControllerConfig[Controller].MaxBoxes; MsgNr++) {\r
             /* Initialize the Arrays for Transmit and Cancellation handling */\r
             *(ControllerConfig[Controller].CancelPtr + MsgNr) = 0;\r
             *(ControllerConfig[Controller].TxPtr     + MsgNr) = 0;\r
             \r
-            /* Set the current FilterMaskPointer */\r
-            CurFilterMaskPtr = CurControllerPtr->FilterMaskPtr;\r
             /* Wait until Busy Flag is 0 */\r
             while(CanBase[Controller]->IFx[IfRegId].COM & 0x00008000)\r
             {\r
@@ -320,82 +355,119 @@ void CAN_INIT(const Can_ConfigType *Config)
                     return;\r
                 }\r
             }\r
-            /* Configure the post-build defined MessageObjects */\r
-            if(MsgNr < ControllerConfig[Controller].MessageBoxCount)\r
-            {   \r
-                /* Check, if the next message object has the same values as the current, and if it is the last one */             \r
-                if((MsgNr     < (ControllerConfig[Controller].MessageBoxCount - 1)) &&\r
-                   (MsgBoxPtr->Direction       == CAN_RECEIVE                     ) &&\r
-                   (MsgBoxPtr->Direction       == (MsgBoxPtr + 1)->Direction      ) &&\r
-                   (MsgBoxPtr->IdType          == (MsgBoxPtr + 1)->IdType         ) &&\r
-                   (MsgBoxPtr->IdValue         == (MsgBoxPtr + 1)->IdValue        ) &&\r
-                   (MsgBoxPtr->FilterMaskIndex == (MsgBoxPtr + 1)->FilterMaskIndex) &&\r
-                   (MsgBoxPtr->HandleType      == (MsgBoxPtr + 1)->HandleType     )\r
-                  )\r
-                {\r
-                    /* EndOfBlock Bit will not be set */\r
-                    Eob = 0x00000000;\r
-                }\r
-                else\r
-                {\r
-                    /* EndOfBlock Bit will be set */\r
-                    Eob = 0x00000080;\r
-                }\r
-                /* DLC=8, Use Mask only for receive, Set RxIE/TxIE depending on pre-config settings, Eob */\r
-                CanBase[Controller]->IFx[IfRegId].MC   = 0x00001008 | ControllerConfig[Controller].RxProc | (ControllerConfig[Controller].TxProc << 1) | Eob & ~(MsgBoxPtr->Direction >> 17);\r
-                \r
-                if(MsgBoxPtr->IdType == CAN_STANDARD)      /* Standard Identifiers */\r
-                {\r
-                    /* Only Standard-Ids are accepted, Set Mask */\r
-                    CanBase[Controller]->IFx[IfRegId].MASK = 0x80000000 | ((*(CurFilterMaskPtr + MsgBoxPtr->FilterMaskIndex)) & 0x1FFFFFFF);\r
-                    /* Message valid, Id, Direction */\r
-                    CanBase[Controller]->IFx[IfRegId].ARB  = 0x80000000 | ((MsgBoxPtr->IdValue & 0x7FF) << 18) | MsgBoxPtr->Direction;\r
-                }\r
-                else if(MsgBoxPtr->IdType == CAN_EXTENDED) /* Extended Identifiers */\r
-                {\r
-                    /* Only Extended-Ids are accepted, Set Mask */\r
-                    CanBase[Controller]->IFx[IfRegId].MASK = 0x80000000 | ((*(CurFilterMaskPtr + MsgBoxPtr->FilterMaskIndex)) & 0x1FFFFFFF);\r
-                    /* Message valid, Id, Direction */\r
-                    CanBase[Controller]->IFx[IfRegId].ARB  = 0xC0000000 | (MsgBoxPtr->IdValue & 0x1FFFFFFF) | MsgBoxPtr->Direction;    \r
-                }\r
-                else /* Mixed Identifiers */\r
-                {\r
-                    /* Standard- and Mixed-Ids are accepted, Set Mask */\r
-                    CanBase[Controller]->IFx[IfRegId].MASK = 0x00000000 | ((*(CurFilterMaskPtr + MsgBoxPtr->FilterMaskIndex)) & 0x1FFFFFF);\r
-                    /* Message valid, Id, Direction */\r
-                    CanBase[Controller]->IFx[IfRegId].ARB  = 0xC0000000 | (MsgBoxPtr->IdValue & 0x1FFFFFF) | MsgBoxPtr->Direction;\r
-                }\r
-                /* Start writing Mask, Arb, Control and Id bits */\r
-                CanBase[Controller]->IFx[IfRegId].COM  = 0x00F80000 | (MsgNr + 1);\r
-                \r
-                /* Save FilterMask reference of actual MessageObject */\r
-                *(ControllerConfig[Controller].MaskRefPtr + MsgNr) = MsgBoxPtr->FilterMaskIndex;\r
-\r
-                /* Increment Pointer to next MessageObject */\r
-                MsgBoxPtr++;\r
-            }\r
-            else /* Configure all other MessageObjects to not valid */\r
-            {\r
-                /* Valid = 0 */\r
-                CanBase[Controller]->IFx[IfRegId].ARB = 0x00000000;\r
-                /* Start writing Arbitration Bits */\r
-                CanBase[Controller]->IFx[IfRegId].COM = 0x00A80000 | (MsgNr + 1);\r
-            }\r
-            /* Use IFx[0] and IFx[1] alternating */\r
-            IfRegId ^= 1;\r
+\r
+            // Initialize all message objects for this controller to invalid state.\r
+            /* Valid = 0 */\r
+                       CanBase[Controller]->IFx[IfRegId].ARB = 0x00000000;\r
+                       /* Start writing Arbitration Bits */\r
+                       CanBase[Controller]->IFx[IfRegId].COM = 0x00A80000 | (MsgNr + 1);\r
+\r
+                       /* Use IFx[0] and IFx[1] alternating */\r
+                       IfRegId ^= 1;\r
+\r
         }\r
+\r
+               /* Configure the HOHs for this controller. */\r
+               const Can_HardwareObjectType* hoh;\r
+               hoh = CanControllerConfigData[Controller].Can_Arc_Hoh;\r
+               hoh--;\r
+               do {\r
+                       hoh++;\r
+                       uint64 mbMask = hoh->Can_Arc_MbMask;\r
+                       uint32 mbNr = 0;\r
+                       uint32 nProcessedMb = 0;\r
+\r
+                       // For every message object in this hoh\r
+                       for(; mbMask != 0; mbMask >>= 1) {\r
+                               mbNr++;\r
+                               if (!(mbMask & 1)) {\r
+                                       // This message object is not part of this hoh.\r
+                                       continue;\r
+                               }\r
+                               nProcessedMb++;\r
+\r
+                               // Check if this is the last message box for this hoh.\r
+                               if((mbMask != 1) &&\r
+                                  (hoh->CanObjectType == CAN_OBJECT_TYPE_RECEIVE)) {\r
+                                       /* EndOfBlock Bit will not be set */\r
+                                       Eob = 0x00000000;\r
+                               }\r
+                               else\r
+                               {\r
+                                       /* EndOfBlock Bit will be set */\r
+                                       Eob = 0x00000080;\r
+                               }\r
+\r
+                               /* DLC=8, Use Mask only for receive, Set RxIE/TxIE depending on pre-config settings, Eob */\r
+                               CanBase[Controller]->IFx[IfRegId].MC = 0x00001008 | CanControllerConfigData[Controller].CanRxProcessing | (CanControllerConfigData[Controller].CanTxProcessing << 1) | Eob & ~(hoh->CanObjectType >> 17);\r
+\r
+                               if(hoh->CanIdType == CAN_ID_TYPE_STANDARD)      /* Standard Identifiers */\r
+                               {\r
+                                       /* Only Standard-Ids are accepted, Set Mask */\r
+                                       CanBase[Controller]->IFx[IfRegId].MASK = 0x80000000 | ((*(hoh->CanFilterMaskRef)) & 0x1FFFFFFF);\r
+                                       /* Message valid, Id, Direction */\r
+                                       CanBase[Controller]->IFx[IfRegId].ARB  = 0x80000000 | ((hoh->CanIdValue & 0x7FF) << 18) | hoh->CanObjectType;\r
+                               }\r
+                               else if(hoh->CanIdType == CAN_ID_TYPE_EXTENDED) /* Extended Identifiers */\r
+                               {\r
+                                       /* Only Extended-Ids are accepted, Set Mask */\r
+                                       CanBase[Controller]->IFx[IfRegId].MASK = 0x80000000 | ((*(hoh->CanFilterMaskRef)) & 0x1FFFFFFF);\r
+                                       /* Message valid, Id, Direction */\r
+                                       CanBase[Controller]->IFx[IfRegId].ARB  = 0xC0000000 | (hoh->CanIdValue & 0x1FFFFFFF) | hoh->CanObjectType;\r
+                               }\r
+                               else /* Mixed Identifiers */\r
+                               {\r
+                                       /* Standard- and Mixed-Ids are accepted, Set Mask */\r
+                                       CanBase[Controller]->IFx[IfRegId].MASK = 0x00000000 | ((*(hoh->CanFilterMaskRef)) & 0x1FFFFFF);\r
+                                       /* Message valid, Id, Direction */\r
+                                       CanBase[Controller]->IFx[IfRegId].ARB  = 0xC0000000 | (hoh->CanIdValue & 0x1FFFFFF) | hoh->CanObjectType;\r
+                               }\r
+                               /* Start writing Mask, Arb, Control and Id bits */\r
+                               CanBase[Controller]->IFx[IfRegId].COM  = 0x00F80000 | mbNr;\r
+\r
+                               /* Use IFx[0] and IFx[1] alternating */\r
+                               IfRegId ^= 1;\r
+\r
+                       }\r
+               } while (!hoh->Can_Arc_EOL);\r
+\r
+\r
         /* Set Bit Timing Register */\r
-        CanBase[Controller]->BTR  = CurControllerPtr->CanTimeRegister;\r
+        CanBase[Controller]->BTR = Can_CalculateBTR(Controller);\r
+\r
         /* Reset CCE Bit */\r
         CanBase[Controller]->CTL &= ~0x00000040;\r
 \r
-        /* Switch Controller pointer to next ConfigSet */\r
-        CurControllerPtr++;\r
-\r
 #if(CAN_DEV_ERROR_DETECT == STD_ON)\r
         /* Switch Controller State to CANIF_CS_STOPPED */\r
         ControllerMode[Controller] = CANIF_CS_STOPPED;\r
 #endif\r
+\r
+        // Install interrupt handlers\r
+               TaskType tid;\r
+               if (CanControllerConfigData[Controller].CanControllerId == DCAN1) {\r
+                       tid = Os_Arc_CreateIsr(Can1_InterruptHandler, 2 ,"DCAN1Level0");\r
+                       Irq_AttachIsr2(tid, NULL, 16);\r
+\r
+                       tid = Os_Arc_CreateIsr(Can1_InterruptHandler, 2, "DCAN1Level1");\r
+                       Irq_AttachIsr2(tid, NULL, 29);\r
+\r
+               } else if (CanControllerConfigData[Controller].CanControllerId == DCAN2) {\r
+                       tid = Os_Arc_CreateIsr(Can2_InterruptHandler, 2 ,"DCAN2Level0");\r
+                       Irq_AttachIsr2(tid, NULL, 35);\r
+\r
+                       tid = Os_Arc_CreateIsr(Can2_InterruptHandler, 2, "DCAN2Level1");\r
+                       Irq_AttachIsr2(tid, NULL, 42);\r
+\r
+               } else if (CanControllerConfigData[Controller].CanControllerId == DCAN3) {\r
+                       tid = Os_Arc_CreateIsr(Can3_InterruptHandler, 2 ,"DCAN3Level0");\r
+                       Irq_AttachIsr2(tid, NULL, 45);\r
+\r
+                       tid = Os_Arc_CreateIsr(Can3_InterruptHandler, 2, "DCAN3Level1");\r
+                       Irq_AttachIsr2(tid, NULL, 55);\r
+\r
+               }\r
+\r
     }\r
 #if(CAN_DEV_ERROR_DETECT == STD_ON)\r
     /* Switch Module State to CAN_READY */\r
@@ -403,33 +475,13 @@ void CAN_INIT(const Can_ConfigType *Config)
 #endif\r
 \r
 \r
-    // ARC INSTALL HANDLERS\r
-    TaskType tid;\r
-    tid = Os_Arc_CreateIsr(CAN1_INTERRUPTHANDLER_0, 2 ,"Can0Level0");\r
-    Irq_AttachIsr2(tid, NULL, 16);\r
-\r
-    tid = Os_Arc_CreateIsr(CAN1_INTERRUPTHANDLER_0, 2, "Can0Level1");\r
-    Irq_AttachIsr2(tid, NULL, 29);\r
 \r
 }\r
 \r
 \r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_InitController                                          */\r
-/* Service Id:    0x02                                                        */\r
-/* Execution:     Synchronous                                                 */\r
-/* Re-entrant:    No                                                          */\r
-/* Description:   Initializes only CAN cantroller specific settings           */\r
-/* Controller:    CAN controller to be initialized                            */\r
-/* Config:        Pointer to controller configuration                         */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
-void CAN_INITCONTROLLER(uint8 Controller, const Can_ControllerConfigType* Config)\r
+void Can_InitController(uint8 Controller, const Can_ControllerConfigType* Config)\r
 {\r
-    uint32 *CurMaskRef;\r
     uint8   MsgNr;\r
     uint32  ErrCounter;\r
 \r
@@ -444,7 +496,7 @@ void CAN_INITCONTROLLER(uint8 Controller, const Can_ControllerConfigType* Config
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 2, CAN_E_UNINIT);\r
         return;\r
     }\r
-    if(Controller >= CAN_CONTROLLER_COUNT)\r
+    if(Controller >= CAN_ARC_CTRL_CONFIG_CNT)\r
     {\r
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 2, CAN_E_PARAM_CONTROLLER);\r
         return;\r
@@ -456,11 +508,24 @@ void CAN_INITCONTROLLER(uint8 Controller, const Can_ControllerConfigType* Config
     }\r
 #endif \r
 \r
-    CurMaskRef = ControllerConfig[Controller].MaskRefPtr;\r
     ErrCounter = CAN_TIMEOUT_DURATION;\r
     \r
-    for(MsgNr = 0; MsgNr < ControllerConfig[Controller].MessageBoxCount; MsgNr++)\r
-    {\r
+    //for(MsgNr = 0; MsgNr < ControllerConfig[Controller].MessageBoxCount; MsgNr++)\r
+       const Can_HardwareObjectType* hoh;\r
+       hoh = CanControllerConfigData[Controller].Can_Arc_Hoh;\r
+       uint64 mbMask = hoh->Can_Arc_MbMask;\r
+       uint32 nProcessedMb = 0;\r
+       MsgNr = 0;\r
+\r
+       // For every message object in this hoh\r
+       for(; mbMask != 0; mbMask >>= 1) {\r
+               if (!(mbMask & 1)) {\r
+                       // This message object is not part of this hoh.\r
+                       continue;\r
+               }\r
+               MsgNr++;\r
+               nProcessedMb++;\r
+\r
         /* Wait until Busy Flag is 0 */\r
         while(CanBase[Controller]->IFx[IfRegId].COM & 0x00008000)\r
         {\r
@@ -473,7 +538,7 @@ void CAN_INITCONTROLLER(uint8 Controller, const Can_ControllerConfigType* Config
             }\r
         }\r
         /* Read actual MaskRegister value of MessageObject */\r
-        CanBase[Controller]->IFx[IfRegId].COM = 0x004C0000 | (MsgNr + 1);\r
+        CanBase[Controller]->IFx[IfRegId].COM = 0x004C0000 | (MsgNr);\r
 \r
         /* Wait until Busy Flag is 0 */\r
         while(CanBase[Controller]->IFx[IfRegId].COM & 0x00008000)\r
@@ -488,14 +553,13 @@ void CAN_INITCONTROLLER(uint8 Controller, const Can_ControllerConfigType* Config
         }\r
         CanBase[Controller]->IFx[IfRegId].MASK &= 0xD0000000;\r
         /* Set new Mask */\r
-        CanBase[Controller]->IFx[IfRegId].MASK |= *(Config->FilterMaskPtr + *CurMaskRef) & 0x1FFFFFFF;\r
+        CanBase[Controller]->IFx[IfRegId].MASK |= (*(hoh->CanFilterMaskRef)) & 0x1FFFFFFF;\r
         /* Write new Mask to MaskRegister */\r
-        CanBase[Controller]->IFx[IfRegId].COM   = 0x00C80000 | (MsgNr + 1);       \r
-        \r
-        CurMaskRef++;\r
+        CanBase[Controller]->IFx[IfRegId].COM   = 0x00C80000 | (MsgNr);\r
 \r
         IfRegId ^= 1;\r
     }\r
+\r
     /* Wait until Busy Flag is 0 */\r
     while(CanBase[Controller]->IFx[IfRegId].COM & 0x00008000)\r
     {\r
@@ -510,26 +574,13 @@ void CAN_INITCONTROLLER(uint8 Controller, const Can_ControllerConfigType* Config
     /* Set CCE Bit to allow access to BitTiming Register (Init already set, in mode "stopped") */\r
     CanBase[Controller]->CTL |= 0x00000040;\r
     /* Set Bit Timing Register */\r
-    CanBase[Controller]->BTR  = Config->CanTimeRegister;\r
+    CanBase[Controller]->BTR = Can_CalculateBTR(Controller);\r
     /* Clear CCE Bit */\r
     CanBase[Controller]->CTL &= ~0x00000040;\r
 \r
 }\r
 \r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_SetControllerMode                                       */\r
-/* Service Id:    0x03                                                        */\r
-/* Execution:     Asynchronous                                                */\r
-/* Re-entrant:    No                                                          */\r
-/* Descrpition:   Performs software triggered state transitions               */\r
-/* Controller:    CAN controller for which the status shall be changed        */\r
-/* Transition:    Transition to be done                                        */\r
-/* Return Value:  - CAN_OK: transition initiated                              */\r
-/*                - CAN_NOT_OK: error or wakeup during transition to 'sleep'  */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
 Can_ReturnType Can_SetControllerMode(uint8 Controller, Can_StateTransitionType Transition)\r
 {\r
     Can_ReturnType Status     = CAN_OK;\r
@@ -542,7 +593,7 @@ Can_ReturnType Can_SetControllerMode(uint8 Controller, Can_StateTransitionType T
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 3, CAN_E_UNINIT);\r
         return CAN_NOT_OK;\r
     }\r
-    if(Controller >= CAN_CONTROLLER_COUNT)\r
+    if(Controller >= CAN_ARC_CTRL_CONFIG_CNT)\r
     {\r
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 3, CAN_E_PARAM_CONTROLLER);\r
         return CAN_NOT_OK;\r
@@ -625,17 +676,6 @@ Can_ReturnType Can_SetControllerMode(uint8 Controller, Can_StateTransitionType T
 }\r
 \r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_DisableControllerInterrupts                             */\r
-/* Service Id:    0x04                                                        */\r
-/* Execution:     Synchronous                                                 */\r
-/* Re-entrant:    Yes                                                         */\r
-/* Description:   Disables all interrupts for this controller                 */\r
-/* Controller:    CAN controller for which interrupts shall be disabled       */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
 void Can_DisableControllerInterrupts(uint8 Controller)\r
 {\r
 #if(CAN_DEV_ERROR_DETECT == STD_ON)\r
@@ -644,7 +684,7 @@ void Can_DisableControllerInterrupts(uint8 Controller)
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 4, CAN_E_UNINIT);\r
         return;\r
     }\r
-    if(Controller >= CAN_CONTROLLER_COUNT)\r
+    if(Controller >= CAN_ARC_CTRL_CONFIG_CNT)\r
     {\r
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 4, CAN_E_PARAM_CONTROLLER);\r
         return;\r
@@ -656,18 +696,6 @@ void Can_DisableControllerInterrupts(uint8 Controller)
     IntDisableCount[Controller]++;\r
 }\r
 \r
-\r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_EnableControllerInterrupts                              */\r
-/* Service Id:    0x05                                                        */\r
-/* Execution:     Synchronous                                                 */\r
-/* Re-entrant:    Yes                                                         */\r
-/* Description:   Enables all allowed interrupts for this controller          */\r
-/* Controller:    CAN controller for which interrupts shall be re-enabled     */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
 void Can_EnableControllerInterrupts(uint8 Controller)\r
 {\r
 #if(CAN_DEV_ERROR_DETECT == STD_ON)\r
@@ -676,7 +704,7 @@ void Can_EnableControllerInterrupts(uint8 Controller)
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 5, CAN_E_UNINIT);\r
         return;\r
     }\r
-    if(Controller >= CAN_CONTROLLER_COUNT)\r
+    if(Controller >= CAN_ARC_CTRL_CONFIG_CNT)\r
     {\r
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 5, CAN_E_PARAM_CONTROLLER);\r
         return;\r
@@ -694,23 +722,11 @@ void Can_EnableControllerInterrupts(uint8 Controller)
 }\r
 \r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_Cbk_CheckWakeup                                         */\r
-/* Service Id:    0x0b                                                        */\r
-/* Execution:     Synchronous                                                 */\r
-/* Re-entrant:    No                                                          */\r
-/* Description:   Checks if a wakeup has occurred for the given controller    */\r
-/* Controller:    CAN controller to be checked for wakeup                     */\r
-/* Return Value:  - E_OK: Wakeup was detected for given controller            */\r
-/*                - E_NOT_OK: No Wakeup was detected                          */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
 void Can_Cbk_CheckWakeup(uint8 Controller)\r
 {\r
-       /*\r
+       /* TODO not supported yet.\r
 #if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-    if(Controller >= CAN_CONTROLLER_COUNT)\r
+    if(Controller >= CAN_ARC_CTRL_CONFIG_CNT)\r
     {\r
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 0x0B, CAN_E_PARAM_CONTROLLER);\r
         return CAN_NOT_OK;\r
@@ -729,37 +745,19 @@ void Can_Cbk_CheckWakeup(uint8 Controller)
 }\r
 \r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_Write                                                   */\r
-/* Service Id:    0x06                                                        */\r
-/* Execution:     Synchronous                                                 */\r
-/* Re-entrant:    Yes (thread-safe)                                           */\r
-/* Description:   --                                                          */\r
-/* Hth:           HW-transmit handle to be used for transmit                  */\r
-/* PduInfo:       Pointer to SDU user memory, DLC and Identifier              */\r
-/* Return Value:  - CAN_OK: Write command has been accepted                   */\r
-/*                - CAN_NOT_OK: Development error occured                     */\r
-/*                - CAN_BUSY: No TX hw buffer available or preemptive call    */ \r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
 Can_ReturnType Can_Write(Can_Arc_HTHType Hth, Can_PduType *PduInfo)\r
 {\r
     uint32                 ErrCounter;\r
     uint8                  ControllerId;\r
     uint8                  MsgNr;\r
-    uint32                 CancelId;\r
-    uint8                  CancelNr;  \r
     uint32                 ArbRegValue;\r
     uint8                  DataByteIndex;\r
     uint8                 *CurSduPtr;\r
     Can_PduType           *CurPduArrayPtr;\r
     uint8                 *CurCancelRqstPtr;\r
     uint8                 *CurTxRqstPtr;\r
-    Can_MessageObjectType *CurMsgBoxPtr;\r
 \r
     CurSduPtr       = PduInfo->sdu;\r
-    CurMsgBoxPtr    = CurConfig->MessageBoxPtr + Hth;\r
     ErrCounter      = CAN_TIMEOUT_DURATION;\r
     \r
 /* DET Error Check */\r
@@ -779,20 +777,32 @@ Can_ReturnType Can_Write(Can_Arc_HTHType Hth, Can_PduType *PduInfo)
         Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 6, CAN_E_PARAM_DLC);\r
         return CAN_NOT_OK;        \r
     }\r
-    if(CurMsgBoxPtr->Direction != CAN_TRANSMIT)\r
-    {\r
-        Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 6, CAN_E_PARAM_HANDLE);\r
-        return CAN_NOT_OK;\r
-    }      \r
 #endif\r
 \r
-    ControllerId     = CurMsgBoxPtr->Controller;\r
+    ControllerId = Can_FindControllerId(Hth);\r
     \r
-    MsgNr            = Hth - ControllerConfig[ControllerId].FirstHandle;\r
+    const Can_HardwareObjectType *hoh = Can_FindTxHoh(Hth);\r
 \r
-    CurPduArrayPtr   = ControllerConfig[ControllerId].PduPtr    + MsgNr;\r
-    CurCancelRqstPtr = ControllerConfig[ControllerId].CancelPtr + MsgNr;\r
-    CurTxRqstPtr     = ControllerConfig[ControllerId].TxPtr     + MsgNr;\r
+#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
+    if(hoh->CanObjectType != CAN_OBJECT_TYPE_TRANSMIT)\r
+       {\r
+               Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 6, CAN_E_PARAM_HANDLE);\r
+               return CAN_NOT_OK;\r
+       }\r
+#endif\r
+    uint64 mbMask = hoh->Can_Arc_MbMask;\r
+    MsgNr = 0;\r
+    for(; mbMask != 0; mbMask >>= 1) {\r
+               if (!(mbMask & 1)) {\r
+                       continue; // This message object is not part of this hoh.\r
+               }\r
+               // Just use the first message object.\r
+               MsgNr++;\r
+    }\r
+\r
+    CurPduArrayPtr   = ControllerConfig[ControllerId].PduPtr    + (MsgNr - 1);\r
+    CurCancelRqstPtr = ControllerConfig[ControllerId].CancelPtr + (MsgNr - 1);\r
+    CurTxRqstPtr     = ControllerConfig[ControllerId].TxPtr     + (MsgNr - 1);\r
     \r
     /* Bring Id Value to appropriate format and set ArbRegValue */\r
     if(PduInfo->id & 0x80000000)\r
@@ -809,138 +819,6 @@ Can_ReturnType Can_Write(Can_Arc_HTHType Hth, Can_PduType *PduInfo)
     /* Check if TxRqst Bit of MsgObject is set */\r
     if(CanBase[ControllerId]->TRx[MsgNr >> 5] & (1 << (MsgNr & 0x1F)))\r
     {\r
-\r
-#if(CAN_MULTIPLEXED_TRANSMISSION == STD_ON)\r
-\r
-        CancelId = ArbRegValue & 0x1FFFFFFF;\r
-        CancelNr = MsgNr;\r
-\r
-        for(MsgNr = ControllerConfig[ControllerId].MessageBoxCount; MsgNr < ControllerConfig[ControllerId].MaxBoxes; MsgNr++)\r
-        {\r
-            /* Read actual MessageObject status: Data, Arbitration, Control */\r
-            CanBase[ControllerId]->IFx[IfRegId].COM = 0x00330000 | (MsgNr + 1);       \r
-            /* Wait until Busy Flag is 0 */\r
-            while(CanBase[ControllerId]->IFx[IfRegId].COM & 0x00008000)\r
-            {\r
-                ErrCounter--;\r
-                if(ErrCounter == 0)\r
-                {\r
-                    Dem_ReportErrorStatus(CAN_E_TIMEOUT, DEM_EVENT_STATUS_FAILED);\r
-                    ErrCounter = CAN_TIMEOUT_DURATION;\r
-                    return CAN_NOT_OK;\r
-                }\r
-            }\r
-\r
-            /* If MessageObject is free, use it */\r
-            if(!(CanBase[ControllerId]->IFx[IfRegId].MC & 0x00000100))\r
-            {\r
-                CurPduArrayPtr   = ControllerConfig[ControllerId].PduPtr + MsgNr;\r
-                break;\r
-            }\r
-            /* Check if Id of MessageObject is higher */\r
-            if((CanBase[ControllerId]->IFx[IfRegId].ARB & 0x1FFFFFFF) > CancelId )\r
-            {\r
-                /* Save the highest ID (low priority) */\r
-                CancelId = CanBase[ControllerId]->IFx[IfRegId].ARB & 0x1FFFFFFF;\r
-                /* and corresponding message number */\r
-                CancelNr = MsgNr;\r
-            }\r
-        }\r
-        if(MsgNr == ControllerConfig[ControllerId].MaxBoxes)\r
-        {\r
-#if(CAN_HW_TRANSMIT_CANCELLATION == STD_ON)\r
-             /* Clear TxRqst */\r
-            CanBase[ControllerId]->IFx[IfRegId].MC  &= ~0x00000100;\r
-            /* Transfer Control bits to MessageObject */\r
-            CanBase[ControllerId]->IFx[IfRegId].COM  =  0x90000000 | (CancelNr + 1);\r
-                        \r
-            if(ControllerConfig[ControllerId].TxProc == INTERRUPT)\r
-            {\r
-                /* Set CurPduPtr to Pdu of object to cancel */             \r
-                CurPduArrayPtr  = ControllerConfig[ControllerId].PduPtr + CancelNr;\r
-                /* Wait until Busy Flag is 0 */\r
-                while(CanBase[ControllerId]->IFx[IfRegId].COM & 0x00008000)\r
-                {\r
-                    ErrCounter--;\r
-                    if(ErrCounter == 0)\r
-                    {\r
-                        Dem_ReportErrorStatus(CAN_E_TIMEOUT, DEM_EVENT_STATUS_FAILED);\r
-                        ErrCounter = CAN_TIMEOUT_DURATION;\r
-                        return CAN_NOT_OK;\r
-                    }\r
-                }\r
-                /* Notification about cancellation of object */\r
-                CanIf_CancelTxConfirmation((const Can_PduType *)CurPduArrayPtr);\r
-            }\r
-            else\r
-            {\r
-                /* Set CancelPointer to Position of cancelled Object */\r
-                CurCancelRqstPtr = ControllerConfig[ControllerId].CancelPtr + CancelNr;\r
-                /* Set Arrayelement to 1 to indicate cancellation request */\r
-                *CurCancelRqstPtr = 1;\r
-            }\r
-#endif\r
-        }\r
-#elif(CAN_HW_TRANSMIT_CANCELLATION == STD_ON)\r
-    \r
-        /* Wait until Busy Flag is 0 */\r
-        while(CanBase[ControllerId]->IFx[IfRegId].COM & 0x00008000)\r
-        {\r
-            ErrCounter--;\r
-            if(ErrCounter == 0)\r
-            {\r
-                Dem_ReportErrorStatus(CAN_E_TIMEOUT, DEM_EVENT_STATUS_FAILED);\r
-                ErrCounter = CAN_TIMEOUT_DURATION;\r
-                return CAN_NOT_OK;\r
-            }\r
-        }\r
-\r
-        /* Read actual MessageObject status: Data, Arbitration, Control */\r
-        CanBase[ControllerId]->IFx[IfRegId].COM = 0x00330000 | (MsgNr + 1);\r
-\r
-        /* Wait until Busy Flag is 0 */\r
-        while(CanBase[ControllerId]->IFx[IfRegId].COM & 0x00008000)\r
-        {\r
-            ErrCounter--;\r
-            if(ErrCounter == 0)\r
-            {\r
-                Dem_ReportErrorStatus(CAN_E_TIMEOUT, DEM_EVENT_STATUS_FAILED);\r
-                ErrCounter = CAN_TIMEOUT_DURATION;\r
-                return CAN_NOT_OK;\r
-            }\r
-        }  \r
-          \r
-        /* Check if actual message has higher priority */\r
-        if((ArbRegValue & 0x1FFFFFFF) < (CanBase[ControllerId]->IFx.ARB & 0x1FFFFFFF))\r
-        {\r
-            /* Clear TxRqst */\r
-            CanBase[ControllerId]->IFx[IfRegId].MC  &= ~0x00000100;\r
-            /* Transfer Control bits to MessageObject */\r
-            CanBase[ControllerId]->IFx[IfRegId].COM  =  0x90000000 | (MsgNr + 1);\r
-            \r
-            if(ControllerConfig[ControllerId].TxProc == INTERRUPT)\r
-            {\r
-                /* Wait until Busy Flag is 0 */\r
-                while(CanBase[ControllerId]->IFx[IfRegId].COM & 0x00008000)\r
-                {\r
-                    ErrCounter--;\r
-                    if(ErrCounter == 0)\r
-                    {\r
-                        Dem_ReportErrorStatus(CAN_E_TIMEOUT, DEM_EVENT_STATUS_FAILED);\r
-                        ErrCounter = CAN_TIMEOUT_DURATION;\r
-                        return CAN_NOT_OK;\r
-                    }\r
-                } \r
-                /* Notification about cancellation of object */\r
-                CanIf_CancelTxConfirmation((const Can_PduType *)CurPduArrayPtr);\r
-            }\r
-            else\r
-            {\r
-                /* Set Arrayelement to 1 to indicate cancellation request */\r
-                *CurCancelRqstPtr = 1;\r
-            }\r
-        }\r
-#endif\r
         return CAN_BUSY;\r
     }\r
 \r
@@ -957,7 +835,7 @@ Can_ReturnType Can_Write(Can_Arc_HTHType Hth, Can_PduType *PduInfo)
     }\r
 \r
     /* Set NewDat, TxIE (dep on ControllerConfig), TxRqst, EoB and DLC */\r
-    CanBase[ControllerId]->IFx[IfRegId].MC = 0x00000180 | (0x000F & PduInfo->length) | (ControllerConfig[ControllerId].TxProc << 1);\r
+    CanBase[ControllerId]->IFx[IfRegId].MC = 0x00000180 | (0x000F & PduInfo->length) | (CanControllerConfigData[ControllerId].CanTxProcessing << 1);\r
 \r
     /* Set ArbitrationRegister */\r
     CanBase[ControllerId]->IFx[IfRegId].ARB = ArbRegValue;\r
@@ -969,7 +847,7 @@ Can_ReturnType Can_Write(Can_Arc_HTHType Hth, Can_PduType *PduInfo)
     }\r
 \r
     /* Start transmission to MessageRAM */\r
-    CanBase[ControllerId]->IFx[IfRegId].COM = 0x00BF0000 | (MsgNr + 1);\r
+    CanBase[ControllerId]->IFx[IfRegId].COM = 0x00BF0000 | MsgNr;\r
     \r
     /* Save the PduInfo in PduArray, so that messages can be identified later */\r
     *CurPduArrayPtr = *PduInfo;\r
@@ -982,337 +860,24 @@ Can_ReturnType Can_Write(Can_Arc_HTHType Hth, Can_PduType *PduInfo)
 }\r
 \r
 \r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_MainFunction_Write                                      */\r
-/* Service Id:    0x01                                                        */\r
-/* Timing:        FIXED_CYCLIC                                                */\r
-/* Description:   Polling of TX confirmation and TX cancellation confirmation */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
-void CAN_MAINFUNCTION_WRITE()\r
+void Can_MainFunction_Write()\r
 {\r
-#if 0\r
-    uint8        Controller;\r
-    uint8        MsgNr;\r
-    Can_PduType *CurPduPtr;\r
-\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-    if(ModuleState == CAN_UNINIT)\r
-    {\r
-        Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 1, CAN_E_UNINIT);\r
-        return;\r
-    }\r
-#endif       \r
-    /* Check all controllers */\r
-    for(Controller = 0; Controller < CAN_CONTROLLER_COUNT; Controller++)\r
-    {\r
-        /* Check all MessageObjects */\r
-        for(MsgNr = 0; MsgNr < ControllerConfig[Controller].MaxBoxes; MsgNr++)\r
-        {\r
-            /* Check if a transmission was initiated for this MessageObject */\r
-            if(*(ControllerConfig[Controller].TxPtr + MsgNr) == 1)\r
-            {\r
-                /* Check if TxRqst Bit has already been reset */\r
-                if(!(CanBase[Controller]->TRx[MsgNr >> 5] & (1 << (MsgNr & 0x1F))))\r
-                {\r
-                    /* Reset swTxRqst */\r
-                    *(ControllerConfig[Controller].TxPtr + MsgNr) = 0;\r
-                    \r
-                    CurPduPtr = ControllerConfig[Controller].PduPtr + MsgNr;\r
-                    /* A Message was successfully transmitted */\r
-                    CanIf_TxConfirmation(CurPduPtr->swPduHandle);\r
-                }\r
-            }\r
-            /* Check if a cancellation was initiated for this MessageObject */\r
-            if(*(ControllerConfig[Controller].CancelPtr + MsgNr) == 1)\r
-            {\r
-                /* Check if TxRqst Bit has already been reset */\r
-                if(!(CanBase[Controller]->TRx[MsgNr >> 5] & (1 << (MsgNr & 0x1F))))\r
-                {\r
-                    /* Reset swCancelRqst */\r
-                    *(ControllerConfig[Controller].CancelPtr + MsgNr) = 0;\r
-                    \r
-                    CurPduPtr = ControllerConfig[Controller].PduPtr + MsgNr;\r
-                    /* A Message was successfully transmitted */\r
-                     CanIf_CancelTxConfirmation(CurPduPtr);     \r
-                }\r
-            }\r
-        }\r
-    }\r
-#endif\r
+       // Not supported\r
 }\r
 \r
-\r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_MainFunction_Read                                       */\r
-/* Service Id:    0x08                                                        */\r
-/* Timing:        FIXED_CYCLIC                                                */\r
-/* Description:   Polling of RX indications                                   */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
-void CAN_MAINFUNCTION_READ()\r
+void Can_MainFunction_Read()\r
 {\r
-#if 0\r
-    uint8                  Controller;\r
-    uint8                  MsgNr;\r
-    Can_MessageObjectType *CurMsgBoxPtr;\r
-    uint8                  MsgDlc;\r
-    uint32                 Identifier;\r
-    uint8                  DataByteIndex;\r
-    uint8                 *SduPtr;\r
-    uint32                 ErrCounter;    \r
-   \r
-\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-    if(ModuleState == CAN_UNINIT)\r
-    {\r
-        Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 8, CAN_E_UNINIT);\r
-        return;\r
-    }\r
-#endif\r
-\r
-    CurMsgBoxPtr = CurConfig->MessageBoxPtr;\r
-    \r
-    for(Controller = 0; Controller < CAN_CONTROLLER_COUNT; Controller++)\r
-    {\r
-        for(MsgNr = 0; MsgNr < ControllerConfig[Controller].MessageBoxCount; MsgNr++)\r
-        {\r
-            /* Check if NewDat Bit is set and if MessageObject is Receive Object */\r
-            if((CanBase[Controller]->NDx[MsgNr >> 5] & (1 << (MsgNr & 0x1F))) && (CurMsgBoxPtr->Direction == RECEIVE))\r
-            {\r
-            \r
-                /* Read Arbitration, Control and Data Bits and clear IntPnd and NewDat*/\r
-                CanBase[Controller]->IFx[IfRegId].COM = 0x003F0000 | (MsgNr + 1);\r
-                \r
-                ErrCounter = CAN_TIMEOUT_DURATION;\r
-                /* Wait until Busy Flag is 0 */\r
-                while(CanBase[Controller]->IFx[IfRegId].COM & 0x8000)\r
-                {\r
-                    ErrCounter--;\r
-                    if(ErrCounter == 0)\r
-                    {\r
-                        Dem_ReportErrorStatus(CAN_E_TIMEOUT, DEM_EVENT_STATUS_FAILED);\r
-                        return;\r
-                    }\r
-                }\r
-                /* Extended Id */\r
-                if(CanBase[0]->IFx[IfRegId].ARB & 0x40000000)\r
-                {\r
-                    /* Bring Id to standardized format (MSB marks extended Id) */\r
-                    Identifier = (CanBase[0]->IFx[IfRegId].ARB & 0x1FFFFFFF) | 0x80000000;\r
-                }\r
-                /* Standard Id */\r
-                else\r
-                {\r
-                    /* Bring Id to standardized format (MSB marks extended Id) */\r
-                    Identifier = (CanBase[0]->IFx[IfRegId].ARB & 0x1FFC0000) >> 18;\r
-                }\r
-                /* DLC (Max 8) */\r
-                MsgDlc = CanBase[0]->IFx[IfRegId].MC & 0x000F;\r
-                if(MsgDlc > 8)\r
-                {\r
-                    MsgDlc = 8;\r
-                }\r
-                /* Let SduPtr point to Shadow Buffer */\r
-                SduPtr = RxShadowBuf;\r
-\r
-                /* Copy Message Data to Shadow Buffer */\r
-                for(DataByteIndex = 0; DataByteIndex < MsgDlc; DataByteIndex++)\r
-                {\r
-                    RxShadowBuf[DataByteIndex] = CanBase[0]->IFx[IfRegId].DATx[ElementIndex[DataByteIndex]];\r
-                }\r
-                /* Indicate successful Reception */\r
-                CanIf_RxIndication(MsgNr, Identifier, MsgDlc, SduPtr);\r
-            }     \r
-            CurMsgBoxPtr++;\r
-        }\r
-    }\r
-#endif\r
+       // Not supported\r
 }\r
 \r
-\r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_MainFunction_BusOff                                     */\r
-/* Service Id:    0x09                                                        */\r
-/* Timing:        FIXED_CYCLIC                                                */\r
-/* Description:   Polling of bus-off events                                   */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
-void CAN_MAINFUNCTION_BUSOFF()\r
+void Can_MainFunction_BusOff()\r
 {\r
-    uint8  Controller;\r
-\r
-/* DET Error Check */\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-    if(ModuleState == CAN_UNINIT)\r
-    {\r
-        Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 9, CAN_E_UNINIT);\r
-        return;\r
-    }    \r
-#endif\r
-    \r
-    for(Controller = 0 ; Controller < CAN_CONTROLLER_COUNT; Controller++)\r
-    {\r
-        /* Bus Off */\r
-        if(CanBase[Controller]->SR & 0x00000080)\r
-        {\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-            ControllerMode[Controller] = CANIF_CS_STOPPED;\r
-#endif\r
-            CanIf_ControllerBusOff(Controller);\r
-        }\r
-    }\r
+  // Not supported\r
 }\r
 \r
-\r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can_MainFunction_Wakeup                                     */\r
-/* Service Id:    0x0a                                                        */\r
-/* Timing:        FIXED_CYCLIC                                                */\r
-/* Description:   Polling of wake-up events                                   */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-\r
-void CAN_MAINFUNCTION_WAKEUP()\r
+void Can_MainFunction_Wakeup()\r
 {\r
-    uint8 Controller;\r
-\r
-/* DET Error Check */\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-    if(ModuleState == CAN_UNINIT)\r
-    {\r
-        Det_ReportError(CAN_MODULE_ID, CAN_INSTANCE, 0xA, CAN_E_UNINIT);\r
-        return;\r
-    }    \r
-#endif\r
-\r
-    for(Controller = 0 ; Controller < CAN_CONTROLLER_COUNT; Controller++)\r
-    {\r
-        /* Check WakeUp Pending */\r
-        if(CanBase[Controller]->SR & 0x200)\r
-        {\r
-            /* Set Init Bit, so that Controller is in Stop state */\r
-            CanBase[Controller]->CTL |= 0x1;\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-            ControllerMode[Controller] = CANIF_CS_STOPPED;\r
-#endif\r
-            //EcuM_CheckWakeUp(ControllerConfig[Controller].WakeupSrc);\r
-        }\r
-    }\r
+   // Not supported\r
 }\r
 \r
 \r
-\r
-\r
-/*----------------------------------------------------------------------------*/\r
-/* Function Name: Can2_InterruptHandler_0                                     */\r
-/* Description:   CAN Node 2 Level 0 Interrupt Service Routine                */\r
-/* Return Value:  None                                                        */\r
-/* Remarks:       -/-                                                         */\r
-/*                                                                            */\r
-#ifdef CanController_1\r
-//#pragma INTERRUPT(CAN2_INTERRUPTHANDLER_0,IRQ)\r
-\r
-void CAN2_INTERRUPTHANDLER_0()\r
-{\r
-\r
-    uint32  ErrCounter;\r
-    uint32  MsgNr;\r
-    uint32  MsgId;\r
-    uint8   MsgDlc;\r
-    uint8   DataByteIndex;\r
-    uint8  *SduPtr; \r
-\r
-    ErrCounter = CAN_TIMEOUT_DURATION;\r
-    \r
-    if(CanBase[1]->IR == 0x8000)\r
-    {\r
-        /* WakeUp Pending */\r
-        if(CanBase[1]->SR & 0x200)\r
-        {\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-            ControllerMode[1] = CANIF_CS_STOPPED;\r
-#endif\r
-            /* Set Init Bit, so that Controller is in Stop state */\r
-            CanBase[1]->CTL |= 0x1;\r
-          //  EcuM_CheckWakeUp(ControllerConfig[1].WakeupSrc);\r
-        }\r
-        /* Bus Off */\r
-        if(CanBase[1]->SR & 0x080)\r
-        {\r
-#if(CAN_DEV_ERROR_DETECT == STD_ON)\r
-            ControllerMode[1] = CANIF_CS_STOPPED;\r
-#endif\r
-            CanIf_ControllerBusOff(1);\r
-        }\r
-    }\r
-    else\r
-    {\r
-        MsgNr = CanBase[1]->IR;\r
-        \r
-        /* Read Arbitration, Control and Data Bits and clear IntPnd */\r
-        CanBase[1]->IFx[IfRegId].COM = 0x003F0000 | MsgNr;\r
-        \r
-        /* Wait until Busy Flag is 0 */\r
-        while(CanBase[1]->IFx[IfRegId].COM & 0x8000)\r
-        {\r
-            ErrCounter--;\r
-            if(ErrCounter == 0)\r
-            {\r
-                Dem_ReportErrorStatus(CAN_E_TIMEOUT, DEM_EVENT_STATUS_FAILED);\r
-                ErrCounter = CAN_TIMEOUT_DURATION;\r
-                return;\r
-            }\r
-        }\r
-        \r
-        /* Transmit Object */\r
-        if(CanBase[1]->IFx[IfRegId].ARB & 0x20000000)\r
-        {\r
-            /* Reset TxRqst-Array Element */\r
-            TxRqstArray_1[MsgNr - 1] = 0;\r
-            /* A Message was successfully transmitted */\r
-            CanIf_TxConfirmation(PduInfoArray_1[MsgNr - 1].swPduHandle);\r
-        }        \r
-        /* Receive Object */\r
-        else\r
-        {\r
-            /* Extended Id */\r
-            if(CanBase[1]->IFx[IfRegId].ARB & 0x40000000)\r
-            {\r
-                /* Bring Id to standardized format (MSB marks extended Id) */\r
-                MsgId = (CanBase[1]->IFx[IfRegId].ARB & 0x1FFFFFFF) | 0x80000000;\r
-            }\r
-            /* Standard Id */\r
-            else\r
-            {\r
-                /* Bring Id to standardized format (MSB marks extended Id) */\r
-                MsgId = (CanBase[1]->IFx[IfRegId].ARB & 0x1FFC0000) >> 18;\r
-            }\r
-            /* DLC (Max 8) */\r
-            MsgDlc = CanBase[1]->IFx[IfRegId].MC & 0x000F;\r
-            if(MsgDlc > 8)\r
-            {\r
-                MsgDlc = 8;\r
-            }\r
-            /* Let SduPtr point to Shadow Buffer */\r
-            SduPtr = RxShadowBuf;\r
-\r
-            /* Copy Message Data to Shadow Buffer */\r
-            for(DataByteIndex = 0; DataByteIndex < MsgDlc; DataByteIndex++)\r
-            {\r
-                RxShadowBuf[DataByteIndex] = CanBase[1]->IFx[IfRegId].DATx[ElementIndex[DataByteIndex]];\r
-            }\r
-            /* Indicate successful Reception */\r
-            CanIf_RxIndication(MsgNr - 1, MsgId, MsgDlc, SduPtr);\r
-        }\r
-    }\r
-\r
-}\r
-#endif\r
diff --git a/arch/arm/arm_cr4/drivers/Can_cortexr4.h b/arch/arm/arm_cr4/drivers/Can_cortexr4.h
deleted file mode 100644 (file)
index a8cb7ac..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
-\r
-#ifndef CAN_H\r
-#define CAN_H\r
-\r
-/*\r
-// Include Files\r
-#include "ComStack_Types.h"\r
-#include "Can_Cfg.h"\r
-*/\r
-\r
-/*\r
-// Std_Types Version Check\r
-#if (STD_TYPES_AR_MAJOR_VERSION != 2)\r
-    #error Can.h: STD_TYPES_AR_MAJOR_VERSION of Std_Types.h is incompatible.\r
-#endif\r
-#if (STD_TYPES_AR_MINOR_VERSION != 1)\r
-    #error Can.h: STD_TYPES_AR_MINOR_VERSION of Std_Types.h is incompatible.\r
-#endif\r
-*/\r
-\r
-/*\r
-// CAN Published Information\r
-\r
-#define CAN_VENDOR_ID        44\r
-#define CAN_MODULE_ID       111\r
-#define CAN_AR_MAJOR_VERSION  3\r
-#define CAN_AR_MINOR_VERSION  1\r
-#define CAN_AR_PATCH_VERSION  0\r
-#define CAN_SW_MAJOR_VERSION  1\r
-#define CAN_SW_MINOR_VERSION  0\r
-#define CAN_SW_PATCH_VERSION  0\r
-\r
-\r
-\r
-// CAN Development Error Codes\r
-\r
-#define CAN_E_PARAM_POINTER              0x01\r
-#define CAN_E_PARAM_HANDLE               0x02\r
-#define CAN_E_PARAM_DLC                  0x03\r
-#define CAN_E_PARAM_CONTROLLER           0x04\r
-#define CAN_E_UNINIT                     0x05\r
-#define CAN_E_TRANSITION                 0x06\r
-*/\r
-\r
-\r
-/*\r
-// CAN register definition\r
-\r
-typedef volatile struct\r
-{\r
-    uint32   CTL;\r
-    uint32   SR;\r
-    unsigned     : 16;\r
-    unsigned REC :  8;\r
-    unsigned TEC :  8;\r
-    uint32   BTR;\r
-    uint32   IR;\r
-    uint32   TR;\r
-    unsigned : 32;\r
-    uint32   PEC;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-       unsigned : 32;\r
-       unsigned : 32;\r
-    uint32   ABOT;\r
-    uint32   TRX;\r
-    uint32   TRx[4];\r
-    uint32   NDX;\r
-    uint32   NDx[4];\r
-    uint32   IPX;\r
-    uint32   IPx[4];\r
-    uint32   MVX;\r
-    uint32   MVx[4];\r
-    unsigned : 32;\r
-    uint32   IPMx[4];\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-       unsigned : 32;\r
-    struct\r
-    {\r
-        uint32   COM;\r
-        uint32   MASK;\r
-        uint32   ARB;\r
-        uint32   MC;\r
-        uint8    DATx[8];\r
-        unsigned : 32;\r
-        unsigned : 32;\r
-    } IFx[3];\r
-    uint32   IF3UEy[4];\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-    unsigned : 32;\r
-       unsigned : 32;\r
-       unsigned : 32;\r
-       unsigned : 32;\r
-    uint32   IOTX;\r
-    uint32   IORX;\r
-} Can_RegisterType;\r
-\r
-#ifdef CAN_BASE_ADDRESS_0\r
-#define Can0_Base ((Can_RegisterType *)CAN_BASE_ADDRESS_0)\r
-#endif\r
-#ifdef CAN_BASE_ADDRESS_1\r
-#define Can1_Base ((Can_RegisterType *)CAN_BASE_ADDRESS_1)\r
-#endif\r
-*/\r
-\r
-/*----------------------------------------------------------------------------*/\r
-/* CAN Type Definitions                                                       */\r
-/*                                                                            */\r
-/* CanTimeRegister: - Bit0...Bit5: BRP (Baud Rate Prescaler)                  */\r
-/*                  - Bit6...Bit7: SJW (Synchronization Jump Width)           */\r
-/*                  - Bit8...Bit11: TSeg1                                     */\r
-/*                  - Bit12...Bit14: TSeg2                                    */\r
-/*                  - Bit16...Bit19: BRPE (Baud Rate Prescaler Extension)     */\r
-/*                                                                            */\r
-/*----------------------------------------------------------------------------*/\r
-//typedef uint32 Can_IdType;\r
-\r
-typedef enum\r
-{\r
-    CAN_RECEIVE  = 0x00000000,\r
-    CAN_TRANSMIT = 0x20000000\r
-} Can_ObjectType;\r
-\r
-typedef enum\r
-{\r
-    BASIC,\r
-       FULL\r
-} Can_HandleType;\r
-\r
-typedef enum\r
-{\r
-       CAN_EXTENDED,\r
-    CAN_MIXED,\r
-    CAN_STANDARD\r
-} Can_IdModeType;\r
-\r
-\r
-\r
-\r
-typedef struct\r
-{\r
-    Can_HandleType  HandleType;\r
-    Can_IdModeType  IdType;\r
-    Can_IdType      IdValue;\r
-       uint8           ObjectId;\r
-    Can_ObjectType  Direction;\r
-    uint8           Controller;\r
-    uint32          FilterMaskIndex;\r
-} Can_MessageObjectType;\r
-\r
-typedef struct \r
-{\r
-    uint32 CanTimeRegister;\r
-       uint32 *FilterMaskPtr;\r
-       uint8 CanControllerId;\r
-} Can_ControllerConfigType;\r
-\r
-typedef struct\r
-{\r
-    Can_ControllerConfigType *ControllerConfigPtr;\r
-    Can_MessageObjectType       *MessageBoxPtr;\r
-} Can_ConfigType;\r
-\r
-/** COPIED FROM ARC **/\r
-typedef enum {\r
-  CAN_ARC_HANDLE_TYPE_BASIC,\r
-  CAN_ARC_HANDLE_TYPE_FULL\r
-} Can_Arc_HohType;\r
-\r
-typedef enum {\r
-  CAN_HTH_A_1 = 0,\r
-  CAN_HTH_C_1,\r
-  NUM_OF_HTHS\r
-} Can_Arc_HTHType;\r
-\r
-typedef enum {\r
-  CAN_HRH_A_1 = 0,\r
-  CAN_HRH_C_1,\r
-  NUM_OF_HRHS\r
-} Can_Arc_HRHType;\r
-\r
-/** Container for callback configuration. */\r
-typedef struct {\r
-  void (*CancelTxConfirmation)( const Can_PduType *);               /**< Not supported. */\r
-  void (*RxIndication)( uint8 ,Can_IdType ,uint8 , const uint8 * ); /**< Called on successful reception of a PDU. */\r
-  void (*ControllerBusOff)(uint8);                                  /**< Called on BusOff. */\r
-  void (*TxConfirmation)(PduIdType);                                /**< Called on successful transmission of a PDU. */\r
-  void (*ControllerWakeup)(uint8);                                  /**< Not supported. */\r
-  void (*Arc_Error)(uint8,Can_Arc_ErrorType);                       /**< Called on HW error. */\r
-} Can_CallbackType;\r
-\r
-/** Container for controller parameters. */\r
-typedef struct {\r
-  const Can_ControllerConfigType *CanController;\r
-\r
-  // Callbacks( Extension )\r
-  const Can_CallbackType *CanCallbacks;\r
-} Can_ConfigSetType;\r
-\r
-/** Available HW controllers. */\r
-typedef enum {\r
-  CAN_CTRL_A = 0,\r
-  CAN_CTRL_B,\r
-  CAN_CTRL_C,\r
-  CAN_CTRL_D,\r
-  CAN_CTRL_E,\r
-  CAN_CTRL_F,\r
-  CAN_CONTROLLER_CNT\r
-}CanControllerIdType;\r
-\r
-/** Top level container for parameters. */\r
-extern const Can_ConfigType CanConfigData;\r
-/** For direct access to controller list */\r
-extern const Can_ControllerConfigType CanControllerConfigData[];\r
-/** Container for controller parameters. */\r
-extern const Can_ConfigSetType Can_ConfigSet;\r
-\r
-/** END COPIED FROM ARC **/\r
-\r
-\r
-/*\r
-// CAN Driver Function Prototypes\r
-\r
-extern void Can_Init(const Can_ConfigType *Config);\r
-extern void Can_InitController(uint8 Controller, const Can_ControllerConfigType *Config);\r
-extern Can_ReturnType Can_SetControllerMode(uint8 Controller, Can_StateTransitionType Transition);\r
-extern void Can_DisableControllerInterrupts(uint8 Controller);\r
-extern void Can_EnableControllerInterrupts(uint8 Controller);\r
-extern Std_ReturnType Can_Cbk_CheckWakeup(uint8 Controller);\r
-extern Can_ReturnType Can_Write(uint8 Hth, const Can_PduType *PduInfo);\r
-\r
-#if(CAN_VERSION_INFO_API == STD_ON)\r
-extern void Can_GetVersionInfo(Std_VersionInfoType *versioninfo);\r
-#endif\r
-\r
-extern void Can_MainFunction_Write();\r
-extern void Can_MainFunction_Read();\r
-extern void Can_MainFunction_BusOff();\r
-extern void Can_MainFunction_Wakeup();\r
-\r
-extern void Can1_InterruptHandler_0();\r
-extern void Can2_InterruptHandler_0();\r
-*/\r
-#endif /* CAN_H */\r
-\r
-/*----------------------------------------------------------------------------*/\r
index 64b8ed7e7a3ec6c855911999178052bb8803b366..5ee6570970d5eb6318762ce0d7b8b717687d8f50 100644 (file)
@@ -481,7 +481,10 @@ void McuE_ExitCriticalSection(uint32_t old_state)
  */\r
 uint32_t McuE_GetPeripheralClock(McuE_PeriperalClock_t type)\r
 {\r
-       // Not supported yet.\r
+       if (type == PERIPHERAL_CLOCK_CAN) {\r
+               uint8 vclockDiv = systemREG1->VCLKR;\r
+               return McuE_GetSystemClock() / (vclockDiv + 1);\r
+       }\r
        return 0;\r
 }\r
 \r
index cc111a79b302fff528048f0267ac9a3172f81608..33cd5bfb71fe15272544898e33620d9eb56b9e9b 100644 (file)
@@ -1,9 +1,18 @@
-\r
-/*\r
- *  Copyright ArcCore AB\r
+/* -------------------------------- Arctic Core ------------------------------\r
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
  *\r
+ * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
  *\r
- */\r
+ * This source code is free software; you can redistribute it and/or modify it\r
+ * under the terms of the GNU General Public License version 2 as published by the\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ *\r
+ * This program is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
+ * for more details.\r
+ * -------------------------------- Arctic Core ------------------------------*/\r
+\r
 \r
 #define _ASSEMBLER_\r
 #include "kernel_offset.h"\r
        .global Svc_Handler\r
     .type      Svc_Handler, %function    \r
 \r
+       .global Data_Exc_Handler\r
+    .type      Data_Exc_Handler, %function\r
+    \r
+    .global Prefetch_Exc_Handler\r
+    .type      Prefetch_Exc_Handler, %function\r
+    \r
+    .global Dummy_Irq\r
+    .type      Dummy_Irq, %function        \r
+\r
 \r
 // Registers part of context.\r
-#define REG_SAVE r4-r8,r10,r11\r
+#define REG_SAVE r0-r12\r
+\r
+\r
+// A data exception handler. This let us put a breakpoint and return to the place where the exception was caught.\r
+// If DEBUG_EXCEPTIONS is off then just use the ordinary dummy irq.\r
+Data_Exc_Handler: \r
+#ifdef CFG_ARM_CR4_DEBUG_EXCEPTIONS\r
+       // Setup return address. This requires subtraction from LR.\r
+       sub             lr, lr, #8\r
+       \r
+       // Store return stuff on system mode's stack\r
+       srsdb   sp!, #31 // 31 = System mode\r
+       \r
+       // Switch to system mode.\r
+       cpsid   i, #31  // 31 = system mode\r
+       \r
+       // Return using stuff from stack.\r
+    rfeia      sp!\r
+#else\r
+       b               Dummy_Irq\r
+#endif\r
+\r
+// A prefetch exception handler. This let us put a breakpoint and return to the place where the exception was caught.\r
+// If DEBUG_EXCEPTIONS is off then just use the ordinary dummy irq.\r
+Prefetch_Exc_Handler: \r
+#ifdef CFG_ARM_CR4_DEBUG_EXCEPTIONS    \r
+\r
+       // Switch to system mode.\r
+       cpsid   i, #31  // 31 = system mode\r
+       \r
+       // Setup return address. This requires subtraction from LR.\r
+       sub             lr, lr, #4\r
+       \r
+       // Return to the place before the instruction that caused the interrupt.\r
+    MOVS  PC, LR\r
+    \r
+#else\r
+       b               Dummy_Irq\r
+#endif\r
 \r
 \r
 Irq_Handler:\r
@@ -210,4 +266,15 @@ os_lc_restore:
     rfeia      sp!\r
 \r
     \r
-\r
+/* Interrupt routine used to catch unused interrupts and exceptions */\r
+Dummy_Irq:\r
+       /* Go back to sys mode for easier debugging.\r
+        Save link register*/\r
+       mov   r3, lr\r
+       /* We don't want to use the IRQ mode\r
+          so swich back to sys mode. */\r
+       mov   r2,               #0xDF\r
+    msr   cpsr_c,   r2\r
+    /* Restore link register again */\r
+    mov   lr, r3\r
+       b Dummy_Irq\r
index 6c85a302e20fa36975b62ef574f2be9e64dae92f..c229971ef66b173222d77567450ed6a2b3d81169 100644 (file)
@@ -1,9 +1,17 @@
-/*\r
- * core_cr4.h\r
+/* -------------------------------- Arctic Core ------------------------------\r
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
  *\r
- *  Created on: 12 okt 2010\r
- *      Author: maek\r
- */\r
+ * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
+ *\r
+ * This source code is free software; you can redistribute it and/or modify it\r
+ * under the terms of the GNU General Public License version 2 as published by the\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ *\r
+ * This program is distributed in the hope that it will be useful, but\r
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
+ * for more details.\r
+ * -------------------------------- Arctic Core ------------------------------*/\r
 \r
 #ifndef CORE_CR4_H_\r
 #define CORE_CR4_H_\r
@@ -421,8 +429,9 @@ typedef volatile struct
 } Can_RegisterType;\r
 \r
 \r
-#define Can0_Base ((Can_RegisterType *)0xFFF7DC00)\r
-#define Can1_Base ((Can_RegisterType *)0xFFF7DE00)\r
+#define DCAN1_Base ((Can_RegisterType *)0xFFF7DC00)\r
+#define DCAN2_Base ((Can_RegisterType *)0xFFF7DE00)\r
+#define DCAN3_Base ((Can_RegisterType *)0xFFF7E000)\r
 \r
 \r
 \r
index 9854810ed860b6c681d7e6617c6dbef580e8b517..792e124ca79e9cf8a63d5e8973d0995be8a13bff 100644 (file)
@@ -19,6 +19,7 @@
 #include "irq.h"
 #include "core_cr4.h"
 
+extern TaskType Os_Arc_CreateIsr( void (*entry)(void ), uint8_t prio, const char *name );
 extern void *Irq_VectorTable[NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS];
 
 /*
@@ -98,18 +99,27 @@ static void NVIC_InitVector(IRQn_Type vector, uint32_t prio)
  * The stack holds C, NVGPR, VGPR and the EXC frame.
  *
  */
+#define MAX_WAIT_COUNT 1000
 void *Irq_Entry( void *stack_p )
 {
        uint32_t *stack;
 
        // Get the active interrupt channel
-       uint8 channel = IrqGetCurrentInterruptSource();
+       volatile sint8 channel;
+       volatile uint32 c = 0;
+       do {
+               channel = IrqGetCurrentInterruptSource();
+               c++;
+       } while (channel < 0 && c < MAX_WAIT_COUNT);
 
-       if (channel == 255) {
-               // This irq is a result of a svc call
-               register uint32 irq_vector asm("r1");
-               channel = irq_vector;
+       if (c >= MAX_WAIT_COUNT) {
+               // No interrupt is pending
+               return stack_p;
 
+               // This irq is a result of a svc call
+               //register uint32 irq_vector asm("r1");
+               //channel = irq_vector;
+               //channel = IrqGetCurrentInterruptSource();
        }
 
        //Irq_Disable();
@@ -171,6 +181,11 @@ void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {
 }
 
 
+void SoftIrqRunner() {
+       uint32 vector = systemREG1->SSISR1 & 0xFF;
+       struct OsPcb *isr_p = Irq_VectorTable[SYS_SWI_NR];
+}
+
 /**
  * Generates a soft interrupt, ie sets pending bit.
  * This could also be implemented using ISPR regs.
@@ -178,8 +193,11 @@ void Irq_AttachIsr2(TaskType tid,void *int_ctrl,IrqType vector ) {
  * @param vector
  */
 void Irq_GenerateSoftInt( IrqType vector ) {
-
-       __asm volatile("svc #0");
+       if (Irq_VectorTable[SYS_SWI_NR] == NULL) {
+               TaskType tid = Os_Arc_CreateIsr(SoftIrqRunner,6,"SoftIrq");
+               Irq_AttachIsr2(tid,NULL, SYS_SWI_NR);
+       }
+       systemREG1->SSISR1 = 0x00007500 + vector;
 }
 
 /**
index f48851b1c9b187576cbad5bdbd0ba935f1aaeb6c..7b72753efdc091739b0a3dc4a1df0e74f341af95 100644 (file)
 #ifndef IRQ_TYPES_H\r
 #define IRQ_TYPES_H\r
 \r
+#define SYS_SWI_NR 21\r
+\r
 #define IrqGetCurrentInterruptSource() \\r
-       (((uint8)vimREG->IRQIVEC) - 1)\r
+       (((volatile sint8)vimREG->IRQIVEC) - 1)\r
 \r
 /** IrqActivateChannel turns the selected channel on in the VIM */\r
 #define IrqActivateChannel(_channel) \\r
-       vimREG->REQMASKSET0 |= (1 << _channel)\r
+       if (_channel > 31) { \\r
+               vimREG->REQMASKSET1 |= (1 << (_channel - 32)); \\r
+       } else { \\r
+               vimREG->REQMASKSET0 |= (1 << _channel); \\r
+       }\r
 \r
 \r
 /** IrqDeactivateChannel turns the selected channel off in the VIM */\r
 #define IrqDeactivateChannel(_channel) \\r
-       vimREG->REQMASKCLR0 = (1 << _channel)\r
+       if (_channel > 31) { \\r
+               vimREG->REQMASKCLR1 = (1 << (_channel - 32)); \\r
+       } else { \\r
+               vimREG->REQMASKCLR0 = (1 << _channel); \\r
+       }\r
 \r
 \r
 #define Irq_SOI() \\r
-       uint8 channel = IrqGetCurrentInterruptSource(); \\r
+       sint8 channel = IrqGetCurrentInterruptSource(); \\r
        IrqDeactivateChannel(channel)\r
 \r
 \r
 \r
 \r
 \r
-typedef enum IRQn\r
-{\r
-/******  Cortex-M3 Processor Exceptions Numbers ***************************************************/\r
-  NonMaskableInt_IRQn         = -14,    /*!< 2 Non Maskable Interrupt                             */\r
-  MemoryManagement_IRQn       = -12,    /*!< 4 Cortex-M3 Memory Management Interrupt              */\r
-  BusFault_IRQn               = -11,    /*!< 5 Cortex-M3 Bus Fault Interrupt                      */\r
-  UsageFault_IRQn             = -10,    /*!< 6 Cortex-M3 Usage Fault Interrupt                    */\r
-  SVCall_IRQn                 = -5,     /*!< 11 Cortex-M3 SV Call Interrupt                       */\r
-  DebugMonitor_IRQn           = -4,     /*!< 12 Cortex-M3 Debug Monitor Interrupt                 */\r
-  PendSV_IRQn                 = -2,     /*!< 14 Cortex-M3 Pend SV Interrupt                       */\r
-  SysTick_IRQn                = -1,     /*!< 15 Cortex-M3 System Tick Interrupt                   */\r
-\r
-/******  STM32 specific Interrupt Numbers *********************************************************/\r
-  WWDG_IRQn                   = 0,      /*!< Window WatchDog Interrupt                            */\r
-  PVD_IRQn                    = 1,      /*!< PVD through EXTI Line detection Interrupt            */\r
-  TAMPER_IRQn                 = 2,      /*!< Tamper Interrupt                                     */\r
-  RTC_IRQn                    = 3,      /*!< RTC global Interrupt                                 */\r
-  FLASH_IRQn                  = 4,      /*!< FLASH global Interrupt                               */\r
-  RCC_IRQn                    = 5,      /*!< RCC global Interrupt                                 */\r
-  EXTI0_IRQn                  = 6,      /*!< EXTI Line0 Interrupt                                 */\r
-  EXTI1_IRQn                  = 7,      /*!< EXTI Line1 Interrupt                                 */\r
-  EXTI2_IRQn                  = 8,      /*!< EXTI Line2 Interrupt                                 */\r
-  EXTI3_IRQn                  = 9,      /*!< EXTI Line3 Interrupt                                 */\r
-  EXTI4_IRQn                  = 10,     /*!< EXTI Line4 Interrupt                                 */\r
-  DMA1_Channel1_IRQn          = 11,     /*!< DMA1 Channel 1 global Interrupt                      */\r
-  DMA1_Channel2_IRQn          = 12,     /*!< DMA1 Channel 2 global Interrupt                      */\r
-  DMA1_Channel3_IRQn          = 13,     /*!< DMA1 Channel 3 global Interrupt                      */\r
-  DMA1_Channel4_IRQn          = 14,     /*!< DMA1 Channel 4 global Interrupt                      */\r
-  DMA1_Channel5_IRQn          = 15,     /*!< DMA1 Channel 5 global Interrupt                      */\r
-  DMA1_Channel6_IRQn          = 16,     /*!< DMA1 Channel 6 global Interrupt                      */\r
-  DMA1_Channel7_IRQn          = 17,     /*!< DMA1 Channel 7 global Interrupt                      */\r
-  ADC1_2_IRQn                 = 18,     /*!< ADC1 and ADC2 global Interrupt                       */\r
-\r
-#ifdef STM32F10X_LD\r
-  USB_HP_CAN1_TX_IRQn         = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */\r
-  USB_LP_CAN1_RX0_IRQn        = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */\r
-  CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */\r
-  CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */\r
-  EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */\r
-  TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */\r
-  TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */\r
-  TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */\r
-  TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */\r
-  TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */\r
-  TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */\r
-  I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */\r
-  I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */\r
-  SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */\r
-  USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */\r
-  USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */\r
-  EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */\r
-  RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */\r
-  USBWakeUp_IRQn              = 42,     /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */\r
-#endif /* STM32F10X_LD */\r
-\r
-#ifdef STM32F10X_MD\r
-  USB_HP_CAN1_TX_IRQn         = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */\r
-  USB_LP_CAN1_RX0_IRQn        = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */\r
-  CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */\r
-  CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */\r
-  EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */\r
-  TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */\r
-  TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */\r
-  TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */\r
-  TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */\r
-  TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */\r
-  TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */\r
-  TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */\r
-  I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */\r
-  I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */\r
-  I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */\r
-  I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */\r
-  SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */\r
-  SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */\r
-  USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */\r
-  USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */\r
-  USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */\r
-  EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */\r
-  RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */\r
-  USBWakeUp_IRQn              = 42,     /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */\r
-#endif /* STM32F10X_MD */\r
-\r
-#ifdef STM32F10X_HD\r
-  USB_HP_CAN1_TX_IRQn         = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */\r
-  USB_LP_CAN1_RX0_IRQn        = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */\r
-  CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */\r
-  CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */\r
-  EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */\r
-  TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */\r
-  TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */\r
-  TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */\r
-  TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */\r
-  TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */\r
-  TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */\r
-  TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */\r
-  I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */\r
-  I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */\r
-  I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */\r
-  I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */\r
-  SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */\r
-  SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */\r
-  USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */\r
-  USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */\r
-  USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */\r
-  EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */\r
-  RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */\r
-  USBWakeUp_IRQn              = 42,     /*!< USB Device WakeUp from suspend through EXTI Line Interrupt */\r
-  TIM8_BRK_IRQn               = 43,     /*!< TIM8 Break Interrupt                                 */\r
-  TIM8_UP_IRQn                = 44,     /*!< TIM8 Update Interrupt                                */\r
-  TIM8_TRG_COM_IRQn           = 45,     /*!< TIM8 Trigger and Commutation Interrupt               */\r
-  TIM8_CC_IRQn                = 46,     /*!< TIM8 Capture Compare Interrupt                       */\r
-  ADC3_IRQn                   = 47,     /*!< ADC3 global Interrupt                                */\r
-  FSMC_IRQn                   = 48,     /*!< FSMC global Interrupt                                */\r
-  SDIO_IRQn                   = 49,     /*!< SDIO global Interrupt                                */\r
-  TIM5_IRQn                   = 50,     /*!< TIM5 global Interrupt                                */\r
-  SPI3_IRQn                   = 51,     /*!< SPI3 global Interrupt                                */\r
-  UART4_IRQn                  = 52,     /*!< UART4 global Interrupt                               */\r
-  UART5_IRQn                  = 53,     /*!< UART5 global Interrupt                               */\r
-  TIM6_IRQn                   = 54,     /*!< TIM6 global Interrupt                                */\r
-  TIM7_IRQn                   = 55,     /*!< TIM7 global Interrupt                                */\r
-  DMA2_Channel1_IRQn          = 56,     /*!< DMA2 Channel 1 global Interrupt                      */\r
-  DMA2_Channel2_IRQn          = 57,     /*!< DMA2 Channel 2 global Interrupt                      */\r
-  DMA2_Channel3_IRQn          = 58,     /*!< DMA2 Channel 3 global Interrupt                      */\r
-  DMA2_Channel4_5_IRQn        = 59      /*!< DMA2 Channel 4 and Channel 5 global Interrupt        */\r
-#endif /* STM32F10X_HD */\r
-\r
-#ifdef STM32F10X_CL\r
-  CAN1_TX_IRQn                = 19,     /*!< USB Device High Priority or CAN1 TX Interrupts       */\r
-  CAN1_RX0_IRQn               = 20,     /*!< USB Device Low Priority or CAN1 RX0 Interrupts       */\r
-  CAN1_RX1_IRQn               = 21,     /*!< CAN1 RX1 Interrupt                                   */\r
-  CAN1_SCE_IRQn               = 22,     /*!< CAN1 SCE Interrupt                                   */\r
-  EXTI9_5_IRQn                = 23,     /*!< External Line[9:5] Interrupts                        */\r
-  TIM1_BRK_IRQn               = 24,     /*!< TIM1 Break Interrupt                                 */\r
-  TIM1_UP_IRQn                = 25,     /*!< TIM1 Update Interrupt                                */\r
-  TIM1_TRG_COM_IRQn           = 26,     /*!< TIM1 Trigger and Commutation Interrupt               */\r
-  TIM1_CC_IRQn                = 27,     /*!< TIM1 Capture Compare Interrupt                       */\r
-  TIM2_IRQn                   = 28,     /*!< TIM2 global Interrupt                                */\r
-  TIM3_IRQn                   = 29,     /*!< TIM3 global Interrupt                                */\r
-  TIM4_IRQn                   = 30,     /*!< TIM4 global Interrupt                                */\r
-  I2C1_EV_IRQn                = 31,     /*!< I2C1 Event Interrupt                                 */\r
-  I2C1_ER_IRQn                = 32,     /*!< I2C1 Error Interrupt                                 */\r
-  I2C2_EV_IRQn                = 33,     /*!< I2C2 Event Interrupt                                 */\r
-  I2C2_ER_IRQn                = 34,     /*!< I2C2 Error Interrupt                                 */\r
-  SPI1_IRQn                   = 35,     /*!< SPI1 global Interrupt                                */\r
-  SPI2_IRQn                   = 36,     /*!< SPI2 global Interrupt                                */\r
-  USART1_IRQn                 = 37,     /*!< USART1 global Interrupt                              */\r
-  USART2_IRQn                 = 38,     /*!< USART2 global Interrupt                              */\r
-  USART3_IRQn                 = 39,     /*!< USART3 global Interrupt                              */\r
-  EXTI15_10_IRQn              = 40,     /*!< External Line[15:10] Interrupts                      */\r
-  RTCAlarm_IRQn               = 41,     /*!< RTC Alarm through EXTI Line Interrupt                */\r
-  OTG_FS_WKUP_IRQn            = 42,     /*!< USB OTG FS WakeUp from suspend through EXTI Line Interrupt */\r
-  TIM5_IRQn                   = 50,     /*!< TIM5 global Interrupt                                */\r
-  SPI3_IRQn                   = 51,     /*!< SPI3 global Interrupt                                */\r
-  UART4_IRQn                  = 52,     /*!< UART4 global Interrupt                               */\r
-  UART5_IRQn                  = 53,     /*!< UART5 global Interrupt                               */\r
-  TIM6_IRQn                   = 54,     /*!< TIM6 global Interrupt                                */\r
-  TIM7_IRQn                   = 55,     /*!< TIM7 global Interrupt                                */\r
-  DMA2_Channel1_IRQn          = 56,     /*!< DMA2 Channel 1 global Interrupt                      */\r
-  DMA2_Channel2_IRQn          = 57,     /*!< DMA2 Channel 2 global Interrupt                      */\r
-  DMA2_Channel3_IRQn          = 58,     /*!< DMA2 Channel 3 global Interrupt                      */\r
-  DMA2_Channel4_IRQn          = 59,     /*!< DMA2 Channel 4 global Interrupt                      */\r
-  DMA2_Channel5_IRQn          = 60,     /*!< DMA2 Channel 5 global Interrupt                      */\r
-  ETH_IRQn                    = 61,     /*!< Ethernet global Interrupt                            */\r
-  ETH_WKUP_IRQn               = 62,     /*!< Ethernet Wakeup through EXTI line Interrupt          */\r
-  CAN2_TX_IRQn                = 63,     /*!< CAN2 TX Interrupt                                    */\r
-  CAN2_RX0_IRQn               = 64,     /*!< CAN2 RX0 Interrupt                                   */\r
-  CAN2_RX1_IRQn               = 65,     /*!< CAN2 RX1 Interrupt                                   */\r
-  CAN2_SCE_IRQn               = 66,     /*!< CAN2 SCE Interrupt                                   */\r
-  OTG_FS_IRQn                 = 67      /*!< USB OTG FS global Interrupt                          */\r
-#endif /* STM32F10X_CL */\r
-} IRQn_Type;\r
-\r
-typedef IRQn_Type IrqType;\r
-\r
-/* Offset from start of exceptions to interrupts\r
- * Exceptions have negative offsets while interrupts have positive\r
- */\r
-//#define IRQ_INTERRUPT_OFFSET  16\r
-\r
 /* Total number of interrupts and exceptions\r
  */\r
 #define NUMBER_OF_INTERRUPTS_AND_EXCEPTIONS 65\r
@@ -226,9 +57,12 @@ typedef enum {
          PERIPHERAL_CLOCK_AHB,\r
          PERIPHERAL_CLOCK_APB1,\r
          PERIPHERAL_CLOCK_APB2,\r
+         PERIPHERAL_CLOCK_CAN,\r
+         PERIPHERAL_CLOCK_DCAN1,\r
+         PERIPHERAL_CLOCK_DCAN2,\r
+         PERIPHERAL_CLOCK_DCAN3\r
 } McuE_PeriperalClock_t;\r
 \r
-\r
 typedef enum {\r
        CPU_0=0,\r
 } Cpu_t;\r
index eaa8cee7c9ebf3a75c40ad3d62cce5c712b1f62d..6014158de0032ff93c43004e9d47b8eb08f9b80e 100644 (file)
  * -------------------------------- Arctic Core ------------------------------*/\r
 \r
 \r
-/*\r
- * context.h\r
- *\r
- *  Created on: 7 jul 2009\r
- *      Author: mahi\r
- *\r
- * DESCRIPTION\r
- *   ARM Cortex-M3 (architecture ARMv7-M).\r
- *\r
- * REFERENCES\r
- * - Procedure Call Standard for the ARM Architecture, release 2.07\r
- *\r
- * REGISTER USE\r
- *   Args\r
- *     r0-r3\r
- *\r
- * RETURN\r
- *   ?? r0?\r
- *\r
- *   Non-volatile regs (saved by function call)\r
- *     r4-r8,r10,r11 and SP\r
- *\r
- *   Misc\r
- *     r9 - Platform specific ???\r
- *     r12 - IP (Intra Procedure call)\r
- *     r13 - SP\r
- *     r14 - LR\r
- *     r15 - PC\r
- *\r
- *   See "Procedure Call Standard for the ARMĀ® Architecture" for more information.\r
- *\r
- *   Other:\r
- *   PSR\r
- *   PRIMASK[0]      0 - No effect,\r
- *                   1 - Prevents the activation of all exceptions with\r
- *                       configurable priority.\r
- *   FAULTMASK\r
- *   BASEPRI[7:4]    0x0 - No effect\r
- *                   !=0 -  When BASEPRI is set to a nonzero value, it prevents\r
- *                          the activation of all exceptions with same or lower\r
- *                          priority level as the BASEPRI value.\r
- *   CONTOROL\r
- *\r
- *\r
- * EXCEPTION FRAME\r
- *\r
- *   The following registers are auto-magically pushed by the CPU\r
- *   Pushes:\r
- *     <previous>\r
- *     xPSR\r
- *     PC (r15)\r
- *     LR (r14)\r
- *     r12,r3,r2,r1,r0\r
- *\r
- * EXCEPTION/IRQ TABLE\r
- *   The table is a combined exception and irq table. The first 16 (0 to 15) entries\r
- *   are exceptions and the rest are irq's.\r
- *   The table just lists the addresses of the handlers (offset of 4 bytes)\r
- *\r
- *   EXCEPTIONS\r
- *     There are fixed negative priority values for Reset, Hard fault and NMI.\r
- *     For the rest of the exceptions prio's can be set to 0-15. Priority 0 have higher\r
- *     priority than 1. Access through SHPRx.\r
- *\r
- *   IRQ\r
- *     The IRQ's also have 4-bits of priority. All IRQ prio's are squeezed into\r
- *     17 registers (4 in each) -> 68 IRQ's. Of the 8 bits accesssible to the\r
- *     priority only 4 bits are used, the least significant nibble is 0.\r
- *     Access through NVIC_IPR0 to IVPR_IPR16.\r
- *\r
- * EXCEPTION/IRQ FLOW\r
- *  MODES\r
- *    - Thread mode (normal execution). The privilige level can be set.\r
- *    - Handler mode (exception mode). The privilige level is always "priviliged"\r
- *\r
- *  STACKS\r
- *    Two stacks, process and main.\r
- *\r
- *\r
- *  ENTRY\r
- *   - The exception hits\r
- *      - Irq_Handler() is called.\r
- *      - The processor now enters "handler" mode and saves\r
- *        - r0--r3,r12,LR,PC, xPSR on the current stack (MSR) (Don't use PSP)\r
- *        - Sets LR to EXC_RETURN (0xFFFF_FFFx)\r
- *\r
- *  EXIT\r
- *  - Exception return instructions are bx,poppc or ldr, ldm\r
- *  - When the interrupt return instruction is excuted, the registers\r
- *    - will be pop:ed back\r
- *    - The active bit in the NVIC controller will be clear\r
- *    - The ICSR register will ?????\r
- *\r
- *\r
- *  STRATEGY\r
- *  - _estack and\r
- *\r
- *\r
- *\r
- */\r
-\r
 #ifndef CONTEXT_H_\r
 #define CONTEXT_H_\r
 \r
 #define SAVE_ALL_GPR(_x,_y)\r
 #define RESTORE_ALL_GPR(_x,_y)\r
 \r
-#if 0\r
-#define C_SIZE                 16\r
-#define C_SP_OFF               0\r
-#define C_CONTEXT_OFF  4\r
-#define C_LR_OFF               8\r
-#define C_CR_OFF               12\r
-\r
-#define C_CONTEXT_OFFS 10\r
-#endif\r
 \r
-// NVREGS: r4+r5+r6+r7+r8++r10+r11+lr = 9*4 = 36\r
-#define NVGPR_SIZE             32\r
+// NVREGS: r0+r1+r2+r3+r4+r5+r6+r7+r8+r9+r10+r11+r12+lr = 14*4 = 40\r
+#define NVGPR_SIZE             56\r
 // VGPR: 9*4 = 36\r
-#define VGPR_SIZE              36\r
+//#define VGPR_SIZE            36\r
 // SP + context\r
 #define C_SIZE                 8\r
-\r
-//...\r
 #define VGPR_LR_OFF            (C_SIZE+NVGPR_SIZE-4)\r
 #define C_CONTEXT_OFFS  4\r
 #define C_SP_OFF               0\r
-\r
-\r
 #define SC_SIZE                        (NVGPR_SIZE+C_SIZE)\r
 \r
-#if !defined(_ASSEMBLER_)\r
-\r
-/* These are auto-magically pushed by the hardware */\r
-typedef struct StackException {\r
-       uint32_t backChain;\r
-       uint32_t psr;\r
-       uint32_t pc;\r
-       uint32_t lr;\r
-       uint32_t r12;\r
-       uint32_t r3;\r
-       uint32_t r2;\r
-       uint32_t r1;\r
-} StackExceptionType;\r
-\r
-typedef struct StackNvgpr {\r
-       uint32_t r4;\r
-       uint32_t r5;\r
-       uint32_t r6;\r
-       uint32_t r7;\r
-       uint32_t r8;\r
-       uint32_t r10;\r
-       uint32_t r11;\r
-       uint32_t va;\r
-} StackNvgprType;\r
-\r
-struct StackVGpr {\r
-       uint32_t i_have_no_idea;\r
-};\r
-\r
-\r
-typedef struct StackCallAndContext {\r
-       uint32_t context;\r
-       // possibly some backchains and other stuff here..\r
-} StackCallAndContextType;\r
-\r
-#endif /* _ASSEMBLER_ */\r
 \r
 \r
 #endif /* CONTEXT_H_ */\r
index b31ff42318651bddcfebe345d6e1636a1df81802..f124d257ca61671f5f997fae9ab196f31aefb6ff 100644 (file)
@@ -44,7 +44,7 @@
        .weak   Reset_Handler\r
        .type   Reset_Handler, %function\r
 \r
-Reset_Handler: \r
+Reset_Handler:\r
 \r
 /* Set big endian state */\r
        SETEND BE\r
@@ -171,18 +171,7 @@ LoopFillZero:
        bcc     FillZero\r
        bx  lr\r
 \r
-/* Interrupt routine used to catch unused interrupts and exceptions */\r
-Dummy_Irq:\r
-       /* Go back to sys mode for easier debugging.\r
-        Save link register*/\r
-       mov   r3, lr\r
-       /* We don't want to use the IRQ mode\r
-          so swich back to sys mode. */\r
-       mov   r2,               #0xDF\r
-    msr   cpsr_c,   r2\r
-    /* Restore link register again */\r
-    mov   lr, r3\r
-       b Dummy_Irq\r
+\r
 \r
 .size  Reset_Handler, .-Reset_Handler\r
 \r
@@ -208,13 +197,22 @@ Infinite_Loop:
        .section        .int_vecs,"ax",%progbits\r
        .extern Irq_Handler\r
        .extern Svc_Handler\r
-\r
-        b   Reset_Handler      /* Reset? */\r
+       .extern Data_Exc_Handler\r
+       .extern Prefetch_Exc_Handler\r
+       .extern Dummy_Irq\r
+\r
+               /* This is the reset handler. Since the CPU is in ARM mode when this instruction is executed\r
+                  it has to be hard coded (otherwise GCC will compile it wrongly.\r
+                  Instruction branches to address 0x22 while changing instruction mode to THUMB. */\r
+        .word 0xfb000006\r
         b   Dummy_Irq          /* Undefined instruction exception */\r
         b   Svc_Handler        /* SVC, to be able to use software interrupt instruction. */\r
-        b   Dummy_Irq          /* Prefetch exception */\r
-        b   Dummy_Irq          /* Data exception */\r
+        b   Prefetch_Exc_Handler          /* Prefetch exception */\r
+        b   Data_Exc_Handler   /* Data exception */\r
         b   Dummy_Irq          /* Reserved */\r
         b   Irq_Handler        /* Ordinary interrupts (IRQ) */\r
            b   Irq_Handler        /* Fast interrupts (FIR) */\r
 \r
+               nop\r
+               b       Reset_Handler      /* Branch to the real reset handler. */\r
+\r
index 65c645708a495a9ed9c950411d72c24d6285ba7f..8d6c1cd86fbb4a4416c21c25b994af7055d670aa 100644 (file)
@@ -1,4 +1,4 @@
 \r
-intvecs(R)      : ORIGIN = 0x0000000, LENGTH = 0x20\r
-flash(R) : ORIGIN = 0x00000020, LENGTH = 2M\r
+intvecs(R) : ORIGIN = 0x0000000, LENGTH = 0x40\r
+flash(R) : ORIGIN = 0x00000040, LENGTH = 2M\r
 ram(RW)  : ORIGIN = 0x08000000, LENGTH = 160K\r
index 6b706f2ea0be211e770176092f2dc193bcf63df4..0d72cebe698c75204b1b3fd0c8cb9a4d7310d288 100644 (file)
@@ -185,7 +185,7 @@ void Irq_InstallVector(void (*func)(), IrqType vector, uint8_t priority, Cpu_t c
 void Irq_GenerateSoftInt( IrqType vector );\r
 uint8_t Irq_GetCurrentPriority( Cpu_t cpu);\r
 uint32_t McuE_GetSystemClock( void );\r
-#if defined(CFG_MPC55XX)\r
+#if defined(CFG_MPC55XX) || defined(CFG_ARM_CR4)\r
 uint32_t McuE_GetPeripheralClock( McuE_PeriperalClock_t type );\r
 #endif\r
 #include "McuExtensions.h"\r
index de3bdd1914dadff6897169fdd83e2cb8f450ae21..68b9888bfd568c337dcac1ad81b34e991bc6f8c4 100644 (file)
@@ -144,7 +144,7 @@ void *Os_Isr( void *stack, void *isr_p ) {
 
        Irq_SOI();
 
-#ifndef CFG_HCS12D
+#if !defined(CFG_HCS12D)
        Irq_Enable();
        isrPtr->entry();
        Irq_Disable();