1 /* -------------------------------- Arctic Core ------------------------------
\r
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
\r
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
\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
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
14 * -------------------------------- Arctic Core ------------------------------*/
\r
16 /** @addtogroup EcuM ECU State Manager
\r
20 * API and type definitions for ECU State Manager.
\r
26 #define ECUM_MODULE_ID MODULE_ID_ECUM
\r
27 #define ECUM_VENDOR_ID 1
\r
29 #define ECUM_SW_MAJOR_VERSION 2
\r
30 #define ECUM_SW_MINOR_VERSION 0
\r
31 #define ECUM_SW_PATCH_VERSION 0
\r
33 #define ECUM_AR_MAJOR_VERSION 1
\r
34 #define ECUM_AR_MINOR_VERSION 2
\r
35 #define ECUM_AR_PATCH_VERSION 2
\r
37 #include "EcuM_Cfg.h"
\r
39 #if defined(USE_COM)
\r
40 #include "ComStack_Types.h"
\r
42 #if defined(USE_RTE)
\r
43 #include "Rte_Type.h"
\r
47 /** @name Error Codes */
\r
49 #define ECUM_E_NOT_INITIATED (0x10)
\r
50 #define ECUM_E_SERVICE_DISABLED (0x11)
\r
51 #define ECUM_E_NULL_POINTER (0x12)
\r
52 #define ECUM_E_INVALID_PAR (0x13)
\r
53 #define ECUM_E_MULTIPLE_RUN_REQUESTS (0x14)
\r
54 #define ECUM_E_MISMATCHED_RUN_RELEASE (0x15)
\r
55 #define ECUM_E_STATE_PAR_OUT_OF_RANGE (0x16)
\r
56 #define ECUM_E_UNKNOWN_WAKEUP_SOURCE (0x17)
\r
57 #define ECUM_E_ARC_TIMERERROR (0x18)
\r
60 /** @name Service id's */
\r
62 #define ECUM_REQUESTRUN_ID (0x03)
\r
63 #define ECUM_RELEASERUN_ID (0x04)
\r
64 #define ECUM_SELECTSHUTDOWNTARGET_ID (0x06)
\r
65 #define ECUM_GETSTATE_ID (0x07)
\r
66 #define ECUM_GETSHUTDOWNTARGET_ID (0x09)
\r
67 #define ECUM_COMM_REQUESTRUN_ID (0x0e)
\r
68 #define ECUM_REQUESTPOSTRUN_ID (0x0a)
\r
69 #define ECUM_RELEASEPOSTRUN_ID (0x0b)
\r
70 #define ECUM_SELECTAPPMODE_ID (0x0f)
\r
71 #define ECUM_COMM_RELEASERUN_ID (0x10)
\r
72 #define ECUM_GETAPPMODE_ID (0x11)
\r
73 #define ECUM_SELECT_BOOTARGET_ID (0x12)
\r
74 #define ECUM_GET_BOOTARGET_ID (0x13)
\r
75 #define ECUM_MAINFUNCTION_ID (0x18)
\r
76 #define ECUM_COMM_HASREQUESTEDRUN_ID (0x1b)
\r
77 #define ECUM_ARC_STARTUPTWO_ID (0x20)
\r
79 #if !defined(_DEFINED_TYPEDEF_FOR_EcuM_StateType_)
\r
80 /** Possible states */
\r
82 ECUM_STATE_APP_RUN = 0x32,
\r
83 ECUM_STATE_SHUTDOWN = 0x40,
\r
84 ECUM_STATE_WAKEUP = 0x20,
\r
85 ECUM_SUBSTATE_MASK = 0x0F,
\r
86 ECUM_STATE_WAKEUP_WAKESLEEP = 0x25,
\r
87 ECUM_STATE_WAKEUP_ONE = 0x21,
\r
88 ECUM_STATE_OFF = 0x80,
\r
89 ECUM_STATE_STARTUP = 0x10,
\r
90 ECUM_STATE_PREP_SHUTDOWN = 0x44,
\r
91 ECUM_STATE_RUN = 0x30,
\r
92 ECUM_STATE_STARTUP_TWO = 0x12,
\r
93 ECUM_STATE_WAKEUP_TTII = 0x26,
\r
94 ECUM_STATE_WAKEUP_VALIDATION = 0x22,
\r
95 ECUM_STATE_GO_SLEEP = 0x49,
\r
96 ECUM_STATE_STARTUP_ONE = 0x11,
\r
97 ECUM_STATE_WAKEUP_TWO = 0x24,
\r
98 ECUM_STATE_SLEEP = 0x50,
\r
99 ECUM_STATE_WAKEUP_REACTION = 0x23,
\r
100 ECUM_STATE_APP_POST_RUN = 0x33,
\r
101 ECUM_STATE_GO_OFF_TWO = 0x4e,
\r
102 ECUM_STATE_RESET = 0x90,
\r
103 ECUM_STATE_GO_OFF_ONE = 0x4d
\r
106 #define _DEFINED_TYPEDEF_FOR_EcuM_StateType_
\r
110 typedef uint8 EcuM_UserType;
\r
113 /** Internal reset of µC (bit 2).
\r
114 * The internal reset typically only resets the µC
\r
115 * core but not peripherals or memory
\r
116 * controllers. The exact behavior is hardware
\r
118 * This source may also indicate an unhandled
\r
120 ECUM_WKSOURCE_INTERNAL_RESET = 0x04,
\r
122 /** Reset by external watchdog (bit 4), if
\r
123 * detection supported by hardware */
\r
124 ECUM_WKSOURCE_EXTERNAL_WDG = 0x10,
\r
126 /** Reset by internal watchdog (bit 3) */
\r
127 ECUM_WKSOURCE_INTERNAL_WDG = 0x08,
\r
129 /** Power cycle (bit 0) */
\r
130 ECUM_WKSOURCE_POWER = 0x01,
\r
132 /** ~0 to the power of 29 */
\r
133 ECUM_WKSOURCE_ALL_SOURCES = 0x3FFFFFFF,
\r
135 /** Hardware reset (bit 1).
\r
136 * If hardware cannot distinguish between a
\r
137 * power cycle and a reset reason, then this
\r
138 * shall be the default wakeup source */
\r
139 ECUM_WKSOURCE_RESET = 0x02
\r
142 typedef uint32 EcuM_WakeupSourceType;
\r
146 ECUM_WKSTATUS_NONE = 0, /**< No pending wakeup event was detected */
\r
147 ECUM_WKSTATUS_PENDING = 1, /**< The wakeup event was detected but not yet validated */
\r
148 ECUM_WKSTATUS_VALIDATED = 2, /**< The wakeup event is valid */
\r
149 ECUM_WKSTATUS_EXPIRED = 3 /**< The wakeup event has not been validated and has expired therefore */
\r
150 } EcuM_WakeupStatusType;
\r
154 ECUM_WWKACT_RUN = 0, /**< Initialization into RUN state */
\r
155 ECUM_WKACT_TTII = 2, /**< Execute time triggered increased inoperation protocol and shutdown */
\r
156 ECUM_WKACT_SHUTDOWN = 3 /**< Immediate shutdown */
\r
157 } EcuM_WakeupReactionType;
\r
159 #if !defined(_DEFINED_TYPEDEF_FOR_EcuM_BootTargetType_)
\r
162 ECUM_BOOT_TARGET_APP = 0, /**< The Ecu will boot into the application */
\r
163 ECUM_BOOT_TARGET_BOOTLOADER = 1 /**< The Ecu will boot into the bootloader */
\r
164 } EcuM_BootTargetType;
\r
165 #define _DEFINED_TYPEDEF_FOR_EcuM_BootTargetType_
\r
169 #define ECUM_MODULE_ID MODULE_ID_ECUM
\r
170 #define ECUM_VENDOR_ID 1
\r
172 #define ECUM_SW_MAJOR_VERSION 2
\r
173 #define ECUM_SW_MINOR_VERSION 0
\r
174 #define ECUM_SW_PATCH_VERSION 0
\r
176 #define ECUM_AR_MAJOR_VERSION 1
\r
177 #define ECUM_AR_MINOR_VERSION 2
\r
178 #define ECUM_AR_PATCH_VERSION 2
\r
180 #include "EcuM_Cfg.h"
\r
182 #if ( ECUM_VERSION_INFO_API == STD_ON)
\r
183 #define EcuM_GetVersionInfo(_vi) STD_GET_VERSION_INFO(_vi,ECUM)
\r
186 void EcuM_Init( void );
\r
187 void EcuM_StartupTwo(void);
\r
188 void EcuM_Shutdown(void);
\r
190 Std_ReturnType EcuM_GetState(EcuM_StateType* state);
\r
192 Std_ReturnType EcuM_RequestRUN(EcuM_UserType user);
\r
193 Std_ReturnType EcuM_ReleaseRUN(EcuM_UserType user);
\r
195 Std_ReturnType EcuM_RequestPOST_RUN(EcuM_UserType user);
\r
196 Std_ReturnType EcuM_ReleasePOST_RUN(EcuM_UserType user);
\r
198 void EcuM_KillAllRUNRequests(void);
\r
200 #if defined(USE_COMM)
\r
201 Std_ReturnType EcuM_ComM_RequestRUN(NetworkHandleType channel);
\r
202 Std_ReturnType EcuM_ComM_ReleaseRUN(NetworkHandleType channel);
\r
203 boolean EcuM_ComM_HasRequestedRUN(NetworkHandleType channel);
\r
206 Std_ReturnType EcuM_SelectShutdownTarget(EcuM_StateType shutdownTarget, uint8 sleepMode);
\r
207 Std_ReturnType EcuM_GetShutdownTarget(EcuM_StateType* shutdownTarget, uint8* sleepMode);
\r
208 Std_ReturnType EcuM_GetLastShutdownTarget(EcuM_StateType* shutdownTarget, uint8* sleepMode);
\r
210 EcuM_WakeupSourceType EcuM_GetPendingWakeupEvents(void);
\r
211 void EcuM_ClearWakeupEvent(EcuM_WakeupSourceType sources);
\r
212 EcuM_WakeupSourceType EcuM_GetValidatedWakeupEvents(void);
\r
213 EcuM_WakeupSourceType EcuM_GetExpiredWakeupEvents(void);
\r
214 EcuM_WakeupStatusType EcuM_GetStatusOfWakeupSource(EcuM_WakeupSourceType sources);
\r
216 Std_ReturnType EcuM_SelectApplicationMode(AppModeType appMode);
\r
217 Std_ReturnType EcuM_GetApplicationMode(AppModeType* appMode);
\r
219 Std_ReturnType EcuM_SelectBootTarget(EcuM_BootTargetType target);
\r
220 Std_ReturnType EcuM_GetBootTarget(EcuM_BootTargetType* target);
\r
222 void EcuM_MainFunction(void);
\r