]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp-test-sw/commands/cmd_fr_basic_test.c
a8d5ec2d6c995cccc31539e2eae8342e755cccd5
[pes-rpp/rpp-test-sw.git] / rpp-test-sw / commands / cmd_fr_basic_test.c
1 /*
2  * Copyright (C) 2012-2013 Czech Technical University in Prague
3  *
4  * Created on: 6.8.2013
5  *
6  * Authors:
7  *     - Michal Horn
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * File : cmd_fr_basic_test.c
23  *
24  * Abstract:
25  *              The file contains a set of commands to control the FlexRay driver.
26  *              Those commands can be used to configure RPP board as a FlexRay node,
27  *              configure a set of TX and RX buffers, get status of the buffers and
28  *              the FlexRay controller, manipulate with timers and control the transmission
29  *              of messages.
30  */
31
32
33 #include "cmd_fr_basic_test.h"
34
35 #ifndef DOCGEN
36
37 #include <string.h>
38 #include "cmdproc_utils.h"
39 #include "drv/drv.h"
40 #include "rpp/rpp.h"
41 #include "hal/hal.h"
42 #include "stdio.h"
43
44 #define printf rpp_sci_printf
45
46 static inline int badpar(const char *msg)
47 {
48         printf("%s", msg);
49         return -CMDERR_BADPAR;
50 }
51
52 /**
53  * Flag to recognize whether the FlexRay driver was already initialized. If it was, no further configuration is allowed.
54  */
55 static boolean_t fr_initialized = FALSE;
56
57 /**
58  * This structure contains global FlexRay configuration.
59  * All nodes in the network have to use the same values for
60  * all parameters of this structure.
61  */
62 static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
63         .gColdStartAttempts = 0x2,
64         .gListenNoise = 0xF,
65         .gMacroPerCycle = 0x15E0,   // (cycle period, 5.6us)
66         .gMaxWithoutClockCorrectionFatal = 0xF,
67         .gMaxWithoutClockCorrectionPassive = 0xF,
68         .gNetworkManagementVectorLength = 12,
69         .gNumberOfMinislots = 0x15A,
70         .gNumberOfStaticSlots = 0x8,
71         .gOffsetCorrectionStart = 0xAE4,
72         .gPayloadLengthStatic = 0x9,
73         .gSyncNodeMax = 0xF,
74         .gdActionPointOffset = 0x4,
75         .gdCASRxLowMax = 0x43,
76         .gdDynamicSlotIdlePhase = 0x1,
77         .gdMinislot = 0x4,
78         .gdMinislotActionPointOffset = 0x2,
79         .gdNIT = 0xAE3,
80         .gdSampleClockPeriod = 0,       // 10mbit/sec
81         .gdStaticSlot = 0x56,
82         .gdTSSTransmitter = 0xA,
83         .gdWakeupSymbolRxIdle = 18,
84         .gdWakeupSymbolRxLow = 18,
85         .gdWakeupSymbolRxWindow = 76,
86         .gdWakeupSymbolTxIdle = 180,
87         .gdWakeupSymbolTxLow = 60
88 };
89
90 /**
91  * This structure contains local configuration of the FlexRay node A.
92  * All nodes in the network shall have their own local configuraion,
93  * but it does not matters if they share some together, until their
94  * buffer configuration differs.
95  */
96 static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
97         .pAllowHaltDueToClock = 0,
98         .pAllowPassiveToActive = 0xF,
99         .pChannels = FR_CHANNEL_AB,
100         .pClusterDriftDamping = 0x1,
101         .pDelayCompensationA = 0x3,
102         .pDelayCompensationB = 0x3,
103         .pExternOffsetCorrection = 0,
104         .pExternRateCorrection = 0,
105         .pKeySlotUsedForStartup = TRUE,
106         .pKeySlotUsedForSync = TRUE,
107         .pLatestTx = 0x10D,
108         .pMacroInitialOffsetA = 0x6,
109         .pMacroInitialOffsetB = 0x6,
110         .pMicroInitialOffsetA = 0x18,
111         .pMicroInitialOffsetB = 0x18,
112         .pMicroPerCycle = 0x36B00,
113         .pRateCorrectionOut = 0xCD,
114         .pOffsetCorrectionOut = 0x151,
115         .pSamplesPerMicrotick = 0,      // 10 mbit/sec
116         .pSingleSlotEnabled = TRUE,
117         .pWakeupChannel = FR_CHANNEL_A,
118         .pWakeupPattern = 2,
119         .pdAcceptedStartupRange = 0x81,
120         .pdListenTimeout = 0x36DA2,
121         .pdMaxDrift = 0x151,
122         .pDecodingCorrection = 0x33
123 };
124
125 /**
126  * This structure contains local configuration of the FlexRay node B.
127  * All nodes in the network shall have their own local configuraion,
128  * but it does not matters if they share some together, until their
129  * buffer configuration differs.
130  */
131 static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
132         .pAllowHaltDueToClock = 0,
133         .pAllowPassiveToActive = 0xF,
134         .pChannels = FR_CHANNEL_AB,
135         .pClusterDriftDamping = 0x1,
136         .pDelayCompensationA = 0x3,
137         .pDelayCompensationB = 0x3,
138         .pExternOffsetCorrection = 0,
139         .pExternRateCorrection = 0,
140         .pKeySlotUsedForStartup = TRUE,
141         .pKeySlotUsedForSync = TRUE,
142         .pLatestTx = 0x10D,
143         .pMacroInitialOffsetA = 0x6,
144         .pMacroInitialOffsetB = 0x6,
145         .pMicroInitialOffsetA = 0x18,
146         .pMicroInitialOffsetB = 0x18,
147         .pMicroPerCycle = 0x36B00,
148         .pRateCorrectionOut = 0xCD,
149         .pOffsetCorrectionOut = 0x151,
150         .pSamplesPerMicrotick = 0,          // 10 mbit/sec
151         .pSingleSlotEnabled = TRUE,
152         .pWakeupChannel = FR_CHANNEL_A,
153         .pWakeupPattern = 2,
154         .pdAcceptedStartupRange = 0x81,
155         .pdListenTimeout = 0x36DA2,
156         .pdMaxDrift = 0x151,
157         .pDecodingCorrection = 0x33
158 };
159
160 static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
161         .dynSegmentBufferCount = 3,
162         .fifoBufferCount = 5,
163         .secureBuffers = FR_SB_RECONFIG_ENABLED,
164         .statSegmentBufferCount = 5,
165         .syncFramePayloadMultiplexEnabled = 0
166 };
167
168 static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
169         .dynSegmentBufferCount = 3,
170         .fifoBufferCount = 5,
171         .secureBuffers = FR_SB_RECONFIG_ENABLED,
172         .statSegmentBufferCount = 5,
173         .syncFramePayloadMultiplexEnabled = 0
174 };
175
176 static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
177         {
178                 .channel = FR_CHANNEL_AB,
179                 .cycleCounterFiltering = 0,
180                 .fidMask = 0,
181                 .isTx = TRUE,
182                 .maxPayload = 9,
183                 .msgBufferInterrupt = TRUE,
184                 .payloadPreambleIndicatorTr = FALSE,
185                 .rejectNullFrames = FALSE,
186                 .rejectStaticSegment = FALSE,
187                 .singleTransmit = FALSE,
188                 .slotId = 1
189         },
190         {
191                 .channel = FR_CHANNEL_AB,
192                 .cycleCounterFiltering = 0,
193                 .fidMask = 0,
194                 .isTx = FALSE,
195                 .maxPayload = 9,
196                 .msgBufferInterrupt = TRUE,
197                 .payloadPreambleIndicatorTr = FALSE,
198                 .rejectNullFrames = FALSE,
199                 .rejectStaticSegment = FALSE,
200                 .singleTransmit = FALSE,
201                 .slotId = 2
202         },
203         {
204                 .channel = FR_CHANNEL_AB,
205                 .cycleCounterFiltering = 0,
206                 .fidMask = 0,
207                 .isTx = TRUE,
208                 .maxPayload = 9,
209                 .msgBufferInterrupt = TRUE,
210                 .payloadPreambleIndicatorTr = FALSE,
211                 .rejectNullFrames = FALSE,
212                 .rejectStaticSegment = FALSE,
213                 .singleTransmit = TRUE,
214                 .slotId = 3
215         },
216         {
217                 .channel = FR_CHANNEL_AB,
218                 .cycleCounterFiltering = 0,
219                 .fidMask = 0,
220                 .isTx = FALSE,
221                 .maxPayload = 9,
222                 .msgBufferInterrupt = TRUE,
223                 .payloadPreambleIndicatorTr = FALSE,
224                 .rejectNullFrames = FALSE,
225                 .rejectStaticSegment = FALSE,
226                 .singleTransmit = TRUE,
227                 .slotId = 4
228         },
229         {
230                 .channel = FR_CHANNEL_AB,
231                 .cycleCounterFiltering = 0,
232                 .fidMask = 0,
233                 .isTx = TRUE,
234                 .maxPayload = 9,
235                 .msgBufferInterrupt = TRUE,
236                 .payloadPreambleIndicatorTr = TRUE,
237                 .rejectNullFrames = FALSE,
238                 .rejectStaticSegment = FALSE,
239                 .singleTransmit = FALSE,
240                 .slotId = 5
241         }
242
243 };
244
245 static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
246         {
247                 .channel = FR_CHANNEL_AB,
248                 .cycleCounterFiltering = 0,
249                 .fidMask = 0,
250                 .isTx = TRUE,
251                 .maxPayload = 9,
252                 .msgBufferInterrupt = TRUE,
253                 .payloadPreambleIndicatorTr = FALSE,
254                 .rejectNullFrames = FALSE,
255                 .rejectStaticSegment = FALSE,
256                 .singleTransmit = FALSE,
257                 .slotId = 2
258         },
259         {
260                 .channel = FR_CHANNEL_AB,
261                 .cycleCounterFiltering = 0,
262                 .fidMask = 0,
263                 .isTx = FALSE,
264                 .maxPayload = 9,
265                 .msgBufferInterrupt = TRUE,
266                 .payloadPreambleIndicatorTr = FALSE,
267                 .rejectNullFrames = FALSE,
268                 .rejectStaticSegment = FALSE,
269                 .singleTransmit = FALSE,
270                 .slotId = 1
271         },
272         {
273                 .channel = FR_CHANNEL_AB,
274                 .cycleCounterFiltering = 0,
275                 .fidMask = 0,
276                 .isTx = TRUE,
277                 .maxPayload = 9,
278                 .msgBufferInterrupt = TRUE,
279                 .payloadPreambleIndicatorTr = FALSE,
280                 .rejectNullFrames = FALSE,
281                 .rejectStaticSegment = FALSE,
282                 .singleTransmit = TRUE,
283                 .slotId = 4
284         },
285         {
286                 .channel = FR_CHANNEL_AB,
287                 .cycleCounterFiltering = 0,
288                 .fidMask = 0,
289                 .isTx = FALSE,
290                 .maxPayload = 9,
291                 .msgBufferInterrupt = TRUE,
292                 .payloadPreambleIndicatorTr = FALSE,
293                 .rejectNullFrames = FALSE,
294                 .rejectStaticSegment = FALSE,
295                 .singleTransmit = TRUE,
296                 .slotId = 3
297         },
298         {
299                 .channel = FR_CHANNEL_AB,
300                 .cycleCounterFiltering = 0,
301                 .fidMask = 0,
302                 .isTx = FALSE,
303                 .maxPayload = 9,
304                 .msgBufferInterrupt = TRUE,
305                 .payloadPreambleIndicatorTr = TRUE,
306                 .rejectNullFrames = FALSE,
307                 .rejectStaticSegment = FALSE,
308                 .singleTransmit = FALSE,
309                 .slotId = 5
310         }
311 };
312
313 static Fr_TMS570LS_BufferConfigType Fr_node_A_dynamic_buffers_config[] = {
314         {
315                 .channel = FR_CHANNEL_A,
316                 .cycleCounterFiltering = 0,
317                 .fidMask = 0,
318                 .isTx = TRUE,
319                 .maxPayload = 64,
320                 .msgBufferInterrupt = TRUE,
321                 .payloadPreambleIndicatorTr = FALSE,
322                 .rejectNullFrames = FALSE,
323                 .rejectStaticSegment = FALSE,
324                 .singleTransmit = FALSE,
325                 .slotId = 9
326         },
327         {
328                 .channel = FR_CHANNEL_B,
329                 .cycleCounterFiltering = 0,
330                 .fidMask = 0,
331                 .isTx = FALSE,
332                 .maxPayload = 32,
333                 .msgBufferInterrupt = TRUE,
334                 .payloadPreambleIndicatorTr = FALSE,
335                 .rejectNullFrames = FALSE,
336                 .rejectStaticSegment = FALSE,
337                 .singleTransmit = FALSE,
338                 .slotId = 10
339         },
340         {
341                 .channel = FR_CHANNEL_A,
342                 .cycleCounterFiltering = 0,
343                 .fidMask = 0,
344                 .isTx = TRUE,
345                 .maxPayload = 16,
346                 .msgBufferInterrupt = TRUE,
347                 .payloadPreambleIndicatorTr = FALSE,
348                 .rejectNullFrames = FALSE,
349                 .rejectStaticSegment = FALSE,
350                 .singleTransmit = TRUE,
351                 .slotId = 11
352         }
353 };
354
355
356 static Fr_TMS570LS_BufferConfigType Fr_node_B_dynamic_buffers_config[] = {
357         {
358                 .channel = FR_CHANNEL_B,
359                 .cycleCounterFiltering = 0,
360                 .fidMask = 0,
361                 .isTx = TRUE,
362                 .maxPayload = 32,
363                 .msgBufferInterrupt = TRUE,
364                 .payloadPreambleIndicatorTr = FALSE,
365                 .rejectNullFrames = FALSE,
366                 .rejectStaticSegment = FALSE,
367                 .singleTransmit = TRUE,
368                 .slotId = 10
369         },
370         {
371                 .channel = FR_CHANNEL_A,
372                 .cycleCounterFiltering = 0,
373                 .fidMask = 0,
374                 .isTx = FALSE,
375                 .maxPayload = 64,
376                 .msgBufferInterrupt = TRUE,
377                 .payloadPreambleIndicatorTr = FALSE,
378                 .rejectNullFrames = FALSE,
379                 .rejectStaticSegment = FALSE,
380                 .singleTransmit = TRUE,
381                 .slotId = 9
382         },
383         {
384                 .channel = FR_CHANNEL_A,
385                 .cycleCounterFiltering = 0,
386                 .fidMask = 0,
387                 .isTx = TRUE,
388                 .maxPayload = 9,
389                 .msgBufferInterrupt = TRUE,
390                 .payloadPreambleIndicatorTr = FALSE,
391                 .rejectNullFrames = FALSE,
392                 .rejectStaticSegment = FALSE,
393                 .singleTransmit = TRUE,
394                 .slotId = 12
395         }
396 };
397
398 static Fr_TMS570LS_BufferConfigType Fr_node_A_fifo_buffers_config[] = {
399         {
400                 .channel = FR_CHANNEL_AB,
401                 .cycleCounterFiltering = 0,
402                 .fidMask = 0,
403                 .isTx = FALSE,
404                 .maxPayload = 127,
405                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
406                 .payloadPreambleIndicatorTr = FALSE,
407                 .rejectNullFrames = TRUE,
408                 .rejectStaticSegment = FALSE,
409                 .singleTransmit = FALSE,
410                 .slotId = 12
411         },
412         {
413                 .channel = FR_CHANNEL_AB,
414                 .cycleCounterFiltering = 0,
415                 .fidMask = 0,
416                 .isTx = FALSE,
417                 .maxPayload = 127,
418                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
419                 .payloadPreambleIndicatorTr = FALSE,
420                 .rejectNullFrames = TRUE,
421                 .rejectStaticSegment = FALSE,
422                 .singleTransmit = FALSE,
423                 .slotId = 12
424         },
425         {
426                 .channel = FR_CHANNEL_AB,
427                 .cycleCounterFiltering = 0,
428                 .fidMask = 0,
429                 .isTx = FALSE,
430                 .maxPayload = 127,
431                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
432                 .payloadPreambleIndicatorTr = FALSE,
433                 .rejectNullFrames = TRUE,
434                 .rejectStaticSegment = FALSE,
435                 .singleTransmit = FALSE,
436                 .slotId = 12
437         },
438         {
439                 .channel = FR_CHANNEL_AB,
440                 .cycleCounterFiltering = 0,
441                 .fidMask = 0,
442                 .isTx = FALSE,
443                 .maxPayload = 127,
444                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
445                 .payloadPreambleIndicatorTr = FALSE,
446                 .rejectNullFrames = TRUE,
447                 .rejectStaticSegment = FALSE,
448                 .singleTransmit = FALSE,
449                 .slotId = 12
450         },
451         {
452                 .channel = FR_CHANNEL_AB,
453                 .cycleCounterFiltering = 0,
454                 .fidMask = 0,
455                 .isTx = FALSE,
456                 .maxPayload = 127,
457                 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
458                 .payloadPreambleIndicatorTr = FALSE,
459                 .rejectNullFrames = TRUE,
460                 .rejectStaticSegment = FALSE,
461                 .singleTransmit = FALSE,
462                 .slotId = 12
463         }
464 };
465
466 static Fr_TMS570LS_BufferConfigType Fr_node_B_fifo_buffers_config[] = {
467         {
468                 .channel = FR_CHANNEL_AB,
469                 .cycleCounterFiltering = 0,
470                 .fidMask = 0,
471                 .isTx = FALSE,
472                 .maxPayload = 64,
473                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
474                 .payloadPreambleIndicatorTr = FALSE,
475                 .rejectNullFrames = TRUE,
476                 .rejectStaticSegment = FALSE,
477                 .singleTransmit = FALSE,
478                 .slotId = 0 // No Frame is rejected
479         },
480         {
481                 .channel = FR_CHANNEL_AB,
482                 .cycleCounterFiltering = 0,
483                 .fidMask = 0,
484                 .isTx = FALSE,
485                 .maxPayload = 64,
486                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
487                 .payloadPreambleIndicatorTr = FALSE,
488                 .rejectNullFrames = TRUE,
489                 .rejectStaticSegment = FALSE,
490                 .singleTransmit = FALSE,
491                 .slotId = 0 // No Frame is rejected
492         },
493         {
494                 .channel = FR_CHANNEL_AB,
495                 .cycleCounterFiltering = 0,
496                 .fidMask = 0,
497                 .isTx = FALSE,
498                 .maxPayload = 64,
499                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
500                 .payloadPreambleIndicatorTr = FALSE,
501                 .rejectNullFrames = TRUE,
502                 .rejectStaticSegment = FALSE,
503                 .singleTransmit = FALSE,
504                 .slotId = 0 // No Frame is rejected
505         },
506         {
507                 .channel = FR_CHANNEL_AB,
508                 .cycleCounterFiltering = 0,
509                 .fidMask = 0,
510                 .isTx = FALSE,
511                 .maxPayload = 64,
512                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
513                 .payloadPreambleIndicatorTr = FALSE,
514                 .rejectNullFrames = TRUE,
515                 .rejectStaticSegment = FALSE,
516                 .singleTransmit = FALSE,
517                 .slotId = 0 // No Frame is rejected
518         },
519         {
520                 .channel = FR_CHANNEL_AB,
521                 .cycleCounterFiltering = 0,
522                 .fidMask = 0,
523                 .isTx = FALSE,
524                 .maxPayload = 64,
525                 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
526                 .payloadPreambleIndicatorTr = FALSE,
527                 .rejectNullFrames = TRUE,
528                 .rejectStaticSegment = FALSE,
529                 .singleTransmit = FALSE,
530                 .slotId = 0 // No Frame is rejected
531         }
532 };
533
534 /**
535  * This is an unifying configuration structure for the node A.
536  * It joins all the configuration structure together.
537  */
538 static Fr_ConfigType Fr_config_node_A = {
539         .clusterConfiguration = &Fr_cluster_config,
540         .dynamicBufferConfigs = Fr_node_A_dynamic_buffers_config,
541         .fifoBufferConfigs = Fr_node_A_fifo_buffers_config,
542         .msgRAMConfig = &Fr_node_A_msgRAM_config,
543         .nodeConfiguration = &Fr_node_A_config,
544         .staticBufferConfigs = Fr_node_A_static_buffers_config
545 };
546
547 /**
548  * This is an unifying configuration structure for the node A.
549  * It joins all the configuration structure together.
550  */
551 static Fr_ConfigType Fr_config_node_B = {
552         .clusterConfiguration = &Fr_cluster_config,
553         .dynamicBufferConfigs = Fr_node_B_dynamic_buffers_config,
554         .fifoBufferConfigs = Fr_node_B_fifo_buffers_config,
555         .msgRAMConfig = &Fr_node_B_msgRAM_config,
556         .nodeConfiguration = &Fr_node_B_config,
557         .staticBufferConfigs = Fr_node_B_static_buffers_config
558 };
559
560 /* User configuration */
561
562 static Fr_TMS570LS_ClusterConfigType user_cluster_config;
563 static Fr_TMS570LS_NodeConfigType user_node_config;
564 static Fr_TMS570LS_MsgRAMConfig user_msg_ram_config;
565 static Fr_TMS570LS_BufferConfigType user_static_buffer_config[RPP_FR_MAX_STATIC_BUF_CNT];
566 static Fr_TMS570LS_BufferConfigType user_dynamic_buffer_config[RPP_FR_MAX_DYNAMIC_BUF_CNT];
567 static Fr_TMS570LS_BufferConfigType user_fifo_buffer_config[RPP_FR_MAX_FIFO_BUF_DEPTH];
568 static Fr_ConfigType user_configuration = {
569         .clusterConfiguration = &user_cluster_config,
570         .nodeConfiguration = &user_node_config,
571         .msgRAMConfig = &user_msg_ram_config,
572         .staticBufferConfigs = user_static_buffer_config,
573         .dynamicBufferConfigs = user_dynamic_buffer_config,
574         .fifoBufferConfigs = user_fifo_buffer_config,
575 };
576 ;
577
578 #define USER_CONFIG_NOT_DONE        0x0
579 #define USER_CONFIG_CLUSTER         0x1
580 #define USER_CONFIG_NODE            0x2
581
582 static uint8_t user_configuration_state = USER_CONFIG_NOT_DONE;
583 static uint8_t user_static_buffer_configured = 0;
584 static uint8_t user_dynamic_buffer_configured = 0;
585 static uint8_t user_fifo_buffer_depth = 0;
586
587 /**
588  * Split string into numbers
589  *
590  * The function takes a string with hexadecimal numbers,
591  * separated by spaces, and converts it into an array of numbers.
592  *
593  * For example "0x2 0xA 0XDD 0xABCD" -> {0x2, 0xA, 0XDD, 0xABCD}
594  *
595  * @param [in] params Address of the string which will be converted
596  * @param [in] params_cnt A number of parameters, which should be found and converted from the string params
597  * @param [out] tmp_params Address, where converted array of numbers will be stored
598  *
599  * @return SUCCESS when all parameters were converted to the array of numbers,
600  *         FAILURE when the string was too short, too long or some other error occurred.
601  */
602 static int8_t cmd_fr_parse_params(const char *params, uint32_t params_cnt, uint32_t *tmp_params)
603 {
604         char cpy_params[256];
605         char *token;
606         int i;
607
608         if (params == NULL || tmp_params == NULL)
609                 return FAILURE;
610         strncpy(cpy_params, params, 256);
611         token = strtok(cpy_params, " ");
612         if (token == NULL)
613                 return FAILURE;
614         for (i = 0; i < params_cnt; i++) {
615                 if (sscanf(token, "%i", &tmp_params[i]) == EOF)     // No number found
616                         return FAILURE;
617                 if ((token = strtok(NULL, " ")) == NULL && i < params_cnt-1)    // Not enough parameters in the string
618                         return FAILURE;
619         }
620         return SUCCESS;
621 }
622
623 int8_t cmd_fr_config_cluster_params(const char *params)
624 {
625         uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
626
627         if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE)
628                 return FAILURE;
629
630         user_cluster_config.gColdStartAttempts = tmp_params[0];
631         user_cluster_config.gListenNoise = tmp_params[1];
632         user_cluster_config.gMacroPerCycle = tmp_params[2];
633         user_cluster_config.gMaxWithoutClockCorrectionFatal = tmp_params[3];
634         user_cluster_config.gMaxWithoutClockCorrectionPassive = tmp_params[4];
635         user_cluster_config.gNetworkManagementVectorLength = tmp_params[5];
636         user_cluster_config.gNumberOfMinislots = tmp_params[6];
637         user_cluster_config.gNumberOfStaticSlots = tmp_params[7];
638         user_cluster_config.gOffsetCorrectionStart = tmp_params[8];
639         user_cluster_config.gPayloadLengthStatic = tmp_params[9];
640         user_cluster_config.gSyncNodeMax = tmp_params[10];
641         user_cluster_config.gdActionPointOffset = tmp_params[11];
642         user_cluster_config.gdCASRxLowMax = tmp_params[12];
643         user_cluster_config.gdDynamicSlotIdlePhase = tmp_params[13];
644         user_cluster_config.gdMinislot = tmp_params[14];
645         user_cluster_config.gdMinislotActionPointOffset = tmp_params[15];
646         user_cluster_config.gdNIT = tmp_params[16];
647         user_cluster_config.gdSampleClockPeriod = tmp_params[17];
648         user_cluster_config.gdStaticSlot = tmp_params[18];
649         user_cluster_config.gdTSSTransmitter = tmp_params[19];
650         user_cluster_config.gdWakeupSymbolRxIdle = tmp_params[20];
651         user_cluster_config.gdWakeupSymbolRxLow = tmp_params[21];
652         user_cluster_config.gdWakeupSymbolRxWindow = tmp_params[22];
653         user_cluster_config.gdWakeupSymbolTxIdle = tmp_params[23];
654         user_cluster_config.gdWakeupSymbolTxLow = tmp_params[24];
655
656         user_configuration_state |= USER_CONFIG_CLUSTER;
657         return SUCCESS;
658 }
659
660 int8_t cmd_fr_config_node_params(const char *params)
661 {
662         uint32_t tmp_params[FR_NODE_PARAMS_CNT+2];  // +2 because two more parameters from message RAM structure are expected in the string.
663         Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
664         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};
665
666         if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE)
667                 return FAILURE;
668
669         user_node_config.pAllowHaltDueToClock = tmp_params[0];
670         user_node_config.pAllowPassiveToActive = tmp_params[1];
671         if (tmp_params[2] > 2) return FAILURE;
672         user_node_config.pChannels = channels[ tmp_params[2] ];
673         user_node_config.pClusterDriftDamping = tmp_params[3];
674         user_node_config.pDelayCompensationA = tmp_params[4];
675         user_node_config.pDelayCompensationB = tmp_params[5];
676         user_node_config.pExternOffsetCorrection = tmp_params[6];
677         user_node_config.pExternRateCorrection = tmp_params[7];
678         user_node_config.pKeySlotUsedForStartup = tmp_params[8];
679         user_node_config.pKeySlotUsedForSync = tmp_params[9];
680         user_node_config.pLatestTx = tmp_params[10];
681         user_node_config.pMacroInitialOffsetA = tmp_params[11];
682         user_node_config.pMacroInitialOffsetB = tmp_params[12];
683         user_node_config.pMicroInitialOffsetA = tmp_params[13];
684         user_node_config.pMicroInitialOffsetB = tmp_params[14];
685         user_node_config.pMicroPerCycle = tmp_params[15];
686         user_node_config.pRateCorrectionOut = tmp_params[16];
687         user_node_config.pOffsetCorrectionOut = tmp_params[17];
688         user_node_config.pSamplesPerMicrotick = tmp_params[18];
689         user_node_config.pSingleSlotEnabled = tmp_params[19];
690         if (tmp_params[20] > 1) return FAILURE;
691         user_node_config.pWakeupChannel = channels[ tmp_params[20] ];
692         user_node_config.pWakeupPattern = tmp_params[21];
693         user_node_config.pdAcceptedStartupRange = tmp_params[22];
694         user_node_config.pdListenTimeout = tmp_params[23];
695         user_node_config.pdMaxDrift = tmp_params[24];
696         user_node_config.pDecodingCorrection = tmp_params[25];
697         user_msg_ram_config.syncFramePayloadMultiplexEnabled = tmp_params[26];
698         if (tmp_params[27] > 3) return FAILURE;
699         user_msg_ram_config.secureBuffers = secure[ tmp_params[27] ];
700
701         user_configuration_state |= USER_CONFIG_NODE;
702         return SUCCESS;
703 }
704
705 int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
706 {
707         Fr_TMS570LS_BufferConfigType *fifo_buffer_ptr = &user_fifo_buffer_config[0];
708         int ret, i;
709         char channel[3], rej_static_frames[8], rej_null_frames[8];
710         unsigned depth, slot, cycleset, maxpayload, mask;
711         Fr_TMS570LS_BufferConfigType tmp_buffer;
712
713         if (fr_initialized) {
714                 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
715                 return -CMDERR_BADCFG;
716         }
717
718         ret = sscanf(param[2], "rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s",
719                                  &slot,
720                                  &mask,
721                                  &depth,
722                                  channel,
723                                  &cycleset,
724                                  &maxpayload,
725                                  rej_null_frames,
726                                  rej_static_frames
727                                  );
728         if (ret != 8) {
729                 printf("Error parsing parameter %d\n", ret+1);
730                 return -CMDERR_BADPAR;
731         }
732
733         if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
734                 return badpar("Depth too high\n");
735         user_fifo_buffer_depth = depth;
736
737         if (slot > 2047)
738                 return badpar("Invalid slot number\n");
739         tmp_buffer.slotId = slot;
740         if (slot > 2047)
741                 return badpar("Invalid mask\n");
742         tmp_buffer.fidMask = mask;
743         if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
744         else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
745         else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
746         else return badpar("Channel parsing error\n");
747
748         if (cycleset >= 0x80)
749                 return badpar("Cycle set must be less than 0x80.\n");
750         tmp_buffer.cycleCounterFiltering = cycleset;
751
752         if (maxpayload >= 128)
753                 return badpar("Maximum payload in half-words must be less than 128\n");
754         tmp_buffer.maxPayload = maxpayload;
755
756         if (strcmp(rej_null_frames, "rejnull") == 0) tmp_buffer.rejectNullFrames = true;
757         else if (strcmp(rej_null_frames, "accnull") == 0) tmp_buffer.rejectNullFrames = false;
758         else return badpar("Reject/accept NULL frames parsing error\n");
759
760         if (strcmp(rej_static_frames, "rejstat") == 0)
761                 tmp_buffer.rejectStaticSegment = true;
762         else if (strcmp(rej_static_frames, "accstat") == 0)
763                 tmp_buffer.rejectStaticSegment = false;
764         else return badpar("Invalid reject/accept static frame parameter");
765
766         for (i = 0; i < user_fifo_buffer_depth; i++) {
767                 fifo_buffer_ptr[i].slotId = tmp_buffer.slotId;
768                 fifo_buffer_ptr[i].fidMask = tmp_buffer.fidMask;
769                 fifo_buffer_ptr[i].maxPayload = tmp_buffer.maxPayload;
770                 fifo_buffer_ptr[i].channel = tmp_buffer.channel;
771                 fifo_buffer_ptr[i].cycleCounterFiltering = tmp_buffer.cycleCounterFiltering;
772                 fifo_buffer_ptr[i].isTx = FALSE;
773                 fifo_buffer_ptr[i].singleTransmit = FALSE;
774                 fifo_buffer_ptr[i].payloadPreambleIndicatorTr = FALSE;
775                 fifo_buffer_ptr[i].rejectNullFrames = tmp_buffer.rejectNullFrames;
776                 fifo_buffer_ptr[i].rejectStaticSegment = tmp_buffer.rejectStaticSegment;
777                 fifo_buffer_ptr[i].msgBufferInterrupt = 0;
778         }
779
780         printf("frbtcfgfifo rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s\n",
781                    slot,
782                    mask,
783                    depth,
784                    channel,
785                    cycleset,
786                    maxpayload,
787                    rej_null_frames,
788                    rej_static_frames
789                    );
790
791         return SUCCESS;
792 }
793
794 int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
795 {
796         Fr_TMS570LS_BufferConfigType *cfg;
797
798         int ret;
799         char buf_type, channel[3],rxtx[3], single_continuous[11];
800         unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
801
802         if (fr_initialized) {
803                 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
804                 return -CMDERR_BADCFG;
805         }
806
807         ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
808                                  &buf_type,
809                                  &buffer,
810                                  &slot,
811                                  channel,
812                                  &cycleset,
813                                  rxtx,
814                                  &maxpayload,
815                                  single_continuous,
816                                  &preamb,
817                                  &intr
818                                  );
819         if (ret != 10) {
820                 printf("Error parsing parameter %d\n", ret+1);
821                 return -CMDERR_BADPAR;
822
823         }
824
825         switch (buf_type) {
826         case 'S':
827                 if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
828                         return badpar("Buffer index too high\n");
829                 cfg = &user_static_buffer_config[buffer];
830                 break;
831         case 'D':
832                 if (buffer >= RPP_FR_MAX_DYNAMIC_BUF_CNT)
833                         return badpar("Buffer index too high\n");
834                 cfg = &user_dynamic_buffer_config[buffer];
835                 break;
836         default:
837                 return badpar("Invalid buffer type (S, D)\n");
838         }
839
840         if (slot < 1 || slot > 2047)
841                 return badpar("Invalid slot number\n");
842         cfg->slotId = slot;
843
844         if (strcmp(channel, "A") == 0) cfg->channel = FR_CHANNEL_A;
845         else if (strcmp(channel, "B") == 0) cfg->channel = FR_CHANNEL_B;
846         else if (strcmp(channel, "AB") == 0) cfg->channel = FR_CHANNEL_AB;
847         else return badpar("Channel parsing error\n");
848         if (buf_type == 'D' && cfg->channel == FR_CHANNEL_AB)
849                 return badpar("Dynamic segment buffers cannot have AB channels.\n");
850
851         if (cycleset >= 0x80)
852                 return badpar("Cycle set must be less than 0x80.\n");
853         cfg->cycleCounterFiltering = cycleset;
854
855         if (strcmp(rxtx, "tx") == 0) cfg->isTx = true;
856         else if (strcmp(rxtx, "rx") == 0) cfg->isTx = false;
857         else return badpar("RX/TX parsing error\n");
858
859         if (maxpayload >= 128)
860                 return badpar("Maximum payload in half-words must be less than 128\n");
861         cfg->maxPayload = maxpayload;
862
863         if (0 == strcmp(single_continuous, "single") ||
864                 0 == strcmp(single_continuous, "s"))
865                 cfg->singleTransmit = true;
866         else if (0 == strcmp(single_continuous, "continuous") ||
867                          0 == strcmp(single_continuous, "c"))
868                 cfg->singleTransmit = false;
869         else return badpar("Invalid single/continuous parameter");
870
871         if (preamb > 1)
872                 return badpar("Payload preamble indicator must be 0 or 1");
873         cfg->payloadPreambleIndicatorTr = preamb;
874
875         if (intr > 1)
876                 return badpar("Interrupt parameter must be 0 or 1");
877         cfg->msgBufferInterrupt = intr;
878
879         switch (buf_type) {
880         case 'S':
881                 if (buffer >= user_static_buffer_configured)
882                         user_static_buffer_configured = buffer + 1;
883                 break;
884         case 'D':
885                 if (buffer >= user_dynamic_buffer_configured)
886                         user_dynamic_buffer_configured = buffer + 1;
887                 break;
888         }
889
890         printf("frbtcfgbuf%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i\n",
891                    buf_type,
892                    buffer,
893                    slot,
894                    channel,
895                    cycleset,
896                    rxtx,
897                    maxpayload,
898                    single_continuous,
899                    preamb,
900                    intr
901                    );
902
903         return 0;
904 }
905
906
907
908 /**
909  *  @brief      Do the user configuration of the FlexRay cluster parameters
910  *
911  * @param[in]   cmd_io  Pointer to IO stack
912  * @param[in]   des             Pointer to command descriptor
913  * @param[in]   param   Parameters of command
914  * @return      0 when OK or error code
915  */
916 int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
917 {
918         char *token;
919
920         if (fr_initialized) {
921                 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
922                 return -CMDERR_BADCFG;
923         }
924
925         token = strtok(param[1], " ");
926         if (strcmp(token, "cluster") == 0) {
927                 if (cmd_fr_config_cluster_params(param[2]) == FAILURE) {
928                         rpp_sci_printf("FlexRay cluster configuration not accepted.\n");
929                         return -CMDERR_BADPAR;
930                 }
931                 rpp_sci_printf("FlexRay cluster configuration accepted.\n");
932         }
933         else if (strcmp(token, "node") == 0) {
934                 if (cmd_fr_config_node_params(param[2]) == FAILURE) {
935                         rpp_sci_printf("FlexRay node configuration not accepted.\n");
936                         return -CMDERR_BADPAR;
937                 }
938                 rpp_sci_printf("FlexRay node configuration accepted.\n");
939         }
940         else
941                 return -CMDERR_BADPAR;
942
943         return 0;
944 }
945
946 /**
947  *  @brief      Initialize the device as FlexRay node.
948  *
949  * @param[in]   cmd_io  Pointer to IO stack
950  * @param[in]   des             Pointer to command descriptor
951  * @param[in]   param   Parameters of command
952  * @return      0 when OK or error code
953  */
954 int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
955 {
956         const Fr_ConfigType *Fr_ConfigPtr = NULL;
957         int8_t retVal = SUCCESS;
958         uint32_t error = ERR_PARAM_NO_ERROR;
959
960         if (*param[1] == 'A')
961                 Fr_ConfigPtr = &Fr_config_node_A;
962         else if (*param[1] == 'B')
963                 Fr_ConfigPtr = &Fr_config_node_B;
964         else if (*param[1] == 'U') {    // Select the user configuration  -  call config commands first
965                 user_msg_ram_config.statSegmentBufferCount = user_static_buffer_configured;
966                 user_msg_ram_config.dynSegmentBufferCount = user_dynamic_buffer_configured;
967                 user_msg_ram_config.fifoBufferCount = user_fifo_buffer_depth;
968                 Fr_ConfigPtr = &user_configuration;
969         }
970         else
971                 return -CMDERR_BADPAR;
972
973         retVal = rpp_fr_init_driver(Fr_ConfigPtr, &error);
974         if (retVal == SUCCESS) {
975                 rpp_sci_printf("FlexRay driver initialized.\r\n");
976                 fr_initialized = TRUE;
977         }
978         else {
979                 retVal = rpp_fr_init_controller(0, &error);
980                 if (retVal == SUCCESS) {
981                         rpp_sci_printf("FlexRay controller reinitialized.\r\n");
982                         return 0;
983                 }
984                 else {
985                         rpp_sci_printf("FlexRay needs to be configured before initialization.\r\n");
986                         return -CMDERR_BADCFG;
987                 }
988         }
989
990         retVal = rpp_fr_init_controller(0, &error);
991         if (retVal == SUCCESS)
992                 rpp_sci_printf("FlexRay controller initialized.\r\n");
993         else {
994                 if (error & FR_INIT_ERR_CLUSTER_CONFIG)
995                         rpp_sci_printf("Cluster configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
996                 else if (error & FR_INIT_ERR_NODE_CONFIG)
997                         rpp_sci_printf("Node configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
998                 else if (error & FR_INIT_ERR_MSGRAM_CONFIG)
999                         rpp_sci_printf("Message RAM configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1000                 else if (error & FR_INIT_ERR_BUFFPARAM_CONFIG)
1001                         rpp_sci_printf("Buffer configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1002                 else if (error & (uint32_t)FR_INIT_ERR_BUFF_CONFIG)
1003                         rpp_sci_printf("Buffer configuration error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1004                 else
1005                         rpp_sci_printf("POC state switching error.\r\n");
1006                 return -CMDERR_BADCFG;
1007         }
1008         return 0;
1009 }
1010
1011 /**
1012  *  @brief      Starts FlexRay communication
1013  *
1014  * @param[in]   cmd_io  Pointer to IO stack
1015  * @param[in]   des             Pointer to command descriptor
1016  * @param[in]   param   Parameters of command
1017  * @return      0 when OK or error code
1018  */
1019 int cmd_do_fr_start(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1020 {
1021         int8_t retVal = SUCCESS;
1022         uint32_t error = ERR_PARAM_NO_ERROR;
1023
1024         retVal = rpp_fr_start_communication(0, &error);
1025         if (retVal == SUCCESS)
1026                 rpp_sci_printf("FlexRay communication is running.\r\n");
1027         else {
1028                 if (error & FR_STARTUP_ERR_SW_STUP_FOLLOW)
1029                         rpp_sci_printf("Can not switch POC to RUN state.\r\n");
1030                 else if (error & FR_STARTUP_ERR_CSINH_DIS)
1031                         rpp_sci_printf("Cold start inhibit disabled error.\r\n");
1032                 else if (error & FR_STARTUP_ERR_SW_STUP_READY)
1033                         rpp_sci_printf("Can not switch back to READY from STARTUP.\r\n");
1034                 else if (error & FR_STARTUP_ERR_SW_STUP_AS_NCOLD)
1035                         rpp_sci_printf("Can not switch to STARTUP as non-coldstarter.\r\n");
1036                 else
1037                         rpp_sci_printf("General error.\r\n");
1038                 return -CMDERR_BADCFG;
1039         }
1040         return 0;
1041 }
1042
1043 /**
1044  *  @brief      Invokes POC command ALL_SLOTS
1045  *
1046  * @param[in]   cmd_io  Pointer to IO stack
1047  * @param[in]   des             Pointer to command descriptor
1048  * @param[in]   param   Parameters of command
1049  * @return      0 when OK or error code
1050  */
1051 int cmd_do_fr_allslots(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1052 {
1053         int8_t retVal = ERR_PARAM_NO_ERROR;
1054
1055         retVal = rpp_fr_all_slots(0);
1056         if (retVal == SUCCESS)
1057                 rpp_sci_printf("FlexRay node started communication in all slots.\r\n");
1058         else {
1059                 rpp_sci_printf("General error.\r\n");
1060                 return -CMDERR_BADCFG;
1061         }
1062         return 0;
1063 }
1064
1065 /**
1066  *  @brief      Halt FlexRay communication
1067  *
1068  * @param[in]   cmd_io  Pointer to IO stack
1069  * @param[in]   des             Pointer to command descriptor
1070  * @param[in]   param   Parameters of command
1071  * @return      0 when OK or error code
1072  */
1073 int cmd_do_fr_halt(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1074 {
1075         int8_t retVal = ERR_PARAM_NO_ERROR;
1076
1077         retVal = rpp_fr_halt_communication(0);
1078         if (retVal == SUCCESS)
1079                 rpp_sci_printf("FlexRay node communication halted.\r\n");
1080         else {
1081                 rpp_sci_printf("General error.\r\n");
1082                 return -CMDERR_BADCFG;
1083         }
1084         return 0;
1085 }
1086
1087 /**
1088  *  @brief      Abort FlexRay communication
1089  *
1090  * @param[in]   cmd_io  Pointer to IO stack
1091  * @param[in]   des             Pointer to command descriptor
1092  * @param[in]   param   Parameters of command
1093  * @return      0 when OK or error code
1094  */
1095 int cmd_do_fr_abort(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1096 {
1097         int8_t retVal = ERR_PARAM_NO_ERROR;
1098
1099         retVal = rpp_fr_abort_communication(0);
1100         if (retVal == SUCCESS)
1101                 rpp_sci_printf("FlexRay node communication aborted.\r\n");
1102         else {
1103                 rpp_sci_printf("General error.\r\n");
1104                 return -CMDERR_BADCFG;
1105         }
1106         return 0;
1107 }
1108
1109 /**
1110  *  @brief      Send wake up pattern
1111  *
1112  * @param[in]   cmd_io  Pointer to IO stack
1113  * @param[in]   des             Pointer to command descriptor
1114  * @param[in]   param   Parameters of command
1115  * @return      0 when OK or error code
1116  */
1117 int cmd_do_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1118 {
1119         int8_t retVal = ERR_PARAM_NO_ERROR;
1120
1121         retVal = rpp_fr_send_wup(0);
1122         if (retVal == SUCCESS)
1123                 rpp_sci_printf("Wake up pattern has been sent.\r\n");
1124         else {
1125                 rpp_sci_printf("General error.\r\n");
1126                 return -CMDERR_BADCFG;
1127         }
1128         return 0;
1129 }
1130
1131 /**
1132  *  @brief      Set channel for wake up pattern sending.
1133  *
1134  * @param[in]   cmd_io  Pointer to IO stack
1135  * @param[in]   des             Pointer to command descriptor
1136  * @param[in]   param   Parameters of command
1137  * @return      0 when OK or error code
1138  */
1139 int cmd_do_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1140 {
1141         int8_t retVal = ERR_PARAM_NO_ERROR;
1142         Fr_ChannelType channel = FR_CHANNEL_A;
1143
1144         if (*param[1] == 'A')
1145                 channel = FR_CHANNEL_A;
1146         else if (*param[1] == 'B')
1147                 channel = FR_CHANNEL_B;
1148         else
1149                 return -CMDERR_BADPAR;
1150         retVal = rpp_fr_set_wu_channel(0, channel);
1151         if (retVal == SUCCESS)
1152                 rpp_sci_printf("Wake up channel has been set.\r\n");
1153         else {
1154                 rpp_sci_printf("General error.\r\n");
1155                 return -CMDERR_BADCFG;
1156         }
1157         return 0;
1158 }
1159
1160 /**
1161  *  @brief      Get and print POC status of the FlexRay controller.
1162  *
1163  * @param[in]   cmd_io  Pointer to IO stack
1164  * @param[in]   des             Pointer to command descriptor
1165  * @param[in]   param   Parameters of command
1166  * @return      0 when OK or error code
1167  */
1168 int cmd_do_fr_getpocstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1169 {
1170         int8_t retVal = ERR_PARAM_NO_ERROR;
1171         Fr_POCStatusType status;
1172         char *ErrorModeStrings[] = {"ACTIVE", "HALT", "PASSIVE"};
1173         char *SlotModeStrings[]  = {"KEYSLOT", "ALL_PENDING", "ALL"};
1174         char *StartupStateStrings[]  = {
1175                 "UNDEFINED", "COLDSTART_LISTEN", "COLDSTART_CHECK", "COLDSTART_JOIN",
1176                 "COLDSTART_CONSISTENCY_CHECK", "INTEGRATION_LISTEN", "INITIALIZE_SCHEDULE", "INTEGRATION_CONSISTENCY_CHECK",
1177                 "COLDSTART_GAP", "EXTERNAL_STARTUP", "ABORT", "COLDSTART_COLLISION_RESOLUTION",
1178                 "PREPARE"
1179         };
1180         char *StateStrings[]  = {
1181                 "CONFIG", "DEFAULT_CONFIG", "HALT", "NORMAL_ACTIVE",
1182                 "NORMAL_PASSIVE", "READY", "STARTUP", "LOOPBACK",
1183                 "MONITOR", "WAKEUP"
1184         };
1185         char *WakeupStatusStrings[]  = {
1186                 "UNDEFINED", "RECEIVED_HEADER", "RECEIVED_WUP", "COLLISION_HEADER",
1187                 "COLLISION_WUP", "COLLISION_UNKNOWN", "TRANSMITTED"
1188         };
1189
1190         retVal = rpp_fr_get_poc_status(0, &status);
1191         if (retVal == SUCCESS) {
1192                 rpp_sci_printf("POC status:\r\n");
1193                 rpp_sci_printf("CHIHaltRequest: %s\r\n", (status.CHIHaltRequest == TRUE) ? "TRUE" : "FALSE");
1194                 rpp_sci_printf("CHIReadyRequest: %s\r\n", (status.CHIReadyRequest == TRUE) ? "TRUE" : "FALSE");
1195                 rpp_sci_printf("ColdstartNoise: %s\r\n", (status.ColdstartNoise == TRUE) ? "TRUE" : "FALSE");
1196                 rpp_sci_printf("Freeze: %s\r\n", (status.Freeze == TRUE) ? "TRUE" : "FALSE");
1197                 rpp_sci_printf("ErrorMode: %s\r\n", ErrorModeStrings[status.ErrorMode]);
1198                 rpp_sci_printf("SlotMode: %s\r\n", SlotModeStrings[status.SlotMode]);
1199                 rpp_sci_printf("StartupState: %s\r\n", StartupStateStrings[status.StartupState]);
1200                 rpp_sci_printf("State: %s\r\n", StateStrings[status.State]);
1201                 rpp_sci_printf("WakeupStatus: %s\r\n", WakeupStatusStrings[status.WakeupStatus]);
1202         }
1203         else {
1204                 rpp_sci_printf("General error.\r\n");
1205                 return -CMDERR_BADCFG;
1206         }
1207         return 0;
1208 }
1209
1210 /**
1211  *  @brief      Send given data through the FlexRay in selected slot.
1212  *
1213  * @param[in]   cmd_io  Pointer to IO stack
1214  * @param[in]   des             Pointer to command descriptor
1215  * @param[in]   param   Parameters of command
1216  * @return      0 when OK or error code
1217  */
1218 int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1219 {
1220         int8_t retVal = ERR_PARAM_NO_ERROR;
1221         uint32_t slotID;
1222         uint8_t dataLength;
1223         int values[MAX_PARAM_VALUES_NUM];
1224         uint8_t data[MAX_PARAM_VALUES_NUM];
1225         char *token = NULL;
1226
1227         if (sscanf(param[1], "%d", &slotID) != 1)
1228                 return -CMDERR_BADPAR;
1229         if (sscanf(param[2], " %2x", &values[0]) != 1)
1230                 return -CMDERR_BADPAR;
1231         data[0] = (uint8_t)values[0];
1232         token = strtok(param[2], " ");
1233         token = strtok(NULL, " ");
1234         dataLength = 1;
1235         while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
1236                 if (sscanf(token, "%2x", &values[dataLength]) == EOF)
1237                         break;
1238                 data[dataLength] = (uint8_t)values[dataLength];
1239                 token = strtok(NULL, " ");
1240                 dataLength++;
1241         }
1242
1243         retVal = rpp_fr_transmit_lpdu(0, slotID, data, dataLength);
1244         if (retVal == SUCCESS)
1245                 rpp_sci_printf("Data were set for transmission.\r\n");
1246         else {
1247                 rpp_sci_printf("General error.\r\n");
1248                 return -CMDERR_BADCFG;
1249         }
1250         return 0;
1251 }
1252
1253 /**
1254  *  @brief      Cancel the transmission in the selected slot.
1255  *
1256  * @param[in]   cmd_io  Pointer to IO stack
1257  * @param[in]   des             Pointer to command descriptor
1258  * @param[in]   param   Parameters of command
1259  * @return      0 when OK or error code
1260  */
1261 int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1262 {
1263         int8_t retVal = ERR_PARAM_NO_ERROR;
1264         uint32_t slotID;
1265
1266         if (sscanf(param[1], "%d", &slotID) != 1)
1267                 return -CMDERR_BADPAR;
1268         if (param[2] != NULL)
1269                 return -CMDERR_BADPAR;
1270
1271         retVal = rpp_fr_cancel_transmit_lpdu(0, slotID);
1272         if (retVal == SUCCESS)
1273                 rpp_sci_printf("Transmission canceled.\r\n");
1274         else {
1275                 rpp_sci_printf("General error.\r\n");
1276                 return -CMDERR_BADCFG;
1277         }
1278         return 0;
1279 }
1280
1281 /**
1282  *  @brief      Receive data from selected slot.
1283  *
1284  * @param[in]   cmd_io  Pointer to IO stack
1285  * @param[in]   des             Pointer to command descriptor
1286  * @param[in]   param   Parameters of command
1287  * @return      0 when OK or error code
1288  */
1289 int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1290 {
1291         int8_t retVal = ERR_PARAM_NO_ERROR;
1292         uint32_t slotID;
1293         uint8_t data[cPayloadLengthMax];
1294         Fr_RxLPduStatusType status;
1295         uint8_t receivedLength = 0;
1296         uint8_t i;
1297
1298         if (sscanf(param[1], "%d", &slotID) != 1)
1299                 return -CMDERR_BADPAR;
1300         if (param[2] != NULL)
1301                 return -CMDERR_BADPAR;
1302
1303         memset(data, 0, sizeof(data));
1304
1305         retVal = rpp_fr_receive_lpdu(0, slotID, data, &status, &receivedLength);
1306         if (retVal == SUCCESS) {
1307                 switch (status) {
1308                 case FR_RECEIVED_MORE_DATA_AVAILABLE:
1309                         rpp_sci_printf("More messages are still in FIFO:\r\n");
1310                 case FR_RECEIVED:
1311                         rpp_sci_printf("Received message (%d B):\r\n", receivedLength);
1312                         for (i = 0; i < receivedLength; i++) {
1313                                 rpp_sci_printf(" %02x", data[i]);
1314                         }
1315                         rpp_sci_printf("\r\n");
1316                         break;
1317                 default:
1318                         rpp_sci_printf("No message received.\r\n");
1319                         break;
1320                 }
1321         }
1322         else {
1323                 rpp_sci_printf("General error.\r\n");
1324                 return -CMDERR_BADCFG;
1325         }
1326         return 0;
1327 }
1328
1329 /**
1330  *  @brief      Returns TX LPdu status.
1331  *
1332  * @param[in]   cmd_io  Pointer to IO stack
1333  * @param[in]   des             Pointer to command descriptor
1334  * @param[in]   param   Parameters of command
1335  * @return      0 when OK or error code
1336  */
1337 int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1338 {
1339         int8_t retVal = ERR_PARAM_NO_ERROR;
1340         uint32_t slotID;
1341         Fr_TxLPduStatusType status;
1342         char *statusStrings[] = {"is not", "is"};
1343
1344         if (sscanf(param[1], "%d", &slotID) != 1)
1345                 return -CMDERR_BADPAR;
1346         if (param[2] != NULL)
1347                 return -CMDERR_BADPAR;
1348
1349         retVal = rpp_fr_check_tx_lpdu_status(0, slotID, &status);
1350         if (retVal == SUCCESS)
1351                 rpp_sci_printf("Message transmission %s pending.\r\n", statusStrings[status]);
1352         else {
1353                 rpp_sci_printf("General error.\r\n");
1354                 return -CMDERR_BADCFG;
1355         }
1356         return 0;
1357 }
1358
1359 /**
1360  *  @brief      Disable buffer.
1361  *
1362  * @param[in]   cmd_io  Pointer to IO stack
1363  * @param[in]   des             Pointer to command descriptor
1364  * @param[in]   param   Parameters of command
1365  * @return      0 when OK or error code
1366  */
1367 int cmd_do_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1368 {
1369         int8_t retVal = ERR_PARAM_NO_ERROR;
1370         uint32_t slotID;
1371
1372         if (sscanf(param[1], "%d", &slotID) != 1)
1373                 return -CMDERR_BADPAR;
1374         if (param[2] != NULL)
1375                 return -CMDERR_BADPAR;
1376
1377         retVal = rpp_fr_disable_lpdu(0, slotID);
1378         if (retVal == SUCCESS)
1379                 rpp_sci_printf("Buffer disabled.\r\n");
1380         else {
1381                 rpp_sci_printf("General error.\r\n");
1382                 return -CMDERR_BADCFG;
1383         }
1384         return 0;
1385 }
1386
1387 /**
1388  *  @brief      Print global time of the FlexRay network.
1389  *
1390  * @param[in]   cmd_io  Pointer to IO stack
1391  * @param[in]   des             Pointer to command descriptor
1392  * @param[in]   param   Parameters of command
1393  * @return      0 when OK or error code
1394  */
1395 int cmd_do_fr_getglobaltime(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1396 {
1397         int8_t retVal = ERR_PARAM_NO_ERROR;
1398         uint8_t cycle = 0;
1399         uint16_t macroTick = 0;
1400
1401         retVal = rpp_fr_get_global_time(0, &cycle, &macroTick);
1402         if (retVal == SUCCESS)
1403                 rpp_sci_printf("Cycle number: %d\r\nMacrotick number: %d\r\n", cycle, macroTick);
1404         else {
1405                 rpp_sci_printf("General error.\r\n");
1406                 return -CMDERR_BADCFG;
1407         }
1408         return 0;
1409 }
1410
1411 /**
1412  *  @brief      Print network management vector of the FlexRay node.
1413  *
1414  * @param[in]   cmd_io  Pointer to IO stack
1415  * @param[in]   des             Pointer to command descriptor
1416  * @param[in]   param   Parameters of command
1417  * @return      0 when OK or error code
1418  */
1419 int cmd_do_fr_getnmvector(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1420 {
1421         int8_t retVal = ERR_PARAM_NO_ERROR;
1422         uint8_t nmVector[12];
1423         uint8_t i;
1424
1425         retVal = rpp_fr_get_network_management_vector(0, nmVector);
1426         if (retVal == SUCCESS) {
1427                 rpp_sci_printf("Network management vector:");
1428                 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1429                         rpp_sci_printf(" %x", nmVector[i]);
1430                 }
1431                 rpp_sci_printf("\r\n");
1432         }
1433         else {
1434                 rpp_sci_printf("General error.\r\n");
1435                 return -CMDERR_BADCFG;
1436         }
1437         return 0;
1438 }
1439
1440 int cmd_do_fr_nmwatch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1441 {
1442         int8_t retVal = ERR_PARAM_NO_ERROR;
1443         uint8_t nmVector[12];
1444         uint8_t i;
1445
1446         // Calculate wait time in OS ticks
1447         static const portTickType freq_ticks = 100 /* ms */ / portTICK_RATE_MS;
1448         portTickType last_wake_time = xTaskGetTickCount();
1449
1450         while (cmd_io->getc(cmd_io) < 0) {
1451                 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1452                 if (retVal == SUCCESS) {
1453                         rpp_sci_printf("Network management vector:");
1454                         for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1455                                 rpp_sci_printf(" %02x", nmVector[i]);
1456                         }
1457                         rpp_sci_printf("\r");
1458                 }
1459                 else {
1460                         rpp_sci_printf("General error.\r\n");
1461                         return -CMDERR_BADCFG;
1462                 }
1463                 vTaskDelayUntil(&last_wake_time, freq_ticks);
1464         }
1465         rpp_sci_printf("\n");
1466         return 0;
1467 }
1468
1469 /**
1470  *  @brief      Print both channels status of the FlexRay node.
1471  *
1472  * @param[in]   cmd_io  Pointer to IO stack
1473  * @param[in]   des             Pointer to command descriptor
1474  * @param[in]   param   Parameters of command
1475  * @return      0 when OK or error code
1476  */
1477 int cmd_do_fr_getchannelstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1478 {
1479         int8_t retVal = ERR_PARAM_NO_ERROR;
1480         uint8_t index;
1481         uint8_t channel;
1482         char *decodeStrings[] = {
1483                 "aggregated channel status vSS!ValidFrame",
1484                 "aggregated channel status vSS!SyntaxError",
1485                 "aggregated channel status vSS!ContentError",
1486                 "aggregated channel status additional communication",
1487                 "aggregated channel status vSS!Bviolation",
1488                 "aggregated channel status vSS!TxConflict",
1489                 "Not used (0)",
1490                 "Not used (0)",
1491                 "symbol window status data vSS!ValidMTS",
1492                 "symbol window status data vSS!SyntaxError",
1493                 "symbol window status data vSS!Bviolation",
1494                 "symbol window status data vSS!TxConflict",
1495                 "NIT status data vSS!SyntaxError",
1496                 "NIT status data vSS!Bviolation",
1497                 "Not used (0)",
1498                 "Not used (0)"
1499         };
1500         char *channelNames[] = {"A", "B"};
1501         char *boolStrings[] = {"FALSE", "TRUE"};
1502         uint16_t channelStatuses[2];
1503
1504         retVal = rpp_fr_get_channel_status(0, &channelStatuses[0], &channelStatuses[1]);
1505         if (retVal == SUCCESS)
1506                 for (channel = 0; channel < 2; channel++) {
1507                         rpp_sci_printf("Channel %s status:\r\n", channelNames[channel]);
1508                         for (index = 0; index < 16; index++) {
1509                                 rpp_sci_printf("\t%s: %s\r\n", decodeStrings[index], boolStrings[ (channelStatuses[channel] >> index) & 0x1 ] );
1510                         }
1511                 }
1512         else {
1513                 rpp_sci_printf("General error.\r\n");
1514                 return -CMDERR_BADCFG;
1515         }
1516         return 0;
1517 }
1518
1519 /**
1520  *  @brief      Print clock correction of the FlexRay node
1521  *
1522  * @param[in]   cmd_io  Pointer to IO stack
1523  * @param[in]   des             Pointer to command descriptor
1524  * @param[in]   param   Parameters of command
1525  * @return      0 when OK or error code
1526  */
1527 int cmd_do_fr_getclockcorrection(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1528 {
1529         int8_t retVal = ERR_PARAM_NO_ERROR;
1530         int16_t rateCorrection;
1531         int32_t offsetCorrection;
1532
1533         retVal = rpp_fr_get_clock_correction(0, &rateCorrection, &offsetCorrection);
1534         if (retVal == SUCCESS)
1535                 rpp_sci_printf("Rate correction: %d\r\nOffset correction: %d\r\n", rateCorrection, offsetCorrection);
1536         else {
1537                 rpp_sci_printf("General error.\r\n");
1538                 return -CMDERR_BADCFG;
1539         }
1540         return 0;
1541 }
1542
1543 /**
1544  *  @brief      Print list of syncframec transmitted on both channels via the even and odd cycle.
1545  *
1546  * @param[in]   cmd_io  Pointer to IO stack
1547  * @param[in]   des             Pointer to command descriptor
1548  * @param[in]   param   Parameters of command
1549  * @return      0 when OK or error code
1550  */
1551 int cmd_do_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1552 {
1553         int8_t retVal = ERR_PARAM_NO_ERROR;
1554         uint16_t channelAEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1555         uint16_t channelBEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1556         uint16_t channelAOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1557         uint16_t channelBOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1558         uint32_t listSize = 0;
1559         uint8_t i;
1560
1561         if (sscanf(param[1], "%d", &listSize) != 1)
1562                 return -CMDERR_BADPAR;
1563         if (param[2] != NULL)
1564                 return -CMDERR_BADPAR;
1565         if (listSize > FR_MAX_SYNC_FRAME_LIST_SIZE)
1566                 return -CMDERR_BADPAR;
1567
1568         retVal = rpp_fr_get_sync_frame_list(0, listSize, channelAEvenList, channelBEvenList, channelAOddList, channelBOddList);
1569         if (retVal == SUCCESS) {
1570                 rpp_sci_printf("| Channel A even | channel B even | channel A odd  | channel B odd  |\r\n");
1571                 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1572                 for (i = 0; i < listSize; i++) {
1573                         rpp_sci_printf("| %-14x | %-14x | %-14x | %-14x |\r\n", channelAEvenList[i], channelBEvenList[i], channelAOddList[i], channelBOddList[i]);
1574                 }
1575                 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1576
1577         }
1578         else {
1579                 rpp_sci_printf("General error.\r\n");
1580                 return -CMDERR_BADCFG;
1581         }
1582         return 0;
1583 }
1584
1585 /**
1586  *  @brief      Print status of wakeup on each channels (wakeup received on channel or not yet received).
1587  *
1588  * @param[in]   cmd_io  Pointer to IO stack
1589  * @param[in]   des             Pointer to command descriptor
1590  * @param[in]   param   Parameters of command
1591  * @return      0 when OK or error code
1592  */
1593 int cmd_do_fr_getwakeuprxstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1594 {
1595         int8_t retVal = ERR_PARAM_NO_ERROR;
1596         uint8_t status = 0;
1597         char *statusStrings[] = {"was not yet", "was"};
1598         char *channelNames[] = {"A", "B"};
1599         uint8_t i;
1600
1601         retVal = rpp_fr_get_wakeup_rx_status(0, &status);
1602         if (retVal == SUCCESS)
1603                 for (i = 0; i < 2; i++) {
1604                         rpp_sci_printf("Wake up pattern %s received on channel %s.\r\n", statusStrings[(status >> i) & 0x1], channelNames[i]);
1605                 }
1606         else {
1607                 rpp_sci_printf("General error.\r\n");
1608                 return -CMDERR_BADCFG;
1609         }
1610         return 0;
1611 }
1612
1613 /**
1614  *  @brief      Set and start absolute timer.
1615  *
1616  * @param[in]   cmd_io  Pointer to IO stack
1617  * @param[in]   des             Pointer to command descriptor
1618  * @param[in]   param   Parameters of command
1619  * @return      0 when OK or error code
1620  */
1621 int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1622 {
1623         int8_t retVal = ERR_PARAM_NO_ERROR;
1624         int timer = 0;
1625         int cycle = 0;
1626         int offset = 0;
1627
1628         if (sscanf(param[1], "%i %i %i", &timer, &cycle, &offset) != 3)
1629                 return -CMDERR_BADPAR;
1630
1631         retVal = rpp_fr_set_timer(0, timer, cycle, offset);
1632         if (retVal == SUCCESS) {
1633                 uint8_t i = 0x40;
1634                 while (i && (cycle & i) == 0)
1635                         i >>= 1;
1636                 if (!i)
1637                         i = 1;
1638
1639                 rpp_sci_printf("Timer was set for every %d-th cycle, offset %d, macrotick %d\n",
1640                                            i, cycle & ~i, offset);
1641         }
1642         else {
1643                 rpp_sci_printf("General error.\r\n");
1644                 return -CMDERR_BADCFG;
1645         }
1646         return 0;
1647 }
1648
1649 /**
1650  *  @brief      Cancel selected timer
1651  *
1652  * @param[in]   cmd_io  Pointer to IO stack
1653  * @param[in]   des             Pointer to command descriptor
1654  * @param[in]   param   Parameters of command
1655  * @return      0 when OK or error code
1656  */
1657 int cmd_do_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1658 {
1659         int8_t retVal = ERR_PARAM_NO_ERROR;
1660         int timer = 0;
1661
1662         if (sscanf(param[1], "%d", &timer) != 1)
1663                 return -CMDERR_BADPAR;
1664
1665         if (param[2] != NULL)
1666                 return -CMDERR_BADPAR;
1667
1668         retVal = rpp_fr_cancel_timer(0, timer);
1669         if (retVal == SUCCESS)
1670                 rpp_sci_printf("Timer was canceled.\r\n");
1671         else {
1672                 rpp_sci_printf("General error.\r\n");
1673                 return -CMDERR_BADCFG;
1674         }
1675         return 0;
1676 }
1677
1678 /**
1679  *  @brief      Enable/disable, acknowledge, get timer IRQ
1680  *
1681  * @param[in]   cmd_io  Pointer to IO stack
1682  * @param[in]   des             Pointer to command descriptor
1683  * @param[in]   param   Parameters of command
1684  * @return      0 when OK or error code
1685  */
1686 int cmd_do_fr_timerirq(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1687 {
1688         int8_t retVal = ERR_PARAM_NO_ERROR;
1689         int timer = 0;
1690         char str[4];
1691         boolean_t status = FALSE;
1692         char *boolStrings[] = {"FALSE", "TRUE"};
1693
1694
1695         if (sscanf(param[1], "%d", &timer) != 1)
1696                 return -CMDERR_BADPAR;
1697
1698         if (param[2] == NULL) {     // Get timer IRQ
1699                 retVal = rpp_fr_get_timer_irq_status(0, timer, &status);
1700                 if (retVal == SUCCESS)
1701                         rpp_sci_printf("IRQ = %s\r\n", boolStrings[status]);
1702                 else {
1703                         rpp_sci_printf("General error.\r\n");
1704                         return -CMDERR_BADCFG;
1705                 }
1706         }
1707         else {  // Some set action
1708                 if (sscanf(param[2], "%4s", str) != 1)
1709                         return -CMDERR_BADPAR;
1710                 if (strcmp(str, "EN") == 0)   // Enable IRQ
1711                         retVal = SUCCESS;   // No interrupts imlemented
1712                 else if (strcmp(str, "DIS") == 0)   // Disable IRQ
1713                         retVal = SUCCESS;   // No interrupts implemented
1714                 else if  (strcmp(str, "ACK") == 0)   // Clear IRQ
1715                         retVal = rpp_fr_clear_timer_irq(0, timer);
1716                 else    // Bad argument
1717                         return -CMDERR_BADPAR;
1718
1719                 if (retVal == SUCCESS)
1720                         rpp_sci_printf("OK\r\n");
1721                 else {
1722                         rpp_sci_printf("General error.\r\n");
1723                         return -CMDERR_BADCFG;
1724                 }
1725         }
1726         return 0;
1727 }
1728
1729 /**
1730  *  @brief      Print FlexRay driver version info.
1731  *
1732  * @param[in]   cmd_io  Pointer to IO stack
1733  * @param[in]   des             Pointer to command descriptor
1734  * @param[in]   param   Parameters of command
1735  * @return      0 when OK or error code
1736  */
1737 int cmd_do_fr_getversioninfo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1738 {
1739         Std_VersionInfoType versionInfo;
1740
1741         rpp_fr_get_driver_version(&versionInfo);
1742         rpp_sci_printf("vendorID: %#x\r\n", versionInfo.vendorID);
1743         rpp_sci_printf("moduleID: %#x\r\n", versionInfo.moduleID);
1744         rpp_sci_printf("sw_major_version: %#x\r\n", versionInfo.sw_major_version);
1745         rpp_sci_printf("sw_minor_version: %#x\r\n", versionInfo.sw_minor_version);
1746         rpp_sci_printf("sw_patch_version: %#x\r\n", versionInfo.sw_patch_version);
1747
1748         return 0;
1749 }
1750
1751 /**
1752  *  @brief      Print value of FlexRay configuratoin parameter.
1753  *
1754  * @param[in]   cmd_io  Pointer to IO stack
1755  * @param[in]   des             Pointer to command descriptor
1756  * @param[in]   param   Parameters of command
1757  * @return      0 when OK or error code
1758  */
1759 int cmd_do_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1760 {
1761         int8_t retVal = ERR_PARAM_NO_ERROR;
1762         int index = 0;
1763         uint32_t value = 0;
1764
1765         if (sscanf(param[1], "%d", &index) != 1)
1766                 return -CMDERR_BADPAR;
1767
1768         if (param[2] != NULL)
1769                 return -CMDERR_BADPAR;
1770
1771         retVal = rpp_fr_read_com_ctrl_config(0, index, &value);
1772         if (retVal == SUCCESS)
1773                 rpp_sci_printf("Value = %#x\r\n", value);
1774         else {
1775                 rpp_sci_printf("General error.\r\n");
1776                 return -CMDERR_BADCFG;
1777         }
1778         return 0;
1779 }
1780
1781 /**
1782  *  @brief      Reconfigure buffer
1783  *
1784  * @param[in]   cmd_io  Pointer to IO stack
1785  * @param[in]   des             Pointer to command descriptor
1786  * @param[in]   param   Parameters of command
1787  * @return      0 when OK or error code
1788  */
1789 int cmd_do_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1790 {
1791         int ret;
1792         char channel[3];
1793         unsigned id, slot, maxpayload, cycleset, cycleoffset;
1794         Fr_TMS570LS_BufferConfigType tmp_buffer;
1795         boolean_t is_pow2;
1796         uint8_t pow2;
1797
1798         ret = sscanf(param[2], "id%i slot%i %2s cycset%i cycoffset%i max%i",
1799                                  &id,
1800                                  &slot,
1801                                  channel,
1802                                  &cycleset,
1803                                  &cycleoffset,
1804                                  &maxpayload
1805                                  );
1806         if (ret != 6) {
1807                 printf("Error parsing parameter %d\n", ret+1);
1808                 return -CMDERR_BADPAR;
1809         }
1810
1811         if (slot > 2047 || id > 2047)
1812                 return badpar("Invalid slot number\n");
1813         tmp_buffer.slotId = slot;
1814         if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
1815         else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
1816         else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
1817         else return badpar("Channel parsing error\n");
1818         if (cycleset == 0) cycleset = 1;
1819         for (pow2 = 1, is_pow2 = FALSE; pow2 < 128; pow2 *= 2) {
1820                 if (cycleset == pow2) {
1821                         is_pow2 = TRUE;
1822                         break;
1823                 }
1824         }
1825         if (!is_pow2)
1826                 return badpar("Cycle set must be one of 0, 1, 2, 4, 8, 16, 32, 64.\n");
1827         if (cycleoffset >= cycleset)
1828                 return badpar("Cycle offset must in range 0 - cycset-1.\n");
1829
1830         if (maxpayload >= 256)
1831                 return badpar("Maximum payload in bytes must be less than 256\n");
1832         tmp_buffer.maxPayload = maxpayload;
1833
1834         if (rpp_fr_reconfigure_lpdu(0, id, tmp_buffer.slotId, tmp_buffer.channel, cycleset, cycleoffset, tmp_buffer.maxPayload, 0) == SUCCESS) {
1835                 printf("id%i slot%i %2s cycset%i cycoffset%i max%i\n",
1836                            id,
1837                            slot,
1838                            channel,
1839                            cycleset,
1840                            cycleoffset,
1841                            maxpayload
1842                            );
1843                 return 0;
1844         }
1845         else
1846                 printf("Reconfiguration failed.\n");
1847         return -CMDERR_BADPAR;
1848 }
1849
1850 #endif  /* DOCGEN */
1851
1852 /** Command descriptor for FlexRay user config cluster command */
1853 cmd_des_t const cmd_des_fr_user_config = {
1854         0, 0,
1855         "frbtconfig*","Set the user configuration parameters",
1856         "### Command syntax ###\n"
1857         "\n"
1858         "    frbtconfig<TYPE> <PARAMS>\n"
1859         "where\n"
1860         "\n"
1861         "- `<TYPE>` is a string specifying the type of parameters to be set. It can be: \"cluster\" or  \"node\"\n"
1862         "- `<PARAMS>` is a sequence of numbers separated by spaces. Each number stands for one parameter.\n"
1863         "\n"
1864         "### Description ###\n"
1865         "\n"
1866         "The command takes the configuration parameters in the form of a string\n"
1867         "and sets the appropriate type of the FlexRay parameters. It is\n"
1868         "necessary to configure parameters of at least cluster, and node and\n"
1869         "one static buffer (see frbtcfgbuf command). The parameters set by this\n"
1870         "command are applied by the frbtinitU command. Once frbtinit is called,\n"
1871         "it is no longer possible to change the parameters.\n"
1872         "\n"
1873         "The type of the parameters can be selected by the `<TYPE>` selector.\n"
1874         "\n"
1875         "Type \"cluster\" sets global FlexRay network parameters. It expects a\n"
1876         "sequence of 25 parameters in this order:\n"
1877         "\n"
1878         "- 1) gColdStartAttempts\n"
1879         "- 2) gListenNoise\n"
1880         "- 3) gMacroPerCycle\n"
1881         "- 4) gMaxWithoutClockCorrectionFatal\n"
1882         "- 5) gMaxWithoutClockCorrectionPassive\n"
1883         "- 6) gNetworkManagementVectorLength\n"
1884         "- 7) gNumberOfMinislots\n"
1885         "- 8) gNumberOfStaticSlots\n"
1886         "- 9) gOffsetCorrectionStart\n"
1887         "- 10) gPayloadLengthStatic\n"
1888         "- 11) gSyncNodeMax\n"
1889         "- 12) gdActionPointOffset\n"
1890         "- 13) gdCASRxLowMax\n"
1891         "- 14) gdDynamicSlotIdlePhase\n"
1892         "- 15) gdMinislot\n"
1893         "- 16) gdMinislotActionPointOffset\n"
1894         "- 17) gdNIT\n"
1895         "- 18) gdSampleClockPeriod\n"
1896         "- 19) gdStaticSlot\n"
1897         "- 20) gdTSSTransmitter\n"
1898         "- 21) gdWakeupSymbolRxIdle\n"
1899         "- 22) gdWakeupSymbolRxLow\n"
1900         "- 23) gdWakeupSymbolRxWindow\n"
1901         "- 24) gdWakeupSymbolTxIdle\n"
1902         "- 25) gdWakeupSymbolTxLow\n"
1903         "\n"
1904         "Type \"node\" sets local FlexRay network parameters. It expects a\n"
1905         "sequence of 28 parameters in this order:\n"
1906         "\n"
1907         "- 1) pAllowHaltDueToClock\n"
1908         "- 2) pAllowPassiveToActive\n"
1909         "- 3) pChannels (0 - A, 1 - B, 2 - AB)\n"
1910         "- 4) pClusterDriftDamping\n"
1911         "- 5) pDelayCompensationA\n"
1912         "- 6) pDelayCompensationB\n"
1913         "- 7) pExternOffsetCorrection\n"
1914         "- 8) pExternRateCorrection\n"
1915         "- 9) pKeySlotUsedForStartup\n"
1916         "- 10) pKeySlotUsedForSync\n"
1917         "- 11) pLatestTx\n"
1918         "- 12) pMacroInitialOffsetA\n"
1919         "- 13) pMacroInitialOffsetB\n"
1920         "- 14) pMicroInitialOffsetA\n"
1921         "- 15) pMicroInitialOffsetB\n"
1922         "- 16) pMicroPerCycle\n"
1923         "- 17) pRateCorrectionOut\n"
1924         "- 18) pOffsetCorrectionOut\n"
1925         "- 19) pSamplesPerMicrotick\n"
1926         "- 20) pSingleSlotEnabled\n"
1927         "- 21) pWakeupChannel (0 - A, 1 - B)\n"
1928         "- 22) pWakeupPattern\n"
1929         "- 23) pdAcceptedStartupRange\n"
1930         "- 24) pdListenTimeout\n"
1931         "- 25) pdMaxDrift\n"
1932         "- 26) pDecodingCorrection\n"
1933         "- 27) syncFramePayloadMultiplexEnabled\n"
1934         "- 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"
1935         "\n"
1936         "### Example ###\n"
1937         "\n"
1938         "    --> 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"
1939         "    FlexRay cluster configuration accepted.\n"
1940         "    --> 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"
1941         "    FlexRay node configuration accepted.\n",
1942         CMD_HANDLER(cmd_do_fr_user_config), (void *)&cmd_list_fr_basic_test
1943 };
1944
1945 cmd_des_t const cmd_des_fr_config_buffer = {
1946         0, 0,
1947         "frbtcfgbuf?*","Configure a message buffer in the user configuration",
1948         "### Command syntax ###\n"
1949         "\n"
1950         "    frbtcfgbuf<TYPE><NUM> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\n"
1951         "where\n"
1952         "\n"
1953         "- `<TYPE>` is 'S' for static segment buffers and 'D' for dynamic segment buffers,\n"
1954         "- `<NUM>` is the number of the buffer. Both static and dynamic buffers are numbered independently starting from zero,\n"
1955         "- `<SLOT>` is the number of the slot,\n"
1956         "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1957         "- `<CYC>` is the cycle set when to send the buffer,\n"
1958         "- `<RXTX>` is either string \"rx\" or \"tx\",\n"
1959         "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1960         "- `<REP>` is a string \"s\" or \"single\" for single transmission or \"c\" or \"continuous\" for continuous transmission,\n"
1961         "- `<PPI>` is 0 or 1 determining whether the payload preamble indicator is set,\n"
1962         "- `<INT>` is 0 or 1 and is currently ignored.\n"
1963         "\n"
1964         "### Description ###\n"
1965         "\n"
1966         "The command sets the configuration parameters for static or dynamic\n"
1967         "buffers in user configuration. The parameters set by this command are\n"
1968         "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1969         "longer possible to change the parameters.\n"
1970         "\n"
1971         "### Example ###\n"
1972         "\n"
1973         "    --> frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1974         "    frbtcfgbufS0 slot2 AB cyc0 tx max9  continous ppi0 int1\n"
1975         "    --> frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1976         "    frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1977         "    --> frbtcfgbufD0  slot9  A cyc0 rx max0x40 single ppi0 int0\n"
1978         "    frbtcfgbufD0 slot9  A cyc0 rx max64 single ppi0 int0\n"
1979         "    --> frbtcfgbufD1  slot10 A cyc0 tx max0x40 single ppi0 int0\n"
1980         "    frbtcfgbufD1 slot10  A cyc0 tx max64 single ppi0 int0\n",
1981         CMD_HANDLER(cmd_do_fr_config_bufer), (void *)&cmd_list_fr_basic_test
1982 };
1983
1984 cmd_des_t const cmd_des_fr_config_fifo = {
1985         0, 0,
1986         "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
1987         "### Command syntax ###\n"
1988         "\n"
1989         "    frbtcfgfifo rejslot<SLOT> slotmask<MASK> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT>\n"
1990         "where\n"
1991         "- `<SLOT>` is the number of the slot that will be rejected. If it is 0, no slot will be rejected,\n"
1992         "- `<MASK>` is a number specifying which bits of the `<SLOT>` will be ignored,"
1993         "- `<DEPTH>` is a number specifying the depth of the FIFO,\n"
1994         "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1995         "- `<CYC>` is the cycle set when to send the buffer,\n"
1996         "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1997         "- `<REJNULL>` is a string \"rejnull\" for rejecting NULL frames or \"accnull\" for accepting NULL frames,\n"
1998         "- `<REJSTAT>` is a string \"rejstat\" for rejecting frames in static segment or \"accstat\" for accepting frames from static segment,\n"
1999         "\n"
2000         "### Description ###\n"
2001         "\n"
2002         "The command sets the configuration parameters for RX FIFO buffer\n"
2003         "in user configuration. The parameters set by this command are\n"
2004         "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
2005         "longer possible to change the parameters.\n"
2006         "Those messages, which are not accepted by any other buffer and pass the\n"
2007         "FIFO rejection filter will be stored in the RX FIFO buffer.\n"
2008         "\n"
2009         "### Example ###\n"
2010         "\n"
2011         "    --> frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n"
2012         "    frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n",
2013         CMD_HANDLER(cmd_do_fr_config_fifo), (void *)&cmd_list_fr_basic_test
2014 };
2015
2016 /** Command descriptor for FlexRay init command */
2017 cmd_des_t const cmd_des_fr_init = {
2018         0, 0,
2019         "frbtinit?","Initialize a FlexRay node",
2020         "### Command syntax ###\n"
2021         "\n"
2022         "    frbtinit<CFG>\n"
2023         "\n"
2024         "where `<CFG>` identifies the configuration to use. It can be one of A, B\n"
2025         "or U. The A and B are predefined configurations. If U is specified,\n"
2026         "the user configuration previously set by frbtconfig command is used.\n"
2027         "\n"
2028         "### Description ###\n"
2029         "\n"
2030         "The command stands for Fr_Init and Fr_ControllerInit functions from\n"
2031         "the Autosar specification. It initializes the internal data structures\n"
2032         "of the driver and then, based on those data, the controller\n"
2033         "configuration is done. During the controller configuration the\n"
2034         "parameters of the cluster, node, message RAM and buffers are checked.\n"
2035         "If anything goes bad, the command returns an error number, which can\n"
2036         "be decoded by macros defined in driver header file fr_tms570.h with\n"
2037         "prefix ERR_PARAM. If all parameters are OK, all necessary registers of\n"
2038         "the controller are initialized according to the specified\n"
2039         "configuration parameters. At the end of the command, the FlexRay\n"
2040         "controller is switched into READY state and all buffers are configured\n"
2041         "to send NULL frames. This command should be called as the very first\n"
2042         "command, when trying to communicate over the FlexRay bus.\n"
2043         "\n"
2044         "### Example ###\n"
2045         "\n"
2046         "    --> frbtinitA\n"
2047         "    FlexRay driver initialized.\n"
2048         "    FlexRay controller initialized.\n",
2049         CMD_HANDLER(cmd_do_fr_init), (void *)&cmd_list_fr_basic_test
2050 };
2051
2052 /** Command descriptor for FlexRay controller init command */
2053 cmd_des_t const cmd_des_fr_start = {
2054         0, 0,
2055         "frbtstart","Start a new FlexRay network or join to the existing one",
2056         "### Command syntax ###\n"
2057         "\n"
2058         "    frbtstart\n"
2059         "\n"
2060         "### Description ###\n"
2061         "\n"
2062         "The command stands for Fr_StartCommunication function from the Autosar\n"
2063         "specification.\n"
2064         "If the FlexRay node is configured as a coldstarter node\n"
2065         "(as for example by frbtinitA/B command), then the command first listen\n"
2066         "on the bus. When it does not detect any existing bus communication, it\n"
2067         "tries to initiate a new network. If the initiation fails, the FlexRay\n"
2068         "controller is switched back to the ready state for another attempt\n"
2069         "(calling frbtstart again). If the FlexRay node is configured as\n"
2070         "non-coldstarter, it is listening on the bus until some existing\n"
2071         "communication is detected.\n"
2072         "\n"
2073         "The command should be called after the frbtinit command.\n"
2074         "\n"
2075         "### Example ###\n"
2076         "\n"
2077         "    --> frbtstart\n"
2078         "    FlexRay communication is running.\n",
2079         CMD_HANDLER(cmd_do_fr_start), (void *)&cmd_list_fr_basic_test
2080 };
2081
2082 /** Command descriptor for FlexRay controller all slots command */
2083 cmd_des_t const cmd_des_fr_allslots = {
2084         0, 0,
2085         "frbtallslots","Enables communication for all frames",
2086         "### Command syntax ###\n"
2087         "\n"
2088         "    frbtallslots\n"
2089         "\n"
2090         "### Description ###\n"
2091         "\n"
2092         "The command stands for Fr_AllSlots function from the Autosar\n"
2093         "specification.\n"
2094         "\n"
2095         "The node can be configured to communicate only on key frames by\n"
2096         "default (as in the case of frbtinitA/B). This command can be used to\n"
2097         "allow the communication on all configured frames. The command invokes\n"
2098         "the FlexRay POC command ALL_SLOTS which enables the communication on\n"
2099         "all frames. The command can be called after the controller\n"
2100         "initialization.\n"
2101         "\n"
2102         "### Example ###\n"
2103         "\n"
2104         "    --> frbtallslots\n"
2105         "    FlexRay node started communication on all slots.\n",
2106         CMD_HANDLER(cmd_do_fr_allslots), (void *)&cmd_list_fr_basic_test
2107 };
2108
2109 /** Command descriptor for FlexRay controller halt command */
2110 cmd_des_t const cmd_des_fr_halt = {
2111         0, 0,
2112         "frbthalt","Halt FlexRay communication after the end of the actual communication cycle",
2113         "### Command syntax ###\n"
2114         "\n"
2115         "    frbthalt\n"
2116         "\n"
2117         "### Description ###\n"
2118         "\n"
2119         "The command stands for Fr_HaltCommunication function from the Autosar\n"
2120         "specification. The command invokes the FlexRay POC command HALT, which\n"
2121         "means that communication is stopped after the end of the actual\n"
2122         "communication cycle. On the opposite side, there is a frbtfreeze\n"
2123         "command, which stops the communication immediately. To restart the\n"
2124         "communication, the frbtinit and frbtstart commands have to be called.\n"
2125         "\n"
2126         "### Example ###\n"
2127         "\n"
2128         "    --> frbthalt\n"
2129         "    FlexRay node communication halted.\n",
2130         CMD_HANDLER(cmd_do_fr_halt), (void *)&cmd_list_fr_basic_test
2131 };
2132
2133 /** Command descriptor for FlexRay controller abort command */
2134 cmd_des_t const cmd_des_fr_abort = {
2135         0, 0,
2136         "frbtabort","Abort FlexRay communication immediately",
2137         "### Command syntax ###\n"
2138         "\n"
2139         "    frbtabort\n"
2140         "\n"
2141         "### Description ###\n"
2142         "\n"
2143         "The command stands for Fr_AbortCommunication function from the Autosar\n"
2144         "specification. The command invokes the FlexRay POC command FREEZE,\n"
2145         "which means that the communication is stopped immediately. On the\n"
2146         "opposite side there is a frbthalt command, which stops the\n"
2147         "communication after the end of the actual communication cycle. To\n"
2148         "restart the communication, the frbtinit and frbtstart commands have\n"
2149         "to be called.\n"
2150         "\n"
2151         "### Example ###\n"
2152         "\n"
2153         "    --> frbtabort\n"
2154         "    FlexRay node communication aborted.\n",
2155         CMD_HANDLER(cmd_do_fr_abort), (void *)&cmd_list_fr_basic_test
2156 };
2157
2158 /** Command descriptor for FlexRay controller send wake up pattern command */
2159 cmd_des_t const cmd_des_fr_sendwup = {
2160         0, 0,
2161         "frbtwup","Initiate the wake up procedure",
2162         "### Command syntax ###\n"
2163         "\n"
2164         "    frbtwup\n"
2165         "\n"
2166         "### Description ###\n"
2167         "\n"
2168         "The command stands for Fr_SendWUP function from the Autosar\n"
2169         "specification. It initiates the wake up procedure by switching FlexRay\n"
2170         "controller state machine to WAKEUP state.\n"
2171         "\n"
2172         "### Example ###\n"
2173         "\n"
2174         "    --> frbtwup\n"
2175         "    Wake up pattern has been sent.\n",
2176         CMD_HANDLER(cmd_do_fr_sendwup), (void *)&cmd_list_fr_basic_test
2177 };
2178
2179 /** Command descriptor for FlexRay controller sent wake up pattern channel command */
2180 cmd_des_t const cmd_des_fr_setwuchannel = {
2181         0, 0,
2182         "frbtsetwuch?","Set wake up channel",
2183         "### Command syntax ###\n"
2184         "\n"
2185         "    frbtsetwuch<CHANNEL>\n"
2186         "\n"
2187         "where `<CHANNEL>` is a character A or B, specifying the channel.\n"
2188         "\n"
2189         "### Description ###\n"
2190         "\n"
2191         "The command stands for Fr_SetWakeupChannel function from the Autosar\n"
2192         "specification. Wake up channel is the channel, where Wake Up Pattern\n"
2193         "is sent. The channel can be set after the driver and controller are\n"
2194         "initialized and before the communication is running. The actual\n"
2195         "wake-up pattern is sent by the frbtwup command.\n"
2196         "\n"
2197         "### Example ###\n"
2198         "\n"
2199         "    --> frbtsetwuchA\n"
2200         "    Wake up channel has been set.\n",
2201         CMD_HANDLER(cmd_do_fr_setwuchannel), (void *)&cmd_list_fr_basic_test
2202 };
2203
2204 /** Command descriptor for FlexRay controller get POC status command */
2205 cmd_des_t const cmd_des_fr_getpocstatus = {
2206         0, 0,
2207         "frbtgetpocst","Print FlexRay POC status",
2208         "### Command syntax ###\n"
2209         "\n"
2210         "    frbtgetpocst\n"
2211         "\n"
2212         "### Description ###\n"
2213         "\n"
2214         "The command stands for Fr_GetPOCStatus function from the Autosar\n"
2215         "specification. It prints the main FlexRay POC status values in the\n"
2216         "form of a table. The command should be called after the frbtinit\n"
2217         "command.\n"
2218         "\n"
2219         "### Example ###\n"
2220         "\n"
2221         "    --> frbtgetpocst\n"
2222         "    POC status:\n"
2223         "    CHIHaltRequest: FALSE\n"
2224         "    CHIReadyRequest: FALSE\n"
2225         "    ColdstartNoise: FALSE\n"
2226         "    Freeze: FALSE\n"
2227         "    ErrorMode: ACTIVE\n"
2228         "    SlotMode: ALL\n"
2229         "    StartupState: UNDEFINED\n"
2230         "    State: READY\n"
2231         "    WakeupStatus: UNDEFINED\n",
2232         CMD_HANDLER(cmd_do_fr_getpocstatus), (void *)&cmd_list_fr_basic_test
2233 };
2234
2235 /** Command descriptor for FlexRay transmit tx lpdu command */
2236 cmd_des_t const cmd_des_fr_transmittxlpdu = {
2237         0, 0,
2238         "frbttransmit*","Transmit data in selected frame",
2239         "### Command syntax ###\n"
2240         "\n"
2241         "    frbttransmit<FRID> <DATA>\n"
2242         "where\n"
2243         "\n"
2244         "- `<FRID>` is a decimal number specifying the ID of the frame for which a buffer has been configured.\n"
2245         "- `<DATA>` is a sequence of hexadecimal numbers separated by spaces. Each number represents one byte of the message.\n"
2246         "\n"
2247         "### Description ###\n"
2248         "\n"
2249         "The command stands for Fr_TransmitTxLPdu function from the Autosar\n"
2250         "specification. The command finds the first buffer assigned to the\n"
2251         "specified frame ID and copies the given data into its data section in\n"
2252         "the message RAM. Transmit request is set after the data are copied, so\n"
2253         "transmission starts at the next occurrence of the frame in the\n"
2254         "communication cycle.\n"
2255         "\n"
2256         "### Example ###\n"
2257         "\n"
2258         "    --> frbttransmit1 12 34 56 AA BB CC\n"
2259         "    Data were set for transmission.\n",
2260         CMD_HANDLER(cmd_do_fr_transmittxlpdu), (void *)&cmd_list_fr_basic_test
2261 };
2262
2263 /** Command descriptor for FlexRay cancel tx lpdu command */
2264 cmd_des_t const cmd_des_fr_canceltxlpdu = {
2265         0, 0,
2266         "frbtcanceltx*","Stop the transmission of the frame",
2267         "### Command syntax ###\n"
2268         "\n"
2269         "    frbtcanceltx<FRID>\n"
2270         "\n"
2271         "where `<FRID>` is a decimal number specifying the ID of the frame for\n"
2272         "which a buffer has been configured.\n"
2273         "\n"
2274         "### Description ###\n"
2275         "\n"
2276         "The command stands for Fr_CancelTxLPdu function from the Autosar\n"
2277         "specification. The command finds all buffers assigned to the specified\n"
2278         "frame ID and reconfigures them to stop transmitting data. The command\n"
2279         "finishes successfully only if reconfiguration is allowed in message\n"
2280         "RAM configuration (secureBuffers configuration parameter). Only TX\n"
2281         "buffers and buffers not used for startup frames can be canceled.\n"
2282         "\n"
2283         "### Example ###\n"
2284         "\n"
2285         "    --> frbtcanceltx3\n"
2286         "    Transmission canceled.\n",
2287         CMD_HANDLER(cmd_do_fr_canceltxlpdu), (void *)&cmd_list_fr_basic_test
2288 };
2289
2290 /** Command descriptor for FlexRay receive rx lpdu command */
2291 cmd_des_t const cmd_des_fr_receiverxlpdu = {
2292         0, 0,
2293         "frbtreceive*","Receive a new message",
2294         "### Command syntax ###\n"
2295         "\n"
2296         "    frbtreceive<FRID>\n"
2297         "\n"
2298         "where `<FRID>` is a decimal number specifying the ID of the frame for\n"
2299         "which a buffer was configured.\n"
2300         "\n"
2301         "### Description ###\n"
2302         "\n"
2303         "The command stands for Fr_ReceiveRxLPdu function from the Autosar\n"
2304         "specification. The command finds the first buffer assigned to the\n"
2305         "specified frame ID, determines if a new message has been received and\n"
2306         "reads it out of the buffer. If no message was received, \"No message\n"
2307         "received\" is printed. If a new message was received, all message data\n"
2308         "are printed as a hexadecimal values. If a new message was retrieved\n"
2309         "from a FIFO buffer and more messages are available in it, \"More\n"
2310         "messages are still in FIFO\" is printed.\n"
2311         "\n"
2312         "### Example ###\n"
2313         "\n"
2314         "    --> frbtreceive0\n"
2315         "    More messages are still in FIFO:\n"
2316         "    Received message (32 B):\n"
2317         "     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",
2318         CMD_HANDLER(cmd_do_fr_receiverxlpdu), (void *)&cmd_list_fr_basic_test
2319 };
2320
2321 /** Command descriptor for FlexRay check TX LPdu status command */
2322 cmd_des_t const cmd_des_fr_checktxlpdustatus = {
2323         0, 0,
2324         "frbtchecktx*","Print the status of the transmit buffer",
2325         "### Command syntax ###\n"
2326         "\n"
2327         "    frbtchecktx<FRID>\n"
2328         "\n"
2329         "where `<FRID>` is a decimal number specifying the ID of the frame for\n"
2330         "which a buffer has been configured.\n"
2331         "\n"
2332         "### Description ###\n"
2333         "\n"
2334         "The command stands for Fr_CheckTxLPduStatus function from the Autosar\n"
2335         "specification. The command finds the first buffer assigned to the\n"
2336         "specified frame ID, reads its status and prints it. The buffer can be\n"
2337         "in one of the two states:\n"
2338         "\n"
2339         "- 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"
2340         "- No message transmission is pending, which means that the buffer is in single shot mode and the message has already been sent.\n"
2341         "\n"
2342         "### Example ###\n"
2343         "\n"
2344         "    --> frbtchecktx1\n"
2345         "    Message transmission is not pending.\n",
2346         CMD_HANDLER(cmd_do_fr_checktxlpdustatus), (void *)&cmd_list_fr_basic_test
2347 };
2348
2349 /** Command descriptor for FlexRay disable LPdu command */
2350 cmd_des_t const cmd_des_fr_disablelpdu = {
2351         0, 0,
2352         "frbtdisable*","Disable the buffers assigned to the frame",
2353         "### Command syntax ###\n"
2354         "\n"
2355         "    frbtdisable<FRID>\n"
2356         "\n"
2357         "where `<FRID>` is a decimal number specifying the ID of a frame. The\n"
2358         "buffers configure for this frame will be disabled.\n"
2359         "\n"
2360         "### Description ###\n"
2361         "\n"
2362         "The command stands for Fr_DisableLPdu function from the Autosar\n"
2363         "specification. The command finds all buffers assigned to the specified\n"
2364         "frame ID and disables them. This means that those buffers will be\n"
2365         "unavailable for the communication until their reconfiguration (which\n"
2366         "is not yet implemented). Buffers used for startup frames and FIFO RX\n"
2367         "buffers cannot be disabled.\n"
2368         "\n"
2369         "### Example ###\n"
2370         "\n"
2371         "    --> frbtdisable3\n"
2372         "    Buffer disabled.\n",
2373         CMD_HANDLER(cmd_do_fr_disablelpdu), (void *)&cmd_list_fr_basic_test
2374 };
2375
2376 /** Command descriptor for FlexRay get global time command */
2377 cmd_des_t const cmd_des_fr_getglobaltime = {
2378         0, 0,
2379         "frbtglobtime","Print actual global time of the network",
2380         "### Command syntax ###\n"
2381         "\n"
2382         "    frbtglobtime\n"
2383         "\n"
2384         "### Description ###\n"
2385         "\n"
2386         "The command stands for Fr_GetGlobalTime function from the Autosar\n"
2387         "specification. The command prints the time as a number of the current\n"
2388         "cycle and the offset in the cycle in macroticks.\n"
2389         "\n"
2390         "### Example ###\n"
2391         "\n"
2392         "    --> frbtglobtime\n"
2393         "    Cycle number: 23\n"
2394         "    Macrotick number: 6\n",
2395         CMD_HANDLER(cmd_do_fr_getglobaltime), (void *)&cmd_list_fr_basic_test
2396 };
2397
2398 /** Command descriptor for FlexRay get network management vector command */
2399 cmd_des_t const cmd_des_fr_getnmvector = {
2400         0, 0,
2401         "frbtnmvector","Print network management vector of the node",
2402         "### Command syntax ###\n"
2403         "\n"
2404         "    frbtnmvector\n"
2405         "\n"
2406         "### Description ###\n"
2407         "\n"
2408         "The command stands for Fr_GetNmVector function from the Autosar\n"
2409         "specification. It prints the values of the network management vector\n"
2410         "as hexadecimal numbers.\n"
2411         "\n"
2412         "### Example ###\n"
2413         "\n"
2414         "    --> frbtnmvector\n"
2415         "    Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2416         CMD_HANDLER(cmd_do_fr_getnmvector), (void *)&cmd_list_fr_basic_test
2417 };
2418
2419 /** Command descriptor for FlexRay get network management vector command */
2420 cmd_des_t const cmd_des_fr_nmwatch = {
2421         0, 0,
2422         "frbtnmwatch","Watch the changes of the network managment vector in real-time",
2423         "### Command syntax ###\n"
2424         "\n"
2425         "    frbtnmwatch\n"
2426         "\n"
2427         "### Description ###\n"
2428         "\n"
2429         "Reads the network management vector every 100 ms and prints it out.\n"
2430         "\n"
2431         "### Example ###\n"
2432         "\n"
2433         "    --> frbtnmwatch\n"
2434         "    Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2435         CMD_HANDLER(cmd_do_fr_nmwatch), (void *)&cmd_list_fr_basic_test
2436 };
2437
2438 /** Command descriptor for FlexRay get channel status command */
2439 cmd_des_t const cmd_des_fr_getchannelstatus = {
2440         0, 0,
2441         "frbtchstat","Print channel A and B status",
2442         "### Command syntax ###\n"
2443         "\n"
2444         "    frbtchstat\n"
2445         "\n"
2446         "### Description ###\n"
2447         "\n"
2448         "The command stands for Fr_GetChannelStatus function from the Autosar\n"
2449         "specification.\n"
2450         "\n"
2451         "### Example ###\n"
2452         "\n"
2453         "    --> frbtchstat\n"
2454         "    Channel A status:\n"
2455         "       aggregated channel status vSS!ValidFrame: TRUE\n"
2456         "       aggregated channel status vSS!SyntaxError: FALSE\n"
2457         "       aggregated channel status vSS!ContentError: FALSE\n"
2458         "       aggregated channel status additional communication: FALSE\n"
2459         "       aggregated channel status vSS!Bviolation: FALSE\n"
2460         "       aggregated channel status vSS!TxConflict: FALSE\n"
2461         "       Not used (0): FALSE\n"
2462         "       Not used (0): FALSE\n"
2463         "       symbol window status data vSS!ValidMTS: FALSE\n"
2464         "       symbol window status data vSS!SyntaxError: FALSE\n"
2465         "       symbol window status data vSS!Bviolation: FALSE\n"
2466         "       symbol window status data vSS!TxConflict: FALSE\n"
2467         "       NIT status data vSS!SyntaxError: FALSE\n"
2468         "       NIT status data vSS!Bviolation: FALSE\n"
2469         "       Not used (0): FALSE\n"
2470         "       Not used (0): FALSE\n"
2471         "    Channel B status:\n"
2472         "       aggregated channel status vSS!ValidFrame: TRUE\n"
2473         "       aggregated channel status vSS!SyntaxError: FALSE\n"
2474         "       aggregated channel status vSS!ContentError: FALSE\n"
2475         "       aggregated channel status additional communication: FALSE\n"
2476         "       aggregated channel status vSS!Bviolation: FALSE\n"
2477         "       aggregated channel status vSS!TxConflict: FALSE\n"
2478         "       Not used (0): FALSE\n"
2479         "       Not used (0): FALSE\n"
2480         "       symbol window status data vSS!ValidMTS: FALSE\n"
2481         "       symbol window status data vSS!SyntaxError: FALSE\n"
2482         "       symbol window status data vSS!Bviolation: FALSE\n"
2483         "       symbol window status data vSS!TxConflict: FALSE\n"
2484         "       NIT status data vSS!SyntaxError: FALSE\n"
2485         "       NIT status data vSS!Bviolation: FALSE\n"
2486         "       Not used (0): FALSE\n"
2487         "       Not used (0): FALSE\n",
2488         CMD_HANDLER(cmd_do_fr_getchannelstatus), (void *)&cmd_list_fr_basic_test
2489 };
2490
2491 /** Command descriptor for FlexRay get clock correction command */
2492 cmd_des_t const cmd_des_fr_getclockcorrection = {
2493         0, 0,
2494         "frbtclkcor","Print clock correction (rate and offset)",
2495         "### Command syntax ###\n"
2496         "\n"
2497         "    frbtclkcor\n"
2498         "\n"
2499         "### Description ###\n"
2500         "\n"
2501         "The command stands for Fr_GetClockCorrection function from the Autosar\n"
2502         "specification.\n"
2503         "\n"
2504         "### Example ###\n"
2505         "\n"
2506         "    --> frbtclkcor\n"
2507         "    Rate correction: 0\n"
2508         "    Offset correction: 0\n",
2509         CMD_HANDLER(cmd_do_fr_getclockcorrection), (void *)&cmd_list_fr_basic_test
2510 };
2511
2512 /** Command descriptor for FlexRay get sync frame list command */
2513 cmd_des_t const cmd_des_fr_getsyncframelist = {
2514         0, 0,
2515         "frbtgetsyncfrlist*","Print the list of sync frames transmitted on both channels via the odd and even communication cycle",
2516         "### Command syntax ###\n"
2517         "\n"
2518         "    frbtgetsyncfrlist<LENGTH>\n"
2519         "\n"
2520         "where `<LENGTH>` is a decimal number in range 0 - 15, specifying the\n"
2521         "length of the list to be printed.\n"
2522         "\n"
2523         "### Description ###\n"
2524         "\n"
2525         "The command stands for Fr_GetSyncFrameList function from the Autosar\n"
2526         "specification.\n"
2527         "\n"
2528         "### Example ###\n"
2529         "\n"
2530         "    --> frbtgetsyncfrlist2\n"
2531         "    | Channel A even | channel B even | channel A odd  | channel B odd  |\n"
2532         "    |----------------|----------------|----------------|----------------|\n"
2533         "    | 1              | 1              | 1              | 1              |\n"
2534         "    | 2              | 2              | 2              | 2              |\n"
2535         "    |----------------|----------------|----------------|----------------|\n",
2536         CMD_HANDLER(cmd_do_fr_getsyncframelist), (void *)&cmd_list_fr_basic_test
2537 };
2538
2539 /** Command descriptor for FlexRay get sync frame list command */
2540 cmd_des_t const cmd_des_fr_getwakeuprxstatus = {
2541         0, 0,
2542         "frbtgetwurxstat","Prints whether the wake up pattern has been or has not been received",
2543         "### Command syntax ###\n"
2544         "\n"
2545         "    frbtgetwurxstat\n"
2546         "\n"
2547         "### Description ###\n"
2548         "\n"
2549         "The command stands for Fr_GetWakeupRxStatus function from the Autosar\n"
2550         "specification. The status of the wake up receiving is bitcoded in the\n"
2551         "controller. This command decodes and prints it in a readable format.\n"
2552         "\n"
2553         "### Example ###\n"
2554         "\n"
2555         "    --> frbtgetwurxstat\n"
2556         "    Wake up pattern was not yet received on channel A.\n"
2557         "    Wake up pattern was not yet received on channel B.\n",
2558         CMD_HANDLER(cmd_do_fr_getwakeuprxstatus), (void *)&cmd_list_fr_basic_test
2559 };
2560
2561 /** Command descriptor for FlexRay set absolute timer command */
2562 cmd_des_t const cmd_des_fr_settimer = {
2563         0, 0,
2564         "frbtsettimer*","Set and start timer",
2565         "### Command syntax ###\n"
2566         "\n"
2567         "    frbtsettimer<TMID> <CYCLE> <OFFSET>\n"
2568         "where\n"
2569         "\n"
2570         "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2571         "- `<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"
2572         "- `<OFFSET>` is a decimal number (0 - 16383) specifying the offset in macroticks, where precisely in the cycle should be the timer interrupt requested.\n"
2573         "\n"
2574         "### Description ###\n"
2575         "\n"
2576         "The command is similar to Fr_SetAbsoluteTimer function from the\n"
2577         "Autosar specification. The difference is that the command allows to\n"
2578         "specify a set of cycles, not only one of 64 cycles. It sets the timer\n"
2579         "selected by the parameter and enables it.\n"
2580         "\n"
2581         "Before using this command, FlexRay communication has to be started\n"
2582         "(see frbtstart).\n"
2583         "\n"
2584         "### Example ###\n"
2585         "\n"
2586         "    --> frbtsettimer0 32 50\n"
2587         "    Timer was set for every 32-th cycle, offset 0, macrotick 50\n"
2588         "    --> frbtsettimer0 31 50\n"
2589         "    Timer was set for every 16-th cycle, offset 15, macrotick 50\n"
2590         "    --> frbtsettimer0 0x42 0\n"
2591         "    Timer was set for every 64-th cycle, offset 2, macrotick 0\n",
2592         CMD_HANDLER(cmd_do_fr_settimer), (void *)&cmd_list_fr_basic_test
2593 };
2594
2595 /** Command descriptor for FlexRay cancel absolute timer command */
2596 cmd_des_t const cmd_des_fr_canceltimer = {
2597         0, 0,
2598         "frbtcanceltimer*","Stop the timer",
2599         "### Command syntax ###\n"
2600         "\n"
2601         "    frbtcanceltimer<TMID>\n"
2602         "where `<TMID>` is a number (0 or 1) specifying the timer.\n"
2603         "\n"
2604         "### Description ###\n"
2605         "\n"
2606         "The command stands for Fr_CancelAbsoluteTimer function from the\n"
2607         "Autosar specification. It stops the timer selected by the parameter.\n"
2608         "\n"
2609         "### Example ###\n"
2610         "\n"
2611         "    --> frbtcanceltimer0\n"
2612         "    Timer was canceled.\n",
2613         CMD_HANDLER(cmd_do_fr_canceltimer), (void *)&cmd_list_fr_basic_test
2614 };
2615
2616 /** Command descriptor for FlexRay absolute timer irq manipulation command */
2617 cmd_des_t const cmd_des_fr_timerirq = {
2618         0, 0,
2619         "frbttimerirq*","Perform selected action on the timer IRQ",
2620         "### Command syntax ###\n"
2621         "\n"
2622         "    frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer\n"
2623         "    frbttimerirq<TMID> - Get timer IRQ status\n"
2624         "\n"
2625         "where\n"
2626         "\n"
2627         "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2628         "- where `<ACTION>` is a string specifying the action  to be performed on the selected timer IRQ.\n"
2629         "\n"
2630         "`<ACTIONS>` can be one of:\n"
2631         "\n"
2632         "- EN - Enable the IRQ on the selected timer\n"
2633         "- DIS - Disable the IRQ on the selected timer\n"
2634         "- ACK - Acknowledge the IRQ on the selected timer (reset flag in the register).\n"
2635         "\n"
2636         "### Description ###\n"
2637         "\n"
2638         "The command stands for Fr_EnableAbsoluteTimerIRQ,\n"
2639         "Fr_AckAbsoluteTimerIRQ, Fr_DisableAbsoluteTimerIRQ and\n"
2640         "Fr_GetAbsoluteTimerIRQStatus functions from the Autosar specification.\n"
2641         "It masks or demasks the IRQ for the timer, or acknowledges the\n"
2642         "interrupt request. If no action is specified it prints whether the IRQ\n"
2643         "is pending for the timer.\n"
2644         "\n"
2645         "### Example ###\n"
2646         "\n"
2647         "    --> frbttimerirq0\n"
2648         "    IRQ = FALSE\n"
2649         "\n"
2650         "    --> frbttimerirq0 EN\n"
2651         "    OK\n",
2652         CMD_HANDLER(cmd_do_fr_timerirq), (void *)&cmd_list_fr_basic_test
2653 };
2654
2655 /** Command descriptor for FlexRay get version info command */
2656 cmd_des_t const cmd_des_fr_getversioninfo = {
2657         0, 0,
2658         "frbtversion","Print FlexRay driver version information",
2659         "### Command syntax ###\n"
2660         "\n"
2661         "    frbtversion\n"
2662         "\n"
2663         "### Description ###\n"
2664         "\n"
2665         "The command stands for Fr_GetVersionInfo function from the Autosar\n"
2666         "specification.\n"
2667         "It reads and prints the information about vendor, module and version of\n"
2668         "the FlexRay driver\n"
2669         "\n"
2670         "### Example ###\n"
2671         "\n"
2672         "    --> frbtversion\n"
2673         "    vendorID: 0xAAAA\n"
2674         "    moduleID: 0xBBBB\n"
2675         "    sw_major_version: 0x1\n"
2676         "    sw_minor_version: 0x2\n"
2677         "    sw_patch_version: 0x4\n",
2678         CMD_HANDLER(cmd_do_fr_getversioninfo), (void *)&cmd_list_fr_basic_test
2679 };
2680
2681 /** Command descriptor for FlexRay get controller configuration command */
2682 cmd_des_t const cmd_des_fr_readcconfig = {
2683         0, 0,
2684         "frbtccconfig*","Print value of a FlexRay cluster and node configuration parameter",
2685         "### Command syntax ###\n"
2686         "\n"
2687         "    frbtccconfig<INDEX>\n"
2688         "\n"
2689         "where `<INDEX>` is an identifier of the parameter.\n"
2690         "\n"
2691         "### Description ###\n"
2692         "\n"
2693         "The command stands for Fr_ReadCCConfig function from the Autosar\n"
2694         "specification. The driver stores the configuration parameters as an\n"
2695         "array. Each parameter can be indexed and returned by this command. See\n"
2696         "Autosar specification of the FlexRay driver\n"
2697         "(http://www.autosar.org/download/R4.1/AUTOSAR_SWS_FlexRayDriver.pdf),\n"
2698         "section 8.2.1 for parameter indexes.\n"
2699         "\n"
2700         "### Example ###\n"
2701         "\n"
2702         "    --> frbtccconfig1\n"
2703         "    Value = 0x1\n",
2704         CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
2705 };
2706
2707 /** Command descriptor for FlexRay reconfigure buffer command */
2708 cmd_des_t const cmd_des_fr_reconfigure_buffer = {
2709         0, 0,
2710         "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
2711         "### Command syntax ###\n"
2712         "\n"
2713         "    frbtreconfigurebuf id<ID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> max<MAX>\n"
2714         "where\n"
2715         "\n"
2716         "- `<ID>` is a number specifying a slot, where the buffer is currently communicating,\n"
2717         "- `<SLOT>` is a number, where buffer will be communicating after the reconfiguration,\n"
2718         "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
2719         "- `<CYCS>` is the cycle set. It has to be one of 0, 1, 2, 4, 8, 16, 32, 64. It specifies together with `<CYCO>` the cycle filtering.\n"
2720         "- `<CYCO>` is the cycle offset. It has to be in range 0 - `<CYCS>`-1"
2721         "- `<MAX>` is the number determining the maximum payload (in hald-words).\n"
2722         "\n"
2723         "### Description ###\n"
2724         "\n"
2725         "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
2726         "specification. It reconfigures specified buffer to communicate in\n"
2727         "different slot.\n"
2728         "The reconfiguration must be allowed in node configuration parameter\n"
2729         "secureBuffers. Buffers used for synchronization or assigned to the FIFO\n"
2730         "are not reconfigurable.\n"
2731         "The command can be called any time when the communication is running.\n"
2732         "\n"
2733         "### Example ###\n"
2734         "\n"
2735         "    --> frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n"
2736         "    frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n",
2737         CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
2738 };
2739
2740
2741 /** List of commands for flexRay, defined as external */
2742 cmd_des_t const *cmd_list_fr_basic_test[] = {
2743         &cmd_des_fr_user_config,
2744         &cmd_des_fr_config_buffer,
2745         &cmd_des_fr_config_fifo,
2746         &cmd_des_fr_init,
2747         &cmd_des_fr_start,
2748         &cmd_des_fr_allslots,
2749         &cmd_des_fr_halt,
2750         &cmd_des_fr_abort,
2751         &cmd_des_fr_sendwup,
2752         &cmd_des_fr_setwuchannel,
2753         &cmd_des_fr_getpocstatus,
2754         &cmd_des_fr_transmittxlpdu,
2755         &cmd_des_fr_canceltxlpdu,
2756         &cmd_des_fr_receiverxlpdu,
2757         &cmd_des_fr_checktxlpdustatus,
2758         &cmd_des_fr_disablelpdu,
2759         &cmd_des_fr_getglobaltime,
2760         &cmd_des_fr_getnmvector,
2761         &cmd_des_fr_nmwatch,
2762         &cmd_des_fr_getchannelstatus,
2763         &cmd_des_fr_getclockcorrection,
2764         &cmd_des_fr_getsyncframelist,
2765         &cmd_des_fr_getwakeuprxstatus,
2766         &cmd_des_fr_settimer,
2767         &cmd_des_fr_canceltimer,
2768         &cmd_des_fr_timerirq,
2769         &cmd_des_fr_getversioninfo,
2770         &cmd_des_fr_readcconfig,
2771         &cmd_des_fr_reconfigure_buffer,
2772         NULL
2773 };