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