]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/commitdiff
Merge branch 'eth'
authorMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 10 Sep 2013 15:48:05 +0000 (17:48 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Tue, 10 Sep 2013 15:48:05 +0000 (17:48 +0200)
Conflicts:
rpp-lib

21 files changed:
.cproject
.dir-locals.el [new file with mode: 0644]
.project
Makefile.version [new file with mode: 0644]
cmdproc/include/cmdproc_freertos_tms570.h
cmdproc/src/cmdproc.c
cmdproc/src/cmdproc_freertos_tms570.c
cmdproc/src/cmdproc_io_std_line.c
commands/cmd.c
commands/cmd_adc.c
commands/cmd_dac.c
commands/cmd_fr_basic_test.c [new file with mode: 0644]
commands/cmd_fr_basic_test.h [new file with mode: 0644]
commands/cmd_fray.c
commands/cmd_hbr.c
commands/cmd_hout.c
commands/cmd_motor_example.c
commands/cmd_pin.c
commands/fray_demo.txt [new file with mode: 0644]
commands/main.c
rpp-lib

index 7b1dc7841a39be07501725133492a3b2e9f386c5..40e9c32251129f672f1d579eb57c1276ace868bf 100644 (file)
--- a/.cproject
+++ b/.cproject
@@ -14,7 +14,7 @@
                                </extensions>
                        </storageModule>
                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
-                               <configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1456715682" name="Debug" parent="com.ti.ccstudio.buildDefinitions.TMS470.Debug" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="Get version from git" prebuildStep="echo &quot;#define GIT_VERSION \&quot;$(shell git describe --always)\&quot;&quot; &gt; version.h">
+                               <configuration artifactExtension="out" artifactName="${ProjName}" buildProperties="" cleanCommand="${CG_CLEAN_CMD}" description="" id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1456715682" name="Debug" parent="com.ti.ccstudio.buildDefinitions.TMS470.Debug" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="Get version from git" prebuildStep="$(MAKE) -f ../Makefile.version version.h">
                                        <folderInfo id="com.ti.ccstudio.buildDefinitions.TMS470.Debug.1456715682." name="/" resourcePath="">
                                                <toolChain id="com.ti.ccstudio.buildDefinitions.TMS470_5.0.exe.DebugToolchain.1749595625" name="TI Build Tools" superClass="com.ti.ccstudio.buildDefinitions.TMS470_5.0.exe.DebugToolchain" targetTool="com.ti.ccstudio.buildDefinitions.TMS470_5.0.exe.linkerDebug.1175282572">
                                                        <option id="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS.250889567" superClass="com.ti.ccstudio.buildDefinitions.core.OPT_TAGS" valueType="stringList">
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644 (file)
index 0000000..f3f771a
--- /dev/null
@@ -0,0 +1,6 @@
+((nil
+  (tab-width . 4))
+ (c-mode
+  (indent-tabs-mode . t)
+  (c-basic-offset . 4)
+  (c-file-style . "linux")))
index e929283cee06a34ac311861a3475f801b588a54e..6ad71d4422ecef83b1e87cdb3101c436e02ef207 100644 (file)
--- a/.project
+++ b/.project
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-       <name>CmdProcTISCI</name>
+       <name>rpp-test-sw</name>
        <comment></comment>
        <projects>
        </projects>
diff --git a/Makefile.version b/Makefile.version
new file mode 100644 (file)
index 0000000..c070a2f
--- /dev/null
@@ -0,0 +1,23 @@
+ifeq ($(OS),Windows_NT)\r
+GIT=C:\\Program Files (x86)\\Git\\bin\\git.exe\r
+ifeq ($(shell $(GIT) version),)\r
+GIT=C:\\Program Files\\Git\\bin\\git.exe\r
+ifeq ($(shell $(GIT) version),)\r
+GIT=git.exe\r
+endif\r
+endif\r
+else # UNIX\r
+GIT=git\r
+endif\r
+\r
+VERSION:=$(shell "$(GIT)" describe)\r
+VERSION:=$(if $(VERSION),$(VERSION),unknown)\r
+\r
+.PHONY: version.h\r
+\r
+version.h:\r
+ifeq ($(OS),Windows_NT)\r
+       echo #define GIT_VERSION "$(VERSION)" > $@\r
+else\r
+       echo '#define GIT_VERSION "$(VERSION)"' > $@\r
+endif\r
index 6292d85b35a741a755f85115d3cda4346dfd9b63..d825d56cff198d0e8468a29715e3f32ea2882b4d 100644 (file)
@@ -25,7 +25,7 @@
  *     @param[in]      introText               string shown once after initialization before prompt is shown. Can be NULL.
  *     @param[in]      promptText              string shown when software is ready to read command from RS-232. Can be NULL.
  */
-void initCmdProc(unsigned portBASE_TYPE printPriority, uint8_t * intro, uint8_t * prompt);
+void initCmdProc(unsigned portBASE_TYPE printPriority);
 
 /**    Procedure for task processCmd. Infinite loop that reads and process commands.
  */
index b2cdec3e949b04eaa6a28461825d27feb2995601..94e0d46dc7dfffb8e0c0d06969afebdb4ecab7a4 100644 (file)
@@ -56,6 +56,7 @@ int proc_cmd_line(cmd_io_t *cmd_io, cmd_des_t const **des_arr, char *line)
   int res, i, parcnt;
   param[0]=p=skip_white(p);
   if(!*p) return 0;
+  if(*p == '#') return 0;       /* Ignore comments */
   /* Determine the name of the command */
   if(!isalnum((uint8_t)*p)){
     cmd_len=1;
index c2453a146f5158491ee53278523daa1d493b7d1f..ff3699a8991e47bd9692405e6d1480e1f7b1ead2 100644 (file)
@@ -33,8 +33,7 @@
 
 /** cmdProc task handler */
 xTaskHandle processCmdHandler;
-/** string prompt */
-uint8_t* prompt;
+
 /** Main list of commands */
 extern cmd_des_t const *cmd_list_main[];
 /** IO stack */
@@ -48,12 +47,7 @@ extern cmd_io_t cmd_io_std_line;
  * @param promptText Text printed when CMDPROC is ready to read new command
  *
  */
-void initCmdProc(unsigned portBASE_TYPE priority, uint8_t * introText, uint8_t * promptText) {
-       prompt = NULL;
-       if (promptText != NULL) {
-               prompt = (uint8_t *)pvPortMalloc(strlen((char*)promptText));
-               strcpy((char *)prompt, (const char*)promptText);
-       }
+void initCmdProc(unsigned portBASE_TYPE priority) {
        int taskRetVal;
        if ((taskRetVal = xTaskCreate(processCmd, (const signed char *)"processCmd", 1000, NULL, priority, processCmdHandler)) != pdPASS) {
                rpp_sci_printf("FreeRTOS: Creating task processCmd failed. Error code: %d", taskRetVal);
@@ -61,10 +55,6 @@ void initCmdProc(unsigned portBASE_TYPE priority, uint8_t * introText, uint8_t *
                while(1)
                        ;
        }
-       if (introText != NULL)
-               rpp_sci_printf("%s", introText);
-       if (prompt != NULL)
-               rpp_sci_printf("%s", prompt);
 }
 
 /**
@@ -74,8 +64,7 @@ void initCmdProc(unsigned portBASE_TYPE priority, uint8_t * introText, uint8_t *
 void processCmd(void *pvParameters ) {
        rpp_eth_init_postInit(0, NULL); /* post OS startup init of eth (LwIP) for application usage -- waits for a while, for auto-negotiation of ethernet speed and DHCP if used */
        for (;;) {
+               rpp_sci_printf("--> ");
                cmd_processor_run(&cmd_io_std_line, cmd_list_main);
-               if (prompt != NULL)
-                       rpp_sci_printf("%s", prompt);
        }
 }
index 6ea9b681ee8f3df9a59b494efb990756b52b5dea..87d76fee7474626664f4f07e559b55b09474aa76 100644 (file)
@@ -2,7 +2,7 @@
 #include <string.h>
 #include <cmdproc_io_tisci.h>
 
-#define ED_LINE_CHARS 80
+#define ED_LINE_CHARS 256
 
 char ed_line_in_std[ED_LINE_CHARS+1];
 char ed_line_in_std_history[10*(ED_LINE_CHARS+1)];
index a769d28af93acfa77c1a0f17b29fe474d1c0859e..5c6e16940c80f0217b4ef8b223ab34cbdf409360 100644 (file)
@@ -47,6 +47,7 @@
 #include "cmd_spi.h"
 #include "cmd_vbat.h"
 #include "cmd_motor_example.h"
+#include "cmd_fr_basic_test.h"
 
 #ifndef DOCGEN
 
@@ -74,6 +75,13 @@ int cmd_do_sleep(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
        return 0;
 }
 
+#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 */
@@ -111,6 +119,27 @@ cmd_des_t const cmd_des_help={
     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
  *  ------------------------
@@ -120,6 +149,7 @@ cmd_des_t const cmd_des_help={
 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),
@@ -138,6 +168,7 @@ cmd_des_t const *cmd_list_main[]={
   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
 };
 
index 77b0dbde56120e08aedd92264683f1bc5a92721a..4b5986b99e47118db9d54952882f93715ff3c43b 100644 (file)
@@ -36,7 +36,7 @@
 
 static double lsb2volts(unsigned lsb)
 {
-       return ((double)lsb + 0.5)*2.048/4096*10;
+       return ((double)lsb + 0.0)*2.5/4095*10;
 }
 
 
index 670f425ce12e98850b48de2cc89d5329b4016a4c..7ffb1783d2e2d2b803fec5d6d6003bc2b95b0e92 100644 (file)
@@ -55,12 +55,12 @@ int cmd_do_dac_pin_setup(cmd_io_t *cmd_io, const struct cmd_des *des, char *para
        }
        ret = rpp_dac_setup(pin, enabled);
        if (ret == -1) {
-               rpp_sci_printf("Pin out of range.");
+               rpp_sci_printf("Pin out of range.\n");
                return -CMDERR_BADPAR;
        }
 
        if (rpp_dac_update() == FAILURE) {
-               rpp_sci_printf("DAC update failed.");
+               rpp_sci_printf("DAC update failed.\n");
                return -CMDERR_EIO;
        }
 
@@ -87,16 +87,16 @@ int cmd_do_dac_pin_set_val(cmd_io_t *cmd_io, const struct cmd_des *des, char *pa
        }
        ret = rpp_dac_set(pin, val);
        if (ret == -1) {
-               rpp_sci_printf("Pin out of range.");
+               rpp_sci_printf("Pin out of range.\n");
                return -CMDERR_BADPAR;
        }
        else if (ret == -2) {
-               rpp_sci_printf("Value out of range.");
+               rpp_sci_printf("Value out of range.\n");
                return -CMDERR_BADPAR;
        }
 
        if (rpp_dac_update() == FAILURE) {
-               rpp_sci_printf("DAC update failed.");
+               rpp_sci_printf("DAC update failed.\n");
                return -CMDERR_EIO;
        }
        return cmd_opchar_replong(cmd_io, param, val, 0, 10);
@@ -122,16 +122,16 @@ int cmd_do_dac_pin_set_voltage(cmd_io_t *cmd_io, const struct cmd_des *des, char
        }
        ret = rpp_dac_set_voltage(pin, mV);
        if (ret == -1) {
-               rpp_sci_printf("Pin out of range.");
+               rpp_sci_printf("Pin out of range.\n");
                return -CMDERR_BADPAR;
        }
        else if (ret == -2) {
-               rpp_sci_printf("Voltage out of range.");
+               rpp_sci_printf("Voltage out of range.\n");
                return -CMDERR_BADPAR;
        }
 
        if (rpp_dac_update() == FAILURE) {
-               rpp_sci_printf("DAC update failed.");
+               rpp_sci_printf("DAC update failed.\n");
                return -CMDERR_EIO;
        }
        return cmd_opchar_replong(cmd_io, param, mV, 0, 10);
@@ -215,12 +215,12 @@ cmd_des_t const cmd_des_dac_pin_set_voltage = {
        "=== Example ===\n"
        "\n"
        "   --> dacpinvoltage1 8000\n"
-       "dacpinvoltage1 =8000\n"
+       "   dacpinvoltage1 =8000\n"
        "\n"
        "Sets pin DAC1 to 8V, prints the actual voltage (8000)\n"
        "\n"
        "   --> dacpinvoltage2 500\n"
-       "dacpinvoltage2 =500\n"
+       "   dacpinvoltage2 =500\n"
        "\n"
        "Sets pin DAC2 to 500mV, prints actual voltage (500)\n",
        CMD_HANDLER(cmd_do_dac_pin_set_voltage), (void *)&cmd_list_dac
diff --git a/commands/cmd_fr_basic_test.c b/commands/cmd_fr_basic_test.c
new file mode 100644 (file)
index 0000000..454b814
--- /dev/null
@@ -0,0 +1,2728 @@
+/*
+ * Copyright (C) 2012-2013 Czech Technical University in Prague
+ *
+ * Created on: 6.8.2013
+ *
+ * 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/>.
+ *
+ * File : cmd_fr_basic_test.c
+ *
+ * Abstract:
+ *             The file contains a set of commands to control the FlexRay driver.
+ *             Those commands can be used to configure RPP board as a FlexRay node,
+ *             configure a set of TX and RX buffers, get status of the buffers and
+ *             the FlexRay controller, manipulate with timers and control the transmission
+ *             of messages.
+ */
+
+
+#include "cmd_fr_basic_test.h"
+
+#ifndef DOCGEN
+
+#include <string.h>
+#include "cmdproc_utils.h"
+#include "drv/drv.h"
+#include "rpp/rpp.h"
+#include "hal/hal.h"
+#include "stdio.h"
+
+#define printf rpp_sci_printf
+
+static inline int badpar(const char *msg)
+{
+       printf("%s", msg);
+       return -CMDERR_BADPAR;
+}
+
+
+/**
+ * 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,       // (cycle period, 5.6us)
+       .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.
+ * All nodes in the network shall have their own local configuraion,
+ * but it does not matters if they share some together, until their
+ * buffer configuration differs.
+ */
+static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
+       .pAllowHaltDueToClock = 0,
+       .pAllowPassiveToActive = FALSE,
+       .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
+};
+
+/**
+ * This structure contains local configuration of the FlexRay node B.
+ * All nodes in the network shall have their own local configuraion,
+ * but it does not matters if they share some together, until their
+ * buffer configuration differs.
+ */
+static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
+               .pAllowHaltDueToClock = 0,
+               .pAllowPassiveToActive = FALSE,
+               .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
+};
+
+static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
+       .dynSegmentBufferCount = 3,
+       .fifoBufferCount = 5,
+       .secureBuffers = FR_SB_RECONFIG_ENABLED,
+       .statSegmentBufferCount = 5,
+       .syncFramePayloadMultiplexEnabled = 0
+};
+
+static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
+       .dynSegmentBufferCount = 3,
+       .fifoBufferCount = 5,
+       .secureBuffers = FR_SB_RECONFIG_ENABLED,
+       .statSegmentBufferCount = 5,
+       .syncFramePayloadMultiplexEnabled = 0
+};
+
+static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 1
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 2
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 3
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 4
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = TRUE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 5
+       }
+
+};
+
+static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 2
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 1
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 4
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 3
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = TRUE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 5
+       }
+};
+
+static Fr_TMS570LS_BufferConfigType Fr_node_A_dynamic_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_A,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 64,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 9
+       },
+       {
+               .channel = FR_CHANNEL_B,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 32,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 10
+       },
+       {
+               .channel = FR_CHANNEL_A,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 16,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 11
+       }
+};
+
+
+static Fr_TMS570LS_BufferConfigType Fr_node_B_dynamic_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_B,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 32,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 10
+       },
+       {
+               .channel = FR_CHANNEL_A,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 64,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 9
+       },
+       {
+               .channel = FR_CHANNEL_A,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 12
+       }
+};
+
+static Fr_TMS570LS_BufferConfigType Fr_node_A_fifo_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 127,
+               .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 12
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 127,
+               .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 12
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 127,
+               .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 12
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 127,
+               .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 12
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 127,
+               .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 12
+       }
+};
+
+static Fr_TMS570LS_BufferConfigType Fr_node_B_fifo_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 64,
+               .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 0     // No Frame is rejected
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 64,
+               .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 0     // No Frame is rejected
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 64,
+               .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 0     // No Frame is rejected
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 64,
+               .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 0     // No Frame is rejected
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 64,
+               .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = TRUE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 0     // No Frame is rejected
+       }
+};
+
+/**
+ * This is an unifying configuration structure for the node A.
+ * It joins all the configuration structure together.
+ */
+static Fr_ConfigType Fr_config_node_A= {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = Fr_node_A_dynamic_buffers_config,
+       .fifoBufferConfigs = Fr_node_A_fifo_buffers_config,
+       .msgRAMConfig = &Fr_node_A_msgRAM_config,
+       .nodeConfiguration = &Fr_node_A_config,
+       .staticBufferConfigs = Fr_node_A_static_buffers_config
+};
+
+/**
+ * This is an unifying configuration structure for the node A.
+ * It joins all the configuration structure together.
+ */
+static Fr_ConfigType Fr_config_node_B= {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = Fr_node_B_dynamic_buffers_config,
+       .fifoBufferConfigs = Fr_node_B_fifo_buffers_config,
+       .msgRAMConfig = &Fr_node_B_msgRAM_config,
+       .nodeConfiguration = &Fr_node_B_config,
+       .staticBufferConfigs = Fr_node_B_static_buffers_config
+};
+
+/* User configuration */
+
+static Fr_TMS570LS_ClusterConfigType user_cluster_config;
+static Fr_TMS570LS_NodeConfigType user_node_config;
+static Fr_TMS570LS_MsgRAMConfig user_msg_ram_config;
+static Fr_TMS570LS_BufferConfigType user_static_buffer_config[RPP_FR_MAX_STATIC_BUF_CNT];
+static Fr_TMS570LS_BufferConfigType user_dynamic_buffer_config[RPP_FR_MAX_DYNAMIC_BUF_CNT];
+static Fr_TMS570LS_BufferConfigType user_fifo_buffer_config[RPP_FR_MAX_FIFO_BUF_DEPTH];
+static Fr_ConfigType user_configuration = {
+       .clusterConfiguration = &user_cluster_config,
+       .nodeConfiguration = &user_node_config,
+       .msgRAMConfig = &user_msg_ram_config,
+       .staticBufferConfigs = user_static_buffer_config,
+       .dynamicBufferConfigs = user_dynamic_buffer_config,
+       .fifoBufferConfigs = user_fifo_buffer_config,
+};;
+
+#define USER_CONFIG_NOT_DONE           0x0
+#define USER_CONFIG_CLUSTER            0x1
+#define USER_CONFIG_NODE                       0x2
+
+static uint8_t user_configuration_state = USER_CONFIG_NOT_DONE;
+static uint8_t user_static_buffer_configured = 0;
+static uint8_t user_dynamic_buffer_configured = 0;
+static uint8_t user_fifo_buffer_depth = 0;
+
+/**
+ * Split string into numbers
+ *
+ * The function takes a string with hexadecimal numbers,
+ * separated by spaces, and converts it into an array of numbers.
+ *
+ * For example "0x2 0xA 0XDD 0xABCD" -> {0x2, 0xA, 0XDD, 0xABCD}
+ *
+ * @param [in] params Address of the string which will be converted
+ * @param [in] params_cnt A number of parameters, which should be found and converted from the string params
+ * @param [out] tmp_params Address, where converted array of numbers will be stored
+ *
+ * @return SUCCESS when all parameters were converted to the array of numbers,
+ *         FAILURE when the string was too short, too long or some other error occurred.
+ */
+static int8_t cmd_fr_parse_params(const char* params, uint32_t params_cnt, uint32_t* tmp_params) {
+       char cpy_params[256];
+       char* token;
+       int i;
+
+       if (params == NULL || tmp_params == NULL) {
+               return FAILURE;
+       }
+       strncpy(cpy_params, params, 256);
+       token = strtok(cpy_params, " ");
+       if (token == NULL) {
+               return FAILURE;
+       }
+       for (i = 0; i < params_cnt; i++) {
+               if (sscanf(token, "%i", &tmp_params[i]) == EOF) {       // No number found
+                       return FAILURE;
+               }
+               if ((token = strtok(NULL, " ")) == NULL && i < params_cnt-1) {  // Not enough parameters in the string
+                       return FAILURE;
+               }
+       }
+       return SUCCESS;
+}
+
+int8_t cmd_fr_config_cluster_params(const char* params) {
+       uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
+
+       if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE) {
+               return FAILURE;
+       }
+
+       user_cluster_config.gColdStartAttempts = tmp_params[0];
+       user_cluster_config.gListenNoise = tmp_params[1];
+       user_cluster_config.gMacroPerCycle = tmp_params[2];
+       user_cluster_config.gMaxWithoutClockCorrectionFatal = tmp_params[3];
+       user_cluster_config.gMaxWithoutClockCorrectionPassive = tmp_params[4];
+       user_cluster_config.gNetworkManagementVectorLength = tmp_params[5];
+       user_cluster_config.gNumberOfMinislots = tmp_params[6];
+       user_cluster_config.gNumberOfStaticSlots = tmp_params[7];
+       user_cluster_config.gOffsetCorrectionStart = tmp_params[8];
+       user_cluster_config.gPayloadLengthStatic = tmp_params[9];
+       user_cluster_config.gSyncNodeMax = tmp_params[10];
+       user_cluster_config.gdActionPointOffset = tmp_params[11];
+       user_cluster_config.gdCASRxLowMax = tmp_params[12];
+       user_cluster_config.gdDynamicSlotIdlePhase = tmp_params[13];
+       user_cluster_config.gdMinislot = tmp_params[14];
+       user_cluster_config.gdMinislotActionPointOffset = tmp_params[15];
+       user_cluster_config.gdNIT = tmp_params[16];
+       user_cluster_config.gdSampleClockPeriod = tmp_params[17];
+       user_cluster_config.gdStaticSlot = tmp_params[18];
+       user_cluster_config.gdTSSTransmitter = tmp_params[19];
+       user_cluster_config.gdWakeupSymbolRxIdle = tmp_params[20];
+       user_cluster_config.gdWakeupSymbolRxLow = tmp_params[21];
+       user_cluster_config.gdWakeupSymbolRxWindow = tmp_params[22];
+       user_cluster_config.gdWakeupSymbolTxIdle = tmp_params[23];
+       user_cluster_config.gdWakeupSymbolTxLow = tmp_params[24];
+
+       user_configuration_state |= USER_CONFIG_CLUSTER;
+       return SUCCESS;
+}
+
+int8_t cmd_fr_config_node_params(const char* params) {
+       uint32_t tmp_params[FR_NODE_PARAMS_CNT+2];      // +2 because two more parameters from message RAM structure are expected in the string.
+       Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
+       Fr_TMS570LS_SecureBuffersType secure[4] = {FR_SB_RECONFIG_ENABLED, FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED, FR_SB_ALL_REC_DISABLED, FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED};
+
+       if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE) {
+               return FAILURE;
+       }
+
+       user_node_config.pAllowHaltDueToClock = tmp_params[0];
+       user_node_config.pAllowPassiveToActive = tmp_params[1];
+       if (tmp_params[2] > 2) return FAILURE;
+       user_node_config.pChannels = channels[ tmp_params[2] ];
+       user_node_config.pClusterDriftDamping = tmp_params[3];
+       user_node_config.pDelayCompensationA = tmp_params[4];
+       user_node_config.pDelayCompensationB = tmp_params[5];
+       user_node_config.pExternOffsetCorrection = tmp_params[6];
+       user_node_config.pExternRateCorrection = tmp_params[7];
+       user_node_config.pKeySlotUsedForStartup = tmp_params[8];
+       user_node_config.pKeySlotUsedForSync = tmp_params[9];
+       user_node_config.pLatestTx = tmp_params[10];
+       user_node_config.pMacroInitialOffsetA = tmp_params[11];
+       user_node_config.pMacroInitialOffsetB = tmp_params[12];
+       user_node_config.pMicroInitialOffsetA = tmp_params[13];
+       user_node_config.pMicroInitialOffsetB = tmp_params[14];
+       user_node_config.pMicroPerCycle = tmp_params[15];
+       user_node_config.pRateCorrectionOut = tmp_params[16];
+       user_node_config.pOffsetCorrectionOut = tmp_params[17];
+       user_node_config.pSamplesPerMicrotick = tmp_params[18];
+       user_node_config.pSingleSlotEnabled = tmp_params[19];
+       if (tmp_params[20] > 1) return FAILURE;
+       user_node_config.pWakeupChannel = channels[ tmp_params[20] ];
+       user_node_config.pWakeupPattern = tmp_params[21];
+       user_node_config.pdAcceptedStartupRange = tmp_params[22];
+       user_node_config.pdListenTimeout = tmp_params[23];
+       user_node_config.pdMaxDrift = tmp_params[24];
+       user_node_config.pDecodingCorrection = tmp_params[25];
+       user_msg_ram_config.syncFramePayloadMultiplexEnabled = tmp_params[26];
+       if (tmp_params[27] > 3) return FAILURE;
+       user_msg_ram_config.secureBuffers = secure[ tmp_params[27] ];
+
+       user_configuration_state |= USER_CONFIG_NODE;
+       return SUCCESS;
+}
+
+int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       Fr_TMS570LS_BufferConfigType* fifo_buffer_ptr = &user_fifo_buffer_config[0];
+       int ret, i;
+       char channel[3], rej_static_frames[8], rej_null_frames[8];
+       unsigned depth, slot, cycleset, maxpayload, intr;
+       Fr_TMS570LS_BufferConfigType tmp_buffer;
+
+       ret = sscanf(param[2], "slot%i depth%i %2s cyc%i max%i %10s %10s int%i",
+                    &slot,
+                    &depth,
+                    channel,
+                    &cycleset,
+                    &maxpayload,
+                    rej_null_frames,
+                    rej_static_frames,
+                    &intr
+                    );
+       if (ret != 8) {
+               printf("Error parsing parameter %d\n", ret+1);
+               return -CMDERR_BADPAR;
+       }
+
+       if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
+               return badpar("Depth too high\n");
+       user_fifo_buffer_depth = depth;
+
+       if (slot > 2047)
+               return badpar("Invalid slot number\n");
+       tmp_buffer.slotId = slot;
+       if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
+       else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
+       else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
+       else return badpar("Channel parsing error\n");
+       
+       if (cycleset >= 0x80)
+               return badpar("Cycle set must be less than 0x80.\n");
+       tmp_buffer.cycleCounterFiltering = cycleset;
+
+       if (maxpayload >= 128)
+               return badpar("Maximum payload in half-words must be less than 128\n");
+       tmp_buffer.maxPayload = maxpayload;
+       
+       if (strcmp(rej_null_frames, "rejnull") == 0) tmp_buffer.rejectNullFrames = true;
+       else if (strcmp(rej_null_frames, "accnull") == 0) tmp_buffer.rejectNullFrames = false;
+       else return badpar("Reject/accept NULL frames parsing error\n");
+
+       if (strcmp(rej_static_frames, "rejstat") == 0)
+               tmp_buffer.rejectStaticSegment = true;
+       else if (strcmp(rej_static_frames, "accstat") == 0)
+               tmp_buffer.rejectStaticSegment = false;
+       else return badpar("Invalid reject/accept static frame parameter");
+
+       if (intr > 1)
+               return badpar("Interrupt parameter must be 0 or 1");
+       tmp_buffer.msgBufferInterrupt = intr;
+
+       for (i = 0; i < user_fifo_buffer_depth; i++) {
+               fifo_buffer_ptr[i].slotId = tmp_buffer.slotId;  
+               fifo_buffer_ptr[i].maxPayload = tmp_buffer.maxPayload;
+               fifo_buffer_ptr[i].channel= tmp_buffer.channel;
+               fifo_buffer_ptr[i].cycleCounterFiltering = tmp_buffer.cycleCounterFiltering;
+               fifo_buffer_ptr[i].isTx = FALSE;
+               fifo_buffer_ptr[i].singleTransmit = FALSE;
+               fifo_buffer_ptr[i].payloadPreambleIndicatorTr = FALSE;
+               fifo_buffer_ptr[i].rejectNullFrames = tmp_buffer.rejectNullFrames;
+               fifo_buffer_ptr[i].rejectStaticSegment = tmp_buffer.rejectStaticSegment;
+               fifo_buffer_ptr[i].msgBufferInterrupt = tmp_buffer.msgBufferInterrupt;
+       }
+
+       printf("frbtcfgfifo slot%i depth%i %2s cyc%i max%i %10s %10s int%i\n",
+                    slot,
+                    depth,
+                    channel,
+                    cycleset,
+                    maxpayload,
+                    rej_null_frames,
+                    rej_static_frames,
+                    intr
+               );
+       
+       return SUCCESS;
+}
+
+int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
+{
+       Fr_TMS570LS_BufferConfigType *cfg;
+
+       int ret;
+       char buf_type, channel[3],rxtx[3], single_continuous[11];
+       unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
+       
+       ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
+                    &buf_type,
+                    &buffer,
+                    &slot,
+                    channel,
+                    &cycleset,
+                    rxtx,
+                    &maxpayload,
+                    single_continuous,
+                    &preamb,
+                    &intr
+                    );
+       if (ret != 10) {
+               printf("Error parsing parameter %d\n", ret+1);
+               return -CMDERR_BADPAR;
+       
+       }
+       
+       switch (buf_type) {
+       case 'S':
+               if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
+                       return badpar("Buffer index too high\n");
+               cfg = &user_static_buffer_config[buffer];
+               break;
+       case 'D':
+               if (buffer >= RPP_FR_MAX_DYNAMIC_BUF_CNT)
+                       return badpar("Buffer index too high\n");
+               cfg = &user_dynamic_buffer_config[buffer];
+               break;
+       default:
+               return badpar("Invalid buffer type (S, D)\n");
+       }
+
+       if (slot < 1 || slot > 2047)
+               return badpar("Invalid slot number\n");
+       cfg->slotId = slot;
+
+       if (strcmp(channel, "A") == 0) cfg->channel = FR_CHANNEL_A;
+       else if (strcmp(channel, "B") == 0) cfg->channel = FR_CHANNEL_B;
+       else if (strcmp(channel, "AB") == 0) cfg->channel = FR_CHANNEL_AB;
+       else return badpar("Channel parsing error\n");
+       if (buf_type == 'D' && cfg->channel == FR_CHANNEL_AB)
+               return badpar("Dynamic segment buffers cannot have AB channels.\n");
+
+       if (cycleset >= 0x80)
+               return badpar("Cycle set must be less than 0x80.\n");
+       cfg->cycleCounterFiltering = cycleset;
+
+       if (strcmp(rxtx, "tx") == 0) cfg->isTx = true;
+       else if (strcmp(rxtx, "rx") == 0) cfg->isTx = false;
+       else return badpar("RX/TX parsing error\n");
+
+       if (maxpayload >= 128)
+               return badpar("Maximum payload in half-words must be less than 128\n");
+       cfg->maxPayload = maxpayload;
+
+       if (0 == strcmp(single_continuous, "single") ||
+           0 == strcmp(single_continuous, "s"))
+               cfg->singleTransmit = true;
+       else if (0 == strcmp(single_continuous, "continuous") ||
+           0 == strcmp(single_continuous, "c"))
+               cfg->singleTransmit = false;
+       else return badpar("Invalid single/continuous parameter");
+
+       if (preamb > 1)
+               return badpar("Payload preamble indicator must be 0 or 1");
+       cfg->payloadPreambleIndicatorTr = preamb;
+
+       if (intr > 1)
+               return badpar("Interrupt parameter must be 0 or 1");
+       cfg->msgBufferInterrupt = intr;
+
+       switch (buf_type) {
+       case 'S':
+               if (buffer >= user_static_buffer_configured)
+                       user_static_buffer_configured = buffer + 1;
+               break;
+       case 'D':
+               if (buffer >= user_dynamic_buffer_configured)
+                       user_dynamic_buffer_configured = buffer + 1;
+               break;
+       }
+
+       printf("frbtcfgbuf%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i\n",
+                    buf_type,
+                    buffer,
+                    slot,
+                    channel,
+                    cycleset,
+                    rxtx,
+                    maxpayload,
+                    single_continuous,
+                    preamb,
+                    intr
+               );
+
+       return 0;
+}
+
+
+
+/**
+ *     @brief  Do the user configuration of the FlexRay cluster parameters
+ *
+ * @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_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       char* token;
+       token = strtok(param[1], " ");
+       if (strcmp(token, "cluster") == 0) {
+               if (cmd_fr_config_cluster_params(param[2]) == FAILURE) {
+                       rpp_sci_printf("FlexRay cluster configuration not accepted.\n");
+                       return -CMDERR_BADPAR;
+               }
+               rpp_sci_printf("FlexRay cluster configuration accepted.\n");
+       }
+       else if (strcmp(token, "node") == 0) {
+               if (cmd_fr_config_node_params(param[2]) == FAILURE) {
+                       rpp_sci_printf("FlexRay node configuration not accepted.\n");
+                       return -CMDERR_BADPAR;
+               }
+               rpp_sci_printf("FlexRay node configuration accepted.\n");
+       }
+       else {
+               return -CMDERR_BADPAR;
+       }
+
+       return 0;
+}
+
+/**
+ *     @brief  Initialize the device as FlexRay node.
+ *
+ * @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_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       const Fr_ConfigType* Fr_ConfigPtr = NULL;
+       int8_t retVal = SUCCESS;
+       uint32_t error = ERR_PARAM_NO_ERROR;
+
+       if (*param[1] == 'A') {
+               Fr_ConfigPtr = &Fr_config_node_A;
+       }
+       else if (*param[1] == 'B') {
+               Fr_ConfigPtr = &Fr_config_node_B;
+       }
+       else if (*param[1] == 'U') {    // Select the user configuration  -  call config commands first
+               user_msg_ram_config.statSegmentBufferCount = user_static_buffer_configured;
+               user_msg_ram_config.dynSegmentBufferCount = user_dynamic_buffer_configured;
+               user_msg_ram_config.fifoBufferCount= user_fifo_buffer_depth;
+               Fr_ConfigPtr = &user_configuration;
+       }
+       else {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_init_driver(Fr_ConfigPtr, &error);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("FlexRay driver initialized.\r\n");
+       }
+       else {
+               rpp_sci_printf("FlexRay needs to be configured before initialization.\r\n");
+               return -CMDERR_BADCFG;
+       }
+
+       retVal = rpp_fr_init_controller(0, &error);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("FlexRay controller initialized.\r\n");
+       }
+       else {
+               if (error & FR_INIT_ERR_CLUSTER_CONFIG) {
+                       rpp_sci_printf("Cluster configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
+               }
+               else if (error & FR_INIT_ERR_NODE_CONFIG) {
+                       rpp_sci_printf("Node configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
+               }
+               else if (error & FR_INIT_ERR_MSGRAM_CONFIG) {
+                       rpp_sci_printf("Message RAM configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
+               }
+               else if (error & FR_INIT_ERR_BUFFPARAM_CONFIG) {
+                       rpp_sci_printf("Buffer configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
+               }
+               else if (error & (uint32_t)FR_INIT_ERR_BUFF_CONFIG) {
+                       rpp_sci_printf("Buffer configuration error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
+               }
+               else {
+                       rpp_sci_printf("POC state switching error.\r\n");
+               }
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Starts FlexRay communication
+ *
+ * @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_fr_start(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = SUCCESS;
+       uint32_t error = ERR_PARAM_NO_ERROR;
+
+       retVal = rpp_fr_start_communication(0, &error);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("FlexRay communication is running.\r\n");
+       }
+       else {
+               if (error & FR_STARTUP_ERR_SW_STUP_FOLLOW) {
+                       rpp_sci_printf("Can not switch POC to RUN state.\r\n");
+               }
+               else if (error & FR_STARTUP_ERR_CSINH_DIS) {
+                       rpp_sci_printf("Cold start inhibit disabled error.\r\n");
+               }
+               else if (error & FR_STARTUP_ERR_SW_STUP_READY) {
+                       rpp_sci_printf("Can not switch back to READY from STARTUP.\r\n");
+               }
+               else if (error & FR_STARTUP_ERR_SW_STUP_AS_NCOLD) {
+                       rpp_sci_printf("Can not switch to STARTUP as non-coldstarter.\r\n");
+               }
+               else {
+                       rpp_sci_printf("General error.\r\n");
+               }
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Invokes POC command ALL_SLOTS
+ *
+ * @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_fr_allslots(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       retVal = rpp_fr_all_slots(0);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("FlexRay node started communication in all slots.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Halt FlexRay communication
+ *
+ * @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_fr_halt(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       retVal = rpp_fr_halt_communication(0);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("FlexRay node communication halted.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Abort FlexRay communication
+ *
+ * @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_fr_abort(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       retVal = rpp_fr_abort_communication(0);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("FlexRay node communication aborted.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Send wake up pattern
+ *
+ * @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_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       retVal = rpp_fr_send_wup(0);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Wake up pattern has been sent.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Set channel for wake up pattern sending.
+ *
+ * @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_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       Fr_ChannelType channel = FR_CHANNEL_A;
+
+       if (*param[1] == 'A') {
+               channel = FR_CHANNEL_A;
+       }
+       else if (*param[1] == 'B') {
+               channel = FR_CHANNEL_B;
+       }
+       else {
+               return -CMDERR_BADPAR;
+       }
+       retVal = rpp_fr_set_wu_channel(0, channel);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Wake up channel has been set.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Get and print POC status of the FlexRay controller.
+ *
+ * @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_fr_getpocstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       Fr_POCStatusType status;
+       char* ErrorModeStrings[] = {"ACTIVE", "HALT", "PASSIVE"};
+       char* SlotModeStrings[]  = {"KEYSLOT", "ALL_PENDING", "ALL"};
+       char* StartupStateStrings[]  = {
+                       "UNDEFINED", "COLDSTART_LISTEN", "COLDSTART_CHECK", "COLDSTART_JOIN",
+                       "COLDSTART_CONSISTENCY_CHECK", "INTEGRATION_LISTEN", "INITIALIZE_SCHEDULE", "INTEGRATION_CONSISTENCY_CHECK",
+                       "COLDSTART_GAP", "EXTERNAL_STARTUP", "ABORT", "COLDSTART_COLLISION_RESOLUTION",
+                       "PREPARE"
+       };
+       char* StateStrings[]  = {
+                       "CONFIG", "DEFAULT_CONFIG", "HALT", "NORMAL_ACTIVE",
+                       "NORMAL_PASSIVE", "READY", "STARTUP", "LOOPBACK",
+                       "MONITOR", "WAKEUP"
+       };
+       char* WakeupStatusStrings[]  = {
+                       "UNDEFINED", "RECEIVED_HEADER", "RECEIVED_WUP", "COLLISION_HEADER",
+                       "COLLISION_WUP", "COLLISION_UNKNOWN", "TRANSMITTED"
+       };
+
+       retVal = rpp_fr_get_poc_status(0, &status);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("POC status:\r\n");
+               rpp_sci_printf("CHIHaltRequest: %s\r\n", (status.CHIHaltRequest == TRUE) ? "TRUE" : "FALSE");
+               rpp_sci_printf("CHIReadyRequest: %s\r\n", (status.CHIReadyRequest == TRUE) ? "TRUE" : "FALSE");
+               rpp_sci_printf("ColdstartNoise: %s\r\n", (status.ColdstartNoise == TRUE) ? "TRUE" : "FALSE");
+               rpp_sci_printf("Freeze: %s\r\n", (status.Freeze == TRUE) ? "TRUE" : "FALSE");
+               rpp_sci_printf("ErrorMode: %s\r\n", ErrorModeStrings[status.ErrorMode]);
+               rpp_sci_printf("SlotMode: %s\r\n", SlotModeStrings[status.SlotMode]);
+               rpp_sci_printf("StartupState: %s\r\n", StartupStateStrings[status.StartupState]);
+               rpp_sci_printf("State: %s\r\n", StateStrings[status.State]);
+               rpp_sci_printf("WakeupStatus: %s\r\n", WakeupStatusStrings[status.WakeupStatus]);
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Send given data through the FlexRay in selected slot.
+ *
+ * @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_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint32_t slotID;
+       uint8_t dataLength;
+       int values[MAX_PARAM_VALUES_NUM];
+       uint8_t data[MAX_PARAM_VALUES_NUM];
+       char* token = NULL;
+
+       if (sscanf(param[1], "%d", &slotID) != 1) {
+               return -CMDERR_BADPAR;
+       }
+       if (sscanf(param[2], " %2x", &values[0]) != 1) {
+               return -CMDERR_BADPAR;
+       }
+       data[0] = (uint8_t)values[0];
+       token = strtok(param[2], " ");
+       token = strtok(NULL, " ");
+       dataLength = 1;
+       while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
+               if (sscanf(token, "%2x", &values[dataLength]) == EOF) {
+                       break;
+               }
+               data[dataLength] = (uint8_t)values[dataLength];
+               token = strtok(NULL, " ");
+               dataLength++;
+       }
+
+       retVal = rpp_fr_transmit_lpdu(0, slotID, data, dataLength);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Data were set for transmission.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Cancel the transmission in the selected slot.
+ *
+ * @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_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint32_t slotID;
+
+       if (sscanf(param[1], "%d", &slotID) != 1) {
+               return -CMDERR_BADPAR;
+       }
+       if (param[2] != NULL) {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_cancel_transmit_lpdu(0, slotID);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Transmission canceled.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Receive data from selected slot.
+ *
+ * @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_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint32_t slotID;
+       uint8_t data[cPayloadLengthMax];
+       Fr_RxLPduStatusType status;
+       uint8_t receivedLength = 0;
+       uint8_t i;
+
+       if (sscanf(param[1], "%d", &slotID) != 1) {
+               return -CMDERR_BADPAR;
+       }
+       if (param[2] != NULL) {
+               return -CMDERR_BADPAR;
+       }
+
+       memset(data, 0, sizeof(data));
+
+       retVal = rpp_fr_receive_lpdu(0, slotID, data, &status, &receivedLength);
+       if (retVal == SUCCESS) {
+               switch (status) {
+               case FR_RECEIVED_MORE_DATA_AVAILABLE:
+                       rpp_sci_printf("More messages are still in FIFO:\r\n");
+               case FR_RECEIVED:
+                       rpp_sci_printf("Received message (%d B):\r\n", receivedLength);
+                       for (i = 0; i < receivedLength; i++) {
+                               rpp_sci_printf(" %02x", data[i]);
+                       }
+                       rpp_sci_printf("\r\n");
+                       break;
+               default:
+                       rpp_sci_printf("No message received.\r\n");
+                       break;
+               }
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Returns TX LPdu status.
+ *
+ * @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_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint32_t slotID;
+       Fr_TxLPduStatusType status;
+       char* statusStrings[] = {"is not", "is"};
+
+       if (sscanf(param[1], "%d", &slotID) != 1) {
+               return -CMDERR_BADPAR;
+       }
+       if (param[2] != NULL) {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_check_tx_lpdu_status(0, slotID, &status);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Message transmission %s pending.\r\n", statusStrings[status]);
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Disable buffer.
+ *
+ * @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_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint32_t slotID;
+
+       if (sscanf(param[1], "%d", &slotID) != 1) {
+               return -CMDERR_BADPAR;
+       }
+       if (param[2] != NULL) {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_disable_lpdu(0, slotID);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Buffer disabled.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Print global time of the FlexRay network.
+ *
+ * @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_fr_getglobaltime(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint8_t cycle = 0;
+       uint16_t macroTick = 0;
+
+       retVal = rpp_fr_get_global_time(0, &cycle, &macroTick);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Cycle number: %d\r\nMacrotick number: %d\r\n", cycle, macroTick);
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Print network management vector of the FlexRay node.
+ *
+ * @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_fr_getnmvector(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint8_t nmVector[12];
+       uint8_t i;
+
+       retVal = rpp_fr_get_network_management_vector(0, nmVector);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Network management vector:");
+               for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
+                       rpp_sci_printf(" %x", nmVector[i]);
+               }
+               rpp_sci_printf("\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+int cmd_do_fr_nmwatch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint8_t nmVector[12];
+       uint8_t i;
+
+       // Calculate wait time in OS ticks
+       static const portTickType freq_ticks = 100 /* ms */ / portTICK_RATE_MS;
+       portTickType last_wake_time = xTaskGetTickCount();
+
+       while(cmd_io->getc(cmd_io) < 0) {
+               retVal = rpp_fr_get_network_management_vector(0, nmVector);
+               if (retVal == SUCCESS) {
+                       rpp_sci_printf("Network management vector:");
+                       for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
+                               rpp_sci_printf(" %02x", nmVector[i]);
+                       }
+                       rpp_sci_printf("\r");
+               }
+               else {
+                       rpp_sci_printf("General error.\r\n");
+                       return -CMDERR_BADCFG;
+               }
+               vTaskDelayUntil(&last_wake_time, freq_ticks);
+       }
+       rpp_sci_printf("\n");
+       return 0;
+}
+
+/**
+ *     @brief  Print both channels status of the FlexRay node.
+ *
+ * @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_fr_getchannelstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint8_t index;
+       uint8_t channel;
+       char* decodeStrings[] = {
+                       "aggregated channel status vSS!ValidFrame",
+                       "aggregated channel status vSS!SyntaxError",
+                       "aggregated channel status vSS!ContentError",
+                       "aggregated channel status additional communication",
+                       "aggregated channel status vSS!Bviolation",
+                       "aggregated channel status vSS!TxConflict",
+                       "Not used (0)",
+                       "Not used (0)",
+                       "symbol window status data vSS!ValidMTS",
+                       "symbol window status data vSS!SyntaxError",
+                       "symbol window status data vSS!Bviolation",
+                       "symbol window status data vSS!TxConflict",
+                       "NIT status data vSS!SyntaxError",
+                       "NIT status data vSS!Bviolation",
+                       "Not used (0)",
+                       "Not used (0)"
+       };
+       char* channelNames[] = {"A", "B"};
+       char* boolStrings[] = {"FALSE", "TRUE"};
+       uint16_t channelStatuses[2];
+
+       retVal = rpp_fr_get_channel_status(0, &channelStatuses[0], &channelStatuses[1]);
+       if (retVal == SUCCESS) {
+               for (channel = 0; channel < 2; channel++) {
+                       rpp_sci_printf("Channel %s status:\r\n", channelNames[channel]);
+                       for (index = 0; index < 16; index++) {
+                               rpp_sci_printf("\t%s: %s\r\n", decodeStrings[index], boolStrings[ (channelStatuses[channel] >> index) & 0x1 ] );
+                       }
+               }
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Print clock correction of the FlexRay node
+ *
+ * @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_fr_getclockcorrection(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       int16_t rateCorrection;
+       int32_t offsetCorrection;
+
+       retVal = rpp_fr_get_clock_correction(0, &rateCorrection, &offsetCorrection);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Rate correction: %d\r\nOffset correction: %d\r\n", rateCorrection, offsetCorrection);
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Print list of syncframec transmitted on both channels via the even and odd cycle.
+ *
+ * @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_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint16_t channelAEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
+       uint16_t channelBEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
+       uint16_t channelAOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
+       uint16_t channelBOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
+       uint32_t listSize = 0;
+       uint8_t i;
+
+       if (sscanf(param[1], "%d", &listSize) != 1) {
+               return -CMDERR_BADPAR;
+       }
+       if (param[2] != NULL) {
+               return -CMDERR_BADPAR;
+       }
+       if (listSize > FR_MAX_SYNC_FRAME_LIST_SIZE) {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_get_sync_frame_list(0, listSize, channelAEvenList, channelBEvenList, channelAOddList, channelBOddList);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("| Channel A even | channel B even | channel A odd  | channel B odd  |\r\n");
+               rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
+               for (i = 0; i < listSize; i++) {
+                       rpp_sci_printf("| %-14x | %-14x | %-14x | %-14x |\r\n", channelAEvenList[i], channelBEvenList[i], channelAOddList[i], channelBOddList[i]);
+               }
+               rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
+
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Print status of wakeup on each channels (wakeup received on channel or not yet received).
+ *
+ * @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_fr_getwakeuprxstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       uint8_t status = 0;
+       char* statusStrings[] = {"was not yet", "was"};
+       char* channelNames[] = {"A", "B"};
+       uint8_t i;
+
+       retVal = rpp_fr_get_wakeup_rx_status(0, &status);
+       if (retVal == SUCCESS) {
+               for (i = 0; i < 2; i++) {
+                       rpp_sci_printf("Wake up pattern %s received on channel %s.\r\n", statusStrings[(status >> i) & 0x1], channelNames[i]);
+               }
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Set and start absolute timer.
+ *
+ * @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_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       int timer = 0;
+       int cycle = 0;
+       int offset = 0;
+
+       if (sscanf(param[1], "%i %i %i", &timer, &cycle, &offset) != 3) {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_set_timer(0, timer, cycle, offset);
+       if (retVal == SUCCESS) {
+               uint8_t i = 0x40;
+               while (i && (cycle & i) == 0)
+                       i >>= 1;
+               if (!i)
+                       i = 1;
+
+               rpp_sci_printf("Timer was set for every %d-th cycle, offset %d, macrotick %d\n",
+                              i, cycle & ~i, offset);
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Cancel selected timer
+ *
+ * @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_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       int timer = 0;
+
+       if (sscanf(param[1], "%d", &timer) != 1) {
+               return -CMDERR_BADPAR;
+       }
+
+       if (param[2] != NULL) {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_cancel_timer(0, timer);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Timer was canceled.\r\n");
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Enable/disable, acknowledge, get timer IRQ
+ *
+ * @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_fr_timerirq(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       int timer = 0;
+       char str[4];
+       boolean_t status = FALSE;
+       char* boolStrings[] = {"FALSE", "TRUE"};
+
+
+       if (sscanf(param[1], "%d", &timer) != 1) {
+               return -CMDERR_BADPAR;
+       }
+
+       if (param[2] == NULL) {         // Get timer IRQ
+               retVal = rpp_fr_get_timer_irq_status(0, timer, &status);
+               if (retVal == SUCCESS) {
+                       rpp_sci_printf("IRQ = %s\r\n", boolStrings[status]);
+               }
+               else {
+                       rpp_sci_printf("General error.\r\n");
+                       return -CMDERR_BADCFG;
+               }
+       }
+       else {  // Some set action
+               if (sscanf(param[2], "%4s", str) != 1) {
+                       return -CMDERR_BADPAR;
+               }
+               if (strcmp(str, "EN") == 0) { // Enable IRQ
+                       retVal = SUCCESS;       // No interrupts imlemented
+               }
+               else if (strcmp(str, "DIS") == 0) { // Disable IRQ
+                       retVal = SUCCESS;       // No interrupts implemented
+               }
+               else if  (strcmp(str, "ACK") == 0) { // Clear IRQ
+                       retVal = rpp_fr_clear_timer_irq(0, timer);
+               }
+               else {  // Bad argument
+                       return -CMDERR_BADPAR;
+               }
+
+               if (retVal == SUCCESS) {
+                       rpp_sci_printf("OK\r\n");
+               }
+               else {
+                       rpp_sci_printf("General error.\r\n");
+                       return -CMDERR_BADCFG;
+               }
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Print FlexRay driver version info.
+ *
+ * @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_fr_getversioninfo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       Std_VersionInfoType versionInfo;
+
+       rpp_fr_get_driver_version(&versionInfo);
+       rpp_sci_printf("vendorID: %#x\r\n", versionInfo.vendorID);
+       rpp_sci_printf("moduleID: %#x\r\n", versionInfo.moduleID);
+       rpp_sci_printf("sw_major_version: %#x\r\n", versionInfo.sw_major_version);
+       rpp_sci_printf("sw_minor_version: %#x\r\n", versionInfo.sw_minor_version);
+       rpp_sci_printf("sw_patch_version: %#x\r\n", versionInfo.sw_patch_version);
+
+       return 0;
+}
+
+/**
+ *     @brief  Print value of FlexRay configuratoin parameter.
+ *
+ * @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_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int8_t retVal = ERR_PARAM_NO_ERROR;
+       int index = 0;
+       uint32_t value = 0;
+
+       if (sscanf(param[1], "%d", &index) != 1) {
+               return -CMDERR_BADPAR;
+       }
+
+       if (param[2] != NULL) {
+               return -CMDERR_BADPAR;
+       }
+
+       retVal = rpp_fr_read_com_ctrl_config(0, index, &value);
+       if (retVal == SUCCESS) {
+               rpp_sci_printf("Value = %#x\r\n", value);
+       }
+       else {
+               rpp_sci_printf("General error.\r\n");
+               return -CMDERR_BADCFG;
+       }
+       return 0;
+}
+
+/**
+ *     @brief  Reconfigure buffer
+ *
+ * @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_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
+       int ret;
+       char channel[3];
+       unsigned id, slot, maxpayload, cycleset;
+       Fr_TMS570LS_BufferConfigType tmp_buffer;
+
+       ret = sscanf(param[2], "id%i slot%i %2s cyc%i max%i",
+                    &id,
+                    &slot,
+                    channel,
+                    &cycleset,
+                    &maxpayload
+                    );
+       if (ret != 5) {
+               printf("Error parsing parameter %d\n", ret+1);
+               return -CMDERR_BADPAR;
+       }
+
+       if (slot > 2047 || id > 2047)
+               return badpar("Invalid slot number\n");
+       tmp_buffer.slotId = slot;
+       if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
+       else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
+       else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
+       else return badpar("Channel parsing error\n");
+
+       if (cycleset >= 0x80)
+               return badpar("Cycle set must be less than 0x80.\n");
+       tmp_buffer.cycleCounterFiltering = cycleset;
+
+       if (maxpayload >= 128)
+               return badpar("Maximum payload in half-words must be less than 128\n");
+       tmp_buffer.maxPayload = maxpayload;
+
+       if (rpp_fr_reconfigure_lpdu(0, id, tmp_buffer.slotId, tmp_buffer.channel, tmp_buffer.cycleCounterFiltering, tmp_buffer.maxPayload) == SUCCESS) {
+               printf("frbtreconfigbuf id%i slot%i %2s cyc%i max%i",
+                            id,
+                            slot,
+                            channel,
+                            cycleset,
+                            maxpayload
+                            );
+               return 0;
+       }
+       else {
+               printf("Reconfiguration failed.\n");
+       }
+       return -CMDERR_BADPAR;
+}
+
+#endif /* DOCGEN */
+
+/** Command descriptor for FlexRay user config cluster command */
+cmd_des_t const cmd_des_fr_user_config={
+       0, 0,
+       "frbtconfig*","Set the user configuration parameters",
+               "=== Command syntax ===\n"
+       "\n"
+       "   frbtconfig<TYPE> <PARAMS>\n"
+       "where\n"
+       "* <TYPE> is a string specifying the type of parameters to be set. It can be: \"cluster\" or  \"node\"\n"
+       "* <PARAMS> is a sequence of numbers separated by spaces. Each number stands for one parameter.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command takes the configuration parameters in the form of a string\n"
+       "and sets the appropriate type of the FlexRay parameters. It is\n"
+       "necessary to configure parameters of at least cluster, and node and\n"
+       "one static buffer (see frbtcfgbuf command). The parameters set by this\n"
+       "command are applied by the frbtinitU command. Once frbtinit is called,\n"
+       "it is no longer possible to change the parameters.\n"
+       "\n"
+       "The type of the parameters can be selected by the <TYPE> selector.\n"
+       "\n"
+       "Type \"cluster\" sets global FlexRay network parameters. It expects a\n"
+       "sequence of 25 parameters in this order:\n"
+       "* 1) gColdStartAttempts\n"
+       "* 2) gListenNoise\n"
+       "* 3) gMacroPerCycle\n"
+       "* 4) gMaxWithoutClockCorrectionFatal\n"
+       "* 5) gMaxWithoutClockCorrectionPassive\n"
+       "* 6) gNetworkManagementVectorLength\n"
+       "* 7) gNumberOfMinislots\n"
+       "* 8) gNumberOfStaticSlots\n"
+       "* 9) gOffsetCorrectionStart\n"
+       "* 10) gPayloadLengthStatic\n"
+       "* 11) gSyncNodeMax\n"
+       "* 12) gdActionPointOffset\n"
+       "* 13) gdCASRxLowMax\n"
+       "* 14) gdDynamicSlotIdlePhase\n"
+       "* 15) gdMinislot\n"
+       "* 16) gdMinislotActionPointOffset\n"
+       "* 17) gdNIT\n"
+       "* 18) gdSampleClockPeriod\n"
+       "* 19) gdStaticSlot\n"
+       "* 20) gdTSSTransmitter\n"
+       "* 21) gdWakeupSymbolRxIdle\n"
+       "* 22) gdWakeupSymbolRxLow\n"
+       "* 23) gdWakeupSymbolRxWindow\n"
+       "* 24) gdWakeupSymbolTxIdle\n"
+       "* 25) gdWakeupSymbolTxLow\n"
+       "\n"
+       "Type \"node\" sets local FlexRay network parameters. It expects a\n"
+       "sequence of 28 parameters in this order:\n"
+       "* 1) pAllowHaltDueToClock\n"
+       "* 2) pAllowPassiveToActive\n"
+       "* 3) pChannels (0 - A, 1 - B, 2 - AB)\n"
+       "* 4) pClusterDriftDamping\n"
+       "* 5) pDelayCompensationA\n"
+       "* 6) pDelayCompensationB\n"
+       "* 7) pExternOffsetCorrection\n"
+       "* 8) pExternRateCorrection\n"
+       "* 9) pKeySlotUsedForStartup\n"
+       "* 10) pKeySlotUsedForSync\n"
+       "* 11) pLatestTx\n"
+       "* 12) pMacroInitialOffsetA\n"
+       "* 13) pMacroInitialOffsetB\n"
+       "* 14) pMicroInitialOffsetA\n"
+       "* 15) pMicroInitialOffsetB\n"
+       "* 16) pMicroPerCycle\n"
+       "* 17) pRateCorrectionOut\n"
+       "* 18) pOffsetCorrectionOut\n"
+       "* 19) pSamplesPerMicrotick\n"
+       "* 20) pSingleSlotEnabled\n"
+       "* 21) pWakeupChannel (0 - A, 1 - B)\n"
+       "* 22) pWakeupPattern\n"
+       "* 23) pdAcceptedStartupRange\n"
+       "* 24) pdListenTimeout\n"
+       "* 25) pdMaxDrift\n"
+       "* 26) pDecodingCorrection\n"
+       "* 27) syncFramePayloadMultiplexEnabled\n"
+       "* 28) secureBuffers (0 - FR_SB_RECONFIG_ENABLED, 1 - FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED, 2 - FR_SB_ALL_REC_DISABLED, 3 - FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED)\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C\n"
+       "   FlexRay cluster configuration accepted.\n"
+       "   --> frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0\n"
+       "   FlexRay node configuration accepted.\n",
+       CMD_HANDLER(cmd_do_fr_user_config), (void *)&cmd_list_fr_basic_test
+};
+
+cmd_des_t const cmd_des_fr_config_buffer={
+       0, 0,
+       "frbtcfgbuf?*","Configure a message buffer in the user configuration",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtcfgbuf<TYPE><NUM> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\n"
+       "where\n"
+       "* <TYPE> is 'S' for static segment buffers and 'D' for dynamic segment buffers,\n"
+       "* <NUM> is the number of the buffer. Both static and dynamic buffers are numbered independently starting from zero,\n"
+       "* <SLOT> is the number of the slot,\n"
+       "* <CHN> is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
+       "* <CYC> is the cycle set when to send the buffer,\n"
+       "* <RXTX> is either string \"rx\" or \"tx\",\n"
+       "* <MAX> is the number determining the maximum payload (in hald-words),\n"
+       "* <REP> is a string \"s\" or \"single\" for single transmission or \"c\" or \"continuous\" for continuous transmission,\n"
+       "* <PPI> is 0 or 1 determining whether the payload preamble indicator is set,\n"
+       "* <INT> is 0 or 1 and is currently ignored.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command sets the configuration parameters for static or dynamic\n"
+       "buffers in user configuration. The parameters set by this command are\n"
+       "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
+       "longer possible to change the parameters.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
+       "   frbtcfgbufS0 slot2 AB cyc0 tx max9  continous ppi0 int1\n"
+       "   --> frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
+       "   frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
+       "   --> frbtcfgbufD0  slot9  A cyc0 rx max0x40 single ppi0 int0\n"
+       "   frbtcfgbufD0 slot9  A cyc0 rx max64 single ppi0 int0\n"
+       "   --> frbtcfgbufD1  slot10 A cyc0 tx max0x40 single ppi0 int0\n"
+       "   frbtcfgbufD1 slot10  A cyc0 tx max64 single ppi0 int0\n",
+       CMD_HANDLER(cmd_do_fr_config_bufer), (void *)&cmd_list_fr_basic_test
+};
+
+cmd_des_t const cmd_des_fr_config_fifo={
+       0, 0,
+       "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtcfgfifo slot<SLOT> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT> int<INT>\n"
+       "where\n"
+       "* <SLOT> is the number of the slot,\n"
+       "* <DEPTH> is a number specifying the depth of the FIFO,\n"
+       "* <CHN> is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
+       "* <CYC> is the cycle set when to send the buffer,\n"
+       "* <MAX> is the number determining the maximum payload (in hald-words),\n"
+       "* <REJNULL> is a string \"rejnull\" for rejecting NULL frames or \"accnull\" for accepting NULL frames,\n"
+       "* <REJSTAT> is a string \"rejstat\" for rejecting frames in static segment or \"accstat\" for accepting frames from static segment,\n"
+       "* <INT> is 0 or 1 and is currently ignored.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command sets the configuration parameters for RX FIFO buffer\n"
+       "in user configuration. The parameters set by this command are\n"
+       "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
+       "longer possible to change the parameters.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtcfgfifo slot0 depth5 AB cyc0 max20 rejnull accstat int1\n"
+       "   frbtcfgfifo slot0 depth5 AB cyc0 max20  rejnull accstat int1\n",
+       CMD_HANDLER(cmd_do_fr_config_fifo), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay init command */
+cmd_des_t const cmd_des_fr_init={
+       0, 0,
+       "frbtinit?","Initialize a FlexRay node",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtinit<CFG>\n"
+       "\n"
+       "where <CFG> identifies the configuration to use. It can be one of A, B\n"
+       "or U. The A and B are predefined configurations. If U is specified,\n"
+       "the user configuration previously set by frbtconfig command is used.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_Init and Fr_ControllerInit functions from\n"
+       "the Autosar specification. It initializes the internal data structures\n"
+       "of the driver and then, based on those data, the controller\n"
+       "configuration is done. During the controller configuration the\n"
+       "parameters of the cluster, node, message RAM and buffers are checked.\n"
+       "If anything goes bad, the command returns an error number, which can\n"
+       "be decoded by macros defined in driver header file fr_tms570.h with\n"
+       "prefix ERR_PARAM. If all parameters are OK, all necessary registers of\n"
+       "the controller are initialized according to the specified\n"
+       "configuration parameters. At the end of the command, the FlexRay\n"
+       "controller is switched into READY state and all buffers are configured\n"
+       "to send NULL frames. This command should be called as the very first\n"
+       "command, when trying to communicate over the FlexRay bus.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtinitA\n"
+       "   FlexRay driver initialized.\n"
+       "   FlexRay controller initialized.\n",
+       CMD_HANDLER(cmd_do_fr_init), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay controller init command */
+cmd_des_t const cmd_des_fr_start={
+       0, 0,
+       "frbtstart","Start a new FlexRay network or join to the existing one",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtstart\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_StartCommunication function from the Autosar\n"
+       "specification. If the node was halted by previously called frbthalt\n"
+       "or frbtabort command, the POC is switched automaticaly from HALT state\n"
+       "to READY state to allow restart of the communication.\n"
+       "If the FlexRay node is configured as a coldstarter node\n"
+       "(as for example by frbtinitA/B command), then the command first listen\n"
+       "on the bus. When it does not detect any existing bus communication, it\n"
+       "tries to initiate a new network. If the initiation fails, the FlexRay\n"
+       "controller is switched back to the ready state for another attempt\n"
+       "(calling frbtstart again). If the FlexRay node is configured as\n"
+       "non-coldstarter, it is listening on the bus until some existing\n"
+       "communication is detected.\n"
+       "\n"
+       "The command should be called after the frbtinit command.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtstart\n"
+       "   FlexRay communication is running.\n",
+       CMD_HANDLER(cmd_do_fr_start), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay controller all slots command */
+cmd_des_t const cmd_des_fr_allslots={
+       0, 0,
+       "frbtallslots","Enables communication for all frames",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtallslots\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_AllSlots function from the Autosar\n"
+       "specification.\n"
+       "\n"
+       "The node can be configured to communicate only on key frames by\n"
+       "default (as in the case of frbtinitA/B). This command can be used to\n"
+       "allow the communication on all configured frames. The command invokes\n"
+       "the FlexRay POC command ALL_SLOTS which enables the communication on\n"
+       "all frames. The command can be called after the controller\n"
+       "initialization.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtallslots\n"
+       "   FlexRay node started communication on all slots.\n",
+       CMD_HANDLER(cmd_do_fr_allslots), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay controller halt command */
+cmd_des_t const cmd_des_fr_halt={
+       0, 0,
+       "frbthalt","Halt FlexRay communication after the end of the actual communication cycle",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbthalt\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_HaltCommunication function from the Autosar\n"
+       "specification. The command invokes the FlexRay POC command HALT, which\n"
+       "means that communication is stopped after the end of the actual\n"
+       "communication cycle. On the opposite side, there is a frbtfreeze\n"
+       "command, which stops the communication immediately. To start the\n"
+       "communication again, the frbtstart command has to be called.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbthalt\n"
+       "   FlexRay node communication halted.\n",
+       CMD_HANDLER(cmd_do_fr_halt), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay controller abort command */
+cmd_des_t const cmd_des_fr_abort={
+       0, 0,
+       "frbtabort","Abort FlexRay communication immediately",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtabort\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_AbortCommunication function from the Autosar\n"
+       "specification. The command invokes the FlexRay POC command FREEZE,\n"
+       "which means that the communication is stopped immediately. On the\n"
+       "opposite side there is a frbthalt command, which stops the\n"
+       "communication after the end of the actual communication cycle. To\n"
+       "start the communication again, the frbtstart command has to be called.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtabort\n"
+       "   FlexRay node communication aborted.\n",
+       CMD_HANDLER(cmd_do_fr_abort), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay controller send wake up pattern command */
+cmd_des_t const cmd_des_fr_sendwup={
+       0, 0,
+       "frbtwup","Initiate the wake up procedure",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtwup\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_SendWUP function from the Autosar\n"
+       "specification. It initiates the wake up procedure by switching FlexRay\n"
+       "controller state machine to WAKEUP state.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtwup\n"
+       "   Wake up pattern has been sent.\n",
+       CMD_HANDLER(cmd_do_fr_sendwup), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay controller sent wake up pattern channel command */
+cmd_des_t const cmd_des_fr_setwuchannel={
+       0, 0,
+       "frbtsetwuch?","Set wake up channel",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtsetwuch<CHANNEL>\n"
+       "\n"
+       "where <CHANNEL> is a character A or B, specifying the channel.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_SetWakeupChannel function from the Autosar\n"
+       "specification. Wake up channel is the channel, where Wake Up Pattern\n"
+       "is sent. The channel can be set after the driver and controller are\n"
+       "initialized and before the communication is running. The actual\n"
+       "wake-up pattern is sent by the frbtwup command.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtsetwuchA\n"
+       "   Wake up channel has been set.\n",
+       CMD_HANDLER(cmd_do_fr_setwuchannel), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay controller get POC status command */
+cmd_des_t const cmd_des_fr_getpocstatus={
+       0, 0,
+       "frbtgetpocst","Print FlexRay POC status",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtgetpocst\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetPOCStatus function from the Autosar\n"
+       "specification. It prints the main FlexRay POC status values in the\n"
+       "form of a table. The command should be called after the frbtinit\n"
+       "command.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtgetpocst\n"
+       "   POC status:\n"
+       "   CHIHaltRequest: FALSE\n"
+       "   CHIReadyRequest: FALSE\n"
+       "   ColdstartNoise: FALSE\n"
+       "   Freeze: FALSE\n"
+       "   ErrorMode: ACTIVE\n"
+       "   SlotMode: ALL\n"
+       "   StartupState: UNDEFINED\n"
+       "   State: READY\n"
+       "   WakeupStatus: UNDEFINED\n",
+       CMD_HANDLER(cmd_do_fr_getpocstatus), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay transmit tx lpdu command */
+cmd_des_t const cmd_des_fr_transmittxlpdu={
+       0, 0,
+       "frbttransmit*","Transmit data in selected frame",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbttransmit<FRID> <DATA>\n"
+       "where\n"
+       "* <FRID> is a decimal number specifying the ID of the frame for which a buffer has been configured.\n"
+       "* <DATA> is a sequence of hexadecimal numbers separated by spaces. Each number represents one byte of the message.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_TransmitTxLPdu function from the Autosar\n"
+       "specification. The command finds the first buffer assigned to the\n"
+       "specified frame ID and copies the given data into its data section in\n"
+       "the message RAM. Transmit request is set after the data are copied, so\n"
+       "transmission starts at the next occurrence of the frame in the\n"
+       "communication cycle.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbttransmit1 12 34 56 AA BB CC\n"
+       "   Data were set for transmission.\n",
+       CMD_HANDLER(cmd_do_fr_transmittxlpdu), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay cancel tx lpdu command */
+cmd_des_t const cmd_des_fr_canceltxlpdu={
+       0, 0,
+       "frbtcanceltx*","Stop the transmission of the frame",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtcanceltx<FRID>\n"
+       "\n"
+       "where <FRID> is a decimal number specifying the ID of the frame for\n"
+       "which a buffer has been configured.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_CancelTxLPdu function from the Autosar\n"
+       "specification. The command finds all buffers assigned to the specified\n"
+       "frame ID and reconfigures them to stop transmitting data. The command\n"
+       "finishes successfully only if reconfiguration is allowed in message\n"
+       "RAM configuration (secureBuffers configuration parameter). Only TX\n"
+       "buffers and buffers not used for startup frames can be canceled.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtcanceltx3\n"
+       "   Transmission canceled.\n",
+       CMD_HANDLER(cmd_do_fr_canceltxlpdu), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay receive rx lpdu command */
+cmd_des_t const cmd_des_fr_receiverxlpdu={
+       0, 0,
+       "frbtreceive*","Receive a new message",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtreceive<FRID>\n"
+       "\n"
+       "where <FRID> is a decimal number specifying the ID of the frame for\n"
+       "which a buffer was configured.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_ReceiveRxLPdu function from the Autosar\n"
+       "specification. The command finds the first buffer assigned to the\n"
+       "specified frame ID, determines if a new message has been received and\n"
+       "reads it out of the buffer. If no message was received, \"No message\n"
+       "received\" is printed. If a new message was received, all message data\n"
+       "are printed as a hexadecimal values. If a new message was retrieved\n"
+       "from a FIFO buffer and more messages are available in it, \"More\n"
+       "messages are still in FIFO\" is printed.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtreceive0\n"
+       "   More messages are still in FIFO:\n"
+       "   Received message (32 B):\n"
+       "    ee ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n",
+       CMD_HANDLER(cmd_do_fr_receiverxlpdu), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay check TX LPdu status command */
+cmd_des_t const cmd_des_fr_checktxlpdustatus={
+       0, 0,
+       "frbtchecktx*","Print the status of the transmit buffer",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtchecktx<FRID>\n"
+       "\n"
+       "where <FRID> is a decimal number specifying the ID of the frame for\n"
+       "which a buffer has been configured.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_CheckTxLPduStatus function from the Autosar\n"
+       "specification. The command finds the first buffer assigned to the\n"
+       "specified frame ID, reads its status and prints it. The buffer can be\n"
+       "in one of the two states:\n"
+       "* Message transmission is pending, which means that the buffer has not yet sent its message in single shot mode or that it is in continuous mode.\n"
+       "* No message transmission is pending, which means that the buffer is in single shot mode and the message has already been sent.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtchecktx1\n"
+       "   Message transmission is not pending.\n",
+       CMD_HANDLER(cmd_do_fr_checktxlpdustatus), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay disable LPdu command */
+cmd_des_t const cmd_des_fr_disablelpdu={
+       0, 0,
+       "frbtdisable*","Disable the buffers assigned to the frame",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtdisable<FRID>\n"
+       "\n"
+       "where <FRID> is a decimal number specifying the ID of a frame. The\n"
+       "buffers configure for this frame will be disabled.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_DisableLPdu function from the Autosar\n"
+       "specification. The command finds all buffers assigned to the specified\n"
+       "frame ID and disables them. This means that those buffers will be\n"
+       "unavailable for the communication until their reconfiguration (which\n"
+       "is not yet implemented). Buffers used for startup frames and FIFO RX\n"
+       "buffers cannot be disabled.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtdisable3\n"
+       "   Buffer disabled.\n",
+       CMD_HANDLER(cmd_do_fr_disablelpdu), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get global time command */
+cmd_des_t const cmd_des_fr_getglobaltime={
+       0, 0,
+       "frbtglobtime","Print actual global time of the network",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtglobtime\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetGlobalTime function from the Autosar\n"
+       "specification. The command prints the time as a number of the current\n"
+       "cycle and the offset in the cycle in macroticks.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtglobtime\n"
+       "   Cycle number: 23\n"
+       "   Macrotick number: 6\n",
+       CMD_HANDLER(cmd_do_fr_getglobaltime), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get network management vector command */
+cmd_des_t const cmd_des_fr_getnmvector={
+       0, 0,
+       "frbtnmvector","Print network management vector of the node",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtnmvector\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetNmVector function from the Autosar\n"
+       "specification. It prints the values of the network management vector\n"
+       "as hexadecimal numbers.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtnmvector\n"
+       "   Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
+       CMD_HANDLER(cmd_do_fr_getnmvector), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get network management vector command */
+cmd_des_t const cmd_des_fr_nmwatch={
+       0, 0,
+       "frbtnmwatch","Watch the changes of the network managment vector in real-time",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtnmwatch\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "Reads the network management vector every 100 ms and prints it out.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtnmwatch\n"
+       "   Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
+       CMD_HANDLER(cmd_do_fr_nmwatch), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get channel status command */
+cmd_des_t const cmd_des_fr_getchannelstatus={
+       0, 0,
+       "frbtchstat","Print channel A and B status",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtchstat\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetChannelStatus function from the Autosar\n"
+       "specification.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtchstat\n"
+       "   Channel A status:\n"
+       "       aggregated channel status vSS!ValidFrame: TRUE\n"
+       "       aggregated channel status vSS!SyntaxError: FALSE\n"
+       "       aggregated channel status vSS!ContentError: FALSE\n"
+       "       aggregated channel status additional communication: FALSE\n"
+       "       aggregated channel status vSS!Bviolation: FALSE\n"
+       "       aggregated channel status vSS!TxConflict: FALSE\n"
+       "       Not used (0): FALSE\n"
+       "       Not used (0): FALSE\n"
+       "       symbol window status data vSS!ValidMTS: FALSE\n"
+       "       symbol window status data vSS!SyntaxError: FALSE\n"
+       "       symbol window status data vSS!Bviolation: FALSE\n"
+       "       symbol window status data vSS!TxConflict: FALSE\n"
+       "       NIT status data vSS!SyntaxError: FALSE\n"
+       "       NIT status data vSS!Bviolation: FALSE\n"
+       "       Not used (0): FALSE\n"
+       "       Not used (0): FALSE\n"
+       "   Channel B status:\n"
+       "       aggregated channel status vSS!ValidFrame: TRUE\n"
+       "       aggregated channel status vSS!SyntaxError: FALSE\n"
+       "       aggregated channel status vSS!ContentError: FALSE\n"
+       "       aggregated channel status additional communication: FALSE\n"
+       "       aggregated channel status vSS!Bviolation: FALSE\n"
+       "       aggregated channel status vSS!TxConflict: FALSE\n"
+       "       Not used (0): FALSE\n"
+       "       Not used (0): FALSE\n"
+       "       symbol window status data vSS!ValidMTS: FALSE\n"
+       "       symbol window status data vSS!SyntaxError: FALSE\n"
+       "       symbol window status data vSS!Bviolation: FALSE\n"
+       "       symbol window status data vSS!TxConflict: FALSE\n"
+       "       NIT status data vSS!SyntaxError: FALSE\n"
+       "       NIT status data vSS!Bviolation: FALSE\n"
+       "       Not used (0): FALSE\n"
+       "       Not used (0): FALSE\n",
+       CMD_HANDLER(cmd_do_fr_getchannelstatus), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get clock correction command */
+cmd_des_t const cmd_des_fr_getclockcorrection={
+       0, 0,
+       "frbtclkcor","Print clock correction (rate and offset)",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtclkcor\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetClockCorrection function from the Autosar\n"
+       "specification.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtclkcor\n"
+       "   Rate correction: 0\n"
+       "   Offset correction: 0\n",
+       CMD_HANDLER(cmd_do_fr_getclockcorrection), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get sync frame list command */
+cmd_des_t const cmd_des_fr_getsyncframelist={
+       0, 0,
+       "frbtgetsyncfrlist*","Print the list of sync frames transmitted on both channels via the odd and even communication cycle",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtgetsyncfrlist<LENGTH>\n"
+       "\n"
+       "where <LENGTH> is a decimal number in range 0 - 15, specifying the\n"
+       "length of the list to be printed.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetSyncFrameList function from the Autosar\n"
+       "specification.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtgetsyncfrlist2\n"
+       "   | Channel A even | channel B even | channel A odd  | channel B odd  |\n"
+       "   |----------------|----------------|----------------|----------------|\n"
+       "   | 1              | 1              | 1              | 1              |\n"
+       "   | 2              | 2              | 2              | 2              |\n"
+       "   |----------------|----------------|----------------|----------------|\n",
+       CMD_HANDLER(cmd_do_fr_getsyncframelist), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get sync frame list command */
+cmd_des_t const cmd_des_fr_getwakeuprxstatus={
+       0, 0,
+       "frbtgetwurxstat","Prints whether the wake up pattern has been or has not been received",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtgetwurxstat\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetWakeupRxStatus function from the Autosar\n"
+       "specification. The status of the wake up receiving is bitcoded in the\n"
+       "controller. This command decodes and prints it in a readable format.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtgetwurxstat\n"
+       "   Wake up pattern was not yet received on channel A.\n"
+       "   Wake up pattern was not yet received on channel B.\n",
+       CMD_HANDLER(cmd_do_fr_getwakeuprxstatus), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay set absolute timer command */
+cmd_des_t const cmd_des_fr_settimer={
+       0, 0,
+       "frbtsettimer*","Set and start timer",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtsettimer<TMID> <CYCLE> <OFFSET>\n"
+       "where\n"
+       "* <TMID> is a number (0, 1) specifying the timer.\n"
+       "* <CYCLE> is a 7-bit number (0 - 127) specifying the set of cycles, in which timer interrupt should be requested. The first set bit determines the period (1, 2, ..., 64) and the lower bits determine the offset in cycles within the period.\n"
+       "* <OFFSET> is a decimal number (0 - 16383) specifying the offset in macroticks, where precisely in the cycle should be the timer interrupt requested.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command is similar to Fr_SetAbsoluteTimer function from the\n"
+       "Autosar specification. The difference is that the command allows to\n"
+       "specify a set of cycles, not only one of 64 cycles. It sets the timer\n"
+       "selected by the parameter and enables it.\n"
+       "\n"
+       "Before using this command, FlexRay communication has to be started\n"
+       "(see frbtstart).\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtsettimer0 32 50\n"
+       "   Timer was set for every 32-th cycle, offset 0, macrotick 50\n"
+       "   --> frbtsettimer0 31 50\n"
+       "   Timer was set for every 16-th cycle, offset 15, macrotick 50\n"
+       "   --> frbtsettimer0 0x42 0\n"
+       "   Timer was set for every 64-th cycle, offset 2, macrotick 0\n",
+       CMD_HANDLER(cmd_do_fr_settimer), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay cancel absolute timer command */
+cmd_des_t const cmd_des_fr_canceltimer={
+       0, 0,
+       "frbtcanceltimer*","Stop the timer",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtcanceltimer<TMID>\n"
+       "where <TMID> is a number (0 or 1) specifying the timer.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_CancelAbsoluteTimer function from the\n"
+       "Autosar specification. It stops the timer selected by the parameter.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtcanceltimer0\n"
+       "   Timer was canceled.\n",
+       CMD_HANDLER(cmd_do_fr_canceltimer), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay absolute timer irq manipulation command */
+cmd_des_t const cmd_des_fr_timerirq={
+       0, 0,
+       "frbttimerirq*","Perform selected action on the timer IRQ",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer\n"
+       "   frbttimerirq<TMID> - Get timer IRQ status\n"
+       "\n"
+       "where\n"
+       "* <TMID> is a number (0, 1) specifying the timer.\n"
+       "* where <ACTION> is a string specifying the action  to be performed on the selected timer IRQ.\n"
+       "\n"
+       "<ACTIONS> can be one of:\n"
+       "* EN - Enable the IRQ on the selected timer\n"
+       "* DIS - Disable the IRQ on the selected timer\n"
+       "* ACK - Acknowledge the IRQ on the selected timer (reset flag in the register).\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_EnableAbsoluteTimerIRQ,\n"
+       "Fr_AckAbsoluteTimerIRQ, Fr_DisableAbsoluteTimerIRQ and\n"
+       "Fr_GetAbsoluteTimerIRQStatus functions from the Autosar specification.\n"
+       "It masks or demasks the IRQ for the timer, or acknowledges the\n"
+       "interrupt request. If no action is specified it prints whether the IRQ\n"
+       "is pending for the timer.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbttimerirq0\n"
+       "   IRQ = FALSE\n"
+       "\n"
+       "   --> frbttimerirq0 EN\n"
+       "   OK\n",
+       CMD_HANDLER(cmd_do_fr_timerirq), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get version info command */
+cmd_des_t const cmd_des_fr_getversioninfo={
+       0, 0,
+       "frbtversion","Print FlexRay driver version information",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtversion\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_GetVersionInfo function from the Autosar\n"
+       "specification.\n"
+       "It reads and prints the information about vendor, module and version of\n"
+       "the FlexRay driver\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtversion\n"
+       "   vendorID: 0xAAAA\n"
+       "   moduleID: 0xBBBB\n"
+       "   sw_major_version: 0x1\n"
+       "   sw_minor_version: 0x2\n"
+       "   sw_patch_version: 0x4\n",
+       CMD_HANDLER(cmd_do_fr_getversioninfo), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay get controller configuration command */
+cmd_des_t const cmd_des_fr_readcconfig={
+       0, 0,
+       "frbtccconfig*","Print value of a FlexRay cluster and node configuration parameter",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtccconfig<INDEX>\n"
+       "\n"
+       "where <INDEX> is an identifier of the parameter.\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_ReadCCConfig function from the Autosar\n"
+       "specification. The driver stores the configuration parameters as an\n"
+       "array. Each parameter can be indexed and returned by this command. See\n"
+       "Autosar specification of the FlexRay driver\n"
+       "(http://www.autosar.org/download/R4.1/AUTOSAR_SWS_FlexRayDriver.pdf),\n"
+       "section 8.2.1 for parameter indexes.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtccconfig1\n"
+       "   Value = 0x1\n",
+       CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
+};
+
+/** Command descriptor for FlexRay reconfigure buffer command */
+cmd_des_t const cmd_des_fr_reconfigure_buffer={
+       0, 0,
+       "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
+       "=== Command syntax ===\n"
+       "\n"
+       "   frbtreconfigurebuf id<ID> slot<SLOT> <CHN> cyc<CYC> max<MAX>\n"
+       "where\n"
+       "* <ID> is a number specifying a slot, where the buffer is currently communicating,\n"
+       "* <SLOT> is a number, where buffer will be communicating after the reconfiguration,\n"
+       "* <CHN> is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
+       "* <CYC> is the cycle set when to send the buffer,\n"
+       "* <MAX> is the number determining the maximum payload (in hald-words).\n"
+       "\n"
+       "=== Description ===\n"
+       "\n"
+       "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
+       "specification. It reconfigures specified buffer to communicate in\n"
+       "different slot.\n"
+       "The reconfiguration must be allowed in node configuration parameter\n"
+       "secureBuffers. Buffers used for synchronization or assigned to the FIFO\n"
+       "are not reconfigurable.\n"
+       "\n"
+       "=== Example ===\n"
+       "\n"
+       "   --> frbtreconfigurebuf id2 slot3 AB 0 9\n"
+       "   frbtreconfigurebuf id2 slot3 AB 0 9\n",
+       CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
+};
+
+
+/** List of commands for flexRay, defined as external */
+cmd_des_t const *cmd_list_fr_basic_test[]={
+  &cmd_des_fr_user_config,
+  &cmd_des_fr_config_buffer,
+  &cmd_des_fr_config_fifo,
+  &cmd_des_fr_init,
+  &cmd_des_fr_start,
+  &cmd_des_fr_allslots,
+  &cmd_des_fr_halt,
+  &cmd_des_fr_abort,
+  &cmd_des_fr_sendwup,
+  &cmd_des_fr_setwuchannel,
+  &cmd_des_fr_getpocstatus,
+  &cmd_des_fr_transmittxlpdu,
+  &cmd_des_fr_canceltxlpdu,
+  &cmd_des_fr_receiverxlpdu,
+  &cmd_des_fr_checktxlpdustatus,
+  &cmd_des_fr_disablelpdu,
+  &cmd_des_fr_getglobaltime,
+  &cmd_des_fr_getnmvector,
+  &cmd_des_fr_nmwatch,
+  &cmd_des_fr_getchannelstatus,
+  &cmd_des_fr_getclockcorrection,
+  &cmd_des_fr_getsyncframelist,
+  &cmd_des_fr_getwakeuprxstatus,
+  &cmd_des_fr_settimer,
+  &cmd_des_fr_canceltimer,
+  &cmd_des_fr_timerirq,
+  &cmd_des_fr_getversioninfo,
+  &cmd_des_fr_readcconfig,
+  &cmd_des_fr_reconfigure_buffer,
+  NULL
+};
diff --git a/commands/cmd_fr_basic_test.h b/commands/cmd_fr_basic_test.h
new file mode 100644 (file)
index 0000000..7fa614a
--- /dev/null
@@ -0,0 +1,19 @@
+/**
+ * FlexRay Communication RPP API header file.
+ *
+ * @file cmd_fr_basic_test.h
+ *
+ * @copyright Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * @author Michal Horn <hornmich@fel.cvut.cz>
+ */
+
+
+#ifndef CMD_FR_BASIC_TEST_H_
+#define CMD_FR_BASIC_TEST_H_
+#include "cmdproc.h"
+
+extern cmd_des_t const *cmd_list_fr_basic_test[];
+
+
+#endif /* CMD_FR_BASIC_TEST_H_ */
index 11cde38d70fc78d0ab7395220529a4007d239a13..baa285522669200a4a077b97fc66c77a1513e60a 100644 (file)
  *  - Sending test data on FRAY
  *  - Receiving test data on FRAY
  *
- *  There are FlexRay test commands, which creates node A and node B, wait for network to be started and than
- *  messages are being transmitted.
- *  Node A transmits short message in frame 1 from buffer 0 and longer message in frame 9 from buffer 9.
- *  Node B transmits short message in frame 2 from buffer 0 and longer message in frame 10 from buffer 10.
- *  Node A receives short message from frame 2 to buffer 1 and longer message from frame 10 to buffer 10.
- *  Node B receives short message from frame 1 to buffer 1 and longer message from frame 9 to buffer 9.
- *  Commands are counting number of received messages, number of errors in messages and they print results at the end.
+ *  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 "drv/fray.h"
 #include "cmdproc_utils.h"
 #include "hal/hal.h"
+#include "cmdproc.h"
 
 /**
- *     Fill  data structure with global configuration parameters.
- *     @param  Fr_ConfigPtr    Pointer to data structure to be filled
+ * This structure contains global FlexRay configuration.
+ * All nodes in the network have to use the same values for
+ * all parameters of this structure.
  */
-void configure_global_parameters(cfg *Fr_ConfigPtr) {
-       // GTUs (Global Time Unit ), PRTC configuration
-       Fr_ConfigPtr->gtu1  = 0x00036B00; // pMicroPerCycle = 224000d = 36B00h (has to be x40 of MacroPerCyle)
-                                         // [19:0]: These bits configure the duration of the communication cycle in microticks
-       Fr_ConfigPtr->gtu2  = 0x000F15E0; // gSyncodeMax = Fh, gMacroPerCycle = 5600d = 15E0h  (cycle period, 5.6us)
-                                         //[13:0]: Macrotick per cycle (in macroticks). These bits configure the duration of one communication cycle
-                                         //        in macroticks. The cycle length must be identical in all nodes of a cluster.
-                                         //[19:16]: Sync node max (in frames). These bits configure the maximum number of frames within a cluster
-                                         //         with sync frame indicator bit SYN set. The number of frames must be identical in all nodes of a cluster.
-       Fr_ConfigPtr->gtu3  = 0x00061818; // gMacroInitialOffset = 6h, pMicroInitialOffset = 24d = 18h
-       Fr_ConfigPtr->gtu4  = 0x0AE40AE3; // gOffsetCorrectionStart - 1 = 2788d = AE4h, gMacroPerCycle - gdNIT - 1 = 2787d = AE3h
-       Fr_ConfigPtr->gtu5  = 0x33010303; // pDecodingCorrection = 51d = 33h, pClusterDriftDamping = 1h, pDelayCompensation = 3h
-       Fr_ConfigPtr->gtu6  = 0x01510081; // pdMaxDrift = 337d = 151h, pdAcceptedStartupRange = 129d = 81h
-
-       Fr_ConfigPtr->gtu7  = 0x00080056; // gNumberOfStaticSlots = 8h, gdStaticSlot = 86d = 56h
-                                         // [25:16]: These bits configure the number of static slots in a cycle.
-                                      // [9:0]: These bits configure the duration of a static slot (macroticks).
-
-       Fr_ConfigPtr->gtu8  = 0x015A0004; // gNumberOfMinislots = 346d = 15Ah, gdMinislot = 4h
-                                         // [28:16]:These bits configure the number of minislots in the dynamic segment of a cycle
-                                         // [5:0]: These bits configure the duration of a minislot
-
-       Fr_ConfigPtr->gtu9  = 0x00010204; // gdDynamicSlotIdlePhase = 1, gdMinislotActionPointOffset = 2, gdActionPointOffset = 4h
-       Fr_ConfigPtr->gtu10 = 0x015100CD; // pRateCorrectionOut = 337d = 151h, pOffsetCorrectionOut = 205d = CDh
-       Fr_ConfigPtr->gtu11 = 0x00000000; // pExternRateCorrection = 0, pExternOffsetCorrection = 0, no ext. clk. corr.
-
-
-       Fr_ConfigPtr->succ2 = 0x0F036DA2; // gListenNoise = Fh, pdListenTimeout = 224674d = 36DA2h
-                                                                               //LTN [27:24]: Listen timeout noise. Configures the upper limit for the startup and wakeup listen timeout in the
-                                                                               //presence of noise. Must be identical in all nodes of a cluster.
-                                                                               //The wakeup / startup noise timeout is calculated as follows: LT[20:0] ï¿½ (LTN[3:0] + 1)
-                                           // LT[20:0]: Listen timeout. Configures the upper limit of the startup and wakeup listen timeout.
-
-       Fr_ConfigPtr->succ3 = 0x000000FF; // gMaxWithoutClockCorrectionFatal = Fh , passive = Fh
-                                                                               //WCF[7:4]: Maximum without clock correction fatal. These bits define the number of consecutive even/odd
-                                                                               //cycle pairs with missing clock correction terms that will cause a transition from
-                                                                               //NORMAL_ACTIVE or NORMAL_PASSIVE state.
-
-                                                                               //WCP[3:0]: Maximum without clock correction passive. These bits define the number of consecutive
-                                                                               //even/odd cycle pairs with missing clock correction terms that will cause a transition from
-                                                                               //NORMAL_ACTIVE to NORMAL_PASSIVE to HALT state.
-
-       Fr_ConfigPtr->prtc1 = 0x084C000A; // pWakeupPattern = 2h, gdWakeupSymbolRxWindow = 76d, BRP = 0, gdTSSTransmitter = Ah
-                                                                               //BRP[15:14]; Baud rate prescaler. These bits configure the baud rate on the FlexRay bus. The baud rates
-                                                                               //listed below are valid with a sample clock of 80 MHz. One bit time always consists of 8 samples
-                                                                               //independent of the configured baud rate.  =0 ->10Mb/s
-
-       Fr_ConfigPtr->prtc2 = 0x3CB41212; // gdWakeupSymbolTxLow = 60d, gdWakeupSymbolTxIdle = 180d, gdWakeupSymbolRxLow = 18d, gdWakeupSymbolRxIdle = 18d
-
-       Fr_ConfigPtr->mhdc  = 0x010D0009; // pLatestTransmit = 269d = 010Dh, gPayloadLengthStatic = 9h
-                                                                               //Start of latest transmit (in minislots). These bits configure the maximum minislot value allowed
-                                                                               //minislots before inhibiting new frame transmissions in the Dynamic Segment of the cycle.
-                                           //[7:0]: Static frame data length.
-
-       Fr_ConfigPtr->mrc   = 0x00174004; // LCB=23d, FFB=64d, FDB=4d (0..3 static, 4..23 dyn., 0 fifo)
-}
+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
+};
 
 /**
- *     Configure FlexRay as node A.
- *      - Clear message RAMS
- *      - Configure global parameters
- *      - Initialize buffers
- *      - Go to ready state
- *      - Enable interrupts
- *     This function prepares FlexRay to send data in Frames 1 and 9 and to receive data from frames 2 and 10.
- *     Frame 1 is synchronization frame.
- *     @return SUCCESS or FAILURE when error
+ * This structure contains local configuration of the FlexRay node A.
+ * That is the node that transmits messages to the node B.
  */
-int config_init_a() {
-       cfg Fr_Config;
-
-       if (fray_clear_msg_ram() != SUCCESS) {
-               return FAILURE;
-       }
+static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
+       .pAllowHaltDueToClock = 0,
+       .pAllowPassiveToActive = FALSE,
+       .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
+};
 
-       fray_wait_for_POC_ready();
-       configure_global_parameters(&Fr_Config);
-       fray_init(&Fr_Config);
-       fray_config_buffer(0, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX|FRAY_BUF_SYNC_EN|FRAY_BUF_SFI_EN, 0, 1, 9, 0x80);
-       fray_config_buffer(2, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 2, 9, 0x85);
-       fray_config_buffer(9, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX, 0, 9, 127, 0x200);
-       fray_config_buffer(10, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 10, 127, 0x240);
+/**
+ * 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 = FALSE,
+               .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
+};
 
-       if (fray_controler_init() != SUCCESS) {
-               return FAILURE;
-       }
+/**
+ * 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
+};
 
-       fray_init_irq();
-       return SUCCESS;
-}
+/**
+ * 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
+};
 
 /**
- *     Loads data into TX buffers for FlexRay node A.
+ * 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.
  */
-void start_transmit_node_a() {
-       uint32_t data[6];
-
-       fray_wait_for_new_cycle();
-
-       // write payload for buffers
-       // buffer #1
-       data[0] = 0x00000001;
-       data[1] = 0x000000FF;
-       fray_buffer_set_data(0, data, 2);
-
-       // buffer #9
-       data[0] = 0xFF;                  // Data 1
-       data[1] = 0xFFFF;        // Data 2
-       data[2] = 0xFFFFFF;      // Data 3
-       data[3] = 0xFFFFFFFF;    // Data 4
-       data[4] = 0xFFFFFF00;    // Data 5
-       data[5] = 0xFFFF0000;    // Data 6
-       fray_buffer_set_data(9, data, 6);
-}
+static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
+               {
+                       .channel = FR_CHANNEL_AB,
+                       .cycleCounterFiltering = 0,
+                       .isTx = TRUE,
+                       .maxPayload = 9,
+                       .msgBufferInterrupt = TRUE,
+                       .payloadPreambleIndicatorTr = FALSE,
+                       .rejectNullFrames = FALSE,
+                       .rejectStaticSegment = FALSE,
+                       .singleTransmit = FALSE,
+                       .slotId = 1
+               },
+               {
+                       .channel = FR_CHANNEL_AB,
+                       .cycleCounterFiltering = 0,
+                       .isTx = TRUE,
+                       .maxPayload = 9,
+                       .msgBufferInterrupt = TRUE,
+                       .payloadPreambleIndicatorTr = FALSE,
+                       .rejectNullFrames = FALSE,
+                       .rejectStaticSegment = FALSE,
+                       .singleTransmit = TRUE,
+                       .slotId = 3
+               }
+};
 
 /**
- *     Check if some message was received on message buffer 2 of FlexRay node A.
- *     If yes, get the message and check if it fits the pattern
- *     @return -1 if no message was received
- *                     0 if message was received and is correct
- *                     1 if message was received and is incorrect
+ * 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.
  */
-int receive_node_a() {
-       uint32_t data[6];
-       int error = -1; // No message received
-
-       // check if a message is received in buffer 2 from node B
-    if (fray_buffer_message_received(2)) {
-       fray_buffer_get_data(2, data, 2);
-       if (data[1] != 0x87654321)
-               error = 1;
-       else
-               error = 0;
+static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 2
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 9,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = TRUE,
+               .slotId = 3
        }
-       return error;
-}
+};
 
 /**
- *     Configure FlexRay as node B.
- *      - Clear message RAMS
- *      - Configure global parameters
- *      - Initialize buffers
- *      - Go to ready state
- *      - Enable interrupts
- *     This function prepares FlexRay to send data in Frames 2 and 10 and to receive data from frames 1 and 9.
- *     Frame 2 is synchronization frame.
- *     @return SUCCESS or FAILURE when error
+ * Unifying configuration structure for the node A.
  */
-int config_init_b() {
-       cfg Fr_Config;
-
-       if (fray_clear_msg_ram() != SUCCESS) {
-               return FAILURE;
-       }
+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
+};
 
-       fray_wait_for_POC_ready();
-       configure_global_parameters(&Fr_Config);
-       fray_init(&Fr_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
+};
 
-       fray_config_buffer(0, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX|FRAY_BUF_SYNC_EN|FRAY_BUF_SFI_EN, 0, 2, 9, 0x85);
-       fray_config_buffer(1, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 1, 9, 0x80);
-       fray_config_buffer(10, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX, 0, 10, 127, 0x240);
-       fray_config_buffer(9, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 9, 127, 0x200);
+/**
+ *     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;
 
-       if (fray_controler_init() != SUCCESS) {
-               return FAILURE;
+       // Write payload for the buffer
+       for (i = 0; i < 18; i++) {
+               data[i] = i;
        }
-       fray_init_irq();
-
-       return SUCCESS;
+       return rpp_fr_transmit_lpdu(0, 3, data, 18);
 }
 
 /**
- *     Loads data into TX buffers for FlexRay node B.
+ *     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
  */
-void start_transmit_node_b() {
-       uint32_t data[6];
-
-       fray_wait_for_new_cycle();
-
-       // write payload for buffers
-       // buffer #2
-       data[0] = 0x12345678;
-       data[1] = 0x87654321;
-       fray_buffer_set_data(0, data, 2);
-
-       // buffer #10
-       data[0] = 0xFF;                  // Data 1
-       data[1] = 0xFFFF;        // Data 2
-       data[2] = 0xFFFFFF;      // Data 3
-       data[3] = 0xFFFFFFFF;    // Data 4
-       data[4] = 0xFFFFFF00;    // Data 5
-       data[5] = 0xFFFF0000;    // Data 6
-       fray_buffer_set_data(10, data, 6);
-}
+int check_message(const uint8_t *data) {
+       int i;
 
-/**
- *     Check if some message was received on message buffer 1 of FlexRay node B.
- *     If yes, get the message and check if it fits the pattern
- *     @return -1 if no message was received
- *                     0 if message was received and is correct
- *                     1 if message was received and is incorrect
- */
-int receive_node_b() {
-       uint32_t data[6];
-       int error = -1; // No message received
-
-       // check if a message is received in buffer 2 from node B
-    if (fray_buffer_message_received(1) != 0) {
-       fray_buffer_get_data(1, data, 2);
-       if (data[1] != 0x000000FF)
-               error = 1;
-       else
-               error = 0;
+       for (i = 0; i < 18; i++) {
+               if (data[i] != i) {
+                       return 1;
+               }
        }
-       return error;
+       return 0;
 }
 
+
 /**
  *     @brief  Get FlexRay status in human readable form
  *
@@ -295,16 +318,16 @@ int cmd_do_fray_status(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
        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 (fray_spi_transfer(pin) != 0) return -CMDERR_BADDIO;
+       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, fray_spi_get_cmd(pin), &numFieldDesc);
+       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 = fray_spi_response(pin);
+       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++) {
@@ -314,7 +337,7 @@ int cmd_do_fray_status(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[
 }
 
 /**
- *     @brief  Start sending and receiving data on as node A
+ *     @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
@@ -325,49 +348,73 @@ 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;
-       int ret;
+       uint32_t count = 100;
+       Fr_TxLPduStatusType status;
+       Fr_POCStatusType poc_status;
+
+       if (param[1] && sscanf(param[1], "%d", &count) != 1)
+               return -CMDERR_BADPAR;
 
-       if (config_init_a() != SUCCESS) {
-               rpp_sci_printf("Fray node A initialization failed.\r\n");
-               return 0;
+    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 node A initialized.\r\n");
+       rpp_sci_printf("Fray control node initialized.\r\n");
        rpp_sci_printf("Waiting for network connection...\r\n");
 
-       if (fray_startup_procedure(1) != SUCCESS) {
-               rpp_sci_printf("Integration to the network failed.\r\n");
-               return 0;
+       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");
-       start_transmit_node_a();
-
-       for (i = 0; i < 100; i++){
-           // wait for cycle start interrupt flag
-               fray_wait_for_new_cycle();
-               ret = receive_node_a();
-               if (ret == 0) {
-                       rpp_sci_printf("O");
-                       msg_cnt++;
-               }
-               else if (ret == 1) {
+       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++;
-                       msg_cnt++;
                }
+               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\nReceived %d messages with %d errors.\r\n", msg_cnt, error);
-       if (fray_halt() != SUCCESS) {
+       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\r\n");
+               rpp_sci_printf("FlexRay halted, reset the board to make FlexRay usable again.\r\n");
        }
        return 0;
 }
 
 /**
- *     @brief  Start sending and receiving data on as node B
+ *     @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
@@ -379,39 +426,63 @@ 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;
-       int ret;
+       uint32_t count = 100;
+
+       if (param[1] && sscanf(param[1], "%d", &count) != 1)
+               return -CMDERR_BADPAR;
 
-       if (config_init_b() != SUCCESS) {
-               rpp_sci_printf("Fray node B initialization failed.\r\n");
-               return 0;
+    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 node B initialized.\r\n");
+       rpp_sci_printf("Fray control node initialized.\r\n");
        rpp_sci_printf("Waiting for network connection...\r\n");
 
-       if (fray_startup_procedure(1) != SUCCESS) {
-               rpp_sci_printf("Integration to the network failed.\r\n");
-               return 0;
+       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");
-       start_transmit_node_b();
-
-       for (i = 0; i < 100; i++){
-           // wait for cycle start interrupt flag
-               fray_wait_for_new_cycle();
-               ret = receive_node_b();
-               if (ret == 0) {
+       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 if (ret == 1) {
+               else {
                        rpp_sci_printf("X");
                        error++;
                        msg_cnt++;
                }
        }
        rpp_sci_printf("\r\nReceived %d messages with %d errors.\r\n", msg_cnt, error);
-       if (fray_halt() != SUCCESS) {
+       if (rpp_fr_halt_communication(0) != SUCCESS) {
                rpp_sci_printf("FlexRay HALT command failed, please reset the board to stop transmission.\r\n");
        }
        else {
@@ -450,20 +521,24 @@ cmd_des_t const cmd_des_test_fray_a={
            "fraytestA","Run the FlexRay test as A node",
            "=== Command syntax ===\n"
            "\n"
-           "   fraytestA\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 and receiving\n"
-           "100 messages. The command should be run with two devices connected by\n"
-           "a FlexRay bus and the second device should be running the fraytestB\n"
-           "command (it is necessary to run both commands shortly after each\n"
-           "other).\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 receives a message a character is printed. O means\n"
-           "that the message was received correctly, X signal an reception error.\n"
-           "The number of RX errors and successfully received messages is\n"
-           "maintained during the test and printed at the end.\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
 };
 
@@ -473,20 +548,24 @@ cmd_des_t const cmd_des_test_fray_b={
            "fraytestB","Run the FlexRay test as B node",
            "=== Command syntax ===\n"
            "\n"
-           "   fraytestB\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 sending and receiving\n"
-           "100 messages. The command should be run with two devices connected by\n"
-           "a FlexRay bus and the second device should be running the fraytestA\n"
-           "command (it is necessary to run both commands shortly after each\n"
-           "other).\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 signal an reception error.\n"
-           "The number of RX errors and successfully received messages is\n"
-           "maintained during the test and printed at the end.\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
 };
 
index 3691ffe3e0f98085942f0cbbf0bade6ef0f99e44..fefd72ffc7a619d4e8740e926bb11fbe60f6474b 100644 (file)
@@ -130,8 +130,9 @@ cmd_des_t const cmd_des_hbr_enable = {
     "the H-bridge chip is set, the watchdog reset task is started and the\n"
     "PWM is configured with the specified period and duty cycle 0%.\n"
     "\n"
-    "If the period is lower than one, the default frequency of 18kHz is\n"
-    "used instead. This command should be called before any other command\n"
+    "If the period is zero, the default frequency of 18kHz is\n"
+    "used instead. Minimum period is 50. This command should be\n"
+    "called before any other command\n"
     "starting with hbr is used. If H-bridge is already enabled, an error is\n"
     "printed.\n"
     "\n"
index 487df6af2a2944c03b3e525c1168939ca8c0f881..e5eafbe8f9219722b04b01723a00b4ee25de3750 100644 (file)
@@ -129,7 +129,7 @@ int cmd_do_hout_pwm(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
            if (sscanf(p, "%d %d %1s", &values[0], &values[1], &spareParams) != 2) {
                return -CMDERR_BADPAR;
            }
-               if (values[0] < 1 || values[1] > 100) return -CMDERR_BADPAR;
+               if (values[1] > 100) return -CMDERR_BADPAR;
                hout_pwm_set_signal(pin, (double)values[0], values[1]);
            return 0;
          }
index 94414e21937892d1bde03b411d9d46ae8faf9015..d6b470d8e1faf8655f6c09fa5ef5860171632dea 100644 (file)
  * File : cmd_pin.c
  *
  * Abstract:
- *             Example commands for motor controlling over FlexRay. First board has connected control panel
- *     with two buttons and variable resistor, second board has DC motor connected to H-bridge. Both
- *     boards are connected by FlexRay and user can drive motor by the control panel (speed, direction
- *     and enabling).
+ *             Example commands for motor controlling over FlexRay. The first board has connected a control panel
+ *     with two buttons and variable resistor, the second board has a DC motor connected to the H-bridge.
+ *     Both boards are connected by the FlexRay bus and user can drive the motor by the control panel
+ *     (speed, direction and enabling).
  */
 
 #include "cmd_motor_example.h"
@@ -35,6 +35,7 @@
 #include "rpp/rpp.h"
 #include "hal/hal.h"
 #include "drv/drv.h"
+#include "cmdproc.h"
 
 #define ADC_MAX_VALUE 0x0983
 #define RX_ERROR_MAX 100
 #define DIRECTION_DEBOUNCE_TIME        2
 
 /**
- *     Fill  data structure with global configuration parameters.
- *     @param  Fr_ConfigPtr    Pointer to data structure to be filled
+ * This structure contains global FlexRay configuration.
+ * All nodes in the network have to use the same values for
+ * all parameters of this structure.
  */
-void configure_fray_global_parameters(cfg *Fr_ConfigPtr) {
-       // GTUs (Global Time Unit ), PRTC configuration
-       Fr_ConfigPtr->gtu1  = 0x00036B00; // pMicroPerCycle = 224000d = 36B00h (has to be x40 of MacroPerCyle)
-                                         // [19:0]: These bits configure the duration of the communication cycle in microticks
-       Fr_ConfigPtr->gtu2  = 0x000F15E0; // gSyncodeMax = Fh, gMacroPerCycle = 5600d = 15E0h  (cycle period, 5.6us)
-                                         //[13:0]: Macrotick per cycle (in macroticks). These bits configure the duration of one communication cycle
-                                         //        in macroticks. The cycle length must be identical in all nodes of a cluster.
-                                         //[19:16]: Sync node max (in frames). These bits configure the maximum number of frames within a cluster
-                                         //         with sync frame indicator bit SYN set. The number of frames must be identical in all nodes of a cluster.
-       Fr_ConfigPtr->gtu3  = 0x00061818; // gMacroInitialOffset = 6h, pMicroInitialOffset = 24d = 18h
-       Fr_ConfigPtr->gtu4  = 0x0AE40AE3; // gOffsetCorrectionStart - 1 = 2788d = AE4h, gMacroPerCycle - gdNIT - 1 = 2787d = AE3h
-       Fr_ConfigPtr->gtu5  = 0x33010303; // pDecodingCorrection = 51d = 33h, pClusterDriftDamping = 1h, pDelayCompensation = 3h
-       Fr_ConfigPtr->gtu6  = 0x01510081; // pdMaxDrift = 337d = 151h, pdAcceptedStartupRange = 129d = 81h
-
-       Fr_ConfigPtr->gtu7  = 0x00080056; // gNumberOfStaticSlots = 8h, gdStaticSlot = 86d = 56h
-                                         // [25:16]: These bits configure the number of static slots in a cycle.
-                                      // [9:0]: These bits configure the duration of a static slot (macroticks).
-
-       Fr_ConfigPtr->gtu8  = 0x015A0004; // gNumberOfMinislots = 346d = 15Ah, gdMinislot = 4h
-                                         // [28:16]:These bits configure the number of minislots in the dynamic segment of a cycle
-                                         // [5:0]: These bits configure the duration of a minislot
-
-       Fr_ConfigPtr->gtu9  = 0x00010204; // gdDynamicSlotIdlePhase = 1, gdMinislotActionPointOffset = 2, gdActionPointOffset = 4h
-       Fr_ConfigPtr->gtu10 = 0x015100CD; // pRateCorrectionOut = 337d = 151h, pOffsetCorrectionOut = 205d = CDh
-       Fr_ConfigPtr->gtu11 = 0x00000000; // pExternRateCorrection = 0, pExternOffsetCorrection = 0, no ext. clk. corr.
-
-
-       Fr_ConfigPtr->succ2 = 0x0F036DA2; // gListenNoise = Fh, pdListenTimeout = 224674d = 36DA2h
-                                                                               //LTN [27:24]: Listen timeout noise. Configures the upper limit for the startup and wakeup listen timeout in the
-                                                                               //presence of noise. Must be identical in all nodes of a cluster.
-                                                                               //The wakeup / startup noise timeout is calculated as follows: LT[20:0] ï¿½ (LTN[3:0] + 1)
-                                           // LT[20:0]: Listen timeout. Configures the upper limit of the startup and wakeup listen timeout.
-
-       Fr_ConfigPtr->succ3 = 0x000000FF; // gMaxWithoutClockCorrectionFatal = Fh , passive = Fh
-                                                                               //WCF[7:4]: Maximum without clock correction fatal. These bits define the number of consecutive even/odd
-                                                                               //cycle pairs with missing clock correction terms that will cause a transition from
-                                                                               //NORMAL_ACTIVE or NORMAL_PASSIVE state.
-
-                                                                               //WCP[3:0]: Maximum without clock correction passive. These bits define the number of consecutive
-                                                                               //even/odd cycle pairs with missing clock correction terms that will cause a transition from
-                                                                               //NORMAL_ACTIVE to NORMAL_PASSIVE to HALT state.
-
-       Fr_ConfigPtr->prtc1 = 0x084C000A; // pWakeupPattern = 2h, gdWakeupSymbolRxWindow = 76d, BRP = 0, gdTSSTransmitter = Ah
-                                                                               //BRP[15:14]; Baud rate prescaler. These bits configure the baud rate on the FlexRay bus. The baud rates
-                                                                               //listed below are valid with a sample clock of 80 MHz. One bit time always consists of 8 samples
-                                                                               //independent of the configured baud rate.  =0 ->10Mb/s
-
-       Fr_ConfigPtr->prtc2 = 0x3CB41212; // gdWakeupSymbolTxLow = 60d, gdWakeupSymbolTxIdle = 180d, gdWakeupSymbolRxLow = 18d, gdWakeupSymbolRxIdle = 18d
-
-       Fr_ConfigPtr->mhdc  = 0x010D0006; // pLatestTransmit = 269d = 010Dh, gPayloadLengthStatic = 9h
-                                                                               //Start of latest transmit (in minislots). These bits configure the maximum minislot value allowed
-                                                                               //minislots before inhibiting new frame transmissions in the Dynamic Segment of the cycle.
-                                           //[7:0]: Static frame data length.
-
-       Fr_ConfigPtr->mrc   = 0x00174004; // LCB=23d, FFB=64d, FDB=4d (0..3 static, 4..23 dyn., 0 fifo)
-}
-
+static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
+       .gColdStartAttempts = 0x2,
+       .gListenNoise = 0xF,
+       .gMacroPerCycle = 0x15E0,       // (cycle period, 5.6us)
+       .gMaxWithoutClockCorrectionFatal = 0xF,
+       .gMaxWithoutClockCorrectionPassive = 0xF,
+       .gNetworkManagementVectorLength = 12,
+       .gNumberOfMinislots = 0x15A,
+       .gNumberOfStaticSlots = 0x8,
+       .gOffsetCorrectionStart = 0xAE4,
+       .gPayloadLengthStatic = 0x6,
+       .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
+};
 
 /**
- *     Configure FlexRay as control node.
- *      - Clear message RAMS
- *      - Configure global parameters
- *      - Initialize buffers
- *      - Go to ready state
- *      - Enable interrupts
- *     This function prepares FlexRay to send data in Frame 1.
- *     Frame 1 is synchronization frame.
- *     @return SUCCESS or FAILURE when error
+ * This structure contains local configuration of the FlexRay node for
+ * the control panel reading and sending the data.
  */
-int config_init_fray_control() {
-       cfg Fr_Config;
-
-       if (fray_clear_msg_ram() != SUCCESS) {
-               return FAILURE;
-       }
-
-       fray_wait_for_POC_ready();
-       configure_fray_global_parameters(&Fr_Config);
-       fray_init(&Fr_Config);
+static Fr_TMS570LS_NodeConfigType Fr_node_control_config = {
+       .pAllowHaltDueToClock = 0,
+       .pAllowPassiveToActive = FALSE,
+       .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
+};
 
-       fray_config_buffer(0, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX|FRAY_BUF_SYNC_EN|FRAY_BUF_SFI_EN, 0, 1, 6, 0x80);
-       fray_config_buffer(2, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 2, 6, 0x85);
+/**
+ * This structure contains local configuration of the FlexRay node for
+ * the motor driving. This node receives control data from the FlexRay
+ * and configures the H-bridge.
+ */
+static Fr_TMS570LS_NodeConfigType Fr_node_motor_config = {
+               .pAllowHaltDueToClock = 0,
+               .pAllowPassiveToActive = FALSE,
+               .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
+};
 
-       if (fray_controler_init() != SUCCESS) {
-               return FAILURE;
-       }
+/**
+ * Message RAM configuration for the node reading the control panel.
+ */
+static Fr_TMS570LS_MsgRAMConfig Fr_node_control_msgRAM_config = {
+       .dynSegmentBufferCount = 0,
+       .fifoBufferCount = 0,
+       .secureBuffers = FR_SB_ALL_REC_DISABLED,
+       .statSegmentBufferCount = 2,
+       .syncFramePayloadMultiplexEnabled = 0
+};
 
-       fray_init_irq();
-       return SUCCESS;
-}
+/**
+ * Message RAM configuration for the node receiving the control data and driving the H=bridge.
+ */
+static Fr_TMS570LS_MsgRAMConfig Fr_node_motor_msgRAM_config = {
+       .dynSegmentBufferCount = 0,
+       .fifoBufferCount = 0,
+       .secureBuffers = FR_SB_ALL_REC_DISABLED,
+       .statSegmentBufferCount = 2,
+       .syncFramePayloadMultiplexEnabled = 0
+};
 
 /**
- *     Configure FlexRay as control node.
- *      - Clear message RAMS
- *      - Configure global parameters
- *      - Initialize buffers
- *      - Go to ready state
- *      - Enable interrupts
- *     This function prepares FlexRay to send data in Frame 1.
- *     Frame 1 is synchronization frame.
- *     @return SUCCESS or FAILURE when error
+ * Static buffers configuration for the node reading the control panel.
+ * The node is configured as coldstarter and sync node. This is why the first buffer
+ * is configured as TX.
+ * The second buffer is configured as TX in single-shot mode. The buffer is used to
+ * transfer the control data.
  */
-int config_init_fray_motor() {
-       cfg Fr_Config;
+static Fr_TMS570LS_BufferConfigType Fr_node_control_static_buffers_config[] = {
+               {
+                       .channel = FR_CHANNEL_AB,
+                       .cycleCounterFiltering = 0,
+                       .isTx = TRUE,
+                       .maxPayload = 6,
+                       .msgBufferInterrupt = TRUE,
+                       .payloadPreambleIndicatorTr = FALSE,
+                       .rejectNullFrames = FALSE,
+                       .rejectStaticSegment = FALSE,
+                       .singleTransmit = FALSE,
+                       .slotId = 1
+               },
+               {
+                       .channel = FR_CHANNEL_AB,
+                       .cycleCounterFiltering = 0,
+                       .isTx = TRUE,
+                       .maxPayload = 6,
+                       .msgBufferInterrupt = TRUE,
+                       .payloadPreambleIndicatorTr = FALSE,
+                       .rejectNullFrames = FALSE,
+                       .rejectStaticSegment = FALSE,
+                       .singleTransmit = FALSE,
+                       .slotId = 3
+               }
+};
 
-       if (fray_clear_msg_ram() != SUCCESS) {
-               return FAILURE;
+/**
+ * Static buffers configuration for the node driving the motor.
+ * The node is configured as coldstarter and sync node. This is why the first buffer
+ * is configured as TX.
+ * The second buffer is configured as RX and is receiving the control data.
+ */
+static Fr_TMS570LS_BufferConfigType Fr_node_motor_static_buffers_config[] = {
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = TRUE,
+               .maxPayload = 6,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 2
+       },
+       {
+               .channel = FR_CHANNEL_AB,
+               .cycleCounterFiltering = 0,
+               .isTx = FALSE,
+               .maxPayload = 6,
+               .msgBufferInterrupt = TRUE,
+               .payloadPreambleIndicatorTr = FALSE,
+               .rejectNullFrames = FALSE,
+               .rejectStaticSegment = FALSE,
+               .singleTransmit = FALSE,
+               .slotId = 3
        }
+};
 
-       fray_wait_for_POC_ready();
-       configure_fray_global_parameters(&Fr_Config);
-       fray_init(&Fr_Config);
-
-       fray_config_buffer(0, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_TX|FRAY_BUF_SYNC_EN|FRAY_BUF_SFI_EN, 0, 2, 6, 0x85);
-       fray_config_buffer(1, FRAY_BUF_MBI_EN|FRAY_BUF_CHB_EN|FRAY_BUF_CHA_EN|FRAY_BUF_RX, 0, 1, 6, 0x80);
-
-       if (fray_controler_init() != SUCCESS) {
-               return FAILURE;
-       }
+/**
+ * Unifying configuration structure for the node reading the control panel.
+ */
+static Fr_ConfigType Fr_config_node_control = {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = NULL,
+       .fifoBufferConfigs = NULL,
+       .msgRAMConfig = &Fr_node_control_msgRAM_config,
+       .nodeConfiguration = &Fr_node_control_config,
+       .staticBufferConfigs = Fr_node_control_static_buffers_config
+};
 
-       fray_init_irq();
-       return SUCCESS;
-}
+/**
+ * Unifying configuration structure for the node driving the motor.
+ */
+static Fr_ConfigType Fr_config_node_motor = {
+       .clusterConfiguration = &Fr_cluster_config,
+       .dynamicBufferConfigs = NULL,
+       .fifoBufferConfigs = NULL,
+       .msgRAMConfig = &Fr_node_motor_msgRAM_config,
+       .nodeConfiguration = &Fr_node_motor_config,
+       .staticBufferConfigs = Fr_node_motor_static_buffers_config
+};
 
 /**
- *     Loads data into TX buffers for FlexRay node A.
+ *     Loads data into TX buffers for FlexRay node sending the control data.
+ *
+ *     After data are copied into TX buffer, the TX request is enabled, which
+ *     means that message will be transmitted as soon as the frame occures in the
+ *     communication cycle.
+ *
  *     @param  enable  enable flag to be send
  *     @param  direction       direction flag to be send
  *     @param  duty    duty cycle value to be send
+ *
+ *     @return SUCCESS when data were succesfully sent
+ *             FAILURE when some error occured.
  */
-void transmit_control_data(int enable, int direction, int duty) {
-       uint32_t data[3];
+int8_t transmit_control_data(int enable, int direction, int duty) {
+       uint8_t data[3];
 
-       // write payload for buffers
-       // buffer #1
+       // Write payload for buffer associated with frame 1
        data[0] = duty;
        data[1] = direction;
        data[2] = enable;
-       fray_buffer_set_data(0, data, 3);
+       return rpp_fr_transmit_lpdu(0, 3, data, 3);
 }
 
 /**
- *     Check if some message was received on message buffer 2 of FlexRay motor controller node.
+ *     Checks if some message was received on message buffer 2 of the FlexRay motor controller node.
+ *
+ *     If new message was received, the function copies the data from the buffer.
+ *
  *     @param enable   pointer to variable, where received enable flag will be stored
  *     @param direction pointer to variable, where received direction flag will be stored
  *     @param duty     pointer to variable, where received duty cycle value will be stored
  *     @return 0 if message was received and is correct
  *                     1 if message no message was received
+ *                     2 if receiving failed
  */
 int receive_control_data(int* enable, int* direction, int* duty) {
-       uint32_t data[3];
-       int error = 1; // No message received
+       uint8_t data[3];
+       Fr_RxLPduStatusType status;
+       uint8_t size;
 
-       // check if a message is received in buffer 2 from node B
-    if (fray_buffer_message_received(1)) {
-       fray_buffer_get_data(1, data, 3);
-       error = 0;
+       if (rpp_fr_receive_lpdu(0, 3, data, &status, &size) == FAILURE) {
+               return 2;
+       }
+       if (status == FR_NOT_RECEIVED) {
+               return 1;
+       }
+       else {
        *duty = data[0];
        *direction = data[1];
        *enable = data[2];
-    }
-       return error;
+       return 0;
+       }
 }
 
-
 /**
  * @brief      Read data from control panel and send them to motor controller through FlexRay
  *
+ * This node reads periodically each 10ms the ADC1 channel and computes
+ * the duty cycle. Then reads DIN0, which is connected to the red
+ * button on the control panel (connected as switch to battery) and then
+ * it reads the DIN1, which is connected to the black button (connected as
+ * switch to ground).
+ * Finally all data are sent on the Frame 3.
+ *
+ *
  * @param[in]  cmd_io  Pointer to IO stack
  * @param[in]  des             Pointer to command descriptor
  * @param[in]  param   Parameters of command
@@ -228,38 +336,57 @@ int cmd_do_control(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
     int direction = 1;
     int enable_cnt = 0;                        // Debounce counter for enable button
     int dir_cnt = 0;                   // Debounce counter for direction button
+    uint32_t error;
 
     adc_desc = hal_port_get_dsc(PORT_NAME_ADC, -1);
 
-    din_reset();
-    din_set_int(0,0);  // Disable interrupt and wake-up function
-    din_set_stat(0xFFFC, 0xFFFF);      // Set DIN0 and DIN1 as active
-    din_switch_st();   // Prepare for input state read
+    if (rpp_din_setup(0, FALSE, TRUE, FALSE) == FAILURE) {     // For the red button, which is switch to battery
+               rpp_sci_printf("Din 0 setup failed.\n");
+               return -CMDERR_BADCFG;
+    }
+    if (rpp_din_setup(1, FALSE, TRUE, FALSE) == FAILURE) {     // For the black button, which is switch to ground
+               rpp_sci_printf("Din 1 setup failed.\n");
+               return -CMDERR_BADCFG;
+    }
+    if (rpp_din_update() == FAILURE) {
+               rpp_sci_printf("Din update failed.\n");
+               return -CMDERR_BADCFG;
+    }
 
-       if (config_init_fray_control() != SUCCESS) {
-               rpp_sci_printf("Fray control node initialization failed.\r\n");
-               return 0;
+    if (rpp_fr_init_driver(&Fr_config_node_control, &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 (fray_startup_procedure(1) != SUCCESS) {
-               rpp_sci_printf("Integration to the network failed.\r\n");
-               return 0;
+       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.\r\n");
 
        while(1) {
-           // wait for cycle start interrupt flag
-               fray_wait_for_new_cycle();
+               vTaskDelay(10/portTICK_RATE_MS);
            ret = adc_desc->port_getfnc_ptr(adc_desc->config, PORT_ADC_CHANNEL_NUM, adc_values);
            if (ret < 0) {
-               rpp_sci_printf("ADC read failed!");
+               rpp_sci_printf("ADC read failed!\n");
                break;
            }
            duty = (100*adc_values[0])/ADC_MAX_VALUE;
-           din_spi_transfer();
+           if (rpp_din_update() == FAILURE) {
+                       rpp_sci_printf("Din update failed.\n");
+                       break;
+           }
            button = !rpp_din_get(0);
            if (button == 1) {
                if (enable_cnt++ == ENABLE_DEBOUNCE_TIME) {
@@ -285,16 +412,18 @@ int cmd_do_control(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
                dir_cnt = 0;
            }
 
-           transmit_control_data(enable, direction, duty);
-           rpp_sci_printf(".");
-
+           if (transmit_control_data(enable, direction, duty) == FAILURE) {
+               rpp_sci_printf("Data transmission failed!\n");
+               break;
+           }
+           rpp_sci_printf("Enable: %d, Direction: %s, Duty: %d%%\r", enable, (direction == 1) ? "L" : "R", duty);
        }
 
-       if (fray_halt() != SUCCESS) {
-               rpp_sci_printf("\nFlexRay HALT command failed, please reset the board to stop transmission.\r\n");
+       if (rpp_fr_halt_communication(0) == FAILURE) {
+               rpp_sci_printf("FlexRay HALT command failed, please reset the board to stop transmission.\n");
        }
        else {
-               rpp_sci_printf("FlexRay halted\r\n");
+               rpp_sci_printf("FlexRay halted, reset the board to make FlexRay usable again.\r\n");
        }
        return 0;
 }
@@ -302,61 +431,83 @@ int cmd_do_control(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
 /**
  * @brief      Receive data from FlexRay and control motor on HBR
  *
+ * This FlexRay node receives the control data from the FlexRay network
+ * and configures the H-bridge to drive the DC motor according the
+ * parameters from the received message.
+ *
  * @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_motor(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
-       double hbr_period = 1000;
+       double hbr_period = 50; // us
+       double control = 0.0;
        int hbr_duty = 0;
        int direction = 1;
        int enable = 0;
        uint32_t rx_error = 0;
        int ret;
+       uint32_t error;
 
-       drv_hbr_pwm_set_signal(hbr_period, hbr_duty);
-       drv_hbr_pwm_start();
-       drv_hbr_set_en(enable);
-       drv_hbr_set_dir(direction);
-       drv_hbr_wdg_start();
+       if (rpp_hbr_enable(hbr_period) == FAILURE ||
+               rpp_hbr_control(0) == FAILURE
+       ) {
+               rpp_sci_printf("H-bridge initialization failed.\n");
+               return -CMDERR_BADCFG;
+       }
 
-       if (config_init_fray_motor() != SUCCESS) {
-               rpp_sci_printf("Fray motor node initialization failed.\r\n");
-               return 0;
+    if (rpp_fr_init_driver(&Fr_config_node_motor, &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 motor node initialization failed: %#x.\n", error);
+               return -CMDERR_BADCFG;
        }
        rpp_sci_printf("Fray motor node initialized.\r\n");
        rpp_sci_printf("Waiting for network connection...\r\n");
 
-       if (fray_startup_procedure(1) != SUCCESS) {
-               rpp_sci_printf("Integration to the network failed.\r\n");
-               return 0;
+       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.\r\n");
 
        while (1) {
-               fray_wait_for_new_cycle();
                ret = receive_control_data(&enable, &direction, &hbr_duty);
-
-           drv_hbr_pwm_set_signal(hbr_period, hbr_duty);
-               drv_hbr_set_en(enable);
-               drv_hbr_set_dir(direction);
-
-               if (ret == 1) {
+               if (ret == 2) { // receiving failed
                        rx_error++;
                        if (rx_error > RX_ERROR_MAX) {
-                               drv_hbr_set_en(0);
-                               rpp_sci_printf("Maximum RX errors reached!");
+                               rpp_sci_printf("Maximum RX errors reached!\n");
+                               break;
+                       }
+               }
+               else if (ret == 0) {    // message received
+                       control = hbr_duty/((double)100) * ((direction == 1) ? -1 : 1) * enable;
+                   rpp_sci_printf("Enable: %d, Direction: %s, Duty: %d%%\r", enable, (direction == 1) ? "L" : "R", hbr_duty);
+                       if (rpp_hbr_control(control) == FAILURE) {
+                               rpp_sci_printf("H-bridge control failed!\n");
                                break;
                        }
                }
        }
-       if (fray_halt() != SUCCESS) {
-               rpp_sci_printf("\nFlexRay HALT command failed, please reset the board to stop transmission.\r\n");
+       if (rpp_hbr_disable() == FAILURE) {
+               rpp_sci_printf("H-bridge disabling failed!\n");
+       }
+       else {
+               rpp_sci_printf("H-bridge disabled.\n");
+       }
+       if (rpp_fr_halt_communication(0) == FAILURE) {
+               rpp_sci_printf("FlexRay HALT command failed, please reset the board to stop transmission.\n");
        }
        else {
-               rpp_sci_printf("FlexRay halted\r\n");
+               rpp_sci_printf("FlexRay halted, reset the board to make FlexRay usable again.\r\n");
        }
        return 0;
 }
@@ -374,9 +525,9 @@ cmd_des_t const cmd_des_control={
                "=== Description ===\n"
                "\n"
                "This command creates a FlexRay node and starts to read buttons\n"
-               "(connected to DIN0 and DIN1) and a potentiometer (ADC1) from control\n"
+               "(connected to DIN0 and DIN1) and a potentiometer (ADC1) from control\n"
                "panel. The read data are sent via FlexRay to the second node, created\n"
-               "by running demomot command.\n"
+               "by running demomotdrive command.\n"
                "\n"
                "The purpose of this pair of commands is to demonstrate functionality\n"
                "of the FlexRay, ADC, DIN and HBR peripherals.\n",
@@ -389,7 +540,7 @@ cmd_des_t const cmd_des_motor={
                "demomotdrive","Run motor control demo - drives the DC motor",
                "=== Command syntax ===\n"
                "\n"
-               "   demomotmotor\n"
+               "   demomotdrive\n"
                "\n"
                "=== Description ===\n"
                "\n"
index fc112f583cd2421d8a1573e61be1e4ea4369b358..f763d10bb246b16442ae65e38a004172628f88bd 100644 (file)
@@ -91,7 +91,7 @@ int cmd_do_pin_val(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
          }
          else{ // No more parameters = get values
                uint32_t pin_value = hal_gpio_pin_get_value(*desc);
-               rpp_sci_printf("pinval%s=%d", pinName, pin_value);
+               rpp_sci_printf("pinval%s=%d\n", pinName, pin_value);
                return 0;
          }
 }
@@ -140,7 +140,7 @@ int cmd_do_pin_dir(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) {
          }
          else{ // No more parameters = get values
                uint32_t pin_dir = hal_gpio_pin_get_direction(*desc);
-               rpp_sci_printf("pindir%s=%d", pinName, pin_dir);
+               rpp_sci_printf("pindir%s=%d\n", pinName, pin_dir);
                return 0;
          }
 }
diff --git a/commands/fray_demo.txt b/commands/fray_demo.txt
new file mode 100644 (file)
index 0000000..9cd74ad
--- /dev/null
@@ -0,0 +1,246 @@
+FlexRay simple test of the connection
+===========================================
+This test starts a new FlaxRay network communication. Node A sends 100 messages,
+one message each 10th communication cycle, and node B is suppose to receive all
+of the messages correctly.
+Node A:
+       fraytestA
+Node B:
+       fraytestB
+
+FlexRay motor remote controlling
+===========================================
+Connection:
+       control panel is connected to the node A.
+               black - AIN1 (Low)
+               green - AIN1 (High)
+               white - GND
+               red - 12V
+               yellow - DIN0
+               blue - DIN1
+       DC motor is connected to the node B to the HBR outputs.
+
+Node A:
+       demomotctrl
+Node B:
+       demomotdrive
+Node C
+       simulink demo fray_motor_demo
+
+
+
+Node init:
+------------
+       #Node A configuration
+       frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C
+       frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0
+       ## Stat buffer TX - continuous mode
+       frbtcfgbufS0 slot1 AB cyc0 tx max9 continuous ppi0 int1
+       ## Receiving stat buffer from B
+       frbtcfgbufS1 slot2 AB cyc0 rx max9 continuous ppi0 int1
+       ## Buffer sending message to FIFO in node B - single shot mode
+       frbtcfgbufS2 slot3 A cyc0 tx max9 single ppi0 int1
+       ## NM vector sending and receiving
+       frbtcfgbufS3 slot5 AB cyc0 rx max9 continuous ppi1 int1
+       frbtcfgbufS4 slot4 AB cyc0 tx max9 continuous ppi1 int1
+       ## Dynamic buffers for TX and RX, single shot mode
+       frbtcfgbufD0  slot9  A cyc0 tx max0x40 single ppi0 int0
+       frbtcfgbufD1  slot10 A cyc0 rx max0x40 single ppi0 int0
+       ## RX FIFO buffer
+       frbtcfgfifo slot0 depth5 A cyc0 max0x20 rejnull accstat int0
+       # FlexRay start
+       frbtinitU
+       frbtstart
+       frbtallslots
+
+       #Node B configuration
+       frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C
+       frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0
+       ## Stat buffer TX - continuous mode
+       frbtcfgbufS0 slot2 AB cyc0 tx max9 continuous ppi0 int1
+       ## Receiving stat buffer from A
+       frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1
+       ## Buffer sending to FIFO in node A
+       frbtcfgbufS2 slot6 A cyc0 tx max9 single ppi0 int1
+       ## NM vector sending and receiving
+       frbtcfgbufS3 slot4 AB cyc0 rx max9 continuous ppi1 int1
+       frbtcfgbufS4 slot5 AB cyc0 tx max9 continuous ppi1 int1
+       ## Dynamic buffers for TX and RX, single shot mode
+       frbtcfgbufD0  slot9  A cyc0 rx max0x40 single ppi0 int0
+       frbtcfgbufD1  slot10 A cyc0 tx max0x40 single ppi0 int0
+       ## RX FIFO buffer
+       frbtcfgfifo slot0 depth5 A cyc0 max0x20 rejnull accstat int1
+       # FlexRay start
+       frbtinitU
+       frbtstart
+       frbtallslots
+
+       #Node C configuration (receive network management)
+       frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C
+       frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0
+       ## Stat buffer TX - continuous mode
+       ## NM vector sending and receiving
+       frbtcfgbufS0 slot7 AB cyc0 tx max9 continuous ppi0 int1
+       frbtcfgbufS1 slot4 AB cyc0 rx max9 continuous ppi1 int1
+       frbtcfgbufS2 slot5 AB cyc0 rx max9 continuous ppi1 int1
+       # FlexRay start
+       frbtinitU
+       frbtstart
+       frbtallslots
+
+       # NM Vector demo
+       frbtnmwatch
+
+Test static segment:
+--------------------
+Starts sending a message from A in every cycle in Slot 1. The message is received by node B.
+After the message is sent from A, When the frbtreceive1 command on the node B is called every
+communication cycle after slot 1 has passed, the newly received message should be retrieved.
+Node A:
+       frbttransmit1 AA BB CC
+Node B:
+       frbtreceive1
+
+Test dynamic segment:
+--------------------
+Sends a message from node A in slot 9, which is in dynamic segment of the communication cycle.
+The buffer for this slot is configured as single-shot mode, so the message is sent only once.
+The message is received by node B. When the command frbtreceive9 is called after the message was
+sent from the A node, the newly received message should be retrieved. Every later calling should
+return with a 'No message received'.
+Node A:
+       frbttransmit9 99 99 99 99 99
+NodeB:
+       frbtreceive9
+
+Test FIFO:
+--------------------
+Sends 6 messages from node A in the slot 3, which is in static segment of the communication cycle.
+Node B is configured to receive messages from slot 3 in a FIFO RX buffer. The FIFO has storage space
+for 5 messages, which means that the first message will be thrown away.
+Calling the frbtreceive0 command 5 times after all messages were sent from node A should retrieve the
+last 5 received messages. First 4 calling should return with 'More messages are still in FIFO', the last
+calling should return with 'Received message'. Every later calling should return with the
+'No message received'.
+Node A:
+       frbttransmit3 12 12 12 12 12
+       frbttransmit3 34 34 34 34 34
+       frbttransmit3 56 56 56 56 56
+       frbttransmit3 78 78 78 78 78
+       frbttransmit3 90 90 90 90 90
+       frbttransmit3 AB AB AB AB AB
+Node B:
+       frbtreceive0
+
+Test Network management vector:
+--------------------
+Starts sending a network management vector. The vector has to be manualy sent by the command frbttransmit4
+from the node A. It is then received and processed automaticaly by the node B. Processed network management
+vector can be obtained by calling the command frbtnmvector on the node B.
+Node A:
+       frbttransmit4 FF 00 00 00 00 00 00 00 00 00 00 00
+Node B:
+       frbttransmit5 00 FF 00 00 00 00 00 00 00 00 00 00
+Node C:
+       frbtnmvector
+
+Canceling continuous TX:
+--------------------
+When message was sent on the slot 4 ba calling the command frbttransmit4 on the node A and buffer assigned to
+the slot 4 is configured as continuous mode, it can be canceled by calling the command frbtcanceltx4 on the node A.
+If the frbtreceive4 command is called on the node B after message was sent for the first time from the node A, it
+shoud retrieved the newly received message.
+If the frbtreceive4 command is called after frbtcanceltx4, the last received message should be retrieved and for
+later calling it should return with 'No message received'.
+Node A:
+       frbttransmit4 12 34 56 78 90 AB CD EF EE EE EE EE
+       frbtcanceltx4
+Node B:
+       frbtreceive4
+
+Three nodes test
+===========================================
+Node A is sending a message in single-shot mode in slot 4. This message is received by nodes B and C into the static segment RX buffer.
+Node B is sending a message in single-shot mode in slot 5. This message is received by node A into the static segment RX buffer.
+Node C is sending a message in single shot mode in slot 6. This message is received by node B into the FIFO RX buffer.
+       #Node A configuration
+       frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C
+       frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0
+       ## Stat buffer TX
+       frbtcfgbufS0 slot1 AB cyc0 tx max9 continuous ppi0 int1
+       frbtcfgbufS1 slot4 AB cyc0 tx max9 single ppi0 int1
+       ## Stat buffer RX
+       frbtcfgbufS2 slot5 AB cyc0 rx max9 single ppi0 int1
+       # FlexRay start
+       frbtinitU
+       frbtstart
+       frbtallslots
+
+       #Node B configuration
+       frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C
+       frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0
+       ## Stat buffer TX
+       frbtcfgbufS0 slot2 AB cyc0 tx max9 continuous ppi0 int1
+       frbtcfgbufS1 slot5 AB cyc0 tx max9 single ppi0 int1
+       ## Stat buffer RX
+       frbtcfgbufS2 slot4 AB cyc0 rx max9 single ppi0 int1
+       ## RX FIFO buffer
+       #              dpt ch  cyc  pl  rnf rsf fid
+       frbtconfigfifo 0x5 0x2 0x0 0x20 0x1 0x0 0x0
+       # FlexRay start
+       frbtinitU
+       frbtstart
+       frbtallslots
+
+       #Node C configuration
+       frbtconfigcluster 0x2 0xF 0x15E0 0xF 0xF 0xC 0x15A 0x8 0xAE4 0x9 0xF 0x4 0x43 0x1 0x4 0x2 0xAE3 0x0 0x56 0xA 0x12 0x12 0x4C 0xB4 0x3C
+       frbtconfignode 0x0 0x0 0x2 0x1 0x3 0x3 0x0 0x0 0x1 0x1 0x10D 0x6 0x6 0x18 0x18 0x36B00 0xCD 0x151 0x0 0x1 0x0 0x2 0x81 0x36DA2 0x151 0x33 0x0 0x0
+       ## Stat buffer TX
+       frbtcfgbufS0 slot3 AB cyc0 tx max9 continuous ppi0 int1
+       frbtcfgbufS1 slot6 A cyc0 tx max9 single ppi0 int1
+       ## Stat buffer RX
+       frbtcfgbufS2 slot4 AB cyc0 rx max9 single ppi0 int1
+       # FlexRay start
+       frbtinitU
+       frbtstart
+       frbtallslots
+
+Test of the broadcast
+--------------------
+Sends a message from node A in slot 4. The message should be received by node A and B, once on each of the nodes.
+Node A:
+       frbttransmit4 AA BB CC
+Node B:
+       frbtreceive4
+Node C:
+       frbtreceive4
+
+Test of the A-B exclusive communication
+--------------------
+Sends a message from the node B in slot 5. The message should be received only by node A.
+Node B:
+       frbttransmit5 BB AA
+Node A:
+       frbtreceive5
+Node C:
+       frbtreceive5
+
+Test of the B-C exclusive communication and the FIFO RX buffer
+--------------------
+Sends a messages from the node C in slot 6. 5 latest messages should be received only by node B.
+Node C:
+       frbttransmit6 CC BB 01
+       frbttransmit6 CC BB 02
+       frbttransmit6 CC BB 03
+       frbttransmit6 CC BB 04
+       frbttransmit6 CC BB 05
+       frbttransmit6 CC BB 06
+Node A:
+       frbtreceive0
+Node B:
+       frbtreceive0
+       frbtreceive0
+       frbtreceive0
+       frbtreceive0
+       frbtreceive0
+       frbtreceive0
index 4ffe84fdcdc990b519c924b2df3b5af3b3d007b7..4c40a67e371bd6bd27e3f2609fdaabd754e19d2f 100644 (file)
@@ -45,7 +45,12 @@ void main(void)
        rpp_sci_setup(115200);\r
 \r
        _enable_IRQ();\r
-       initCmdProc(0, "\r\n----\r\n  Rapid Prototyping Platform v00.01-001\r\n  SW ver " GIT_VERSION " \r\n  Porsche Engineering 06/2013\r\n----\r\n", (uint8_t *)"\r\n--> ");\r
+\r
+       rpp_sci_printf("\nRapid Prototyping Platform v00.01-001\n");\r
+       rpp_sci_printf("Test Software version " GIT_VERSION "\n");\r
+       rpp_sci_printf("Porsche Engineering 06/2013\n");\r
+\r
+       initCmdProc(0);\r
        vTaskStartScheduler();\r
 \r
        //We should never get here\r
diff --git a/rpp-lib b/rpp-lib
index a4d0cb921de99b9a39c4a96b570c5ec184e9c3e0..8104e5e3986083ee2e2743f5e87fc38d32e2efd6 160000 (submodule)
--- a/rpp-lib
+++ b/rpp-lib
@@ -1 +1 @@
-Subproject commit a4d0cb921de99b9a39c4a96b570c5ec184e9c3e0
+Subproject commit 8104e5e3986083ee2e2743f5e87fc38d32e2efd6