]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - source/cmd_proc_freertos_tms570.c
Optimalization of print methods
[pes-rpp/rpp-test-sw.git] / source / cmd_proc_freertos_tms570.c
1 /*
2  * cmd_proc_freertos_tms570.c
3  *
4  *  Created on: 1.8.2012
5  *      Author: Michal Horn
6  *
7  *  Implementation of main task for processing commands.
8  *
9  */
10 #include "cmd_proc_freertos_tms570.h"
11
12 xTaskHandle processCmdHandler;
13 uint8_t* prompt;
14 extern cmd_des_t const *cmd_list_main[];                // Main list of commands
15 extern cmd_io_t cmd_io_std_line;                // IO stack
16
17
18 void initCmdProc(unsigned portBASE_TYPE priority, uint8_t * introText, uint8_t * promptText) {
19         initIoBuffer();
20         prompt = NULL;
21         if (promptText != NULL) {
22                 prompt = (uint8_t *)pvPortMalloc(strlen((char*)promptText));
23                 strcpy((char *)prompt, (const char*)promptText);
24         }
25         int taskRetVal;
26         if ((taskRetVal = xTaskCreate(processCmd, (const signed char *)"processCmd", 1000, NULL, priority, processCmdHandler)) != pdPASS) {
27                 uint8_t taskCreateError[]="FreeRTOS: Creating task processCmd failed. Error code: ";
28                 print(taskCreateError);
29                 char buf[20];
30                 i2str(buf, taskRetVal, 1, 0);
31                 print((uint8_t *)buf);
32                 print((uint8_t *)"\r\n");
33                 /* An error occurred, block program */
34                 while(1)
35                         ;
36         }
37         if (introText != NULL)
38                 print((uint8_t *)introText);
39         if (prompt != NULL)
40                 print((uint8_t *)prompt);
41         sciReceive(sciREG, 1, NULL);
42 }
43
44 void processCmd(void *pvParameters ) {
45         for (;;) {
46                 cmd_processor_run(&cmd_io_std_line, cmd_list_main);
47                 if (prompt != NULL)
48                         print((uint8_t *)prompt);
49         }
50 }
51
52
53