]> rtime.felk.cvut.cz Git - arc.git/blob - system/EcuM/EcuM_Main.c
Initial commit.
[arc.git] / system / EcuM / EcuM_Main.c
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 #include "EcuM.h"\r
24 #include "EcuM_Internals.h"\r
25 \r
26 void EcuM_MainFunction(void)\r
27 {\r
28 #if (ECUM_DEV_ERROR_DETECT == STD_ON)\r
29         if (!internal_data->initiated)\r
30         {\r
31                 Det_ReportError(MODULE_ID_ECUM, 1, ECUM_MAINFUNCTION_ID, ECUM_E_NOT_INITIATED);\r
32                 return;\r
33         }\r
34 #endif\r
35 \r
36         // If coming from startup sequence, enter Run mode\r
37         if (internal_data->current_state == ECUM_STATE_STARTUP_TWO)\r
38                 enter_run_mode();\r
39 \r
40         if (internal_data->current_state == ECUM_STATE_APP_RUN)\r
41         {\r
42                 if (!hasRunRequests() && (internal_data_run_state_timeout == 0))\r
43                 {\r
44                         enter_post_run_mode();\r
45                         return;\r
46                 }\r
47         }\r
48 \r
49         if (internal_data->current_state == ECUM_STATE_APP_POST_RUN)\r
50         {\r
51                 if (hasRunRequests())\r
52                 {\r
53                         enter_run_mode(); // ECUM_2866\r
54                         return;\r
55                 }\r
56 \r
57                 if (!hasPostRunRequests())\r
58                 {\r
59                         EcuM_OnExitPostRun(); // ECUM_2761\r
60                         enter_prep_shutdown_mode();\r
61                         return;\r
62                 }\r
63         }\r
64 }\r