]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
Merge branches 'master' and 'rm48/master'
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 8 Jul 2015 15:48:14 +0000 (17:48 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 8 Jul 2015 16:17:14 +0000 (18:17 +0200)
Conflicts:
Makefile
rpp-lib
rpp-test-sw/.ccsproject
rpp-test-sw/.cproject
rpp-test-sw/commands/_tms570_rpp/cmd.c
rpp-test-sw/commands/_tms570_rpp/main.c
rpp-test-sw/commands/cmd_fr_basic_test.c

1  2 
rpp-lib
rpp-test-sw/Makefile.inc
rpp-test-sw/commands/_tms570_rpp/cmd_pin.c
rpp-test-sw/commands/_tms570_rpp/cmd_port.c
rpp-test-sw/commands/cmd.c
rpp-test-sw/commands/cmd_fray.c
rpp-test-sw/commands/cmd_spi.c
rpp-test-sw/commands/main.c

diff --cc rpp-lib
index 5f5cb285cd0a3a9bb79a72f5a91d84fff6c48ebc,bd0f31e2adaa80d99e699a92001c8b296e8d1af3..ab932b46eaec6a8a4253c36454d75ee4fd0a00ff
+++ b/rpp-lib
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 5f5cb285cd0a3a9bb79a72f5a91d84fff6c48ebc
 -Subproject commit bd0f31e2adaa80d99e699a92001c8b296e8d1af3
++Subproject commit ab932b46eaec6a8a4253c36454d75ee4fd0a00ff
index 79be214177d9ce150db9a7cce566536d3569f53d,0000000000000000000000000000000000000000..3b57a8e612cdcfcb63b4a4af73bdfd3d2e848c1a
mode 100644,000000..100644
--- /dev/null
@@@ -1,52 -1,0 +1,72 @@@
 +makefile_inc_dir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
 +
 +all: rpp-test-sw.out
 +
 +# Use the configuration "exported" by library build
 +CONFIG = $(makefile_inc_dir)/../rpp-lib/Makefile.config
 +ifneq ($(wildcard $(CONFIG)),)
 +include $(CONFIG)
 +else
 +$(error "rpp-lib not compiled! Either run `make -C $(makefile_inc_dir)/../rpp-lib/build/<target>/Release` or build the appropriate CCS project.")
 +endif
 +
 +include $(makefile_inc_dir)/../rpp-lib/build/Makefile.rules
 +include $(makefile_inc_dir)/../rpp-lib/common.mk
 +
 +SOURCES = \
 +      cmdproc/src/cmdproc.c \
 +      cmdproc/src/cmdproc_freertos.c \
 +      cmdproc/src/cmdproc_io.c \
 +      cmdproc/src/cmdproc_io_line.c \
 +      cmdproc/src/cmdproc_io_std_line.c \
 +      cmdproc/src/cmdproc_io_tisci.c \
 +      cmdproc/src/cmdproc_run.c \
 +      cmdproc/src/cmdproc_utils.c \
 +      cmdproc/src/i2str.c \
 +      commands/cmd.c \
 +      commands/cmd_adc.c \
 +      commands/cmd_can.c \
 +      commands/cmd_pin.c \
 +      commands/cmd_port.c \
 +      commands/main.c
 +
++SOURCES_tms570_rpp = \
++      commands/cmd_dac.c \
++      commands/cmd_din.c \
++      commands/cmd_emac.c \
++      commands/cmd_fray.c \
++      commands/cmd_fr_basic_test.c \
++      commands/cmd_hbr.c \
++      commands/cmd_hout.c \
++      commands/cmd_lin.c \
++      commands/cmd_lout.c \
++      commands/cmd_motor_example.c \
++      commands/cmd_nc.c \
++      commands/cmd_netstats.c \
++      commands/cmd_sdram.c \
++      commands/cmd_spi.c \
++      commands/cmd_vbat.c
++
++
++SOURCES += $(SOURCES_$(TARGET))
++
 +OBJS = $(SOURCES:%.c=%.obj)
 +
 +RPP_CFLAGS += -I$(makefile_inc_dir)/cmdproc/include -I$(makefile_inc_dir)
 +RPP_CFLAGS += -I. # For version.h
 +
 +rpp-test-sw.out: $(OBJS) $(RPP_LIB_DIR)/rpp-lib.lib
 +      $(LD) $(RPP_CFLAGS) $(RPP_LDFLAGS) $(OBJS) $(RPP_LDLIBS) -o $@
 +
 +$(makefile_inc_dir)/commands/main.c: version.h
 +$(makefile_inc_dir)/commands/cmd.c: version.h
 +include $(makefile_inc_dir)/Makefile.version
 +
 +$(OBJS): %.obj: $(makefile_inc_dir)/%.c
 +      $(call mkdir,$(dir $@))
 +      $(RPP_COMPILE_CMD)
 +
 +clean::
 +      $(call rm,rpp-test-sw.out $(OBJS))
 +
 +-include $(OBJS:%=%.dep)
index 0000000000000000000000000000000000000000,7aa7052213a3f856a2f1e30e0db260019bcd961e..0d8edf450c15cca527f099ac6858656b9d706778
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,292 +1,282 @@@
 - * Copyright (C) 2012-2013 Czech Technical University in Prague
+ /*
 -      "    FANCTRL\n"
 -      "    ETHRST\n"
 -      "    VBAT1EN\n"
 -      "    VBAT2EN\n"
 -      "    VBAT3EN\n"
 -      "    VBATEN\n"
 -      "    SPICSA\n"
 -      "    SPICSB\n"
 -      "    MOUT1EN\n"
 -      "    MOUT2EN\n"
 -      "    CANNSTB\n"
 -      "    CANEN\n"
 -      "    LIN2NSLP\n"
 -      "    LIN1NSLP\n"
 -      "    DININT\n"
 -      "    DIN8\n"
 -      "    DIN9\n"
 -      "    DIN10\n"
 -      "    DIN11\n"
 -      "    DIN12\n"
 -      "    DIN13\n"
 -      "    DIN14\n"
 -      "    DIN15\n"
 -      "    MOUT6EN\n"
 -      "    MOUT5EN\n"
 -      "    MOUT6IN\n"
 -      "    MOUT5IN\n"
 -      "    MOUT4EN\n"
 -      "    MOUT3EN\n"
 -      "    MOUT4IN\n"
 -      "    MOUT3IN\n"
 -      "    HBREN\n"
 -      "    HBRDIR\n"
 -      "    HBRPWM\n"
 -      "    MOUT1IN\n"
 -      "    MOUT2IN\n"
 -      "    HOUT1IN\n"
 -      "    HOUT1DIAG\n"
 -      "    HOUT2IN\n"
 -      "    HOUT2DIAG\n"
 -      "    HOUT3IN\n"
 -      "    HOUT3DIAG\n"
 -      "    HOUT4IN\n"
 -      "    HOUT4DIAG\n"
 -      "    HOUT5IN\n"
 -      "    HOUT5DIAG\n"
 -      "    HOUT6IN\n"
 -      "    HOUT6DIAG\n",
++ * Copyright (C) 2012-2015 Czech Technical University in Prague
+  *
+  * Created on: 28.2.2013
+  *
+  * Authors:
+  *     - Michal Horn
+  *
+  * 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_pin.c
+  *
+  * Abstract:
+  *      Commands for pin controlling
+  *          - Printing list of available pins
+  *          - Setting and getting value to pins
+  *          - Setting and getting pins direction
+  */
+ #include "../cmd_pin.h"
+ #include "stdio.h"
+ #include "string.h"
+ #ifndef DOCGEN
+ #include "rpp/rpp.h"
+ #include "hal/hal.h"
+ #include "cmdproc_utils.h"
+ /**
+  * @brief     Print list of pins
+  *
+  * @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_pin_list(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       uint32_t i;
+       rpp_sci_printf("List of all defined pins. Those names can be used by pinval command.\r\n");
+       for (i = 0; i < MAX_PIN_CNT; i++) {
+               if (pin_map[i].pin_name == PIN_NAME_UNUSED) continue;
+               rpp_sci_printf(pin_map[i].pin_name);
+               rpp_sci_printf("\r\n");
+       }
+       return 1;
+ }
+ /**
+  * @brief     Set or get pin value
+  *
+  * @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_pin_val(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       char *p;
+       long val;
+       uint32_t *desc;
+       char spareParams;
+       char pinName[32];
+       p = param[1];
+       if (sscanf(p, "%31s ", pinName) != 1)
+               return -CMDERR_BADPAR;
+       if ((desc = hal_gpio_pin_get_dsc(pinName, -1)) == NULL) return -CMDERR_BADREG;
+       if (param[2] != NULL) {     // More parameters = set values
+               p = param[2];
+               if (sscanf(p, "%d %1s", &val, &spareParams) != 1)
+                       return -CMDERR_BADPAR;
+               if (val != 0 && val != 1)
+                       return -CMDERR_BADPAR;
+               hal_gpio_pin_set_value(*desc, (uint32_t)val);
+               return cmd_opchar_replong(cmd_io, param, val, 0, 0);
+               ;
+       }
+       else {  // No more parameters = get values
+               uint32_t pin_value = hal_gpio_pin_get_value(*desc);
+               rpp_sci_printf("pinval%s=%d\n", pinName, pin_value);
+               return 0;
+       }
+ }
+ /**
+  * @brief     Set or get pin direction
+  *
+  * @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_pin_dir(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       char *p;
+       long val;
+       uint32_t *desc;
+       char spareParams;
+       char pinName[32];
+       p = param[1];
+       if (sscanf(p, "%31s ", pinName) != 1)
+               return -CMDERR_BADPAR;
+       if ((desc = hal_gpio_pin_get_dsc(pinName, -1)) == NULL) return -CMDERR_BADREG;
+       if (param[2] != NULL) {     // More parameters = set values
+               p = param[2];
+               if (sscanf(p, "%d %1s", &val, &spareParams) != 1)
+                       return -CMDERR_BADPAR;
+               if (val == 1) {
+                       *desc |= PORT_CONF_SET_DIR;
+                       *desc |= PORT_CONF_DIR_OUT;
+               }
+               else if (val == 0) {
+                       *desc &= (~PORT_CONF_DIR_OUT);
+                       *desc |= PORT_CONF_SET_DIR;
+               }
+               else
+                       return -CMDERR_BADPAR;
+               hal_gpio_pin_conf(*desc);
+               return cmd_opchar_replong(cmd_io, param, val, 0, 0);
+       }
+       else {  // No more parameters = get values
+               uint32_t pin_dir = hal_gpio_pin_get_direction(*desc);
+               rpp_sci_printf("pindir%s=%d\n", pinName, pin_dir);
+               return 0;
+       }
+ }
+ #endif  /* DOCGEN */
+ /** Command descriptor for pin list */
+ cmd_des_t const cmd_des_pin_list = {
+       0, 0,
+       "pinlist","Print a list of all defined pins.",
+       "### Command syntax ###\n"
+       "\n"
+       "    pinlist\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "The command prints a list of all defined pins accessible by pinval and\n"
+       "pindir commands.\n"
+       "\n"
+       "### Example ###\n"
+       "\n"
+       "    --> pinlist\n"
+       "    List of all defined pins. Those names can be used by pinval command.\n"
 -      "Most of the pins are accessible indirectly via other highlevel\n"
 -      "commands. HBR_EN is, for example, controlled by the hbrenable command.\n"
 -      "This command serves as supplement to highlevel commands for testing\n"
 -      "purpose.\n"
 -      "\n"
++      "    GIOA0\n"
++      "    GIOA1\n"
++      "    GIOA2\n"
++      "    GIOA3\n"
++      "    GIOA4\n"
++      "    GIOA5\n"
++      "    GIOA6\n"
++      "    GIOA7\n"
++      "    GIOB0\n"
++      "    GIOB1\n"
++      "    GIOB2\n"
++      "    GIOB3\n"
++      "    GIOB4\n"
++      "    GIOB5\n"
++      "    GIOB6\n"
++      "    GIOB7\n"
++      "    NHET10\n"
++      "    NHET11\n"
++      "    NHET12\n"
++      "    NHET13\n"
++      "    NHET14\n"
++      "    NHET15\n"
++      "    NHET16\n"
++      "    NHET17\n"
++      "    NHET18\n"
++      "    NHET19\n"
++      "    NHET110\n"
++      "    NHET111\n"
++      "    NHET112\n"
++      "    NHET113\n"
++      "    NHET114\n"
++      "    NHET115\n"
++      "    NHET116\n"
++      "    NHET117\n"
++      "    NHET118\n"
++      "    NHET119\n"
++      "    NHET120\n"
++      "    NHET121\n"
++      "    NHET122\n"
++      "    NHET123\n"
++      "    NHET124\n"
++      "    NHET125\n"
++      "    NHET126\n"
++      "    NHET127\n"
++      "    NHET128\n"
++      "    NHET129\n"
++      "    NHET130\n"
++      "    NHET131\n",
+       CMD_HANDLER(cmd_do_pin_list), (void *)&cmd_list_pin
+ };
+ /** Command descriptor for pin get/set value */
+ cmd_des_t const cmd_des_pin_val = {
+       0, 0,
+       "pinval*","Set or get the pin value",
+       "### Command syntax ###\n"
+       "\n"
+       "    pinval<NAME> <VAL>\n"
+       "    pinval<NAME>\n"
+       "where\n"
+       "\n"
+       "- `<NAME>` is a string identifying the pin\n"
+       "- `<VAL>` can be 0 or 1\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "This command is sets or gets a value of the particular pin.\n"
+       "\n"
+       "The list of valid pin names can be obtained with pinlist command.\n"
+       "\n"
 -      "    --> pinvalHBREN 1\n"
 -      "    pinvalHBREN=1\n"
+       "### Example ###\n"
+       "\n"
 -      "Sets the HBR_EN pin to 1.\n"
++      "    --> pinvalGIOB0 1\n"
++      "    pinvalGIOB0=1\n"
+       "\n"
 -      "    --> pinvalHBREN\n"
 -      "    pinvalHBREN=1\n"
++      "Sets the GIOB0 pin to 1.\n"
+       "\n"
 -      "Gets a value of the HBR_EN pin.\n",
++      "    --> pinvalGIOB0\n"
++      "    pinvalGIOB0=1\n"
+       "\n"
 -      "Most of the pins are accessible indirectly via other highlevel\n"
 -      "commands HBR_EN is, for example, controlled by the hbrenable command.\n"
 -      "This command serves as supplement to highlevel commands for testing\n"
 -      "purpose.\n"
 -      "\n"
++      "Gets a value of the GIOB0 pin.\n",
+       CMD_HANDLER(cmd_do_pin_val), (void *)&cmd_list_pin
+ };
+ /** Command descriptor for pin get/set direction */
+ cmd_des_t const cmd_des_pin_dir = {
+       0, 0,
+       "pindir*","Set the pin direction",
+       "### Command syntax ###\n"
+       "\n"
+       "    pindir<NAME> <DIR>\n"
+       "    pindir<NAME>\n"
+       "where\n"
+       "\n"
+       "- `<NAME>` is a string identifying the pin\n"
+       "- DIR is be either 0 (input) or 1 (output)\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "This command is used to set or get direction of the particular pin.\n"
+       "\n"
+       "The list of valid pin names can be obtained with pinlist command.\n"
+       "\n"
 -      "    --> pindirHBREN 1\n"
 -      "    pindirHBREN=1\n"
+       "### Example ###\n"
+       "\n"
 -      "Sets the HBR_EN pin as output.\n"
++      "    --> pindirGIOB0 1\n"
++      "    pindirGIOB0=1\n"
+       "\n"
 -      "    --> pindirHBREN\n"
 -      "    pindirHBREN=1\n"
++      "Sets the GIOB0 pin as output.\n"
+       "\n"
 -      "Gets the direction of the HBR_EN pin.\n",
++      "    --> pindirGIOB0\n"
++      "    pindirGIOB0=1\n"
+       "\n"
++      "Gets the direction of the GIOB0 pin.\n",
+       CMD_HANDLER(cmd_do_pin_dir), (void *)&cmd_list_pin
+ };
+ /** List of commands for pin, defined as external */
+ cmd_des_t const *cmd_list_pin[] = {
+       &cmd_des_pin_list,
+       &cmd_des_pin_val,
+       &cmd_des_pin_dir,
+       NULL
+ };
index 0000000000000000000000000000000000000000,bfb869d5f83f0f54c78e125a325bb11f080680e0..e25ec028997735441e3df1f66bbf2e6c6f64e5c6
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,229 +1,215 @@@
 - * Copyright (C) 2012-2013 Czech Technical University in Prague
+ /*
 -              rpp_sci_printf("portval%s=%x", portName, ret);
++ * Copyright (C) 2012-2015 Czech Technical University in Prague
+  *
+  * Created on: 28.2.2013
+  *
+  * Authors:
+  *     - Michal Horn
+  *
+  * 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_port.c
+  *
+  * Abstract:
+  *         Commands for port controlling
+  *          - Printing list of available ports (not yet available)
+  *          - Setting/getting port value*
+  */
+ #include "../cmd_port.h"
+ #include "stdio.h"
+ #ifndef DOCGEN
+ #include "rpp/rpp.h"
+ #include "hal/hal.h"
+ #include "cmdproc_utils.h"
+ int cmd_do_port_list(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       uint32_t i;
+       char *portInterface;
+       rpp_sci_printf("List of all defined ports with its type. Those names can be used by portval command.\r\n");
+       const port_def_t *ports = hal_port_get_definitions();
+       for (i = 0; i < PORT_CNT; i++) {
+               if (ports[i].name == PIN_NAME_UNUSED) continue;
+               if (ports[i].desc->interfaceType == PORT_INTERFACE_SPI)
+                       portInterface = "SPI";
+               else if (ports[i].desc->interfaceType == PORT_INTERFACE_GPIO)
+                       portInterface = "GPIO";
+               else if (ports[i].desc->interfaceType == PORT_INTERFACE_ADC)
+                       portInterface = "ADC";
+               else
+                       portInterface = "UNKNOWN";
+               rpp_sci_printf("%s, %s\r\n", ports[i].name, portInterface);
+       }
+       return 1;
+ }
+ /**
+  * @brief     Read values from specified port
+  *
+  * @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_port_val(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       char *p;
+       int i;
+       port_desc_t *desc;
+       uint32_t ret;
+       uint32_t values[MAX_PARAM_VALUES_NUM];
+       char portName[32];
+       char *token;
+       uint32_t numParams;
+       p = param[1];
+       if (sscanf(p, "%31s ", portName) != 1)
+               return -CMDERR_BADPAR;
+       if ((desc = hal_port_get_dsc(portName, -1)) == NULL) return -CMDERR_BADREG;
+       if (param[2] != NULL) { // More parameters = set values
+               p = param[2];
+               if (desc->port_setfnc_ptr == NULL)
+                       return -CMDERR_WRPERM;
+               else {
+                       if (desc->interfaceType == PORT_INTERFACE_GPIO)
+                               // Information about pin values are encoded as hexadecimal 8b value
+                               numParams = desc->numValues/8+1;
+                       else if (desc->interfaceType == PORT_INTERFACE_SPI)
+                               // Commands are passed as bytes
+                               numParams = desc->numValues;
+                       else if (desc->interfaceType == PORT_INTERFACE_ADC)
+                               return -CMDERR_BADPAR;  // ADC is read only and no other port is supported
+                       token = strtok(p, " ");
+                       i = 0;
+                       while (i < numParams && token != NULL) {
+                               if (sscanf(token, "%x", &values[i]) == EOF)
+                                       break;
+                               token = strtok(NULL, " ");
+                               i++;
+                       }
+                       if (i != numParams || token != NULL)
+                               return -CMDERR_BADPAR;
+                       ret = desc->port_setfnc_ptr(desc->config, desc->numValues, values);
+               }
+               return cmd_opchar_replong(cmd_io, param, ret, 0, 16);
+       }
+       else {
+               if (desc->port_getfnc_ptr == NULL)
+                       return -CMDERR_RDPERM;
+               else {
+                       ret = desc->port_getfnc_ptr(desc->config, desc->numValues, values);
+                       for (i = 0; i < desc->numValues; i++) {
+                               rpp_sci_printf("%d\r\n", values[i]);
+                       }
+               }
 -      "NOTE: For successful communication with the HBR, HBR_EN pin must\n"
 -      "be set first.\n"
 -      "\n"
++              rpp_sci_printf("portval%s=%x\n", portName, ret);
+               return 0;
+       }
+ }
+ #endif  /* DOCGEN */
+ /** Command descriptor for read values from port command */
+ cmd_des_t const cmd_des_port_val = {
+       0, 0,
+       "portval*","Read or write values from or to the port",
+       "### Command syntax ###\n"
+       "\n"
+       "     portval<NAME> <VAL>\n"
+       "     portval<NAME>\n"
+       "where\n"
+       "\n"
+       "- `<NAME>` is a string specifying the name of the port\n"
+       "- `<VAL>` is a sequence of hexadecimal numbers, separated by spaces, e.g. 12 AA CD\n\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "This command sets or gets values of all pins on the specified port.\n"
+       "If the port is connected to the GPIO interface of the MCU, then\n"
+       "when writing the value, the lowest significant bit of the argument\n"
+       "is assigned to the first pin, the second bit is assigned to the\n"
+       "second pin, etc. The command returns zero.\n"
+       "When reading from the port, the command returns values for each pin.\n"
+       "\n"
+       "If the port is connected to the SPI interface of the MCU, then\n"
+       "it is write only and the argument is interpreted as a command for\n"
+       "the port controller. The command returns the response from the\n"
+       "port controller.\n"
+       "For command examples please refer to the project wiki\n"
+       "\n"
+       "If the port is connected to the ADC interface of the MCU, then\n"
+       "it is read only and returns values for each ADC pin.\n"
+       "\n"
+       "Port names and interface type can be obtained with the portlist\n"
+       "command.\n"
+       "\n"
 -      "     --> portvalMOUTIN 3A\n"
 -      "     portvalMOUTIN=0\n"
 -      "     --> portvalMOUTIN\n"
+       "### Example ###\n"
+       "\n"
 -      "This pair of commands sets:\nMOUT1IN"
 -      "MOUT1IN=0\n"
 -      "MOUT2IN=1\n"
 -      "MOUT3IN=0\n"
 -      "MOUT4IN=1\n"
 -      "MOUT5IN=1\n"
 -      "MOUT6IN=1\n"
++      "     --> portvalGIOB 3A\n"
++      "     portvalGIOB=0\n"
++      "     --> portvalGIOB\n"
+       "     0\n"
+       "     1\n"
+       "     0\n"
+       "     1\n"
+       "     1\n"
+       "     1\n"
+       "\n"
 -      "     DINMCU, GPIO\n"
 -      "     DINSPI, SPI\n"
 -      "     HOUTDIAG, GPIO\n"
 -      "     HOUTIN, GPIO\n"
 -      "     HOUTIFBK, ADC\n"
 -      "     ADC, ADC\n"
 -      "     LOUT, SPI\n"
 -      "     DAC12, SPI\n"
 -      "     DAC34, SPI\n"
 -      "     DACDREF, SPI\n"
 -      "     HBR, SPI\n"
 -      "     FRAY1, SPI\n"
 -      "     FRAY2, SPI\n"
 -      "     MOUTEN, GPIO\n"
 -      "     MOUTIN, GPIO\n",
++      "This pair of commands sets:\nGIOB"
++      "GIOB=0\n"
++      "GIOB=1\n"
++      "GIOB=0\n"
++      "GIOB=1\n"
++      "GIOB=1\n"
++      "GIOB=1\n"
+       "Which is shown in getter output\n",
+       CMD_HANDLER(cmd_do_port_val), (void *)&cmd_list_port
+ };
+ /** Command descriptor for port list printout */
+ cmd_des_t const cmd_des_port_list = {
+       0, 0,
+       "portlist","Print a list of all port names",
+       "### Command syntax ###\n"
+       "\n"
+       "     portlist\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "This command prints the list of all defined ports accessible via the\n"
+       "portval command. Each record of the list is a couple of\n"
+       "PortName-PortInterface, where PortInterface is SPI, ADC or GPIO.\n"
+       "The type of the MCU<->port interface slightly modifies the meaning\n"
+       "of the portval command."
+       "\n"
+       "### Example ###\n"
+       "\n"
+       "     --> portlist\n"
+       "     List of all defined ports with its type. Those names can be used by portval command.\n"
++      "     GIOA, GPIO\n"
++      "     GIOB, GPIO\n"
++      "     NHET1, GPIO\n"
++      "     ADC, ADC\n",
+       CMD_HANDLER(cmd_do_port_list), (void *)&cmd_list_port
+ };
+ /** List of commands for port, defined as external */
+ cmd_des_t const *cmd_list_port[] = {
+       &cmd_des_port_val,
+       &cmd_des_port_list,
+       NULL
+ };
index ae0018de24a9c46c6ec25f924ade1a3dc9b5ee45,0000000000000000000000000000000000000000..a53e6a2a4462e843b5ba323e71ca18568c763531
mode 100644,000000..100644
--- /dev/null
@@@ -1,102 -1,0 +1,173 @@@
 +/*
 + * Copyright (C) 2012-2015 Czech Technical University in Prague
 + *
 + * Created on: 31.7.2012
 + *
 + * Authors:
 + *     - Michal Horn
 + *
 + * 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.
 + *
 + */
 +
 +/* Include files */
 +#include "cmdproc.h"
 +#include "cmd.h"
 +#include "cmd_adc.h"
 +#include "cmd_can.h"
 +#include "cmd_pin.h"
 +#include "cmd_port.h"
 +
++#ifdef TARGET_TMS570_RPP
++#include "cmd_dac.h"
++#include "cmd_emac.h"
++#include "cmd_fray.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_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"
 +
 +
 +#include <version.h>
 +
 +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 */
 +
 +/** 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[])
++{
++      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;
++}
++
++/** 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
++};
++#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_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),
 +};
 +
 +/*  ------------------------
 + *  Command lists definitons
 + *  ------------------------
 + */
 +
 +/** @brief Main list of commands */
 +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),
++#ifdef TARGET_TMS570_RPP
++      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_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_motor_example),
++      CMD_DES_INCLUDE_SUBLIST(cmd_list_nc),
++      CMD_DES_INCLUDE_SUBLIST(cmd_list_netstats),
++#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 */
 +cmd_des_t const **cmd_list = cmd_list_main;
index 0000000000000000000000000000000000000000,e21bf204e4c515e9cf624c94cf74fd114af3a704..f2e45624594bcbfb12e55113a92dd28ac686bc47
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,572 +1,573 @@@
 - * Copyright (C) 2012-2013 Czech Technical University in Prague
+ /*
++ * Copyright (C) 2012-2013, 2015 Czech Technical University in Prague
+  *
+  * Created on: 28.2.2013
+  *
+  * Authors:
+  *     - Michal Horn
+  *
+  * 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_fray.c
+  *
+  * Abstract:
+  *  Commands for control FlexRay
+  *  - Getting status of FlexRay from chips on SPI
+  *  - Sending test data on FRAY
+  *  - Receiving test data on FRAY
+  *
+  *  There are FlexRay test commands, to test the connection between two FlexRay nodes A and B
+  *  The node A is sending a message 100 times with some period.
+  *  The node B is receiving this message and check if it fits the pattern.
+  *  Commands are counting the number of errors, which is printed at the end of the test.
+  *  After 100 transmissions both nodes are halted.
+  */
+ #include "cmd_fray.h"
+ #include "stdio.h"
+ #ifndef DOCGEN
+ #include "rpp/rpp.h"
+ #include "drv/fray.h"
+ #include "cmdproc_utils.h"
+ #include "hal/hal.h"
+ #include "cmdproc.h"
+ #include "sys/ti_drv_fray.h"
++#include "hal/spi_resp_transl.h"
+ /**
+  * This structure contains global FlexRay configuration.
+  * All nodes in the network have to use the same values for
+  * all parameters of this structure.
+  */
+ static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
+       .gColdStartAttempts = 0x2,
+       .gListenNoise = 0xF,
+       .gMacroPerCycle = 0x15E0,   // Macrotick = 1us
+       .gMaxWithoutClockCorrectionFatal = 0xF,
+       .gMaxWithoutClockCorrectionPassive = 0xF,
+       .gNetworkManagementVectorLength = 12,
+       .gNumberOfMinislots = 0x15A,
+       .gNumberOfStaticSlots = 0x8,
+       .gOffsetCorrectionStart = 0xAE4,
+       .gPayloadLengthStatic = 0x9,
+       .gSyncNodeMax = 0xF,
+       .gdActionPointOffset = 0x4,
+       .gdCASRxLowMax = 0x43,
+       .gdDynamicSlotIdlePhase = 0x1,
+       .gdMinislot = 0x4,
+       .gdMinislotActionPointOffset = 0x2,
+       .gdNIT = 0xAE3,
+       .gdSampleClockPeriod = 0,       // 10mbit/sec
+       .gdStaticSlot = 0x56,
+       .gdTSSTransmitter = 0xA,
+       .gdWakeupSymbolRxIdle = 18,
+       .gdWakeupSymbolRxLow = 18,
+       .gdWakeupSymbolRxWindow = 76,
+       .gdWakeupSymbolTxIdle = 180,
+       .gdWakeupSymbolTxLow = 60
+ };
+ /**
+  * This structure contains local configuration of the FlexRay node A.
+  * That is the node that transmits messages to the node B.
+  */
+ static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
+       .pAllowHaltDueToClock = 0,
+       .pAllowPassiveToActive = 0xF,
+       .pChannels = FR_CHANNEL_AB,
+       .pClusterDriftDamping = 0x1,
+       .pDelayCompensationA = 0x3,
+       .pDelayCompensationB = 0x3,
+       .pExternOffsetCorrection = 0,
+       .pExternRateCorrection = 0,
+       .pKeySlotUsedForStartup = TRUE,
+       .pKeySlotUsedForSync = TRUE,
+       .pLatestTx = 0x10D,
+       .pMacroInitialOffsetA = 0x6,
+       .pMacroInitialOffsetB = 0x6,
+       .pMicroInitialOffsetA = 0x18,
+       .pMicroInitialOffsetB = 0x18,
+       .pMicroPerCycle = 0x36B00,      // (cycle period, 5.6ms), uT = 25ns@10Mbit/sec,  25ns@5Mbit/sec, 50ns@2.5Mbit/sec
+       .pRateCorrectionOut = 0xCD,
+       .pOffsetCorrectionOut = 0x151,
+       .pSamplesPerMicrotick = 0,      // 10 mbit/sec
+       .pSingleSlotEnabled = TRUE,
+       .pWakeupChannel = FR_CHANNEL_A,
+       .pWakeupPattern = 2,
+       .pdAcceptedStartupRange = 0x81,
+       .pdListenTimeout = 0x36DA2,
+       .pdMaxDrift = 0x151,
+       .pDecodingCorrection = 0x33
+ };
+ /**
+  * This structure contains local configuration of the FlexRay node B.
+  * That is the node that receives messages from the node A.
+  */
+ static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
+       .pAllowHaltDueToClock = 0,
+       .pAllowPassiveToActive = 0xF,
+       .pChannels = FR_CHANNEL_AB,
+       .pClusterDriftDamping = 0x1,
+       .pDelayCompensationA = 0x3,
+       .pDelayCompensationB = 0x3,
+       .pExternOffsetCorrection = 0,
+       .pExternRateCorrection = 0,
+       .pKeySlotUsedForStartup = TRUE,
+       .pKeySlotUsedForSync = TRUE,
+       .pLatestTx = 0x10D,
+       .pMacroInitialOffsetA = 0x6,
+       .pMacroInitialOffsetB = 0x6,
+       .pMicroInitialOffsetA = 0x18,
+       .pMicroInitialOffsetB = 0x18,
+       .pMicroPerCycle = 0x36B00,
+       .pRateCorrectionOut = 0xCD,
+       .pOffsetCorrectionOut = 0x151,
+       .pSamplesPerMicrotick = 0,          // 10 mbit/sec
+       .pSingleSlotEnabled = TRUE,
+       .pWakeupChannel = FR_CHANNEL_A,
+       .pWakeupPattern = 2,
+       .pdAcceptedStartupRange = 0x81,
+       .pdListenTimeout = 0x36DA2,
+       .pdMaxDrift = 0x151,
+       .pDecodingCorrection = 0x33
+ };
+ /**
+  * FlexRay node A message RAM configuration.
+  * Reconfiguration is disabled, 2 static buffers are configured.
+  */
+ static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
+       .dynSegmentBufferCount = 0,
+       .fifoBufferCount = 0,
+       .secureBuffers = FR_SB_ALL_REC_DISABLED,
+       .statSegmentBufferCount = 2,
+       .syncFramePayloadMultiplexEnabled = 0
+ };
+ /**
+  * FlexRay node B message RAM configuration.
+  * Reconfiguration is disabled, 2 static buffers are configured.
+  */
+ static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
+       .dynSegmentBufferCount = 0,
+       .fifoBufferCount = 0,
+       .secureBuffers = FR_SB_ALL_REC_DISABLED,
+       .statSegmentBufferCount = 2,
+       .syncFramePayloadMultiplexEnabled = 0
+ };
+ /**
+  * The FlexRay node A is a sync node and coldstarter. That is why the first buffer
+  * (buffer 0) is configured as TX. All coldstarters and sync nodes must have the
+  * first buffer configured as TX. The FlexRay network has to contain at least two
+  * sync nodes and coldstarters.
+  * The second buffer is used for messages transmission. It is TX and configured as
+  * single-shot to send only one message after some period.
+  */
+ static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .fidMask = 0,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 1
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .fidMask = 0,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 3
+       }
+ };
+ /**
+  * The FlexRay node B is a sync node and coldstarter. That is why the first buffer
+  * (buffer 0) is configured as TX. All coldstarters and sync nodes must have the
+  * first buffer configured as TX. The FlexRay network has to contain at least two
+  * sync nodes and coldstarters.
+  * The second buffer is used for messages receiving.
+  */
+ static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .fidMask = 0,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 2
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .fidMask = 0,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 3
+       }
+ };
+ /**
+  * Unifying configuration structure for the node A.
+  */
+ static Fr_ConfigType Fr_config_node_A = {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = NULL,
+       .fifoBufferConfigs = NULL,
+       .msgRAMConfig = &Fr_node_A_msgRAM_config,
+       .nodeConfiguration = &Fr_node_A_config,
+       .staticBufferConfigs = Fr_node_A_static_buffers_config
+ };
+ /**
+  * Unifying configuration structure for the node B.
+  */
+ static Fr_ConfigType Fr_config_node_B = {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = NULL,
+       .fifoBufferConfigs = NULL,
+       .msgRAMConfig = &Fr_node_B_msgRAM_config,
+       .nodeConfiguration = &Fr_node_B_config,
+       .staticBufferConfigs = Fr_node_B_static_buffers_config
+ };
+ /**
+  *  Loads data into TX buffer for FlexRay node A.
+  *  Set TX Request for the buffer to start the transmission.
+  */
+ int8_t transmit_node_a()
+ {
+       uint8_t data[18];
+       int i;
+       // Write payload for the buffer
+       for (i = 0; i < 18; i++) {
+               data[i] = i;
+       }
+       return rpp_fr_transmit_lpdu(0, 3, data, 18);
+ }
+ /**
+  *    Check data of the received message for correctness.
+  *    @return  0 if message was received and is correct
+  *                     1 if message was received and is incorrect
+  */
+ int check_message(const uint8_t *data)
+ {
+       int i;
+       for (i = 0; i < 18; i++) {
+               if (data[i] != i)
+                       return 1;
+       }
+       return 0;
+ }
+ /**
+  *  @brief    Get FlexRay status in human readable form
+  *
+  *  Command sends some data on SPI (data do not matters, chips are read only) and retreives a response.
+  *  The response is translated and displayed as readable text.
+  *
+  * @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_fray_status(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       char *p;
+       int pin;
+       uint32_t numCmdDesc;
+       int i;
+       uint32_t numFieldDesc;
+       p = param[1];
+       if (sscanf(p, "%d", &pin) != 1)
+               return -CMDERR_BADPAR;
+       pin--; // Highlevel command has pin number mapped according the board scheme, this switches to internal representation
+       if (pin > FRAY_NUM_PORTS || pin < 0) return -CMDERR_BADPAR;
+       if (Fr_spi_transfer(pin) != 0) return -CMDERR_BADDIO;
+       spitr_reg_translate_table_t translatedData;
+       const spitr_cmd_map_t *cmdDesc = get_spi_cmd_map(PORT_NAME_FRAY1, -1, &numCmdDesc);
+       if (cmdDesc == NULL) return -CMDERR_BADREG;
+       const spitr_field_desc_t *fieldDescs = get_spi_field_desc(cmdDesc, numCmdDesc, Fr_spi_get_cmd(pin), &numFieldDesc);
+       if (fieldDescs == NULL)
+               return -CMDERR_BADPAR;
+       uint32_t fr_spi_response = Fr_spi_response(pin);
+       uint32_t lsbResponse = 0 | ((fr_spi_response & 0xFF) << 8) | ((fr_spi_response & 0xFF00) >> 8);
+       spitr_fill_tr_table(fieldDescs, numFieldDesc, lsbResponse, &translatedData);
+       for (i = 0; i < translatedData.num_rows; i++) {
+               rpp_sci_printf("%s: %x\r\n", translatedData.row[i].field_name, translatedData.row[i].value);
+       }
+       return 0;
+ }
+ /**
+  *  @brief    Start sending data on the FlexRay as node A
+  *
+  * @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_test_frayA(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       uint32_t i;
+       uint32_t error = 0;
+       uint32_t msg_cnt = 0;
+       uint32_t count = 100;
+       Fr_TxLPduStatusType status;
+       Fr_POCStatusType poc_status;
+       if (param[1] && sscanf(param[1], "%d", &count) != 1)
+               return -CMDERR_BADPAR;
+       if (rpp_fr_init_driver(&Fr_config_node_A, &error) == FAILURE) {
+               rpp_sci_printf("Fray driver initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       if (rpp_fr_init_controller(0, &error) == FAILURE) {
+               rpp_sci_printf("Fray control node initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       rpp_sci_printf("Fray control node initialized.\r\n");
+       rpp_sci_printf("Waiting for network connection...\r\n");
+       if (rpp_fr_start_communication(0, &error) == FAILURE) {
+               rpp_sci_printf("Integration to the network failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       if (rpp_fr_all_slots(0) == FAILURE) {
+               rpp_sci_printf("All slots mode selection failed.\n");
+               return -CMDERR_BADCFG;
+       }
+       rpp_sci_printf("Connected. Frames transmission is starting. O means OK, X means Error\r\n");
+       if (rpp_fr_clear_timer_irq(0,0) == FAILURE ||
+               rpp_fr_set_timer(0,0,10,1) == FAILURE
+               ) {
+               rpp_sci_printf("Absolute timer setting failed.\n");
+               return -CMDERR_BADCFG;
+       }
+       for (i = 0; i < count; i++) {
+               if (transmit_node_a() == FAILURE) {
+                       rpp_sci_printf("X");
+                       error++;
+               }
+               else
+                       rpp_sci_printf("O");
+               msg_cnt++;
+               do {
+                       rpp_fr_check_tx_lpdu_status(0, 3, &status);
+                       rpp_fr_get_poc_status(0, &poc_status);
+               } while (status == FR_NOT_TRANSMITTED && poc_status.ErrorMode == FR_ERRORMODE_ACTIVE);
+               if (poc_status.ErrorMode != FR_ERRORMODE_ACTIVE) {
+                       rpp_sci_printf("\nFlexRay exited active mode (see command frbtgetpocst)!\n");
+                       break;
+               }
+       }
+       rpp_sci_printf("\r\nTransmitted %d messages with %d errors.\r\n", msg_cnt, error);
+       if (rpp_fr_halt_communication(0) != SUCCESS)
+               rpp_sci_printf("FlexRay HALT command failed, please reset the board to stop transmission.\r\n");
+       else
+               rpp_sci_printf("FlexRay halted, reset the board to make FlexRay usable again.\r\n");
+       return 0;
+ }
+ /**
+  *  @brief    Start receiving data on the FlexRay as node B
+  *
+  * @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_test_frayB(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       uint32_t i;
+       uint32_t error = 0;
+       uint32_t msg_cnt = 0;
+       uint32_t count = 100;
+       if (param[1] && sscanf(param[1], "%d", &count) != 1)
+               return -CMDERR_BADPAR;
+       if (rpp_fr_init_driver(&Fr_config_node_B, &error) == FAILURE) {
+               rpp_sci_printf("Fray driver initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       if (rpp_fr_init_controller(0, &error) == FAILURE) {
+               rpp_sci_printf("Fray control node initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       rpp_sci_printf("Fray control node initialized.\r\n");
+       rpp_sci_printf("Waiting for network connection...\r\n");
+       if (rpp_fr_start_communication(0, &error) == FAILURE) {
+               rpp_sci_printf("Integration to the network failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
+       }
+       if (rpp_fr_all_slots(0) == FAILURE) {
+               rpp_sci_printf("All slots mode selection failed.\n");
+               return -CMDERR_BADCFG;
+       }
+       rpp_sci_printf("Connected. Frames transmission is starting. O means OK, X means Error, T means timeout.\r\n");
+       for (i = 0; i < count; i++) {
+               uint8_t data[18];
+               Fr_RxLPduStatusType status;
+               uint8_t size;
+               uint8_t cycle1, cycle2;
+               uint16_t mtick;
+               rpp_fr_get_global_time(0, &cycle1, &mtick);
+               do {
+                       if (rpp_fr_receive_lpdu(0, 3, data, &status, &size) == FAILURE) {
+                               rpp_sci_printf("\nMessage receiving failed!\n");
+                               break;
+                       }
+                       rpp_fr_get_global_time(0, &cycle2, &mtick);
+               } while (status == FR_NOT_RECEIVED && (cycle2 != ((cycle1-1) & 0x3F)));
+               if (status == FR_NOT_RECEIVED)
+                       rpp_sci_printf("T");
+               else if (check_message(data) == 0) {
+                       rpp_sci_printf("O");
+                       msg_cnt++;
+               }
+               else {
+                       rpp_sci_printf("X");
+                       error++;
+                       msg_cnt++;
+               }
+       }
+       rpp_sci_printf("\r\nReceived %d messages with %d errors.\r\n", msg_cnt, error);
+       if (rpp_fr_halt_communication(0) != SUCCESS)
+               rpp_sci_printf("FlexRay HALT command failed, please reset the board to stop transmission.\r\n");
+       else
+               rpp_sci_printf("FlexRay halted\r\n");
+       return 0;
+ }
+ #endif  /* DOCGEN */
+ /** Command descriptor for FlexRay status command */
+ cmd_des_t const cmd_des_fray_stat = {
+       0, 0,
+       "frayxcvrstat#","Get the status of a FlexRay transceiver in a human readable form",
+       "### Command syntax ###\n"
+       "\n"
+       "    frayxcvrstat<CHN>\n"
+       "where CHN is a number in range 1-2\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "The command receives response from a FlexRay transceiver via SPI, and\n"
+       "prints in the form of attribute-value table.\n"
+       "\n"
+       "### Example ###\n"
+       "\n"
+       "    --> frayxcvrstat1\n"
+       "\n"
+       "Prints the status of FRAY1 transceiver.\n",
+       CMD_HANDLER(cmd_do_fray_status), (void *)&cmd_list_fray
+ };
+ /** Command descriptor for FlexRay 1 test node A */
+ cmd_des_t const cmd_des_test_fray_a = {
+       0, 0,
+       "fraytestA","Run the FlexRay test as A node",
+       "### Command syntax ###\n"
+       "\n"
+       "    fraytestA [<COUNT>]\n"
+       "\n"
+       "where `<COUNT>` is an optional number of messages to send. The default\n"
+       "is 100.\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "The commands creates FlexRay node A and starts sending a message\n"
+       "approximately every communication cycle. COUNT messages are sent for the\n"
+       "test of the connection. The command should be run with two devices\n"
+       "connected by a FlexRay bus and the second device should be running the\n"
+       "fraytestB command (it is necessary to run both commands shortly after\n"
+       "each other).\n"
+       "\n"
+       "When the command transmits a message a character is printed. O means\n"
+       "that the message was transmitted correctly, X signals a transmission\n"
+       "error. The number of TX errors and successfully transmitted messages\n"
+       "is maintained during the test and printed at the end.\n",
+       CMD_HANDLER(cmd_do_test_frayA), (void *)&cmd_list_fray
+ };
+ /** Command descriptor for FlexRay 1 test node B */
+ cmd_des_t const cmd_des_test_fray_b = {
+       0, 0,
+       "fraytestB","Run the FlexRay test as B node",
+       "### Command syntax ###\n"
+       "\n"
+       "    fraytestB [<COUNT>]\n"
+       "\n"
+       "where `<COUNT>` is an optional number of messages to receive. The default\n"
+       "is 100.\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "The commands creates FlexRay node B and starts receiving a messages.\n"
+       "100 messages should be received. The command should be run with two\n"
+       "devices connected by a FlexRay bus and the second device should be\n"
+       "running the fraytestA command (it is necessary to run both commands\n"
+       "shortly after each other).\n"
+       "\n"
+       "When the command receives a message a character is printed. O means\n"
+       "that the message was received correctly, X signals an error in data, T\n"
+       "means timeout (i.e. no message was received within 63 cycles). The\n"
+       "number of RX errors and successfully received messages is maintained\n"
+       "during the test and printed at the end.\n",
+       CMD_HANDLER(cmd_do_test_frayB), (void *)&cmd_list_fray
+ };
+ /** List of commands for din, defined as external */
+ cmd_des_t const *cmd_list_fray[] = {
+       &cmd_des_fray_stat,
+       &cmd_des_test_fray_a,
+       &cmd_des_test_fray_b,
+       NULL
+ };
index 0000000000000000000000000000000000000000,d3d5b400d6b10dc003f110af631be96b0ea5948e..e1d1ca4a2c82544ba6b931dc0258b0a264cde4c9
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,257 +1,259 @@@
 - * Copyright (C) 2012-2013 Czech Technical University in Prague
+ /*
++ * Copyright (C) 2012-2013, 2015 Czech Technical University in Prague
+  *
+  * Created on: 28.2.2013
+  *
+  * Authors:
+  *     - Michal Horn
+  *
+  * 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_spi.c
+  *
+  * Abstract:
+  *      Command for processing data from SPI and
+  *      lowlevel command for sending data on SPI
+  *
+  */
+ #include "cmd_spi.h"
+ #include "stdio.h"
+ #ifndef DOCGEN
+ #include "rpp/rpp.h"
+ #include "cmdproc_utils.h"
+ #include "drv/drv.h"
+ #include <_isfuncdcl.h>
++#include "hal/spi.h"
++#include "hal/spi_resp_transl.h"
+ /**
+  *  @brief    Translate SPI response according the command and peripheral type
+  *
+  * @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_spi_translate(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       char *p;
+       int i;
+       uint32_t ret;
+       uint32_t values[MAX_PARAM_VALUES_NUM];
+       uint32_t numFieldDesc;
+       uint32_t numCmdDesc;
+       uint32_t command;
+       uint32_t response;
+       spitr_reg_translate_table_t translatedData;
+       char peripheralName[32];
+       char spareParams;
+       p = param[1];
+       if (sscanf(p, "%31s ", peripheralName) != 1)
+               return -CMDERR_BADPAR;
+       const spitr_cmd_map_t *cmdDesc = cmdDesc = get_spi_cmd_map(peripheralName, -1, &numCmdDesc);
+       if (cmdDesc == NULL) return -CMDERR_BADREG;
+       if (param[2] != NULL) {         // More parameters expected
+               p = param[2];
+               if (sscanf(p, "%x %x %1s", &values[0], &values[1], &spareParams) != 2)
+                       return -CMDERR_BADPAR;
+               command = values[0];
+               response = values[1];
+               const spitr_field_desc_t *fieldDescs = get_spi_field_desc(cmdDesc, numCmdDesc, command, &numFieldDesc);
+               if (fieldDescs == NULL)
+                       return -CMDERR_BADPAR;
+               ret = spitr_fill_tr_table(fieldDescs, numFieldDesc, response, &translatedData);
+               for (i = 0; i < translatedData.num_rows; i++) {
+                       rpp_sci_printf("%s: %x\r\n", translatedData.row[i].field_name, translatedData.row[i].value);
+               }
+               return cmd_opchar_replong(cmd_io, param, ret, 0, 10);
+       }
+       else
+               return -CMDERR_BADPAR;
+ }
+ /* SPI Master testing command */
+ #define TEST_BUF 64
+ uint8_t spi_test_buf_tx[TEST_BUF];
+ uint8_t spi_test_buf_rx[TEST_BUF];
+ int spimst_print_rx(struct spi_drv *ifc, int status, int addr, uint8_t *buf)
+ {
+       int i;
+       if (status < 0) {
+               rpp_sci_printf("spirx failed: %d\n", status);
+               return -1;
+       }
+       rpp_sci_printf("spirx:%#x(", addr);
+       for (i = 0; i < status; i++) {
+               rpp_sci_printf("%#x", buf[i]);
+               if (i < status-1)
+                       rpp_sci_printf(",");
+       }
+       rpp_sci_printf(")\n");
+       return 0;
+ }
+ /**
+  *  @brief    Send SPI command on SPI and receive response
+  *
+  * @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_spimst(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+ {
+       spi_drv_t *ifc;
+       int i;
+       char *p;
+       char *token;
+       int ret;
+       unsigned int addr;
+       unsigned int rq_len;
+       int spi;
+       int values[MAX_PARAM_VALUES_NUM];
+       p = param[1];
+       if (sscanf(p, "%d", &spi) != 1)
+               return -CMDERR_BADPAR;
+       p = param[2];
+       if (sscanf(p, " %d", &addr) != 1)
+               return -CMDERR_BADPAR;
+       token = strtok(p, " ");
+       token = strtok(NULL, " ");
+       i = 0;
+       while (i < MAX_PARAM_VALUES_NUM && token != NULL) {
+               if (sscanf(token, "%x", &values[i]) == EOF)
+                       break;
+               token = strtok(NULL, " ");
+               spi_test_buf_tx[i] = (uint8_t)values[i];
+               i++;
+       }
+       ifc = spi_find_drv(NULL, spi);
+       if (ifc == NULL)
+               return -CMDERR_NODEV;
+       if (!(ifc->flags & SPI_IFC_ON))
+               //if (spi_tms570_init(ifc) < 0)
+               return -CMDERR_BADCFG;
+       rq_len = i;
+       ret = spi_transfer(ifc, addr, rq_len, spi_test_buf_tx, spi_test_buf_rx);
+       spimst_print_rx(ifc, ret, addr, spi_test_buf_rx);
+       return 0;
+ }
+ #endif  /* DOCGEN */
+ /** Command descriptor for SPI response translation */
+ cmd_des_t const cmd_des_spi_translate = {
+       0, CDESM_OPCHR|CDESM_RW,
+       "spitr*","Translate response from an SPI peripheral",
+       "### Command syntax ###\n"
+       "\n"
+       "    spitr<NAME> <CMD> <RESP>\n"
+       "where\n"
+       "\n"
+       "- `<NAME>` is a string specifying the name of the peripheral (one of DINSPI, LOUT, DAC12, DAC34, HBR, FRAY1 and FRAY2)\n"
+       "- `<CMD>` is a hexadecimal number in range 0 - FFFFFFFF\n"
+       "- `<RESP>` is a hexadecimal number in range 0 - FFFFFFFF\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "This command translates a response from SPI from many different\n"
+       "peripherals into a human readable form. The SPI response is in the\n"
+       "form of a hexadecimal number, which encodes the information. This\n"
+       "commands takes this response, the command which produced this\n"
+       "response, the name of the peripheral and translates the response into\n"
+       "the attribute-value table.\n"
+       "\n"
+       "### Example ###\n"
+       "    --> portvalDINSPI 7F 00 00\n"
+       "    portvalDINSPI=AAC03F\n"
+       "    --> spitrDINSPI 7F0000 3FC0AA\n"
+       "    Thermal flag       : 0\n"
+       "    INT flag   : 0\n"
+       "    SP0  - DIN0        : 1\n"
+       "    SP1  - DIN1        : 1\n"
+       "    SP2  - DIN2        : 1\n"
+       "    SP3  - DIN3        : 1\n"
+       "    SP4  - DIN4        : 1\n"
+       "    SP5  - DIN5        : 1\n"
+       "    SP6  - DIN6        : 1\n"
+       "    SP7  - DIN7        : 1\n"
+       "    SG0  - DIN8        : 0\n"
+       "    SG1  - DIN9        : 1\n"
+       "    SG2  - DIN10       : 0\n"
+       "    SG3  - DIN11       : 1\n"
+       "    SG4  - DIN12       : 0\n"
+       "    SG5  - DIN13       : 1\n"
+       "    SG6  - DIN14       : 0\n"
+       "    SG7  - DIN15       : 1\n"
+       "    SG8  - NA  : 0\n"
+       "    SG9  - NA  : 0\n"
+       "    SG10 - NA  : 0\n"
+       "    SG11 - NA  : 0\n"
+       "    SG12 - NA  : 0\n"
+       "    SG13 - NA  : 0\n"
+       "    spitrDINSPI=24\n"
+       "\n"
+       "Translates response 0x3FC0AA returned by command 0x7F0000 into a human\n"
+       "readable form.\n"
+       "Please notice LSB->MSB conversion of the portval result. The necessity\n"
+       "of the conversion depends on the controller of the examined port.\n",
+       CMD_HANDLER(cmd_do_spi_translate), (void *)&cmd_list_spi
+ };
+ /** Command descriptor for SPI trasfer */
+ cmd_des_t const cmd_des_spimst = {
+       0, 0,
+       "spimst*", "Request SPI master communication",
+       "### Command syntax ###\n"
+       "\n"
+       "    spimst<SPI> <ADDR> <DATA>\n"
+       "where\n"
+       "\n"
+       "- `<SPI>` is a number in range 0 - 4\n"
+       "- `<ADDR>` is a number in range 0 - 2\n"
+       "- `<DATA>` is a sequence of hexadecimal numbers, separated by spaces, e.g. 12 AA CD\n"
+       "\n"
+       "### Description ###\n"
+       "\n"
+       "The command sends given data to the SPI peripheral and prints the\n"
+       "response. The response contains the address and the received data in\n"
+       "parentheses.\n"
+       "\n"
+       "### Example ###\n"
+       "\n"
+       "    --> spimst1 0 7F 00 00\n"
+       "    spirx:0x0(0x3f,0xc0,0xff)\n"
+       "\n"
+       "Sends reset command (0x7F0000) to the DIN peripheral.\n",
+       CMD_HANDLER(cmd_do_spimst), (void *)&cmd_list_spi
+ };
+ /** List of commands for SPI, defined as external */
+ cmd_des_t const *cmd_list_spi[] = {
+       &cmd_des_spi_translate,
+       &cmd_des_spimst,
+       NULL
+ };
index 07dc5e0f6f48617db9fa3a1e1296a27aa7c3a1dd,3efdac523d2040be5a1516841abcc3d18e21386a..6f693bc4d25dc0bdd5a052f3ec24bd1452247d0f
  \r
  /* Include Files */\r
  #include "rpp/rpp.h"\r
 +#include "os/os.h"\r
  #include "cmdproc_freertos.h"\r
 -#include "version.h" // Generated by Eclipse in the pre-build step\r
 +#include "version.h" // Generated by Makefile\r
 +\r
 +#if defined(TARGET_TMS570_HDK)\r
 +#define TARGET_STR "TI HDK TMS570LS3137"\r
 +#elif defined(TARGET_RM48_HDK)\r
 +#define TARGET_STR "TI HDK RM48L952"\r
 +#elif defined(TARGET_TMS570_HYDCTR)\r
 +#define TARGET_STR "Eaton Hydraulics Controller"\r
++#elif defined(TARGET_TMS570_RPP)\r
++#define TARGET_STR "Porsche Rapid Prototyping Platform"\r
 +#elif defined(TARGET_POSIX)\r
 +#define TARGET_STR "POSIX version"\r
 +#else\r
 +#error Unknown target\r
 +#endif\r
  \r
  /** @fn void main(void)\r
   *   @brief Application main function\r