]> rtime.felk.cvut.cz Git - arc.git/blob - system/EcuM/EcuM_Main.c
Merge with hcs12_mcal
[arc.git] / system / EcuM / EcuM_Main.c
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\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
9  *\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
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 \r
18 \r
19 \r
20 \r
21 \r
22 \r
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