]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp-test-sw/commands/main.c
Change license to MIT
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / main.c
1 /*\r
2  * Copyright (C) 2012-2015 Czech Technical University in Prague\r
3  *\r
4  * Created on: 15.3.2012\r
5  *\r
6  * Authors:\r
7  *     - Michal Horn\r
8  *     - Carlos Jenkins <carlos@jenkins.co.cr>\r
9  *\r
10  * Permission is hereby granted, free of charge, to any person\r
11  * obtaining a copy of this software and associated documentation\r
12  * files (the "Software"), to deal in the Software without\r
13  * restriction, including without limitation the rights to use,\r
14  * copy, modify, merge, publish, distribute, sublicense, and/or sell\r
15  * copies of the Software, and to permit persons to whom the\r
16  * Software is furnished to do so, subject to the following\r
17  * conditions:\r
18  *\r
19  * The above copyright notice and this permission notice shall be\r
20  * included in all copies or substantial portions of the Software.\r
21  *\r
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\r
24  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
25  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r
26  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r
27  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\r
29  * OTHER DEALINGS IN THE SOFTWARE.\r
30  *\r
31  * File : main.c\r
32  *\r
33  * Abstract:\r
34  *      This file contains main function and Hook functions used by IDLE task.\r
35  *\r
36  */\r
37 \r
38 /* Include Files */\r
39 #include "rpp/rpp.h"\r
40 #include "os/os.h"\r
41 #include "cmdproc_freertos.h"\r
42 #include "version.h" // Generated by Makefile\r
43 \r
44 #if defined(TARGET_TMS570_HDK)\r
45 #define TARGET_STR "TI HDK TMS570LS3137"\r
46 #elif defined(TARGET_RM48_HDK)\r
47 #define TARGET_STR "TI HDK RM48L952"\r
48 #elif defined(TARGET_TMS570_HYDCTR)\r
49 #define TARGET_STR "Eaton Hydraulics Controller"\r
50 #elif defined(TARGET_TMS570_RPP)\r
51 #define TARGET_STR "Porsche Rapid Prototyping Platform"\r
52 #elif defined(TARGET_POSIX)\r
53 #define TARGET_STR "POSIX version"\r
54 #else\r
55 #error Unknown target\r
56 #endif\r
57 \r
58 /** @fn void main(void)\r
59  *   @brief Application main function\r
60  *\r
61  *   This function is called after startup.\r
62  */\r
63 void main(void)\r
64 {\r
65         rpp_init();\r
66 \r
67         // Speed up the SCI\r
68         rpp_sci_setup(115200);\r
69 \r
70         rpp_sci_printf("\n" TARGET_STR ", FreeRTOS %d.%d.%d\n", FREERTOS_VERSION_NUMBER_MAYOR, FREERTOS_VERSION_NUMBER_MINOR, FREERTOS_VERSION_NUMBER_REV);\r
71         rpp_sci_printf("Test Software version " GIT_VERSION "\n");\r
72         rpp_sci_printf("CTU in Prague 04/2015\n");\r
73 \r
74         initCmdProc(0);\r
75         vTaskStartScheduler();\r
76 \r
77         //We should never get here\r
78         while (1)\r
79                 ;\r
80 }\r
81 \r
82 #if configUSE_MALLOC_FAILED_HOOK == 1\r
83 /**\r
84  * FreeRTOS malloc() failed hook.\r
85  */\r
86 void vApplicationMallocFailedHook(void)\r
87 {\r
88         #ifdef DEBUG\r
89         rpp_sci_printf("ERROR: manual memory allocation failed.\r\n");\r
90         #endif\r
91 }\r
92 #endif\r
93 \r
94 \r
95 #if configCHECK_FOR_STACK_OVERFLOW > 0\r
96 /**\r
97  * FreeRTOS stack overflow hook.\r
98  */\r
99 void vApplicationStackOverflowHook(xTaskHandle xTask,\r
100                                                                    signed portCHAR *pcTaskName)\r
101 {\r
102         #ifdef DEBUG\r
103         rpp_sci_printf("ERROR: Stack overflow : \"%s\".\r\n", pcTaskName);\r
104         #endif\r
105 }\r
106 #endif\r