]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/cmdproc/src/cmdproc_freertos_tms570.c
Yet another place to fix
[pes-rpp/rpp-test-sw.git] / rpp / lib / cmdproc / src / cmdproc_freertos_tms570.c
1 /*
2  * Copyright (C) 2012-2013 Czech Technical University in Prague
3  *
4  * Created on: 1.8.2012
5  *
6  * Authors:
7  *     - Michal Horn
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * File : cmd_proc_freertos_tms570.c
23  *
24  * Abstract:
25  *      This file contains main command processor task function and initialization of CMDPROC
26  *
27  */
28
29 /* Include files */
30 #include "cmdproc_freertos_tms570.h"
31 #include "rpp/sci.h"
32
33 /** cmdProc task handler */
34 xTaskHandle processCmdHandler;
35 /** string prompt */
36 uint8_t* prompt;
37 /** Main list of commands */
38 extern cmd_des_t const *cmd_list_main[];
39 /** IO stack */
40 extern cmd_io_t cmd_io_std_line;
41
42
43 /**
44  * @brief Entry function to start main CMDPROC
45  * @param priority Priority of CMDPROC task (0 is the highest priority)
46  * @param introText Text which will be printed when CMDPROC launches
47  * @param promptText Text printed when CMDPROC is ready to read new command
48  *
49  */
50 void initCmdProc(unsigned portBASE_TYPE priority, uint8_t * introText, uint8_t * promptText) {
51         prompt = NULL;
52         if (promptText != NULL) {
53                 prompt = (uint8_t *)pvPortMalloc(strlen((char*)promptText));
54                 strcpy((char *)prompt, (const char*)promptText);
55         }
56         int taskRetVal;
57         if ((taskRetVal = xTaskCreate(processCmd, (const signed char *)"processCmd", 400, NULL, priority, processCmdHandler)) != pdPASS) {
58                 rpp_sci_printf("FreeRTOS: Creating task processCmd failed. Error code: %d", taskRetVal);
59                 /* An error occurred, block program */
60                 while(1)
61                         ;
62         }
63         if (introText != NULL)
64                 rpp_sci_printf("%s", introText);
65         if (prompt != NULL)
66                 rpp_sci_printf("%s", prompt);
67 }
68
69 /**
70  * @brief CMDPROC task procedure
71  * @param pvParameters Not used, task receives no parameters
72  */
73 void processCmd(void *pvParameters ) {
74         for (;;) {
75                 cmd_processor_run(&cmd_io_std_line, cmd_list_main);
76                 if (prompt != NULL)
77                         rpp_sci_printf("%s", prompt);
78         }
79 }