2 * Copyright (C) 2012-2013 Czech Technical University in Prague
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.
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.
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/>.
22 * File : cmd_fr_basic_test.c
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
33 #include "cmd_fr_basic_test.h"
38 #include "cmdproc_utils.h"
44 #define printf rpp_sci_printf
46 static inline int badpar(const char *msg)
49 return -CMDERR_BADPAR;
53 * Flag to recognize whether the FlexRay driver was already initialized. If it was, no further configuration is allowed.
55 static boolean_t fr_initialized = FALSE;
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.
62 static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
63 .gColdStartAttempts = 0x2,
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,
74 .gdActionPointOffset = 0x4,
75 .gdCASRxLowMax = 0x43,
76 .gdDynamicSlotIdlePhase = 0x1,
78 .gdMinislotActionPointOffset = 0x2,
80 .gdSampleClockPeriod = 0, // 10mbit/sec
82 .gdTSSTransmitter = 0xA,
83 .gdWakeupSymbolRxIdle = 18,
84 .gdWakeupSymbolRxLow = 18,
85 .gdWakeupSymbolRxWindow = 76,
86 .gdWakeupSymbolTxIdle = 180,
87 .gdWakeupSymbolTxLow = 60
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.
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,
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,
119 .pdAcceptedStartupRange = 0x81,
120 .pdListenTimeout = 0x36DA2,
122 .pDecodingCorrection = 0x33
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.
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,
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,
154 .pdAcceptedStartupRange = 0x81,
155 .pdListenTimeout = 0x36DA2,
157 .pDecodingCorrection = 0x33
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
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
176 static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
178 .channel = FR_CHANNEL_AB,
179 .cycleCounterFiltering = 0,
183 .msgBufferInterrupt = TRUE,
184 .payloadPreambleIndicatorTr = FALSE,
185 .rejectNullFrames = FALSE,
186 .rejectStaticSegment = FALSE,
187 .singleTransmit = FALSE,
191 .channel = FR_CHANNEL_AB,
192 .cycleCounterFiltering = 0,
196 .msgBufferInterrupt = TRUE,
197 .payloadPreambleIndicatorTr = FALSE,
198 .rejectNullFrames = FALSE,
199 .rejectStaticSegment = FALSE,
200 .singleTransmit = FALSE,
204 .channel = FR_CHANNEL_AB,
205 .cycleCounterFiltering = 0,
209 .msgBufferInterrupt = TRUE,
210 .payloadPreambleIndicatorTr = FALSE,
211 .rejectNullFrames = FALSE,
212 .rejectStaticSegment = FALSE,
213 .singleTransmit = TRUE,
217 .channel = FR_CHANNEL_AB,
218 .cycleCounterFiltering = 0,
222 .msgBufferInterrupt = TRUE,
223 .payloadPreambleIndicatorTr = FALSE,
224 .rejectNullFrames = FALSE,
225 .rejectStaticSegment = FALSE,
226 .singleTransmit = TRUE,
230 .channel = FR_CHANNEL_AB,
231 .cycleCounterFiltering = 0,
235 .msgBufferInterrupt = TRUE,
236 .payloadPreambleIndicatorTr = TRUE,
237 .rejectNullFrames = FALSE,
238 .rejectStaticSegment = FALSE,
239 .singleTransmit = FALSE,
245 static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
247 .channel = FR_CHANNEL_AB,
248 .cycleCounterFiltering = 0,
252 .msgBufferInterrupt = TRUE,
253 .payloadPreambleIndicatorTr = FALSE,
254 .rejectNullFrames = FALSE,
255 .rejectStaticSegment = FALSE,
256 .singleTransmit = FALSE,
260 .channel = FR_CHANNEL_AB,
261 .cycleCounterFiltering = 0,
265 .msgBufferInterrupt = TRUE,
266 .payloadPreambleIndicatorTr = FALSE,
267 .rejectNullFrames = FALSE,
268 .rejectStaticSegment = FALSE,
269 .singleTransmit = FALSE,
273 .channel = FR_CHANNEL_AB,
274 .cycleCounterFiltering = 0,
278 .msgBufferInterrupt = TRUE,
279 .payloadPreambleIndicatorTr = FALSE,
280 .rejectNullFrames = FALSE,
281 .rejectStaticSegment = FALSE,
282 .singleTransmit = TRUE,
286 .channel = FR_CHANNEL_AB,
287 .cycleCounterFiltering = 0,
291 .msgBufferInterrupt = TRUE,
292 .payloadPreambleIndicatorTr = FALSE,
293 .rejectNullFrames = FALSE,
294 .rejectStaticSegment = FALSE,
295 .singleTransmit = TRUE,
299 .channel = FR_CHANNEL_AB,
300 .cycleCounterFiltering = 0,
304 .msgBufferInterrupt = TRUE,
305 .payloadPreambleIndicatorTr = TRUE,
306 .rejectNullFrames = FALSE,
307 .rejectStaticSegment = FALSE,
308 .singleTransmit = FALSE,
313 static Fr_TMS570LS_BufferConfigType Fr_node_A_dynamic_buffers_config[] = {
315 .channel = FR_CHANNEL_A,
316 .cycleCounterFiltering = 0,
320 .msgBufferInterrupt = TRUE,
321 .payloadPreambleIndicatorTr = FALSE,
322 .rejectNullFrames = FALSE,
323 .rejectStaticSegment = FALSE,
324 .singleTransmit = FALSE,
328 .channel = FR_CHANNEL_B,
329 .cycleCounterFiltering = 0,
333 .msgBufferInterrupt = TRUE,
334 .payloadPreambleIndicatorTr = FALSE,
335 .rejectNullFrames = FALSE,
336 .rejectStaticSegment = FALSE,
337 .singleTransmit = FALSE,
341 .channel = FR_CHANNEL_A,
342 .cycleCounterFiltering = 0,
346 .msgBufferInterrupt = TRUE,
347 .payloadPreambleIndicatorTr = FALSE,
348 .rejectNullFrames = FALSE,
349 .rejectStaticSegment = FALSE,
350 .singleTransmit = TRUE,
356 static Fr_TMS570LS_BufferConfigType Fr_node_B_dynamic_buffers_config[] = {
358 .channel = FR_CHANNEL_B,
359 .cycleCounterFiltering = 0,
363 .msgBufferInterrupt = TRUE,
364 .payloadPreambleIndicatorTr = FALSE,
365 .rejectNullFrames = FALSE,
366 .rejectStaticSegment = FALSE,
367 .singleTransmit = TRUE,
371 .channel = FR_CHANNEL_A,
372 .cycleCounterFiltering = 0,
376 .msgBufferInterrupt = TRUE,
377 .payloadPreambleIndicatorTr = FALSE,
378 .rejectNullFrames = FALSE,
379 .rejectStaticSegment = FALSE,
380 .singleTransmit = TRUE,
384 .channel = FR_CHANNEL_A,
385 .cycleCounterFiltering = 0,
389 .msgBufferInterrupt = TRUE,
390 .payloadPreambleIndicatorTr = FALSE,
391 .rejectNullFrames = FALSE,
392 .rejectStaticSegment = FALSE,
393 .singleTransmit = TRUE,
398 static Fr_TMS570LS_BufferConfigType Fr_node_A_fifo_buffers_config[] = {
400 .channel = FR_CHANNEL_AB,
401 .cycleCounterFiltering = 0,
405 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
406 .payloadPreambleIndicatorTr = FALSE,
407 .rejectNullFrames = TRUE,
408 .rejectStaticSegment = FALSE,
409 .singleTransmit = FALSE,
413 .channel = FR_CHANNEL_AB,
414 .cycleCounterFiltering = 0,
418 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
419 .payloadPreambleIndicatorTr = FALSE,
420 .rejectNullFrames = TRUE,
421 .rejectStaticSegment = FALSE,
422 .singleTransmit = FALSE,
426 .channel = FR_CHANNEL_AB,
427 .cycleCounterFiltering = 0,
431 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
432 .payloadPreambleIndicatorTr = FALSE,
433 .rejectNullFrames = TRUE,
434 .rejectStaticSegment = FALSE,
435 .singleTransmit = FALSE,
439 .channel = FR_CHANNEL_AB,
440 .cycleCounterFiltering = 0,
444 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
445 .payloadPreambleIndicatorTr = FALSE,
446 .rejectNullFrames = TRUE,
447 .rejectStaticSegment = FALSE,
448 .singleTransmit = FALSE,
452 .channel = FR_CHANNEL_AB,
453 .cycleCounterFiltering = 0,
457 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
458 .payloadPreambleIndicatorTr = FALSE,
459 .rejectNullFrames = TRUE,
460 .rejectStaticSegment = FALSE,
461 .singleTransmit = FALSE,
466 static Fr_TMS570LS_BufferConfigType Fr_node_B_fifo_buffers_config[] = {
468 .channel = FR_CHANNEL_AB,
469 .cycleCounterFiltering = 0,
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
481 .channel = FR_CHANNEL_AB,
482 .cycleCounterFiltering = 0,
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
494 .channel = FR_CHANNEL_AB,
495 .cycleCounterFiltering = 0,
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
507 .channel = FR_CHANNEL_AB,
508 .cycleCounterFiltering = 0,
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
520 .channel = FR_CHANNEL_AB,
521 .cycleCounterFiltering = 0,
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
535 * This is an unifying configuration structure for the node A.
536 * It joins all the configuration structure together.
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
548 * This is an unifying configuration structure for the node A.
549 * It joins all the configuration structure together.
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
560 /* User configuration */
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,
578 #define USER_CONFIG_NOT_DONE 0x0
579 #define USER_CONFIG_CLUSTER 0x1
580 #define USER_CONFIG_NODE 0x2
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;
588 * Split string into numbers
590 * The function takes a string with hexadecimal numbers,
591 * separated by spaces, and converts it into an array of numbers.
593 * For example "0x2 0xA 0XDD 0xABCD" -> {0x2, 0xA, 0XDD, 0xABCD}
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
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.
602 static int8_t cmd_fr_parse_params(const char *params, uint32_t params_cnt, uint32_t *tmp_params)
604 char cpy_params[256];
608 if (params == NULL || tmp_params == NULL)
610 strncpy(cpy_params, params, 256);
611 token = strtok(cpy_params, " ");
614 for (i = 0; i < params_cnt; i++) {
615 if (sscanf(token, "%i", &tmp_params[i]) == EOF) // No number found
617 if ((token = strtok(NULL, " ")) == NULL && i < params_cnt-1) // Not enough parameters in the string
623 int8_t cmd_fr_config_cluster_params(const char *params)
625 uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
627 if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE)
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];
656 user_configuration_state |= USER_CONFIG_CLUSTER;
660 int8_t cmd_fr_config_node_params(const char *params)
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};
666 if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE)
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] ];
701 user_configuration_state |= USER_CONFIG_NODE;
705 int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
707 Fr_TMS570LS_BufferConfigType *fifo_buffer_ptr = &user_fifo_buffer_config[0];
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;
713 if (fr_initialized) {
714 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
715 return -CMDERR_BADCFG;
718 ret = sscanf(param[2], "rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s",
729 printf("Error parsing parameter %d\n", ret+1);
730 return -CMDERR_BADPAR;
733 if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
734 return badpar("Depth too high\n");
735 user_fifo_buffer_depth = depth;
738 return badpar("Invalid slot number\n");
739 tmp_buffer.slotId = slot;
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");
748 if (cycleset >= 0x80)
749 return badpar("Cycle set must be less than 0x80.\n");
750 tmp_buffer.cycleCounterFiltering = cycleset;
752 if (maxpayload >= 128)
753 return badpar("Maximum payload in half-words must be less than 128\n");
754 tmp_buffer.maxPayload = maxpayload;
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");
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");
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;
780 printf("frbtcfgfifo rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s\n",
794 int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
796 Fr_TMS570LS_BufferConfigType *cfg;
799 char buf_type, channel[3],rxtx[3], single_continuous[11];
800 unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
802 if (fr_initialized) {
803 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
804 return -CMDERR_BADCFG;
807 ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
820 printf("Error parsing parameter %d\n", ret+1);
821 return -CMDERR_BADPAR;
827 if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
828 return badpar("Buffer index too high\n");
829 cfg = &user_static_buffer_config[buffer];
832 if (buffer >= RPP_FR_MAX_DYNAMIC_BUF_CNT)
833 return badpar("Buffer index too high\n");
834 cfg = &user_dynamic_buffer_config[buffer];
837 return badpar("Invalid buffer type (S, D)\n");
840 if (slot < 1 || slot > 2047)
841 return badpar("Invalid slot number\n");
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");
851 if (cycleset >= 0x80)
852 return badpar("Cycle set must be less than 0x80.\n");
853 cfg->cycleCounterFiltering = cycleset;
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");
859 if (maxpayload >= 128)
860 return badpar("Maximum payload in half-words must be less than 128\n");
861 cfg->maxPayload = maxpayload;
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");
872 return badpar("Payload preamble indicator must be 0 or 1");
873 cfg->payloadPreambleIndicatorTr = preamb;
876 return badpar("Interrupt parameter must be 0 or 1");
877 cfg->msgBufferInterrupt = intr;
881 if (buffer >= user_static_buffer_configured)
882 user_static_buffer_configured = buffer + 1;
885 if (buffer >= user_dynamic_buffer_configured)
886 user_dynamic_buffer_configured = buffer + 1;
890 printf("frbtcfgbuf%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i\n",
909 * @brief Do the user configuration of the FlexRay cluster parameters
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
916 int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
920 if (fr_initialized) {
921 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
922 return -CMDERR_BADCFG;
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;
931 rpp_sci_printf("FlexRay cluster configuration accepted.\n");
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;
938 rpp_sci_printf("FlexRay node configuration accepted.\n");
941 return -CMDERR_BADPAR;
947 * @brief Initialize the device as FlexRay node.
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
954 int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
956 const Fr_ConfigType *Fr_ConfigPtr = NULL;
957 int8_t retVal = SUCCESS;
958 uint32_t error = ERR_PARAM_NO_ERROR;
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;
971 return -CMDERR_BADPAR;
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;
979 retVal = rpp_fr_init_controller(0, &error);
980 if (retVal == SUCCESS) {
981 rpp_sci_printf("FlexRay controller reinitialized.\r\n");
985 rpp_sci_printf("FlexRay needs to be configured before initialization.\r\n");
986 return -CMDERR_BADCFG;
990 retVal = rpp_fr_init_controller(0, &error);
991 if (retVal == SUCCESS)
992 rpp_sci_printf("FlexRay controller initialized.\r\n");
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 );
1005 rpp_sci_printf("POC state switching error.\r\n");
1006 return -CMDERR_BADCFG;
1012 * @brief Starts FlexRay communication
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
1019 int cmd_do_fr_start(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1021 int8_t retVal = SUCCESS;
1022 uint32_t error = ERR_PARAM_NO_ERROR;
1024 retVal = rpp_fr_start_communication(0, &error);
1025 if (retVal == SUCCESS)
1026 rpp_sci_printf("FlexRay communication is running.\r\n");
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");
1037 rpp_sci_printf("General error.\r\n");
1038 return -CMDERR_BADCFG;
1044 * @brief Invokes POC command ALL_SLOTS
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
1051 int cmd_do_fr_allslots(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1053 int8_t retVal = ERR_PARAM_NO_ERROR;
1055 retVal = rpp_fr_all_slots(0);
1056 if (retVal == SUCCESS)
1057 rpp_sci_printf("FlexRay node started communication in all slots.\r\n");
1059 rpp_sci_printf("General error.\r\n");
1060 return -CMDERR_BADCFG;
1066 * @brief Halt FlexRay communication
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
1073 int cmd_do_fr_halt(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1075 int8_t retVal = ERR_PARAM_NO_ERROR;
1077 retVal = rpp_fr_halt_communication(0);
1078 if (retVal == SUCCESS)
1079 rpp_sci_printf("FlexRay node communication halted.\r\n");
1081 rpp_sci_printf("General error.\r\n");
1082 return -CMDERR_BADCFG;
1088 * @brief Abort FlexRay communication
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
1095 int cmd_do_fr_abort(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1097 int8_t retVal = ERR_PARAM_NO_ERROR;
1099 retVal = rpp_fr_abort_communication(0);
1100 if (retVal == SUCCESS)
1101 rpp_sci_printf("FlexRay node communication aborted.\r\n");
1103 rpp_sci_printf("General error.\r\n");
1104 return -CMDERR_BADCFG;
1110 * @brief Send wake up pattern
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
1117 int cmd_do_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1119 int8_t retVal = ERR_PARAM_NO_ERROR;
1121 retVal = rpp_fr_send_wup(0);
1122 if (retVal == SUCCESS)
1123 rpp_sci_printf("Wake up pattern has been sent.\r\n");
1125 rpp_sci_printf("General error.\r\n");
1126 return -CMDERR_BADCFG;
1132 * @brief Set channel for wake up pattern sending.
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
1139 int cmd_do_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1141 int8_t retVal = ERR_PARAM_NO_ERROR;
1142 Fr_ChannelType channel = FR_CHANNEL_A;
1144 if (*param[1] == 'A')
1145 channel = FR_CHANNEL_A;
1146 else if (*param[1] == 'B')
1147 channel = FR_CHANNEL_B;
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");
1154 rpp_sci_printf("General error.\r\n");
1155 return -CMDERR_BADCFG;
1161 * @brief Get and print POC status of the FlexRay controller.
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
1168 int cmd_do_fr_getpocstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
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",
1180 char *StateStrings[] = {
1181 "CONFIG", "DEFAULT_CONFIG", "HALT", "NORMAL_ACTIVE",
1182 "NORMAL_PASSIVE", "READY", "STARTUP", "LOOPBACK",
1185 char *WakeupStatusStrings[] = {
1186 "UNDEFINED", "RECEIVED_HEADER", "RECEIVED_WUP", "COLLISION_HEADER",
1187 "COLLISION_WUP", "COLLISION_UNKNOWN", "TRANSMITTED"
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]);
1204 rpp_sci_printf("General error.\r\n");
1205 return -CMDERR_BADCFG;
1211 * @brief Send given data through the FlexRay in selected slot.
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
1218 int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1220 int8_t retVal = ERR_PARAM_NO_ERROR;
1223 int values[MAX_PARAM_VALUES_NUM];
1224 uint8_t data[MAX_PARAM_VALUES_NUM];
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, " ");
1235 while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
1236 if (sscanf(token, "%2x", &values[dataLength]) == EOF)
1238 data[dataLength] = (uint8_t)values[dataLength];
1239 token = strtok(NULL, " ");
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");
1247 rpp_sci_printf("General error.\r\n");
1248 return -CMDERR_BADCFG;
1254 * @brief Cancel the transmission in the selected slot.
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
1261 int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1263 int8_t retVal = ERR_PARAM_NO_ERROR;
1266 if (sscanf(param[1], "%d", &slotID) != 1)
1267 return -CMDERR_BADPAR;
1268 if (param[2] != NULL)
1269 return -CMDERR_BADPAR;
1271 retVal = rpp_fr_cancel_transmit_lpdu(0, slotID);
1272 if (retVal == SUCCESS)
1273 rpp_sci_printf("Transmission canceled.\r\n");
1275 rpp_sci_printf("General error.\r\n");
1276 return -CMDERR_BADCFG;
1282 * @brief Receive data from selected slot.
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
1289 int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1291 int8_t retVal = ERR_PARAM_NO_ERROR;
1293 uint8_t data[cPayloadLengthMax];
1294 Fr_RxLPduStatusType status;
1295 uint8_t receivedLength = 0;
1298 if (sscanf(param[1], "%d", &slotID) != 1)
1299 return -CMDERR_BADPAR;
1300 if (param[2] != NULL)
1301 return -CMDERR_BADPAR;
1303 memset(data, 0, sizeof(data));
1305 retVal = rpp_fr_receive_lpdu(0, slotID, data, &status, &receivedLength);
1306 if (retVal == SUCCESS) {
1308 case FR_RECEIVED_MORE_DATA_AVAILABLE:
1309 rpp_sci_printf("More messages are still in FIFO:\r\n");
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]);
1315 rpp_sci_printf("\r\n");
1318 rpp_sci_printf("No message received.\r\n");
1323 rpp_sci_printf("General error.\r\n");
1324 return -CMDERR_BADCFG;
1330 * @brief Returns TX LPdu status.
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
1337 int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1339 int8_t retVal = ERR_PARAM_NO_ERROR;
1341 Fr_TxLPduStatusType status;
1342 char *statusStrings[] = {"is not", "is"};
1344 if (sscanf(param[1], "%d", &slotID) != 1)
1345 return -CMDERR_BADPAR;
1346 if (param[2] != NULL)
1347 return -CMDERR_BADPAR;
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]);
1353 rpp_sci_printf("General error.\r\n");
1354 return -CMDERR_BADCFG;
1360 * @brief Disable buffer.
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
1367 int cmd_do_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1369 int8_t retVal = ERR_PARAM_NO_ERROR;
1372 if (sscanf(param[1], "%d", &slotID) != 1)
1373 return -CMDERR_BADPAR;
1374 if (param[2] != NULL)
1375 return -CMDERR_BADPAR;
1377 retVal = rpp_fr_disable_lpdu(0, slotID);
1378 if (retVal == SUCCESS)
1379 rpp_sci_printf("Buffer disabled.\r\n");
1381 rpp_sci_printf("General error.\r\n");
1382 return -CMDERR_BADCFG;
1388 * @brief Print global time of the FlexRay network.
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
1395 int cmd_do_fr_getglobaltime(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1397 int8_t retVal = ERR_PARAM_NO_ERROR;
1399 uint16_t macroTick = 0;
1401 retVal = rpp_fr_get_global_time(0, &cycle, ¯oTick);
1402 if (retVal == SUCCESS)
1403 rpp_sci_printf("Cycle number: %d\r\nMacrotick number: %d\r\n", cycle, macroTick);
1405 rpp_sci_printf("General error.\r\n");
1406 return -CMDERR_BADCFG;
1412 * @brief Print network management vector of the FlexRay node.
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
1419 int cmd_do_fr_getnmvector(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1421 int8_t retVal = ERR_PARAM_NO_ERROR;
1422 uint8_t nmVector[12];
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]);
1431 rpp_sci_printf("\r\n");
1434 rpp_sci_printf("General error.\r\n");
1435 return -CMDERR_BADCFG;
1440 int cmd_do_fr_nmwatch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1442 int8_t retVal = ERR_PARAM_NO_ERROR;
1443 uint8_t nmVector[12];
1446 // Calculate wait time in OS ticks
1447 static const portTickType freq_ticks = 100 /* ms */ / portTICK_RATE_MS;
1448 portTickType last_wake_time = xTaskGetTickCount();
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]);
1457 rpp_sci_printf("\r");
1460 rpp_sci_printf("General error.\r\n");
1461 return -CMDERR_BADCFG;
1463 vTaskDelayUntil(&last_wake_time, freq_ticks);
1465 rpp_sci_printf("\n");
1470 * @brief Print both channels status of the FlexRay node.
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
1477 int cmd_do_fr_getchannelstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1479 int8_t retVal = ERR_PARAM_NO_ERROR;
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",
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",
1500 char *channelNames[] = {"A", "B"};
1501 char *boolStrings[] = {"FALSE", "TRUE"};
1502 uint16_t channelStatuses[2];
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 ] );
1513 rpp_sci_printf("General error.\r\n");
1514 return -CMDERR_BADCFG;
1520 * @brief Print clock correction of the FlexRay node
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
1527 int cmd_do_fr_getclockcorrection(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1529 int8_t retVal = ERR_PARAM_NO_ERROR;
1530 int16_t rateCorrection;
1531 int32_t offsetCorrection;
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);
1537 rpp_sci_printf("General error.\r\n");
1538 return -CMDERR_BADCFG;
1544 * @brief Print list of syncframec transmitted on both channels via the even and odd cycle.
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
1551 int cmd_do_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
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;
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;
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]);
1575 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1579 rpp_sci_printf("General error.\r\n");
1580 return -CMDERR_BADCFG;
1586 * @brief Print status of wakeup on each channels (wakeup received on channel or not yet received).
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
1593 int cmd_do_fr_getwakeuprxstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1595 int8_t retVal = ERR_PARAM_NO_ERROR;
1597 char *statusStrings[] = {"was not yet", "was"};
1598 char *channelNames[] = {"A", "B"};
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]);
1607 rpp_sci_printf("General error.\r\n");
1608 return -CMDERR_BADCFG;
1614 * @brief Set and start absolute timer.
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
1621 int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1623 int8_t retVal = ERR_PARAM_NO_ERROR;
1628 if (sscanf(param[1], "%i %i %i", &timer, &cycle, &offset) != 3)
1629 return -CMDERR_BADPAR;
1631 retVal = rpp_fr_set_timer(0, timer, cycle, offset);
1632 if (retVal == SUCCESS) {
1634 while (i && (cycle & i) == 0)
1639 rpp_sci_printf("Timer was set for every %d-th cycle, offset %d, macrotick %d\n",
1640 i, cycle & ~i, offset);
1643 rpp_sci_printf("General error.\r\n");
1644 return -CMDERR_BADCFG;
1650 * @brief Cancel selected timer
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
1657 int cmd_do_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1659 int8_t retVal = ERR_PARAM_NO_ERROR;
1662 if (sscanf(param[1], "%d", &timer) != 1)
1663 return -CMDERR_BADPAR;
1665 if (param[2] != NULL)
1666 return -CMDERR_BADPAR;
1668 retVal = rpp_fr_cancel_timer(0, timer);
1669 if (retVal == SUCCESS)
1670 rpp_sci_printf("Timer was canceled.\r\n");
1672 rpp_sci_printf("General error.\r\n");
1673 return -CMDERR_BADCFG;
1679 * @brief Enable/disable, acknowledge, get timer IRQ
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
1686 int cmd_do_fr_timerirq(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1688 int8_t retVal = ERR_PARAM_NO_ERROR;
1691 boolean_t status = FALSE;
1692 char *boolStrings[] = {"FALSE", "TRUE"};
1695 if (sscanf(param[1], "%d", &timer) != 1)
1696 return -CMDERR_BADPAR;
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]);
1703 rpp_sci_printf("General error.\r\n");
1704 return -CMDERR_BADCFG;
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;
1719 if (retVal == SUCCESS)
1720 rpp_sci_printf("OK\r\n");
1722 rpp_sci_printf("General error.\r\n");
1723 return -CMDERR_BADCFG;
1730 * @brief Print FlexRay driver version info.
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
1737 int cmd_do_fr_getversioninfo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1739 Std_VersionInfoType versionInfo;
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);
1752 * @brief Print value of FlexRay configuratoin parameter.
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
1759 int cmd_do_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1761 int8_t retVal = ERR_PARAM_NO_ERROR;
1765 if (sscanf(param[1], "%d", &index) != 1)
1766 return -CMDERR_BADPAR;
1768 if (param[2] != NULL)
1769 return -CMDERR_BADPAR;
1771 retVal = rpp_fr_read_com_ctrl_config(0, index, &value);
1772 if (retVal == SUCCESS)
1773 rpp_sci_printf("Value = %#x\r\n", value);
1775 rpp_sci_printf("General error.\r\n");
1776 return -CMDERR_BADCFG;
1782 * @brief Reconfigure buffer
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
1789 int cmd_do_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1793 unsigned id, slot, maxpayload, cycleset, cycleoffset;
1794 Fr_TMS570LS_BufferConfigType tmp_buffer;
1798 ret = sscanf(param[2], "id%i slot%i %2s cycset%i cycoffset%i max%i",
1807 printf("Error parsing parameter %d\n", ret+1);
1808 return -CMDERR_BADPAR;
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) {
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");
1830 if (maxpayload >= 256)
1831 return badpar("Maximum payload in bytes must be less than 256\n");
1832 tmp_buffer.maxPayload = maxpayload;
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",
1846 printf("Reconfiguration failed.\n");
1847 return -CMDERR_BADPAR;
1852 /** Command descriptor for FlexRay user config cluster command */
1853 cmd_des_t const cmd_des_fr_user_config = {
1855 "frbtconfig*","Set the user configuration parameters",
1856 "### Command syntax ###\n"
1858 " frbtconfig<TYPE> <PARAMS>\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"
1864 "### Description ###\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"
1873 "The type of the parameters can be selected by the `<TYPE>` selector.\n"
1875 "Type \"cluster\" sets global FlexRay network parameters. It expects a\n"
1876 "sequence of 25 parameters in this order:\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"
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"
1904 "Type \"node\" sets local FlexRay network parameters. It expects a\n"
1905 "sequence of 28 parameters in this order:\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"
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"
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
1945 cmd_des_t const cmd_des_fr_config_buffer = {
1947 "frbtcfgbuf?*","Configure a message buffer in the user configuration",
1948 "### Command syntax ###\n"
1950 " frbtcfgbuf<TYPE><NUM> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\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"
1964 "### Description ###\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"
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
1984 cmd_des_t const cmd_des_fr_config_fifo = {
1986 "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
1987 "### Command syntax ###\n"
1989 " frbtcfgfifo rejslot<SLOT> slotmask<MASK> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT>\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"
2000 "### Description ###\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"
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
2016 /** Command descriptor for FlexRay init command */
2017 cmd_des_t const cmd_des_fr_init = {
2019 "frbtinit?","Initialize a FlexRay node",
2020 "### Command syntax ###\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"
2028 "### Description ###\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"
2047 " FlexRay driver initialized.\n"
2048 " FlexRay controller initialized.\n",
2049 CMD_HANDLER(cmd_do_fr_init), (void *)&cmd_list_fr_basic_test
2052 /** Command descriptor for FlexRay controller init command */
2053 cmd_des_t const cmd_des_fr_start = {
2055 "frbtstart","Start a new FlexRay network or join to the existing one",
2056 "### Command syntax ###\n"
2060 "### Description ###\n"
2062 "The command stands for Fr_StartCommunication function from the Autosar\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"
2073 "The command should be called after the frbtinit command.\n"
2078 " FlexRay communication is running.\n",
2079 CMD_HANDLER(cmd_do_fr_start), (void *)&cmd_list_fr_basic_test
2082 /** Command descriptor for FlexRay controller all slots command */
2083 cmd_des_t const cmd_des_fr_allslots = {
2085 "frbtallslots","Enables communication for all frames",
2086 "### Command syntax ###\n"
2090 "### Description ###\n"
2092 "The command stands for Fr_AllSlots function from the Autosar\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"
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
2109 /** Command descriptor for FlexRay controller halt command */
2110 cmd_des_t const cmd_des_fr_halt = {
2112 "frbthalt","Halt FlexRay communication after the end of the actual communication cycle",
2113 "### Command syntax ###\n"
2117 "### Description ###\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"
2129 " FlexRay node communication halted.\n",
2130 CMD_HANDLER(cmd_do_fr_halt), (void *)&cmd_list_fr_basic_test
2133 /** Command descriptor for FlexRay controller abort command */
2134 cmd_des_t const cmd_des_fr_abort = {
2136 "frbtabort","Abort FlexRay communication immediately",
2137 "### Command syntax ###\n"
2141 "### Description ###\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"
2154 " FlexRay node communication aborted.\n",
2155 CMD_HANDLER(cmd_do_fr_abort), (void *)&cmd_list_fr_basic_test
2158 /** Command descriptor for FlexRay controller send wake up pattern command */
2159 cmd_des_t const cmd_des_fr_sendwup = {
2161 "frbtwup","Initiate the wake up procedure",
2162 "### Command syntax ###\n"
2166 "### Description ###\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"
2175 " Wake up pattern has been sent.\n",
2176 CMD_HANDLER(cmd_do_fr_sendwup), (void *)&cmd_list_fr_basic_test
2179 /** Command descriptor for FlexRay controller sent wake up pattern channel command */
2180 cmd_des_t const cmd_des_fr_setwuchannel = {
2182 "frbtsetwuch?","Set wake up channel",
2183 "### Command syntax ###\n"
2185 " frbtsetwuch<CHANNEL>\n"
2187 "where `<CHANNEL>` is a character A or B, specifying the channel.\n"
2189 "### Description ###\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"
2199 " --> frbtsetwuchA\n"
2200 " Wake up channel has been set.\n",
2201 CMD_HANDLER(cmd_do_fr_setwuchannel), (void *)&cmd_list_fr_basic_test
2204 /** Command descriptor for FlexRay controller get POC status command */
2205 cmd_des_t const cmd_des_fr_getpocstatus = {
2207 "frbtgetpocst","Print FlexRay POC status",
2208 "### Command syntax ###\n"
2212 "### Description ###\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"
2221 " --> frbtgetpocst\n"
2223 " CHIHaltRequest: FALSE\n"
2224 " CHIReadyRequest: FALSE\n"
2225 " ColdstartNoise: FALSE\n"
2227 " ErrorMode: ACTIVE\n"
2229 " StartupState: UNDEFINED\n"
2231 " WakeupStatus: UNDEFINED\n",
2232 CMD_HANDLER(cmd_do_fr_getpocstatus), (void *)&cmd_list_fr_basic_test
2235 /** Command descriptor for FlexRay transmit tx lpdu command */
2236 cmd_des_t const cmd_des_fr_transmittxlpdu = {
2238 "frbttransmit*","Transmit data in selected frame",
2239 "### Command syntax ###\n"
2241 " frbttransmit<FRID> <DATA>\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"
2247 "### Description ###\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"
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
2263 /** Command descriptor for FlexRay cancel tx lpdu command */
2264 cmd_des_t const cmd_des_fr_canceltxlpdu = {
2266 "frbtcanceltx*","Stop the transmission of the frame",
2267 "### Command syntax ###\n"
2269 " frbtcanceltx<FRID>\n"
2271 "where `<FRID>` is a decimal number specifying the ID of the frame for\n"
2272 "which a buffer has been configured.\n"
2274 "### Description ###\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"
2285 " --> frbtcanceltx3\n"
2286 " Transmission canceled.\n",
2287 CMD_HANDLER(cmd_do_fr_canceltxlpdu), (void *)&cmd_list_fr_basic_test
2290 /** Command descriptor for FlexRay receive rx lpdu command */
2291 cmd_des_t const cmd_des_fr_receiverxlpdu = {
2293 "frbtreceive*","Receive a new message",
2294 "### Command syntax ###\n"
2296 " frbtreceive<FRID>\n"
2298 "where `<FRID>` is a decimal number specifying the ID of the frame for\n"
2299 "which a buffer was configured.\n"
2301 "### Description ###\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"
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
2321 /** Command descriptor for FlexRay check TX LPdu status command */
2322 cmd_des_t const cmd_des_fr_checktxlpdustatus = {
2324 "frbtchecktx*","Print the status of the transmit buffer",
2325 "### Command syntax ###\n"
2327 " frbtchecktx<FRID>\n"
2329 "where `<FRID>` is a decimal number specifying the ID of the frame for\n"
2330 "which a buffer has been configured.\n"
2332 "### Description ###\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"
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"
2344 " --> frbtchecktx1\n"
2345 " Message transmission is not pending.\n",
2346 CMD_HANDLER(cmd_do_fr_checktxlpdustatus), (void *)&cmd_list_fr_basic_test
2349 /** Command descriptor for FlexRay disable LPdu command */
2350 cmd_des_t const cmd_des_fr_disablelpdu = {
2352 "frbtdisable*","Disable the buffers assigned to the frame",
2353 "### Command syntax ###\n"
2355 " frbtdisable<FRID>\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"
2360 "### Description ###\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"
2371 " --> frbtdisable3\n"
2372 " Buffer disabled.\n",
2373 CMD_HANDLER(cmd_do_fr_disablelpdu), (void *)&cmd_list_fr_basic_test
2376 /** Command descriptor for FlexRay get global time command */
2377 cmd_des_t const cmd_des_fr_getglobaltime = {
2379 "frbtglobtime","Print actual global time of the network",
2380 "### Command syntax ###\n"
2384 "### Description ###\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"
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
2398 /** Command descriptor for FlexRay get network management vector command */
2399 cmd_des_t const cmd_des_fr_getnmvector = {
2401 "frbtnmvector","Print network management vector of the node",
2402 "### Command syntax ###\n"
2406 "### Description ###\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"
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
2419 /** Command descriptor for FlexRay get network management vector command */
2420 cmd_des_t const cmd_des_fr_nmwatch = {
2422 "frbtnmwatch","Watch the changes of the network managment vector in real-time",
2423 "### Command syntax ###\n"
2427 "### Description ###\n"
2429 "Reads the network management vector every 100 ms and prints it out.\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
2438 /** Command descriptor for FlexRay get channel status command */
2439 cmd_des_t const cmd_des_fr_getchannelstatus = {
2441 "frbtchstat","Print channel A and B status",
2442 "### Command syntax ###\n"
2446 "### Description ###\n"
2448 "The command stands for Fr_GetChannelStatus function from the Autosar\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
2491 /** Command descriptor for FlexRay get clock correction command */
2492 cmd_des_t const cmd_des_fr_getclockcorrection = {
2494 "frbtclkcor","Print clock correction (rate and offset)",
2495 "### Command syntax ###\n"
2499 "### Description ###\n"
2501 "The command stands for Fr_GetClockCorrection function from the Autosar\n"
2507 " Rate correction: 0\n"
2508 " Offset correction: 0\n",
2509 CMD_HANDLER(cmd_do_fr_getclockcorrection), (void *)&cmd_list_fr_basic_test
2512 /** Command descriptor for FlexRay get sync frame list command */
2513 cmd_des_t const cmd_des_fr_getsyncframelist = {
2515 "frbtgetsyncfrlist*","Print the list of sync frames transmitted on both channels via the odd and even communication cycle",
2516 "### Command syntax ###\n"
2518 " frbtgetsyncfrlist<LENGTH>\n"
2520 "where `<LENGTH>` is a decimal number in range 0 - 15, specifying the\n"
2521 "length of the list to be printed.\n"
2523 "### Description ###\n"
2525 "The command stands for Fr_GetSyncFrameList function from the Autosar\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
2539 /** Command descriptor for FlexRay get sync frame list command */
2540 cmd_des_t const cmd_des_fr_getwakeuprxstatus = {
2542 "frbtgetwurxstat","Prints whether the wake up pattern has been or has not been received",
2543 "### Command syntax ###\n"
2545 " frbtgetwurxstat\n"
2547 "### Description ###\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"
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
2561 /** Command descriptor for FlexRay set absolute timer command */
2562 cmd_des_t const cmd_des_fr_settimer = {
2564 "frbtsettimer*","Set and start timer",
2565 "### Command syntax ###\n"
2567 " frbtsettimer<TMID> <CYCLE> <OFFSET>\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"
2574 "### Description ###\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"
2581 "Before using this command, FlexRay communication has to be started\n"
2582 "(see frbtstart).\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
2595 /** Command descriptor for FlexRay cancel absolute timer command */
2596 cmd_des_t const cmd_des_fr_canceltimer = {
2598 "frbtcanceltimer*","Stop the timer",
2599 "### Command syntax ###\n"
2601 " frbtcanceltimer<TMID>\n"
2602 "where `<TMID>` is a number (0 or 1) specifying the timer.\n"
2604 "### Description ###\n"
2606 "The command stands for Fr_CancelAbsoluteTimer function from the\n"
2607 "Autosar specification. It stops the timer selected by the parameter.\n"
2611 " --> frbtcanceltimer0\n"
2612 " Timer was canceled.\n",
2613 CMD_HANDLER(cmd_do_fr_canceltimer), (void *)&cmd_list_fr_basic_test
2616 /** Command descriptor for FlexRay absolute timer irq manipulation command */
2617 cmd_des_t const cmd_des_fr_timerirq = {
2619 "frbttimerirq*","Perform selected action on the timer IRQ",
2620 "### Command syntax ###\n"
2622 " frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer\n"
2623 " frbttimerirq<TMID> - Get timer IRQ status\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"
2630 "`<ACTIONS>` can be one of:\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"
2636 "### Description ###\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"
2647 " --> frbttimerirq0\n"
2650 " --> frbttimerirq0 EN\n"
2652 CMD_HANDLER(cmd_do_fr_timerirq), (void *)&cmd_list_fr_basic_test
2655 /** Command descriptor for FlexRay get version info command */
2656 cmd_des_t const cmd_des_fr_getversioninfo = {
2658 "frbtversion","Print FlexRay driver version information",
2659 "### Command syntax ###\n"
2663 "### Description ###\n"
2665 "The command stands for Fr_GetVersionInfo function from the Autosar\n"
2667 "It reads and prints the information about vendor, module and version of\n"
2668 "the FlexRay driver\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
2681 /** Command descriptor for FlexRay get controller configuration command */
2682 cmd_des_t const cmd_des_fr_readcconfig = {
2684 "frbtccconfig*","Print value of a FlexRay cluster and node configuration parameter",
2685 "### Command syntax ###\n"
2687 " frbtccconfig<INDEX>\n"
2689 "where `<INDEX>` is an identifier of the parameter.\n"
2691 "### Description ###\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"
2702 " --> frbtccconfig1\n"
2704 CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
2707 /** Command descriptor for FlexRay reconfigure buffer command */
2708 cmd_des_t const cmd_des_fr_reconfigure_buffer = {
2710 "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
2711 "### Command syntax ###\n"
2713 " frbtreconfigurebuf id<ID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> max<MAX>\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"
2723 "### Description ###\n"
2725 "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
2726 "specification. It reconfigures specified buffer to communicate in\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"
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
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,
2748 &cmd_des_fr_allslots,
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,