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