1 /* -------------------------------- Arctic Core ------------------------------
2 * Arctic Core - the open source AUTOSAR platform http://arccore.com
4 * Copyright (C) 2009 ArcCore AB <contact@arccore.com>
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>.
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
14 * -------------------------------- Arctic Core ------------------------------*/
16 /** @addtogroup EcuM ECU State Manager
20 * API and type definitions for ECU State Manager.
26 #include "Std_Types.h"
\r
28 #if defined(USE_COM)
\r
29 #include "ComStack_Types.h"
\r
32 /** @name Error Codes */
34 #define ECUM_E_NOT_INITIATED (0x10)
\r
35 #define ECUM_E_SERVICE_DISABLED (0x11)
\r
36 #define ECUM_E_NULL_POINTER (0x12)
\r
37 #define ECUM_E_INVALID_PAR (0x13)
\r
38 #define ECUM_E_MULTIPLE_RUN_REQUESTS (0x14)
\r
39 #define ECUM_E_MISMATCHED_RUN_RELEASE (0x15)
\r
40 #define ECUM_E_STATE_PAR_OUT_OF_RANGE (0x16)
\r
41 #define ECUM_E_UNKNOWN_WAKEUP_SOURCE (0x17)
\r
44 /** @name Service id's */
46 #define ECUM_GETSTATE_ID (0x07)
\r
47 #define ECUM_SELECTAPPMODE_ID (0x0f)
\r
48 #define ECUM_GETAPPMODE_ID (0x11)
\r
49 #define ECUM_SELECT_BOOTARGET_ID (0x12)
\r
50 #define ECUM_GET_BOOTARGET_ID (0x13)
\r
51 #define ECUM_MAINFUNCTION_ID (0x18)
\r
53 /** Possible states */
55 ECUM_STATE_APP_RUN = 0x32,
\r
56 ECUM_STATE_SHUTDOWN = 0x40,
\r
57 ECUM_STATE_WAKEUP = 0x20,
\r
58 ECUM_SUBSTATE_MASK = 0x0F,
\r
59 ECUM_STATE_WAKEUP_WAKESLEEP = 0x25,
\r
60 ECUM_STATE_WAKEUP_ONE = 0x21,
\r
61 ECUM_STATE_OFF = 0x80,
\r
62 ECUM_STATE_STARTUP = 0x10,
\r
63 ECUM_STATE_PREP_SHUTDOWN = 0x44,
\r
64 ECUM_STATE_RUN = 0x30,
\r
65 ECUM_STATE_STARTUP_TWO = 0x12,
\r
66 ECUM_STATE_WAKEUP_TTII = 0x26,
\r
67 ECUM_STATE_WAKEUP_VALIDATION = 0x22,
\r
68 ECUM_STATE_GO_SLEEP = 0x49,
\r
69 ECUM_STATE_STARTUP_ONE = 0x11,
\r
70 ECUM_STATE_WAKEUP_TWO = 0x24,
\r
71 ECUM_STATE_SLEEP = 0x50,
\r
72 ECUM_STATE_WAKEUP_REACTION = 0x23,
\r
73 ECUM_STATE_APP_POST_RUN = 0x33,
\r
74 ECUM_STATE_GO_OFF_TWO = 0x4e,
\r
75 ECUM_STATE_RESET = 0x90,
\r
76 ECUM_STATE_GO_OFF_ONE = 0x4d
\r
79 typedef uint8 EcuM_UserType;
\r
82 /** Internal reset of µC (bit 2).
83 * The internal reset typically only resets the µC
84 * core but not peripherals or memory
85 * controllers. The exact behavior is hardware
87 * This source may also indicate an unhandled
89 ECUM_WKSOURCE_INTERNAL_RESET = 0x04,
\r
91 /** Reset by external watchdog (bit 4), if
92 * detection supported by hardware */
93 ECUM_WKSOURCE_EXTERNAL_WDG = 0x10,
\r
95 /** Reset by internal watchdog (bit 3) */
96 ECUM_WKSOURCE_INTERNAL_WDG = 0x08,
\r
98 /** Power cycle (bit 0) */
99 ECUM_WKSOURCE_POWER = 0x01,
\r
101 /** ~0 to the power of 29 */
102 ECUM_WKSOURCE_ALL_SOURCES = 0x3FFFFFFF,
\r
104 /** Hardware reset (bit 1).
105 * If hardware cannot distinguish between a
106 * power cycle and a reset reason, then this
107 * shall be the default wakeup source */
108 ECUM_WKSOURCE_RESET = 0x02,
\r
111 typedef uint32 EcuM_WakeupSourceType;
\r
115 ECUM_WKSTATUS_NONE = 0, /**< No pending wakeup event was detected */
116 ECUM_WKSTATUS_PENDING = 1, /**< The wakeup event was detected but not yet validated */
117 ECUM_WKSTATUS_VALIDATED = 2, /**< The wakeup event is valid */
118 ECUM_WKSTATUS_EXPIRED = 3, /**< The wakeup event has not been validated and has expired therefore */
119 } EcuM_WakeupStatusType;
\r
123 ECUM_WWKACT_RUN = 0, /**< Initialization into RUN state */
124 ECUM_WKACT_TTII = 2, /**< Execute time triggered increased inoperation protocol and shutdown */
125 ECUM_WKACT_SHUTDOWN = 3, /**< Immediate shutdown */
126 } EcuM_WakeupReactionType;
\r
130 ECUM_BOOT_TARGET_APP = 0, /**< The Ecu will boot into the application */
131 ECUM_BOOT_TARGET_BOOTLOADER = 1, /**< The Ecu will boot into the bootloader */
132 } EcuM_BootTargetType;
\r
135 #define ECUM_SW_MAJOR_VERSION 1
136 #define ECUM_SW_MINOR_VERSION 0
137 #define ECUM_SW_PATCH_VERSION 0
139 #define ECUM_AR_MAJOR_VERSION 1
140 #define ECUM_AR_MINOR_VERSION 2
141 #define ECUM_AR_PATCH_VERSION 2
143 #include "EcuM_Cfg.h"
\r
145 #if ( ECUM_VERSION_INFO_API == STD_ON)
\r
146 void EcuM_GetVersionInfo( Std_VersionInfoType *versionInfo );
\r
149 void EcuM_Init( void );
\r
150 void EcuM_StartupTwo();
\r
151 void EcuM_Shutdown();
\r
153 Std_ReturnType EcuM_GetState(EcuM_StateType* state);
\r
155 Std_ReturnType EcuM_RequestRUN(EcuM_UserType user);
\r
156 Std_ReturnType EcuM_ReleaseRUN(EcuM_UserType user);
\r
158 Std_ReturnType EcuM_RequestPOST_RUN(EcuM_UserType user);
\r
159 Std_ReturnType EcuM_ReleasePOST_RUN(EcuM_UserType user);
\r
161 void EcuM_KillAllRUNRequests();
\r
163 #if defined(USE_COM)
\r
164 Std_ReturnType EcuM_ComM_RequestRUN(NetworkHandleType channel);
\r
165 Std_ReturnType EcuM_ComM_ReleaseRUN(NetworkHandleType channel);
\r
166 boolean EcuM_ComM_HasRequestedRUN(NetworkHandleType channel);
\r
169 Std_ReturnType EcuM_SelectShutdownTarget(EcuM_StateType target, uint8 mode);
\r
170 Std_ReturnType EcuM_GetShutdownTarget(EcuM_StateType* target, uint8* mode);
\r
171 Std_ReturnType EcuM_GetLastShutdownTarget(EcuM_StateType* target, uint8* mode);
\r
173 EcuM_WakeupSourceType EcuM_GetPendingWakeupEvents();
\r
174 void EcuM_ClearWakeupEvent(EcuM_WakeupSourceType sources);
\r
175 EcuM_WakeupSourceType EcuM_GetValidatedWakeupEvents();
\r
176 EcuM_WakeupSourceType EcuM_GetExpiredWakeupEvents();
\r
177 EcuM_WakeupStatusType EcuM_GetStatusOfWakeupSource(EcuM_WakeupSourceType sources);
\r
179 Std_ReturnType EcuM_SelectApplicationMode(AppModeType appMode);
\r
180 Std_ReturnType EcuM_GetApplicationMode(AppModeType* appMode);
\r
182 Std_ReturnType EcuM_SelectBootTarget(EcuM_BootTargetType target);
\r
183 Std_ReturnType EcuM_GetBootTarget(EcuM_BootTargetType* target);
\r
185 void EcuM_MainFunction(void);
\r
187 void EcuM_OnGoOffTwo( void );
\r
188 void EcuM_AL_SwitchOff( void );
\r