]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blobdiff - rpp-test-sw/commands/cmd.c
Enable Ethernet on all boards
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / cmd.c
index 8a70b729fb926683c24d7f34269b362824fba98b..008027a5f9319da9325c931587f319867b86db06 100644 (file)
@@ -1,28 +1,20 @@
 /*
- * Copyright (C) 2012-2013 Czech Technical University in Prague
+ * Copyright (C) 2012-2016 Czech Technical University in Prague
  *
  * Created on: 31.7.2012
  *
  * Authors:
  *     - Michal Horn
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * This document contains proprietary information belonging to Czech
+ * Technical University in Prague. Passing on and copying of this
+ * document, and communication of its contents is not permitted
+ * without prior written authorization.
  *
  * File : cmd.c
  *
  * Abstract:
- *     This file contains root of the list of the commands.
+ *      This file contains root of the list of the commands.
  *
  */
 
 #include "cmdproc.h"
 #include "cmd.h"
 #include "cmd_adc.h"
-#include "cmd_dac.h"
+#include "cmd_can.h"
+#include "cmd_pin.h"
+#include "cmd_port.h"
+#include "cmd_nc.h"
+#include "cmd_netstats.h"
 #include "cmd_emac.h"
+#include "cmd_echoserver.h"
+
+#ifdef TARGET_TMS570_RPP
+#include "cmd_dac.h"
 #include "cmd_fray.h"
-#include "cmd_can.h"
 #include "cmd_din.h"
 #include "cmd_hbr.h"
 #include "cmd_hout.h"
 #include "cmd_lin.h"
 #include "cmd_lout.h"
-#include "cmd_nc.h"
-#include "cmd_netstats.h"
-#include "cmd_pin.h"
-#include "cmd_port.h"
+#include "cmd_mout.h"
 #include "cmd_sdram.h"
 #include "cmd_spi.h"
 #include "cmd_vbat.h"
 #include "cmd_motor_example.h"
 #include "cmd_fr_basic_test.h"
+#endif
 
 #ifndef DOCGEN
 
 #include "rpp/rpp.h"
-#include "hal/hal.h"
-
-
-/**
- *     @brief  Sleep the board
- *
- * @param[in]  cmd_io  Pointer to IO stack
- * @param[in]  des             Pointer to command descriptor
- * @param[in]  param   Parameters of command
- * @return     0 when OK or error code
- */
-int cmd_do_sleep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
-       hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 1);
-       hal_gpio_pin_set_value(PIN_DSC_CANEN, 1);
-       hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 1);
-       hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 1);
-       vTaskDelay(10/portTICK_RATE_MS);
-       hal_gpio_pin_set_value(PIN_DSC_LIN2NSLP, 0);
-       hal_gpio_pin_set_value(PIN_DSC_LIN1NSLP, 0);
-       hal_gpio_pin_set_value(PIN_DSC_CANNSTB, 0);
-       return 0;
-}
 
 #include <version.h>
 
-int cmd_do_version(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+int cmd_do_version(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
        rpp_sci_printf("version=%s\n", GIT_VERSION);
        return 0;
 }
 
-#endif /* DOCGEN */
+#endif  /* DOCGEN */
 
 /** Root list in which commands are stored */
 cmd_des_t const **cmd_list;
 
+#ifdef TARGET_TMS570_RPP
+int cmd_do_sleep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+#ifndef DOCGEN
+       if (rpp_gio_set(PIN_CANNSTB, 1) == FAILURE) return -CMDERR_BADDIO;
+       if (rpp_gio_set(PIN_CANEN, 1) == FAILURE) return -CMDERR_BADDIO;
+       if (rpp_gio_set(PIN_LIN2NSLP, 1) == FAILURE) return -CMDERR_BADDIO;
+       if (rpp_gio_set(PIN_LIN1NSLP, 1) == FAILURE) return -CMDERR_BADDIO;
+       vTaskDelay(10/portTICK_RATE_MS);
+       if (rpp_gio_set(PIN_LIN2NSLP, 0) == FAILURE) return -CMDERR_BADDIO;
+       if (rpp_gio_set(PIN_LIN1NSLP, 0) == FAILURE) return -CMDERR_BADDIO;
+       if (rpp_gio_set(PIN_CANNSTB, 0) == FAILURE) return -CMDERR_BADDIO;
+#endif
+       return 0;
+}
+
 /** Command descriptor for sleep command */
-cmd_des_t const cmd_des_sleep={
-    0, 0,
-    "sleep","Sleep the board",
-    "### Syntax ###\n"
-    "\n"
-    " sleep\n"
-    "\n"
-    "### Description ###\n"
-    "\n"
-    "This command configures the LIN and CAN peripherals to enter sleep mode\n"
-    "and turn the whole device into sleep mode. External signal on CAN or\n"
-    "LIN will wake the device up.\n",
-    CMD_HANDLER(cmd_do_sleep), (void *)&cmd_list
+cmd_des_t const cmd_des_sleep = {
+               0, 0,
+               "sleep","Sleep the board",
+               "### Syntax ###\n"
+               "\n"
+               " sleep\n"
+               "\n"
+               "### Description ###\n"
+               "\n"
+               "This command configures the LIN and CAN peripherals to enter sleep mode\n"
+               "and turn the whole device into sleep mode. External signal on CAN or\n"
+               "LIN will wake the device up.\n",
+               CMD_HANDLER(cmd_do_sleep), (void *)&cmd_list
 };
+#endif
 
 /** Command descriptor for show help command */
-cmd_des_t const cmd_des_help={
-    0, 0,
-    "help","Print help for commands",
-    "### Syntax ###\n"
-    "\n"
-    " help [command]\n"
-    "\n"
-    "### Description ###\n"
-    "\n"
-    "This command without parameter prints the list of all available\n"
-    "commands with short help text for each of them. If a parameter is\n"
-    "provided, the command prints a long description for given command.\n",
-    CMD_HANDLER(cmd_do_help), (void *)&cmd_list
+cmd_des_t const cmd_des_help = {
+       0, 0,
+       "help","Print help for commands",
+       "### Syntax ###\n"
+       "\n"
+       " help [command]\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "This command without parameter prints the list of all available\n"
+       "commands with short help text for each of them. If a parameter is\n"
+       "provided, the command prints a long description for given command.\n",
+       CMD_HANDLER(cmd_do_help), (void *)&cmd_list
 };
 
-cmd_des_t const cmd_des_version={
-    0, 0,
-    "version","Print version of the software",
-    "### Syntax ###\n"
-    "\n"
-    " version\n"
-    "\n"
-    "### Description ###\n"
-    "\n"
-    "This command prints the version of the test software. The version\n"
-    "number is the output of 'git describe' command, i.e. it is composed\n"
-    "from the last tag in the git repository, the number of commits since\n"
-    "the tag and the abbreviated commit hash.\n"
-    "\n"
-    "### Example ###\n"
-    "\n"
-    "    --> version\n"
-    "    version=v0.2-109-ga81a9dd\n",
-    CMD_HANDLER(cmd_do_version),
+cmd_des_t const cmd_des_version = {
+       0, 0,
+       "version","Print version of the software",
+       "### Syntax ###\n"
+       "\n"
+       " version\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "This command prints the version of the test software. The version\n"
+       "number is the output of 'git describe' command, i.e. it is composed\n"
+       "from the last tag in the git repository, the number of commits since\n"
+       "the tag and the abbreviated commit hash.\n"
+       "\n"
+       "### Example ###\n"
+       "\n"
+       "    --> version\n"
+       "    version=v0.2-109-ga81a9dd\n",
+       CMD_HANDLER(cmd_do_version),
 };
 
 /*  ------------------------
@@ -146,30 +139,38 @@ cmd_des_t const cmd_des_version={
  */
 
 /** @brief Main list of commands */
-cmd_des_t const *cmd_list_main[]={
-  &cmd_des_help,
-  &cmd_des_sleep,
-  &cmd_des_version,
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_adc),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_can),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_emac),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_fray),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_hbr),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_hout),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_lin),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_lout),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_pin),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_port),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_sdram),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_spi),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_vbat),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
-  CMD_DES_INCLUDE_SUBLIST(cmd_list_fr_basic_test),
-  NULL
+cmd_des_t const *cmd_list_main[] = {
+       &cmd_des_help,
+#ifdef TARGET_TMS570_RPP
+       &cmd_des_sleep,
+#endif
+       &cmd_des_version,
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_adc),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_can),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_emac),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_es),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
+#ifdef TARGET_TMS570_RPP
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_dac),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_din),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_fr_basic_test),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_fray),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_hbr),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_hout),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_lin),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_lout),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_mout),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_motor_example),
+#endif
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_pin),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_port),
+#ifdef TARGET_TMS570_RPP
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_sdram),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_spi),
+       CMD_DES_INCLUDE_SUBLIST(cmd_list_vbat),
+#endif
+       NULL
 };
 
 /** Pointer to the root list */