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