]> rtime.felk.cvut.cz Git - arc.git/blobdiff - arch/arm/arm_cr4/kernel/core_cr4.h
LED Blinker running on TMS570LS31x Hercules Development Kit (HDK) (TMS570LS3137ZWT)
[arc.git] / arch / arm / arm_cr4 / kernel / core_cr4.h
index 13f79850e8f34686673f974fdc0b1d528e808fd8..51129059f5f521de1eaf715e95a38f7ad0943805 100644 (file)
@@ -1,13 +1,23 @@
-/*\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
 \r
+#include "Std_Types.h"\r
+\r
 #define     __I     volatile const            /*!< defines 'read only' permissions      */\r
 #define     __O     volatile                  /*!< defines 'write only' permissions     */\r
 #define     __IO    volatile                  /*!< defines 'read / write' permissions   */\r
@@ -319,6 +329,174 @@ typedef volatile struct pcrBase
 #define pcrREG ((pcrBASE_t *)0xFFFFE000U)\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
+\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
+typedef volatile struct gioBase\r
+{\r
+    unsigned GCR0;      /**< 0x0000: Global Control Register */\r
+    unsigned PWDN;      /**< 0x0004: Power Down Register */\r
+    unsigned INTDET;    /**< 0x0008: Interrupt Detect Regsiter*/\r
+    unsigned POL;       /**< 0x000C: Interrupt Polarity Register */\r
+    unsigned INTENASET; /**< 0x0010: Interrupt Enable Set Register */\r
+    unsigned INTENACLR; /**< 0x0014: Interrupt Enable Clear Register */\r
+    unsigned LVLSET;    /**< 0x0018: Interrupt Priority Set Register */\r
+    unsigned LVLCLR;    /**< 0x001C: Interrupt Priority Clear Register */\r
+    unsigned FLG;       /**< 0x0020: Interrupt Flag Register */\r
+    unsigned OFFSET0;   /**< 0x0024: Interrupt Offset A Register */\r
+    unsigned OFFSET1;   /**< 0x0028: Interrupt Offset B Register */\r
+} GIO_Base_RegisterType;\r
+\r
+\r
+/** @struct gioPort\r
+*   @brief GIO Port Register Definition\r
+*/\r
+/** @typedef gioPORT_t\r
+*   @brief GIO Port Register Type Definition\r
+*\r
+*   This type is used to access the GIO Port Registers.\r
+*/\r
+typedef volatile struct gioPort\r
+{\r
+    unsigned DIR;    /**< 0x0000: Data Direction Register */\r
+    unsigned DIN;    /**< 0x0004: Data Input Register */\r
+    unsigned DOUT;   /**< 0x0008: Data Output Register */\r
+    unsigned DSET;   /**< 0x000C: Data Output Set Register */\r
+    unsigned DCLR;   /**< 0x0010: Data Output Clear Register */\r
+    unsigned PDR;    /**< 0x0014: Open Drain Regsiter */\r
+    unsigned PULDIS; /**< 0x0018: Pullup Disable Register */\r
+    unsigned PSL;    /**< 0x001C: Pull Up/Down Selection Register */\r
+} GIO_RegisterType;\r
+\r
+#define GIO_PORTA_BASE ((GIO_RegisterType *)0xFFF7BC34)\r
+#define GIO_PORTB_BASE ((GIO_RegisterType *)0xFFF7BC54)\r
+#define GIO_HET_PORT1_BASE ((GIO_RegisterType *)0xFFF7B84CU)\r
+\r
+/** @def gioREG\r
+*   @brief GIO Register Frame Pointer\r
+*\r
+*   This pointer is used by the GIO driver to access the gio module registers.\r
+*/\r
+#define gioREG   ((GIO_Base_RegisterType *)0xFFF7BC00U)\r
+\r
+/** @def gioPORTA\r
+*   @brief GIO Port (A) Register Pointer\r
+*\r
+*   Pointer used by the GIO driver to access PORTA\r
+*/\r
+#define gioPORTA ((gioPORT_t *)0xFFF7BC34U)\r
+\r
+/** @def gioPORTB\r
+*   @brief GIO Port (B) Register Pointer\r
+*\r
+*   Pointer used by the GIO driver to access PORTB\r
+*/\r
+#define gioPORTB ((gioPORT_t *)0xFFF7BC54U)\r
+\r
+\r
 typedef struct\r
 {\r
   __IO uint32_t CTRL;                         /*!< SysTick Control and Status Register */\r
@@ -327,26 +505,34 @@ typedef struct
   __I  uint32_t CALIB;                        /*!< SysTick Calibration Register        */\r
 } SysTick_Type;\r
 \r
+\r
 static inline void __disable_irq() {\r
   __asm volatile("CPSID if");\r
 }\r
 static inline void __enable_irq() {\r
        __asm volatile("CPSIE if");\r
-\r
-       /*\r
-       __asm volatile("MRS R1, CPSR");\r
-       __asm volatile("BIC R1, R1, #0x80");\r
-       __asm volatile("MSR CPSR, R1");\r
-\r
-       __asm volatile("MRC p15 ,#0 ,R1 ,c1 ,c0 ,#0");\r
-       __asm volatile("ORR R1 ,R1 ,#0x01000000"); //Mask 0-31 bits except bit 24 in Sys ; Ctrl Reg of CORTEX-R4\r
-       __asm volatile("MCR p15 ,#0 ,R1 ,c1 ,c0 ,#0"); //; Enable bit 24\r
-       //__asm volatile("SVC #1");\r
-       */\r
-\r
 }\r
 \r
+static inline unsigned long _Irq_Save(void)\r
+{\r
+   register unsigned long val asm("r0");\r
+   asm("mrs r0, cpsr");\r
+   asm("and r0, r0, #0xC0"); // Mask the I and F bit of CPSR\r
+   __disable_irq();\r
+   return val;\r
+}\r
 \r
-\r
+static inline void _Irq_Restore(unsigned mask) {\r
+       if (mask & 0x80) {\r
+               __asm volatile("CPSID i");\r
+       } else {\r
+               __asm volatile("CPSIE i");\r
+       }\r
+       if (mask & 0x40) {\r
+               __asm volatile("CPSID f");\r
+       } else {\r
+               __asm volatile("CPSIE f");\r
+       }\r
+}\r
 \r
 #endif /* CORE_CR4_H_ */\r