]> rtime.felk.cvut.cz Git - arc.git/blobdiff - include/Mcu.h
Merge branch 'mikulka' of git@rtime.felk.cvut.cz:arc into mikulka
[arc.git] / include / Mcu.h
index 0bec477a0e57bee3216328d68ac974b5ca9c0e9a..0ffa2a5b811f7ac4fa297b41bc31820ce0957fde 100644 (file)
@@ -1,33 +1,46 @@
-/* -------------------------------- Arctic Core ------------------------------
- * Arctic Core - the open source AUTOSAR platform http://arccore.com
- *
- * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
- *
- * This source code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published by the
- * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- * -------------------------------- Arctic Core ------------------------------*/
-
-
-
-
-
-
-
-
+/* -------------------------------- 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
+/** @addtogroup Mcu MCU Driver\r
+ *  @{ */\r
+\r
+/** @file Mcu.h\r
+ * API and type definitions for MCU Driver.\r
+ */\r
+\r
 #ifndef MCU_H_\r
 #define MCU_H_\r
 \r
+#include "Modules.h"\r
+\r
+#define MCU_SW_MAJOR_VERSION           2\r
+#define MCU_SW_MINOR_VERSION               0\r
+#define MCU_SW_PATCH_VERSION           0\r
+\r
+#define MCU_AR_MAJOR_VERSION           2\r
+#define MCU_AR_MINOR_VERSION           2\r
+#define MCU_AR_PATCH_VERSION           2\r
+\r
 #include "Cpu.h"\r
-#include "irq.h"\r
+#include "irq_types.h"\r
+#include "Std_Types.h"\r
+#include "Mcu_Cfg.h"\r
 //#include "mpc55xx_aos.h"\r
 \r
-/* Service ID's */\r
+/** @name Service id's */\r
+//@{\r
 #define MCU_INIT_SERVICE_ID                 0x00\r
 #define MCU_INITRAMSECTION_SERVICE_ID       0x01\r
 #define MCU_INITCLOCK_SERVICE_ID            0x02\r
 #define MCU_SETMODE_SERVICE_ID              0x08\r
 #define MCU_GETVERSIONINFO_SERVICE_ID       0x09\r
 #define MCU_INTCVECTORINSTALL_SERVICE_ID    0x0A // Not in spec but follows pattern\r
+//@}\r
 \r
-/* Development error codes */\r
+/** @name Error Codes */\r
+//@{\r
 #define MCU_E_PARAM_CONFIG                  0x0A\r
 #define MCU_E_PARAM_CLOCK                   0x0B\r
 #define MCU_E_PARAM_MODE                    0x0C\r
 #define MCU_E_PARAM_RAMSECTION              0x0D\r
 #define MCU_E_PLL_NOT_LOCKED                0x0E\r
 #define MCU_E_UNINIT                        0x0F\r
+//@}\r
 \r
 /* Specific return values */\r
-#define MCU_GETRESETRAWVALUE_NORESETREG_RV  0x00 // MCU006\r
-#define MCU_GETRESETRAWVALUE_UNINIT_RV      0xffffffff // MCU135\r
+#define MCU_GETRESETRAWVALUE_NORESETREG_RV  0x00 /**< MCU006 */\r
+#define MCU_GETRESETRAWVALUE_UNINIT_RV      0xffffffff /**< MCU135 */\r
+\r
 \r
 typedef enum {\r
        MCU_PLL_LOCKED,\r
@@ -59,23 +76,93 @@ typedef enum {
 } Mcu_PllStatusType;\r
 \r
 \r
-typedef enum {\r
-       MCU_MODE_NORMAL=0\r
-} Mcu_ModeType;\r
-\r
 //TODO\r
-typedef uint8 Mcu_RamSectionType;\r
+typedef uint8_t Mcu_RamSectionType;\r
 \r
-typedef uint32 Mcu_RawResetType;\r
+typedef uint32_t Mcu_RawResetType;\r
 \r
 typedef enum {\r
        MCU_POWER_ON_RESET,\r
        MCU_WATCHDOG_RESET,\r
        MCU_SW_RESET,\r
-       MCU_RESET_UNDEFINED\r
+       MCU_RESET_UNDEFINED,\r
+       MCU_OSC_FAILURE_RESET,\r
+    MCU_CPU_RESET,\r
+    MCU_EXT_RESET,\r
+    MCU_VSW_RESET\r
 } Mcu_ResetType;\r
 \r
-#include "Mcu_Cfg.h"\r
+typedef struct {\r
+       //      This is the frequency for the specific instance of the McuClockReference-\r
+       //      Point container. It shall be givn in Hz.\r
+       uint32 McuClockReferencePointFrequency;\r
+\r
+       uint8 Pll1; // PLL setting 1\r
+       uint8 Pll2; // PLL setting 2\r
+       uint8 Pll3; // PLL setting 3\r
+       uint8 Pll4; // PLL setting 4\r
+\r
+} Mcu_ClockSettingConfigType;\r
+\r
+typedef struct {\r
+       // This parameter shall represent the Data pre-setting to be initialized\r
+       uint32 McuRamDefaultValue;\r
+\r
+       // This parameter shall represent the MCU RAM section base address\r
+       uint32 McuRamSectionBaseAddress;\r
+\r
+       // This parameter shall represent the MCU RAM Section size\r
+       uint32 McuRamSectionSize;\r
+\r
+} Mcu_RamSectorSettingConfigType;\r
+\r
+typedef struct {\r
+       //      Enables/Disables clock failure notification. In case this feature is not supported\r
+       //      by HW the setting should be disabled.\r
+       uint8   McuClockSrcFailureNotification;\r
+\r
+       //      This parameter shall represent the number of Modes available for the\r
+       //      MCU. calculationFormula = Number of configured McuModeSettingConf\r
+       //uint8 McuNumberOfMcuModes; /* Not supported */\r
+\r
+       //  This parameter shall represent the number of RAM sectors available for\r
+       //  the MCU. calculationFormula = Number of configured McuRamSectorSet-\r
+       //  tingConf\r
+       uint8 McuRamSectors;\r
+\r
+       //  This parameter shall represent the number of clock setting available for\r
+       //  the MCU.\r
+       uint8 McuClockSettings;\r
+\r
+       // This parameter defines the default clock settings that should be used\r
+       // It is an index into the McuClockSettingsConfig\r
+       Mcu_ClockType McuDefaultClockSettings;\r
+\r
+       //      This parameter relates to the MCU specific reset configuration. This ap-\r
+       //      plies to the function Mcu_PerformReset, which performs a microcontroller\r
+       //      reset using the hardware feature of the microcontroller.\r
+       //uint32 McuResetSetting;\r
+\r
+       //      This container contains the configuration (parameters) for the\r
+       //      Clock settings of the MCU. Please see MCU031 for more in-\r
+       //      formation on the MCU clock settings.\r
+       Mcu_ClockSettingConfigType * McuClockSettingConfig;\r
+\r
+       //      This container contains the configuration (parameters) for the\r
+       //      Mode setting of the MCU. Please see MCU035 for more information\r
+       //  on the MCU mode settings.\r
+       //Mcu_ModeSettingConfigType  *McuModeSettingConfig;\r
+\r
+       //      This container contains the configuration (parameters) for the\r
+       //      RAM Sector setting. Please see MCU030 for more information\r
+       //      on RAM sec-tor settings.\r
+       Mcu_RamSectorSettingConfigType *McuRamSectorSettingConfig;\r
+\r
+} Mcu_ConfigType;\r
+\r
+extern const Mcu_ConfigType McuConfigData[];\r
+\r
+\r
 \r
 void Mcu_Init( const Mcu_ConfigType *configPtr );\r
 void Mcu_DeInit();\r
@@ -91,31 +178,21 @@ void Mcu_PerformReset( void );
 void Mcu_SetMode( const Mcu_ModeType McuMode );\r
 \r
 #if ( MCU_VERSION_INFO_API == STD_ON )\r
-#define MCU_SW_MAJOR_VERSION           1\r
-#define MCU_SW_MINOR_VERSION                   0\r
-#define MCU_SW_PATCH_VERSION           0\r
-#define MCU_AR_MAJOR_VERSION           2\r
-#define MCU_AR_MINOR_VERSION           2\r
-#define MCU_AR_PATCH_VERSION           2\r
-\r
 #define Mcu_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,MCU)\r
 #endif\r
 \r
-typedef uint32_t imask_t;\r
+/* ArcCore extensions */\r
 \r
-/* ecore extensions */\r
-void IntCtrl_InstallVector(void (*func)(), IrqType vector, uint8_t priority, Cpu_t cpu );\r
-void IntCtrl_GenerateSoftInt( IrqType vector );\r
-uint8_t IntCtrl_GetCurrentPriority( Cpu_t cpu);\r
+void Irq_InstallVector(void (*func)(), IrqType vector, uint8_t priority, Cpu_t cpu );\r
+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
-imask_t McuE_EnterCriticalSection(void);\r
-void McuE_ExitCriticalSection(imask_t old_state);\r
-void McuE_EnableInterrupts(void);\r
-void McuE_DisableInterrupts(void);\r
-\r
 \r
+void McuE_EnterLowPower( int mode );\r
+void McuE_LowPowerRecoverFlash( void );\r
 \r
 #endif /*MCU_H_*/\r
+/** @} */\r