]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp-test-sw/commands/cmd.c
Apply uncrustify
[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 {
68         hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 1);
69         hal_gpio_pin_set_value(PIN_DSC_CANEN, 1);
70         hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 1);
71         hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 1);
72         vTaskDelay(10/portTICK_RATE_MS);
73         hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 0);
74         hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 0);
75         hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 0);
76         return 0;
77 }
78
79 #include <version.h>
80
81 int cmd_do_version(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
82 {
83         rpp_sci_printf("version=%s\n", GIT_VERSION);
84         return 0;
85 }
86
87 #endif  /* DOCGEN */
88
89 /** Root list in which commands are stored */
90 cmd_des_t const * *cmd_list;
91
92 /** Command descriptor for sleep command */
93 cmd_des_t const cmd_des_sleep = {
94         0, 0,
95         "sleep","Sleep the board",
96         "### Syntax ###\n"
97         "\n"
98         " sleep\n"
99         "\n"
100         "### Description ###\n"
101         "\n"
102         "This command configures the LIN and CAN peripherals to enter sleep mode\n"
103         "and turn the whole device into sleep mode. External signal on CAN or\n"
104         "LIN will wake the device up.\n",
105         CMD_HANDLER(cmd_do_sleep), (void*)&cmd_list
106 };
107
108 /** Command descriptor for show help command */
109 cmd_des_t const cmd_des_help = {
110         0, 0,
111         "help","Print help for commands",
112         "### Syntax ###\n"
113         "\n"
114         " help [command]\n"
115         "\n"
116         "### Description ###\n"
117         "\n"
118         "This command without parameter prints the list of all available\n"
119         "commands with short help text for each of them. If a parameter is\n"
120         "provided, the command prints a long description for given command.\n",
121         CMD_HANDLER(cmd_do_help), (void*)&cmd_list
122 };
123
124 cmd_des_t const cmd_des_version = {
125         0, 0,
126         "version","Print version of the software",
127         "### Syntax ###\n"
128         "\n"
129         " version\n"
130         "\n"
131         "### Description ###\n"
132         "\n"
133         "This command prints the version of the test software. The version\n"
134         "number is the output of 'git describe' command, i.e. it is composed\n"
135         "from the last tag in the git repository, the number of commits since\n"
136         "the tag and the abbreviated commit hash.\n"
137         "\n"
138         "### Example ###\n"
139         "\n"
140         "    --> version\n"
141         "    version=v0.2-109-ga81a9dd\n",
142         CMD_HANDLER(cmd_do_version),
143 };
144
145 /*  ------------------------
146  *  Command lists definitons
147  *  ------------------------
148  */
149
150 /** @brief Main list of commands */
151 cmd_des_t const *cmd_list_main[] = {
152         &cmd_des_help,
153         &cmd_des_sleep,
154         &cmd_des_version,
155         CMD_DES_INCLUDE_SUBLIST(cmd_list_adc),
156         CMD_DES_INCLUDE_SUBLIST(cmd_list_can),
157         CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
158         CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
159         CMD_DES_INCLUDE_SUBLIST(cmd_list_emac),
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_nc),
166         CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
167         CMD_DES_INCLUDE_SUBLIST(cmd_list_pin),
168         CMD_DES_INCLUDE_SUBLIST(cmd_list_port),
169         CMD_DES_INCLUDE_SUBLIST(cmd_list_sdram),
170         CMD_DES_INCLUDE_SUBLIST(cmd_list_spi),
171         CMD_DES_INCLUDE_SUBLIST(cmd_list_vbat),
172         CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
173         CMD_DES_INCLUDE_SUBLIST(cmd_list_fr_basic_test),
174         NULL
175 };
176
177 /** Pointer to the root list */
178 cmd_des_t const **cmd_list = cmd_list_main;