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