]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp-test-sw/commands/cmd.c
Add ping function to debug tools
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / cmd.c
1 /*
2  * Copyright (C) 2012-2016 Czech Technical University in Prague
3  *
4  * Created on: 31.7.2012
5  *
6  * Authors:
7  *     - Michal Horn
8  *
9  * This document contains proprietary information belonging to Czech
10  * Technical University in Prague. Passing on and copying of this
11  * document, and communication of its contents is not permitted
12  * without prior written authorization.
13  *
14  * File : cmd.c
15  *
16  * Abstract:
17  *      This file contains root of the list of the commands.
18  *
19  */
20
21 /* Include files */
22 #include "cmdproc.h"
23 #include "cmd.h"
24 #include "cmd_adc.h"
25 #include "cmd_can.h"
26 #include "cmd_pin.h"
27 #include "cmd_port.h"
28 #include "cmd_nc.h"
29 #include "cmd_netstats.h"
30 #include "cmd_emac.h"
31 #include "cmd_echoserver.h"
32 #include "cmd_ping.h"
33
34 #ifdef TARGET_TMS570_RPP
35 #include "cmd_dac.h"
36 #include "cmd_fray.h"
37 #include "cmd_din.h"
38 #include "cmd_hbr.h"
39 #include "cmd_hout.h"
40 #include "cmd_lin.h"
41 #include "cmd_lout.h"
42 #include "cmd_mout.h"
43 #include "cmd_sdram.h"
44 #include "cmd_spi.h"
45 #include "cmd_vbat.h"
46 #include "cmd_motor_example.h"
47 #include "cmd_fr_basic_test.h"
48 #endif
49
50 #ifndef DOCGEN
51
52 #include "rpp/rpp.h"
53
54 #include <version.h>
55
56 int cmd_do_version(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
57 {
58         rpp_sci_printf("version=%s\n", GIT_VERSION);
59         return 0;
60 }
61
62 #endif  /* DOCGEN */
63
64 /** Root list in which commands are stored */
65 cmd_des_t const **cmd_list;
66
67 #ifdef TARGET_TMS570_RPP
68 int cmd_do_sleep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
69 {
70 #ifndef DOCGEN
71         if (rpp_gio_set(PIN_CANNSTB, 1) == FAILURE) return -CMDERR_BADDIO;
72         if (rpp_gio_set(PIN_CANEN, 1) == FAILURE) return -CMDERR_BADDIO;
73         if (rpp_gio_set(PIN_LIN2NSLP, 1) == FAILURE) return -CMDERR_BADDIO;
74         if (rpp_gio_set(PIN_LIN1NSLP, 1) == FAILURE) return -CMDERR_BADDIO;
75         vTaskDelay(10/portTICK_RATE_MS);
76         if (rpp_gio_set(PIN_LIN2NSLP, 0) == FAILURE) return -CMDERR_BADDIO;
77         if (rpp_gio_set(PIN_LIN1NSLP, 0) == FAILURE) return -CMDERR_BADDIO;
78         if (rpp_gio_set(PIN_CANNSTB, 0) == FAILURE) return -CMDERR_BADDIO;
79 #endif
80         return 0;
81 }
82
83 /** Command descriptor for sleep command */
84 cmd_des_t const cmd_des_sleep = {
85                 0, 0,
86                 "sleep","Sleep the board",
87                 "### Syntax ###\n"
88                 "\n"
89                 " sleep\n"
90                 "\n"
91                 "### Description ###\n"
92                 "\n"
93                 "This command configures the LIN and CAN peripherals to enter sleep mode\n"
94                 "and turn the whole device into sleep mode. External signal on CAN or\n"
95                 "LIN will wake the device up.\n",
96                 CMD_HANDLER(cmd_do_sleep), (void *)&cmd_list
97 };
98 #endif
99
100 /** Command descriptor for show help command */
101 cmd_des_t const cmd_des_help = {
102         0, 0,
103         "help","Print help for commands",
104         "### Syntax ###\n"
105         "\n"
106         " help [command]\n"
107         "\n"
108         "### Description ###\n"
109         "\n"
110         "This command without parameter prints the list of all available\n"
111         "commands with short help text for each of them. If a parameter is\n"
112         "provided, the command prints a long description for given command.\n",
113         CMD_HANDLER(cmd_do_help), (void *)&cmd_list
114 };
115
116 cmd_des_t const cmd_des_version = {
117         0, 0,
118         "version","Print version of the software",
119         "### Syntax ###\n"
120         "\n"
121         " version\n"
122         "\n"
123         "### Description ###\n"
124         "\n"
125         "This command prints the version of the test software. The version\n"
126         "number is the output of 'git describe' command, i.e. it is composed\n"
127         "from the last tag in the git repository, the number of commits since\n"
128         "the tag and the abbreviated commit hash.\n"
129         "\n"
130         "### Example ###\n"
131         "\n"
132         "    --> version\n"
133         "    version=v0.2-109-ga81a9dd\n",
134         CMD_HANDLER(cmd_do_version),
135 };
136
137 /*  ------------------------
138  *  Command lists definitons
139  *  ------------------------
140  */
141
142 /** @brief Main list of commands */
143 cmd_des_t const *cmd_list_main[] = {
144         &cmd_des_help,
145 #ifdef TARGET_TMS570_RPP
146         &cmd_des_sleep,
147 #endif
148         &cmd_des_version,
149         CMD_DES_INCLUDE_SUBLIST(cmd_list_adc),
150         CMD_DES_INCLUDE_SUBLIST(cmd_list_can),
151         CMD_DES_INCLUDE_SUBLIST(cmd_list_emac),
152         CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
153         CMD_DES_INCLUDE_SUBLIST(cmd_list_es),
154         CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
155         CMD_DES_INCLUDE_SUBLIST(cmd_list_ping),
156 #ifdef TARGET_TMS570_RPP
157         CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
158         CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
159         CMD_DES_INCLUDE_SUBLIST(cmd_list_fr_basic_test),
160         CMD_DES_INCLUDE_SUBLIST(cmd_list_fray),
161         CMD_DES_INCLUDE_SUBLIST(cmd_list_hbr),
162         CMD_DES_INCLUDE_SUBLIST(cmd_list_hout),
163         CMD_DES_INCLUDE_SUBLIST(cmd_list_lin),
164         CMD_DES_INCLUDE_SUBLIST(cmd_list_lout),
165         CMD_DES_INCLUDE_SUBLIST(cmd_list_mout),
166         CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
167 #endif
168         CMD_DES_INCLUDE_SUBLIST(cmd_list_pin),
169         CMD_DES_INCLUDE_SUBLIST(cmd_list_port),
170 #ifdef TARGET_TMS570_RPP
171         CMD_DES_INCLUDE_SUBLIST(cmd_list_sdram),
172         CMD_DES_INCLUDE_SUBLIST(cmd_list_spi),
173         CMD_DES_INCLUDE_SUBLIST(cmd_list_vbat),
174 #endif
175         NULL
176 };
177
178 /** Pointer to the root list */
179 cmd_des_t const **cmd_list = cmd_list_main;