]> rtime.felk.cvut.cz Git - arc.git/blob - examples/switch_node/Tasks.c
Starting 'pdur2' branch with copied content from remote repository.
[arc.git] / examples / switch_node / Tasks.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 "Os.h"\r
24 \r
25 #include "EcuM.h"\r
26 #include <stdio.h>\r
27 #include <assert.h>\r
28 #include "Com.h"\r
29 #include "Adc.h"\r
30 \r
31 //#define USE_LDEBUG_PRINTF // Uncomment this to turn debug statements on.\r
32 #include "debug.h"\r
33 \r
34 void OsIdle( void ) {\r
35         for(;;);\r
36 }\r
37 \r
38 \r
39 void ComTask( void ) {\r
40         // Run COM scheduled functions.\r
41         Com_MainFunctionTx();\r
42         Com_MainFunctionRx();\r
43 \r
44         TerminateTask();\r
45 }\r
46 \r
47 void ReadSwitches( void ) {\r
48         // Trigger update of switch readings\r
49         Adc_StartGroupConversion(ADC_SWITCHES); // Read the switches\r
50         Adc_StartGroupConversion(ADC_POTENTIOMETERS);\r
51 \r
52         TerminateTask();\r
53 }\r
54 \r
55 /*\r
56  * This is the startup task. It is activated once immediately after the OS i started.\r
57  */\r
58 void StartupTask( void ) {\r
59 \r
60         // Call second phase of startup sequence.\r
61         EcuM_StartupTwo();\r
62 \r
63         // Startup CanIf due to ComM is missing in this example\r
64         CanIf_InitController(CANIF_CHANNEL_0, CANIF_CHANNEL_0_CONFIG_0);\r
65         CanIf_SetControllerMode(CANIF_CHANNEL_0, CANIF_CS_STARTED);\r
66 \r
67         // Make sure that the right PDU-groups are ready for communication.\r
68         Com_IpduGroupStart(TxGroup, 0);\r
69 \r
70         // End of startup_task().\r
71         TerminateTask();\r
72 }\r
73 \r
74 \r