]> rtime.felk.cvut.cz Git - arc.git/blob - include/Mcu.h
Replaced all occurences of Ecore with Arc and tidied up some names for better conform...
[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
17
18
19
20
21
22
23 #ifndef MCU_H_\r
24 #define MCU_H_\r
25
26 #define MCU_SW_MAJOR_VERSION    1
27 #define MCU_SW_MINOR_VERSION    0
28 #define MCU_SW_PATCH_VERSION    0
29 \r
30 #include "Cpu.h"\r
31 #include "irq.h"\r
32 //#include "mpc55xx_aos.h"\r
33 \r
34 /* Service ID's */\r
35 #define MCU_INIT_SERVICE_ID                 0x00\r
36 #define MCU_INITRAMSECTION_SERVICE_ID       0x01\r
37 #define MCU_INITCLOCK_SERVICE_ID            0x02\r
38 #define MCU_DISTRIBUTEPLLCLOCK_SERVICE_ID   0x03\r
39 #define MCU_GETPLLSTATUS_SERVICE_ID         0x04\r
40 #define MCU_GETRESETREASON_SERVICE_ID       0x05\r
41 #define MCU_GETRESETRAWVALUE_SERVICE_ID     0x06\r
42 #define MCU_PERFORMRESET_SERVICE_ID         0x07\r
43 #define MCU_SETMODE_SERVICE_ID              0x08\r
44 #define MCU_GETVERSIONINFO_SERVICE_ID       0x09\r
45 #define MCU_INTCVECTORINSTALL_SERVICE_ID    0x0A // Not in spec but follows pattern\r
46 \r
47 /* Development error codes */\r
48 #define MCU_E_PARAM_CONFIG                  0x0A\r
49 #define MCU_E_PARAM_CLOCK                   0x0B\r
50 #define MCU_E_PARAM_MODE                    0x0C\r
51 #define MCU_E_PARAM_RAMSECTION              0x0D\r
52 #define MCU_E_PLL_NOT_LOCKED                0x0E\r
53 #define MCU_E_UNINIT                        0x0F\r
54 \r
55 /* Specific return values */\r
56 #define MCU_GETRESETRAWVALUE_NORESETREG_RV  0x00 // MCU006\r
57 #define MCU_GETRESETRAWVALUE_UNINIT_RV      0xffffffff // MCU135\r
58 \r
59 typedef enum {\r
60         MCU_PLL_LOCKED,\r
61         MCU_PLL_UNLOCKED,\r
62         MCU_PLL_STATUS_UNDEFINED,\r
63 } Mcu_PllStatusType;\r
64 \r
65 \r
66 typedef enum {\r
67         MCU_MODE_NORMAL=0\r
68 } Mcu_ModeType;\r
69 \r
70 //TODO\r
71 typedef uint8_t Mcu_RamSectionType;\r
72 \r
73 typedef uint32_t Mcu_RawResetType;\r
74 \r
75 typedef enum {\r
76         MCU_POWER_ON_RESET,\r
77         MCU_WATCHDOG_RESET,\r
78         MCU_SW_RESET,\r
79         MCU_RESET_UNDEFINED\r
80 } Mcu_ResetType;\r
81 \r
82 #include "Mcu_Cfg.h"\r
83 \r
84 void Mcu_Init( const Mcu_ConfigType *configPtr );\r
85 void Mcu_DeInit();\r
86 Std_ReturnType Mcu_InitRamSection( const Mcu_RamSectionType RamSection );\r
87 Std_ReturnType Mcu_InitClock( const Mcu_ClockType ClockSetting );\r
88 void Mcu_DistributePllClock( void );\r
89 Mcu_PllStatusType Mcu_GetPllStatus( void );\r
90 Mcu_ResetType Mcu_GetResetReason( void );\r
91 Mcu_RawResetType Mcu_GetResetRawValue( void );\r
92 #if ( MCU_PERFORM_RESET_API == STD_ON )\r
93 void Mcu_PerformReset( void );\r
94 #endif\r
95 void Mcu_SetMode( const Mcu_ModeType McuMode );\r
96 \r
97 #if ( MCU_VERSION_INFO_API == STD_ON )\r
98 #define MCU_SW_MAJOR_VERSION            1\r
99 #define MCU_SW_MINOR_VERSION            0\r
100 #define MCU_SW_PATCH_VERSION            0\r
101 #define MCU_AR_MAJOR_VERSION            2\r
102 #define MCU_AR_MINOR_VERSION            2\r
103 #define MCU_AR_PATCH_VERSION            2\r
104 \r
105 #define Mcu_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,MCU)\r
106 #endif\r
107 \r
108 typedef uint32_t imask_t;\r
109 \r
110 /* ArcCore extensions */\r
111 void IntCtrl_InstallVector(void (*func)(), IrqType vector, uint8_t priority, Cpu_t cpu );\r
112 void IntCtrl_GenerateSoftInt( IrqType vector );\r
113 uint8_t IntCtrl_GetCurrentPriority( Cpu_t cpu);\r
114 uint32_t McuE_GetSystemClock( void );\r
115 #if defined(CFG_MPC55XX)\r
116 uint32_t McuE_GetPeripheralClock( McuE_PeriperalClock_t type );\r
117 #endif\r
118 imask_t McuE_EnterCriticalSection(void);\r
119 void McuE_ExitCriticalSection(imask_t old_state);\r
120 void McuE_EnableInterrupts(void);\r
121 void McuE_DisableInterrupts(void);\r
122 \r
123 \r
124 \r
125 #endif /*MCU_H_*/\r