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