]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp-test-sw/commands/_tms570_rpp/cmd.c
8b8895bc0ee7d2bff14b5cd52fdf38873347eedd
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / _tms570_rpp / 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 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_dac.h"
26 #include "../cmd_emac.h"
27 #include "../cmd_fray.h"
28 #include "../cmd_can.h"
29 #include "../cmd_din.h"
30 #include "../cmd_hbr.h"
31 #include "../cmd_hout.h"
32 #include "../cmd_lin.h"
33 #include "../cmd_lout.h"
34 #include "../cmd_nc.h"
35 #include "../cmd_netstats.h"
36 #include "../cmd_pin.h"
37 #include "../cmd_port.h"
38 #include "../cmd_sdram.h"
39 #include "../cmd_spi.h"
40 #include "../cmd_vbat.h"
41 #include "../cmd_motor_example.h"
42 #include "../cmd_fr_basic_test.h"
43
44 #ifndef DOCGEN
45
46 #include "rpp/rpp.h"
47 #include "hal/hal.h"
48
49
50 /**
51  *  @brief      Sleep the board
52  *
53  * @param[in]   cmd_io  Pointer to IO stack
54  * @param[in]   des             Pointer to command descriptor
55  * @param[in]   param   Parameters of command
56  * @return      0 when OK or error code
57  */
58 int cmd_do_sleep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
59 {
60         hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 1);
61         hal_gpio_pin_set_value(PIN_DSC_CANEN, 1);
62         hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 1);
63         hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 1);
64         vTaskDelay(10/portTICK_RATE_MS);
65         hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 0);
66         hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 0);
67         hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 0);
68         return 0;
69 }
70
71 #include <version.h>
72
73 int cmd_do_version(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
74 {
75         rpp_sci_printf("version=%s\n", GIT_VERSION);
76         return 0;
77 }
78
79 #endif  /* DOCGEN */
80
81 /** Root list in which commands are stored */
82 cmd_des_t const **cmd_list;
83
84 /** Command descriptor for sleep command */
85 cmd_des_t const cmd_des_sleep = {
86         0, 0,
87         "sleep","Sleep the board",
88         "### Syntax ###\n"
89         "\n"
90         " sleep\n"
91         "\n"
92         "### Description ###\n"
93         "\n"
94         "This command configures the LIN and CAN peripherals to enter sleep mode\n"
95         "and turn the whole device into sleep mode. External signal on CAN or\n"
96         "LIN will wake the device up.\n",
97         CMD_HANDLER(cmd_do_sleep), (void *)&cmd_list
98 };
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         &cmd_des_sleep,
146         &cmd_des_version,
147         CMD_DES_INCLUDE_SUBLIST(cmd_list_adc),
148         CMD_DES_INCLUDE_SUBLIST(cmd_list_can),
149         CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
150         CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
151         CMD_DES_INCLUDE_SUBLIST(cmd_list_emac),
152         CMD_DES_INCLUDE_SUBLIST(cmd_list_fray),
153         CMD_DES_INCLUDE_SUBLIST(cmd_list_hbr),
154         CMD_DES_INCLUDE_SUBLIST(cmd_list_hout),
155         CMD_DES_INCLUDE_SUBLIST(cmd_list_lin),
156         CMD_DES_INCLUDE_SUBLIST(cmd_list_lout),
157         CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
158         CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
159         CMD_DES_INCLUDE_SUBLIST(cmd_list_pin),
160         CMD_DES_INCLUDE_SUBLIST(cmd_list_port),
161         CMD_DES_INCLUDE_SUBLIST(cmd_list_sdram),
162         CMD_DES_INCLUDE_SUBLIST(cmd_list_spi),
163         CMD_DES_INCLUDE_SUBLIST(cmd_list_vbat),
164         CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
165         CMD_DES_INCLUDE_SUBLIST(cmd_list_fr_basic_test),
166         NULL
167 };
168
169 /** Pointer to the root list */
170 cmd_des_t const **cmd_list = cmd_list_main;