]> rtime.felk.cvut.cz Git - arc.git/blob - include/Mcu.h
Merge with 096eddbdea724281bf8285d1b223b30a17c57683
[arc.git] / include / Mcu.h
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 /** @addtogroup Mcu MCU Driver\r
17  *  @{ */\r
18 \r
19 /** @file Mcu.h\r
20  * API and type definitions for MCU Driver.\r
21  */\r
22 \r
23 #ifndef MCU_H_\r
24 #define MCU_H_\r
25 \r
26 #include "Modules.h"\r
27 \r
28 #define MCU_SW_MAJOR_VERSION            2\r
29 #define MCU_SW_MINOR_VERSION        0\r
30 #define MCU_SW_PATCH_VERSION            0\r
31 \r
32 #define MCU_AR_MAJOR_VERSION            2\r
33 #define MCU_AR_MINOR_VERSION            2\r
34 #define MCU_AR_PATCH_VERSION            2\r
35 \r
36 #include "Cpu.h"\r
37 #include "irq_types.h"\r
38 #include "Std_Types.h"\r
39 #include "Mcu_Cfg.h"\r
40 //#include "mpc55xx_aos.h"\r
41 \r
42 /** @name Service id's */\r
43 //@{\r
44 #define MCU_INIT_SERVICE_ID                 0x00\r
45 #define MCU_INITRAMSECTION_SERVICE_ID       0x01\r
46 #define MCU_INITCLOCK_SERVICE_ID            0x02\r
47 #define MCU_DISTRIBUTEPLLCLOCK_SERVICE_ID   0x03\r
48 #define MCU_GETPLLSTATUS_SERVICE_ID         0x04\r
49 #define MCU_GETRESETREASON_SERVICE_ID       0x05\r
50 #define MCU_GETRESETRAWVALUE_SERVICE_ID     0x06\r
51 #define MCU_PERFORMRESET_SERVICE_ID         0x07\r
52 #define MCU_SETMODE_SERVICE_ID              0x08\r
53 #define MCU_GETVERSIONINFO_SERVICE_ID       0x09\r
54 #define MCU_INTCVECTORINSTALL_SERVICE_ID    0x0A // Not in spec but follows pattern\r
55 //@}\r
56 \r
57 /** @name Error Codes */\r
58 //@{\r
59 #define MCU_E_PARAM_CONFIG                  0x0A\r
60 #define MCU_E_PARAM_CLOCK                   0x0B\r
61 #define MCU_E_PARAM_MODE                    0x0C\r
62 #define MCU_E_PARAM_RAMSECTION              0x0D\r
63 #define MCU_E_PLL_NOT_LOCKED                0x0E\r
64 #define MCU_E_UNINIT                        0x0F\r
65 //@}\r
66 \r
67 /* Specific return values */\r
68 #define MCU_GETRESETRAWVALUE_NORESETREG_RV  0x00 /**< MCU006 */\r
69 #define MCU_GETRESETRAWVALUE_UNINIT_RV      0xffffffff /**< MCU135 */\r
70 \r
71 \r
72 typedef enum {\r
73         MCU_PLL_LOCKED,\r
74         MCU_PLL_UNLOCKED,\r
75         MCU_PLL_STATUS_UNDEFINED,\r
76 } Mcu_PllStatusType;\r
77 \r
78 \r
79 typedef enum {\r
80         MCU_MODE_NORMAL=0\r
81 } Mcu_ModeType;\r
82 \r
83 //TODO\r
84 typedef uint8_t Mcu_RamSectionType;\r
85 \r
86 typedef uint32_t Mcu_RawResetType;\r
87 \r
88 typedef enum {\r
89         MCU_POWER_ON_RESET,\r
90         MCU_WATCHDOG_RESET,\r
91         MCU_SW_RESET,\r
92         MCU_RESET_UNDEFINED,\r
93         MCU_OSC_FAILURE_RESET,\r
94     MCU_CPU_RESET,\r
95     MCU_EXT_RESET,\r
96     MCU_VSW_RESET\r
97 } Mcu_ResetType;\r
98 \r
99 typedef struct {\r
100         //      This is the frequency for the specific instance of the McuClockReference-\r
101         //      Point container. It shall be givn in Hz.\r
102         uint32 McuClockReferencePointFrequency;\r
103 \r
104         uint8 Pll1; // PLL setting 1\r
105         uint8 Pll2; // PLL setting 2\r
106         uint8 Pll3; // PLL setting 3\r
107         uint8 Pll4; // PLL setting 4\r
108 \r
109 } Mcu_ClockSettingConfigType;\r
110 \r
111 typedef struct {\r
112         // This parameter shall represent the Data pre-setting to be initialized\r
113         uint32 McuRamDefaultValue;\r
114 \r
115         // This parameter shall represent the MCU RAM section base address\r
116         uint32 McuRamSectionBaseAddress;\r
117 \r
118         // This parameter shall represent the MCU RAM Section size\r
119         uint32 McuRamSectionSize;\r
120 \r
121 } Mcu_RamSectorSettingConfigType;\r
122 \r
123 typedef struct {\r
124         //      Enables/Disables clock failure notification. In case this feature is not supported\r
125         //      by HW the setting should be disabled.\r
126         uint8   McuClockSrcFailureNotification;\r
127 \r
128         //      This parameter shall represent the number of Modes available for the\r
129         //      MCU. calculationFormula = Number of configured McuModeSettingConf\r
130         //uint8 McuNumberOfMcuModes; /* Not supported */\r
131 \r
132         //  This parameter shall represent the number of RAM sectors available for\r
133         //  the MCU. calculationFormula = Number of configured McuRamSectorSet-\r
134         //  tingConf\r
135         uint8 McuRamSectors;\r
136 \r
137         //  This parameter shall represent the number of clock setting available for\r
138         //  the MCU.\r
139         uint8 McuClockSettings;\r
140 \r
141         // This parameter defines the default clock settings that should be used\r
142         // It is an index into the McuClockSettingsConfig\r
143         Mcu_ClockType McuDefaultClockSettings;\r
144 \r
145         //      This parameter relates to the MCU specific reset configuration. This ap-\r
146         //      plies to the function Mcu_PerformReset, which performs a microcontroller\r
147         //      reset using the hardware feature of the microcontroller.\r
148         //uint32 McuResetSetting;\r
149 \r
150         //      This container contains the configuration (parameters) for the\r
151         //      Clock settings of the MCU. Please see MCU031 for more in-\r
152         //      formation on the MCU clock settings.\r
153         Mcu_ClockSettingConfigType * McuClockSettingConfig;\r
154 \r
155         //      This container contains the configuration (parameters) for the\r
156         //      Mode setting of the MCU. Please see MCU035 for more information\r
157         //  on the MCU mode settings.\r
158         //Mcu_ModeSettingConfigType  *McuModeSettingConfig;\r
159 \r
160         //      This container contains the configuration (parameters) for the\r
161         //      RAM Sector setting. Please see MCU030 for more information\r
162         //      on RAM sec-tor settings.\r
163         Mcu_RamSectorSettingConfigType *McuRamSectorSettingConfig;\r
164 \r
165 } Mcu_ConfigType;\r
166 \r
167 extern const Mcu_ConfigType McuConfigData[];\r
168 \r
169 \r
170 \r
171 void Mcu_Init( const Mcu_ConfigType *configPtr );\r
172 void Mcu_DeInit();\r
173 Std_ReturnType Mcu_InitRamSection( const Mcu_RamSectionType RamSection );\r
174 Std_ReturnType Mcu_InitClock( const Mcu_ClockType ClockSetting );\r
175 void Mcu_DistributePllClock( void );\r
176 Mcu_PllStatusType Mcu_GetPllStatus( void );\r
177 Mcu_ResetType Mcu_GetResetReason( void );\r
178 Mcu_RawResetType Mcu_GetResetRawValue( void );\r
179 #if ( MCU_PERFORM_RESET_API == STD_ON )\r
180 void Mcu_PerformReset( void );\r
181 #endif\r
182 void Mcu_SetMode( const Mcu_ModeType McuMode );\r
183 \r
184 #if ( MCU_VERSION_INFO_API == STD_ON )\r
185 #define Mcu_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,MCU)\r
186 #endif\r
187 \r
188 /* ArcCore extensions */\r
189 \r
190 void Irq_InstallVector(void (*func)(), IrqType vector, uint8_t priority, Cpu_t cpu );\r
191 void Irq_GenerateSoftInt( IrqType vector );\r
192 uint8_t Irq_GetCurrentPriority( Cpu_t cpu);\r
193 uint32_t McuE_GetSystemClock( void );\r
194 #if defined(CFG_MPC55XX) || defined(CFG_ARM_CR4)\r
195 uint32_t McuE_GetPeripheralClock( McuE_PeriperalClock_t type );\r
196 #endif\r
197 \r
198 #endif /*MCU_H_*/\r
199 /** @} */\r