2 * Copyright (C) 2012-2013 Czech Technical University in Prague
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
30 * File : cmd_fr_basic_test.c
33 * The file contains a set of commands to control the FlexRay driver.
34 * Those commands can be used to configure RPP board as a FlexRay node,
35 * configure a set of TX and RX buffers, get status of the buffers and
36 * the FlexRay controller, manipulate with timers and control the transmission
41 #include "cmd_fr_basic_test.h"
46 #include "cmdproc_utils.h"
50 #define printf rpp_sci_printf
52 static inline int badpar(const char *msg)
55 return -CMDERR_BADPAR;
59 * Flag to recognize whether the FlexRay driver was already initialized. If it was, no further configuration is allowed.
61 static boolean_t fr_initialized = FALSE;
64 * This structure contains global FlexRay configuration.
65 * All nodes in the network have to use the same values for
66 * all parameters of this structure.
68 static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
69 .gColdStartAttempts = 0x2,
71 .gMacroPerCycle = 0x15E0, // (cycle period, 5.6us)
72 .gMaxWithoutClockCorrectionFatal = 0xF,
73 .gMaxWithoutClockCorrectionPassive = 0xF,
74 .gNetworkManagementVectorLength = 12,
75 .gNumberOfMinislots = 0x15A,
76 .gNumberOfStaticSlots = 0x8,
77 .gOffsetCorrectionStart = 0xAE4,
78 .gPayloadLengthStatic = 0x9,
80 .gdActionPointOffset = 0x4,
81 .gdCASRxLowMax = 0x43,
82 .gdDynamicSlotIdlePhase = 0x1,
84 .gdMinislotActionPointOffset = 0x2,
86 .gdSampleClockPeriod = 0, // 10mbit/sec
88 .gdTSSTransmitter = 0xA,
89 .gdWakeupSymbolRxIdle = 18,
90 .gdWakeupSymbolRxLow = 18,
91 .gdWakeupSymbolRxWindow = 76,
92 .gdWakeupSymbolTxIdle = 180,
93 .gdWakeupSymbolTxLow = 60
97 * This structure contains local configuration of the FlexRay node A.
98 * All nodes in the network shall have their own local configuraion,
99 * but it does not matters if they share some together, until their
100 * buffer configuration differs.
102 static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
103 .pAllowHaltDueToClock = 0,
104 .pAllowPassiveToActive = 0xF,
105 .pChannels = FR_CHANNEL_AB,
106 .pClusterDriftDamping = 0x1,
107 .pDelayCompensationA = 0x3,
108 .pDelayCompensationB = 0x3,
109 .pExternOffsetCorrection = 0,
110 .pExternRateCorrection = 0,
111 .pKeySlotUsedForStartup = TRUE,
112 .pKeySlotUsedForSync = TRUE,
114 .pMacroInitialOffsetA = 0x6,
115 .pMacroInitialOffsetB = 0x6,
116 .pMicroInitialOffsetA = 0x18,
117 .pMicroInitialOffsetB = 0x18,
118 .pMicroPerCycle = 0x36B00,
119 .pRateCorrectionOut = 0xCD,
120 .pOffsetCorrectionOut = 0x151,
121 .pSamplesPerMicrotick = 0, // 10 mbit/sec
122 .pSingleSlotEnabled = TRUE,
123 .pWakeupChannel = FR_CHANNEL_A,
125 .pdAcceptedStartupRange = 0x81,
126 .pdListenTimeout = 0x36DA2,
128 .pDecodingCorrection = 0x33
132 * This structure contains local configuration of the FlexRay node B.
133 * All nodes in the network shall have their own local configuraion,
134 * but it does not matters if they share some together, until their
135 * buffer configuration differs.
137 static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
138 .pAllowHaltDueToClock = 0,
139 .pAllowPassiveToActive = 0xF,
140 .pChannels = FR_CHANNEL_AB,
141 .pClusterDriftDamping = 0x1,
142 .pDelayCompensationA = 0x3,
143 .pDelayCompensationB = 0x3,
144 .pExternOffsetCorrection = 0,
145 .pExternRateCorrection = 0,
146 .pKeySlotUsedForStartup = TRUE,
147 .pKeySlotUsedForSync = TRUE,
149 .pMacroInitialOffsetA = 0x6,
150 .pMacroInitialOffsetB = 0x6,
151 .pMicroInitialOffsetA = 0x18,
152 .pMicroInitialOffsetB = 0x18,
153 .pMicroPerCycle = 0x36B00,
154 .pRateCorrectionOut = 0xCD,
155 .pOffsetCorrectionOut = 0x151,
156 .pSamplesPerMicrotick = 0, // 10 mbit/sec
157 .pSingleSlotEnabled = TRUE,
158 .pWakeupChannel = FR_CHANNEL_A,
160 .pdAcceptedStartupRange = 0x81,
161 .pdListenTimeout = 0x36DA2,
163 .pDecodingCorrection = 0x33
166 static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
167 .dynSegmentBufferCount = 3,
168 .fifoBufferCount = 5,
169 .secureBuffers = FR_SB_RECONFIG_ENABLED,
170 .statSegmentBufferCount = 5,
171 .syncFramePayloadMultiplexEnabled = 0
174 static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
175 .dynSegmentBufferCount = 3,
176 .fifoBufferCount = 5,
177 .secureBuffers = FR_SB_RECONFIG_ENABLED,
178 .statSegmentBufferCount = 5,
179 .syncFramePayloadMultiplexEnabled = 0
182 static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
184 .channel = FR_CHANNEL_AB,
185 .cycleCounterFiltering = 0,
189 .msgBufferInterrupt = TRUE,
190 .payloadPreambleIndicatorTr = FALSE,
191 .rejectNullFrames = FALSE,
192 .rejectStaticSegment = FALSE,
193 .singleTransmit = FALSE,
197 .channel = FR_CHANNEL_AB,
198 .cycleCounterFiltering = 0,
202 .msgBufferInterrupt = TRUE,
203 .payloadPreambleIndicatorTr = FALSE,
204 .rejectNullFrames = FALSE,
205 .rejectStaticSegment = FALSE,
206 .singleTransmit = FALSE,
210 .channel = FR_CHANNEL_AB,
211 .cycleCounterFiltering = 0,
215 .msgBufferInterrupt = TRUE,
216 .payloadPreambleIndicatorTr = FALSE,
217 .rejectNullFrames = FALSE,
218 .rejectStaticSegment = FALSE,
219 .singleTransmit = TRUE,
223 .channel = FR_CHANNEL_AB,
224 .cycleCounterFiltering = 0,
228 .msgBufferInterrupt = TRUE,
229 .payloadPreambleIndicatorTr = FALSE,
230 .rejectNullFrames = FALSE,
231 .rejectStaticSegment = FALSE,
232 .singleTransmit = TRUE,
236 .channel = FR_CHANNEL_AB,
237 .cycleCounterFiltering = 0,
241 .msgBufferInterrupt = TRUE,
242 .payloadPreambleIndicatorTr = TRUE,
243 .rejectNullFrames = FALSE,
244 .rejectStaticSegment = FALSE,
245 .singleTransmit = FALSE,
251 static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
253 .channel = FR_CHANNEL_AB,
254 .cycleCounterFiltering = 0,
258 .msgBufferInterrupt = TRUE,
259 .payloadPreambleIndicatorTr = FALSE,
260 .rejectNullFrames = FALSE,
261 .rejectStaticSegment = FALSE,
262 .singleTransmit = FALSE,
266 .channel = FR_CHANNEL_AB,
267 .cycleCounterFiltering = 0,
271 .msgBufferInterrupt = TRUE,
272 .payloadPreambleIndicatorTr = FALSE,
273 .rejectNullFrames = FALSE,
274 .rejectStaticSegment = FALSE,
275 .singleTransmit = FALSE,
279 .channel = FR_CHANNEL_AB,
280 .cycleCounterFiltering = 0,
284 .msgBufferInterrupt = TRUE,
285 .payloadPreambleIndicatorTr = FALSE,
286 .rejectNullFrames = FALSE,
287 .rejectStaticSegment = FALSE,
288 .singleTransmit = TRUE,
292 .channel = FR_CHANNEL_AB,
293 .cycleCounterFiltering = 0,
297 .msgBufferInterrupt = TRUE,
298 .payloadPreambleIndicatorTr = FALSE,
299 .rejectNullFrames = FALSE,
300 .rejectStaticSegment = FALSE,
301 .singleTransmit = TRUE,
305 .channel = FR_CHANNEL_AB,
306 .cycleCounterFiltering = 0,
310 .msgBufferInterrupt = TRUE,
311 .payloadPreambleIndicatorTr = TRUE,
312 .rejectNullFrames = FALSE,
313 .rejectStaticSegment = FALSE,
314 .singleTransmit = FALSE,
319 static Fr_TMS570LS_BufferConfigType Fr_node_A_dynamic_buffers_config[] = {
321 .channel = FR_CHANNEL_A,
322 .cycleCounterFiltering = 0,
326 .msgBufferInterrupt = TRUE,
327 .payloadPreambleIndicatorTr = FALSE,
328 .rejectNullFrames = FALSE,
329 .rejectStaticSegment = FALSE,
330 .singleTransmit = FALSE,
334 .channel = FR_CHANNEL_B,
335 .cycleCounterFiltering = 0,
339 .msgBufferInterrupt = TRUE,
340 .payloadPreambleIndicatorTr = FALSE,
341 .rejectNullFrames = FALSE,
342 .rejectStaticSegment = FALSE,
343 .singleTransmit = FALSE,
347 .channel = FR_CHANNEL_A,
348 .cycleCounterFiltering = 0,
352 .msgBufferInterrupt = TRUE,
353 .payloadPreambleIndicatorTr = FALSE,
354 .rejectNullFrames = FALSE,
355 .rejectStaticSegment = FALSE,
356 .singleTransmit = TRUE,
362 static Fr_TMS570LS_BufferConfigType Fr_node_B_dynamic_buffers_config[] = {
364 .channel = FR_CHANNEL_B,
365 .cycleCounterFiltering = 0,
369 .msgBufferInterrupt = TRUE,
370 .payloadPreambleIndicatorTr = FALSE,
371 .rejectNullFrames = FALSE,
372 .rejectStaticSegment = FALSE,
373 .singleTransmit = TRUE,
377 .channel = FR_CHANNEL_A,
378 .cycleCounterFiltering = 0,
382 .msgBufferInterrupt = TRUE,
383 .payloadPreambleIndicatorTr = FALSE,
384 .rejectNullFrames = FALSE,
385 .rejectStaticSegment = FALSE,
386 .singleTransmit = TRUE,
390 .channel = FR_CHANNEL_A,
391 .cycleCounterFiltering = 0,
395 .msgBufferInterrupt = TRUE,
396 .payloadPreambleIndicatorTr = FALSE,
397 .rejectNullFrames = FALSE,
398 .rejectStaticSegment = FALSE,
399 .singleTransmit = TRUE,
404 static Fr_TMS570LS_BufferConfigType Fr_node_A_fifo_buffers_config[] = {
406 .channel = FR_CHANNEL_AB,
407 .cycleCounterFiltering = 0,
411 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
412 .payloadPreambleIndicatorTr = FALSE,
413 .rejectNullFrames = TRUE,
414 .rejectStaticSegment = FALSE,
415 .singleTransmit = FALSE,
419 .channel = FR_CHANNEL_AB,
420 .cycleCounterFiltering = 0,
424 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
425 .payloadPreambleIndicatorTr = FALSE,
426 .rejectNullFrames = TRUE,
427 .rejectStaticSegment = FALSE,
428 .singleTransmit = FALSE,
432 .channel = FR_CHANNEL_AB,
433 .cycleCounterFiltering = 0,
437 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
438 .payloadPreambleIndicatorTr = FALSE,
439 .rejectNullFrames = TRUE,
440 .rejectStaticSegment = FALSE,
441 .singleTransmit = FALSE,
445 .channel = FR_CHANNEL_AB,
446 .cycleCounterFiltering = 0,
450 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
451 .payloadPreambleIndicatorTr = FALSE,
452 .rejectNullFrames = TRUE,
453 .rejectStaticSegment = FALSE,
454 .singleTransmit = FALSE,
458 .channel = FR_CHANNEL_AB,
459 .cycleCounterFiltering = 0,
463 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
464 .payloadPreambleIndicatorTr = FALSE,
465 .rejectNullFrames = TRUE,
466 .rejectStaticSegment = FALSE,
467 .singleTransmit = FALSE,
472 static Fr_TMS570LS_BufferConfigType Fr_node_B_fifo_buffers_config[] = {
474 .channel = FR_CHANNEL_AB,
475 .cycleCounterFiltering = 0,
479 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
480 .payloadPreambleIndicatorTr = FALSE,
481 .rejectNullFrames = TRUE,
482 .rejectStaticSegment = FALSE,
483 .singleTransmit = FALSE,
484 .slotId = 0 // No Frame is rejected
487 .channel = FR_CHANNEL_AB,
488 .cycleCounterFiltering = 0,
492 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
493 .payloadPreambleIndicatorTr = FALSE,
494 .rejectNullFrames = TRUE,
495 .rejectStaticSegment = FALSE,
496 .singleTransmit = FALSE,
497 .slotId = 0 // No Frame is rejected
500 .channel = FR_CHANNEL_AB,
501 .cycleCounterFiltering = 0,
505 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
506 .payloadPreambleIndicatorTr = FALSE,
507 .rejectNullFrames = TRUE,
508 .rejectStaticSegment = FALSE,
509 .singleTransmit = FALSE,
510 .slotId = 0 // No Frame is rejected
513 .channel = FR_CHANNEL_AB,
514 .cycleCounterFiltering = 0,
518 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
519 .payloadPreambleIndicatorTr = FALSE,
520 .rejectNullFrames = TRUE,
521 .rejectStaticSegment = FALSE,
522 .singleTransmit = FALSE,
523 .slotId = 0 // No Frame is rejected
526 .channel = FR_CHANNEL_AB,
527 .cycleCounterFiltering = 0,
531 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
532 .payloadPreambleIndicatorTr = FALSE,
533 .rejectNullFrames = TRUE,
534 .rejectStaticSegment = FALSE,
535 .singleTransmit = FALSE,
536 .slotId = 0 // No Frame is rejected
541 * This is an unifying configuration structure for the node A.
542 * It joins all the configuration structure together.
544 static Fr_ConfigType Fr_config_node_A = {
545 .clusterConfiguration = &Fr_cluster_config,
546 .dynamicBufferConfigs = Fr_node_A_dynamic_buffers_config,
547 .fifoBufferConfigs = Fr_node_A_fifo_buffers_config,
548 .msgRAMConfig = &Fr_node_A_msgRAM_config,
549 .nodeConfiguration = &Fr_node_A_config,
550 .staticBufferConfigs = Fr_node_A_static_buffers_config
554 * This is an unifying configuration structure for the node A.
555 * It joins all the configuration structure together.
557 static Fr_ConfigType Fr_config_node_B = {
558 .clusterConfiguration = &Fr_cluster_config,
559 .dynamicBufferConfigs = Fr_node_B_dynamic_buffers_config,
560 .fifoBufferConfigs = Fr_node_B_fifo_buffers_config,
561 .msgRAMConfig = &Fr_node_B_msgRAM_config,
562 .nodeConfiguration = &Fr_node_B_config,
563 .staticBufferConfigs = Fr_node_B_static_buffers_config
566 /* User configuration */
568 static Fr_TMS570LS_ClusterConfigType user_cluster_config;
569 static Fr_TMS570LS_NodeConfigType user_node_config;
570 static Fr_TMS570LS_MsgRAMConfig user_msg_ram_config;
571 static Fr_TMS570LS_BufferConfigType user_static_buffer_config[RPP_FR_MAX_STATIC_BUF_CNT];
572 static Fr_TMS570LS_BufferConfigType user_dynamic_buffer_config[RPP_FR_MAX_DYNAMIC_BUF_CNT];
573 static Fr_TMS570LS_BufferConfigType user_fifo_buffer_config[RPP_FR_MAX_FIFO_BUF_DEPTH];
574 static Fr_ConfigType user_configuration = {
575 .clusterConfiguration = &user_cluster_config,
576 .nodeConfiguration = &user_node_config,
577 .msgRAMConfig = &user_msg_ram_config,
578 .staticBufferConfigs = user_static_buffer_config,
579 .dynamicBufferConfigs = user_dynamic_buffer_config,
580 .fifoBufferConfigs = user_fifo_buffer_config,
584 #define USER_CONFIG_NOT_DONE 0x0
585 #define USER_CONFIG_CLUSTER 0x1
586 #define USER_CONFIG_NODE 0x2
588 static uint8_t user_configuration_state = USER_CONFIG_NOT_DONE;
589 static uint8_t user_static_buffer_configured = 0;
590 static uint8_t user_dynamic_buffer_configured = 0;
591 static uint8_t user_fifo_buffer_depth = 0;
594 * Split string into numbers
596 * The function takes a string with hexadecimal numbers,
597 * separated by spaces, and converts it into an array of numbers.
599 * For example "0x2 0xA 0XDD 0xABCD" -> {0x2, 0xA, 0XDD, 0xABCD}
601 * @param [in] params Address of the string which will be converted
602 * @param [in] params_cnt A number of parameters, which should be found and converted from the string params
603 * @param [out] tmp_params Address, where converted array of numbers will be stored
605 * @return SUCCESS when all parameters were converted to the array of numbers,
606 * FAILURE when the string was too short, too long or some other error occurred.
608 static int8_t cmd_fr_parse_params(const char *params, uint32_t params_cnt, uint32_t *tmp_params)
610 char cpy_params[256];
614 if (params == NULL || tmp_params == NULL)
616 strncpy(cpy_params, params, 256);
617 token = strtok(cpy_params, " ");
620 for (i = 0; i < params_cnt; i++) {
621 if (sscanf(token, "%i", &tmp_params[i]) == EOF) // No number found
623 if ((token = strtok(NULL, " ")) == NULL && i < params_cnt-1) // Not enough parameters in the string
629 int8_t cmd_fr_config_cluster_params(const char *params)
631 uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
633 if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE)
636 user_cluster_config.gColdStartAttempts = tmp_params[0];
637 user_cluster_config.gListenNoise = tmp_params[1];
638 user_cluster_config.gMacroPerCycle = tmp_params[2];
639 user_cluster_config.gMaxWithoutClockCorrectionFatal = tmp_params[3];
640 user_cluster_config.gMaxWithoutClockCorrectionPassive = tmp_params[4];
641 user_cluster_config.gNetworkManagementVectorLength = tmp_params[5];
642 user_cluster_config.gNumberOfMinislots = tmp_params[6];
643 user_cluster_config.gNumberOfStaticSlots = tmp_params[7];
644 user_cluster_config.gOffsetCorrectionStart = tmp_params[8];
645 user_cluster_config.gPayloadLengthStatic = tmp_params[9];
646 user_cluster_config.gSyncNodeMax = tmp_params[10];
647 user_cluster_config.gdActionPointOffset = tmp_params[11];
648 user_cluster_config.gdCASRxLowMax = tmp_params[12];
649 user_cluster_config.gdDynamicSlotIdlePhase = tmp_params[13];
650 user_cluster_config.gdMinislot = tmp_params[14];
651 user_cluster_config.gdMinislotActionPointOffset = tmp_params[15];
652 user_cluster_config.gdNIT = tmp_params[16];
653 user_cluster_config.gdSampleClockPeriod = tmp_params[17];
654 user_cluster_config.gdStaticSlot = tmp_params[18];
655 user_cluster_config.gdTSSTransmitter = tmp_params[19];
656 user_cluster_config.gdWakeupSymbolRxIdle = tmp_params[20];
657 user_cluster_config.gdWakeupSymbolRxLow = tmp_params[21];
658 user_cluster_config.gdWakeupSymbolRxWindow = tmp_params[22];
659 user_cluster_config.gdWakeupSymbolTxIdle = tmp_params[23];
660 user_cluster_config.gdWakeupSymbolTxLow = tmp_params[24];
662 user_configuration_state |= USER_CONFIG_CLUSTER;
666 int8_t cmd_fr_config_node_params(const char *params)
668 uint32_t tmp_params[FR_NODE_PARAMS_CNT+2]; // +2 because two more parameters from message RAM structure are expected in the string.
669 Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
670 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};
672 if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE)
675 user_node_config.pAllowHaltDueToClock = tmp_params[0];
676 user_node_config.pAllowPassiveToActive = tmp_params[1];
677 if (tmp_params[2] > 2) return FAILURE;
678 user_node_config.pChannels = channels[ tmp_params[2] ];
679 user_node_config.pClusterDriftDamping = tmp_params[3];
680 user_node_config.pDelayCompensationA = tmp_params[4];
681 user_node_config.pDelayCompensationB = tmp_params[5];
682 user_node_config.pExternOffsetCorrection = tmp_params[6];
683 user_node_config.pExternRateCorrection = tmp_params[7];
684 user_node_config.pKeySlotUsedForStartup = tmp_params[8];
685 user_node_config.pKeySlotUsedForSync = tmp_params[9];
686 user_node_config.pLatestTx = tmp_params[10];
687 user_node_config.pMacroInitialOffsetA = tmp_params[11];
688 user_node_config.pMacroInitialOffsetB = tmp_params[12];
689 user_node_config.pMicroInitialOffsetA = tmp_params[13];
690 user_node_config.pMicroInitialOffsetB = tmp_params[14];
691 user_node_config.pMicroPerCycle = tmp_params[15];
692 user_node_config.pRateCorrectionOut = tmp_params[16];
693 user_node_config.pOffsetCorrectionOut = tmp_params[17];
694 user_node_config.pSamplesPerMicrotick = tmp_params[18];
695 user_node_config.pSingleSlotEnabled = tmp_params[19];
696 if (tmp_params[20] > 1) return FAILURE;
697 user_node_config.pWakeupChannel = channels[ tmp_params[20] ];
698 user_node_config.pWakeupPattern = tmp_params[21];
699 user_node_config.pdAcceptedStartupRange = tmp_params[22];
700 user_node_config.pdListenTimeout = tmp_params[23];
701 user_node_config.pdMaxDrift = tmp_params[24];
702 user_node_config.pDecodingCorrection = tmp_params[25];
703 user_msg_ram_config.syncFramePayloadMultiplexEnabled = tmp_params[26];
704 if (tmp_params[27] > 3) return FAILURE;
705 user_msg_ram_config.secureBuffers = secure[ tmp_params[27] ];
707 user_configuration_state |= USER_CONFIG_NODE;
711 int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
713 Fr_TMS570LS_BufferConfigType *fifo_buffer_ptr = &user_fifo_buffer_config[0];
715 char channel[3], rej_static_frames[8], rej_null_frames[8];
716 unsigned depth, slot, cycleset, maxpayload, mask;
717 Fr_TMS570LS_BufferConfigType tmp_buffer;
719 if (fr_initialized) {
720 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
721 return -CMDERR_BADCFG;
724 ret = sscanf(param[2], "rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s",
735 printf("Error parsing parameter %d\n", ret+1);
736 return -CMDERR_BADPAR;
739 if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
740 return badpar("Depth too high\n");
741 user_fifo_buffer_depth = depth;
744 return badpar("Invalid slot number\n");
745 tmp_buffer.slotId = slot;
747 return badpar("Invalid mask\n");
748 tmp_buffer.fidMask = mask;
749 if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
750 else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
751 else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
752 else return badpar("Channel parsing error\n");
754 if (cycleset >= 0x80)
755 return badpar("Cycle set must be less than 0x80.\n");
756 tmp_buffer.cycleCounterFiltering = cycleset;
758 if (maxpayload >= 128)
759 return badpar("Maximum payload in half-words must be less than 128\n");
760 tmp_buffer.maxPayload = maxpayload;
762 if (strcmp(rej_null_frames, "rejnull") == 0) tmp_buffer.rejectNullFrames = true;
763 else if (strcmp(rej_null_frames, "accnull") == 0) tmp_buffer.rejectNullFrames = false;
764 else return badpar("Reject/accept NULL frames parsing error\n");
766 if (strcmp(rej_static_frames, "rejstat") == 0)
767 tmp_buffer.rejectStaticSegment = true;
768 else if (strcmp(rej_static_frames, "accstat") == 0)
769 tmp_buffer.rejectStaticSegment = false;
770 else return badpar("Invalid reject/accept static frame parameter");
772 for (i = 0; i < user_fifo_buffer_depth; i++) {
773 fifo_buffer_ptr[i].slotId = tmp_buffer.slotId;
774 fifo_buffer_ptr[i].fidMask = tmp_buffer.fidMask;
775 fifo_buffer_ptr[i].maxPayload = tmp_buffer.maxPayload;
776 fifo_buffer_ptr[i].channel = tmp_buffer.channel;
777 fifo_buffer_ptr[i].cycleCounterFiltering = tmp_buffer.cycleCounterFiltering;
778 fifo_buffer_ptr[i].isTx = FALSE;
779 fifo_buffer_ptr[i].singleTransmit = FALSE;
780 fifo_buffer_ptr[i].payloadPreambleIndicatorTr = FALSE;
781 fifo_buffer_ptr[i].rejectNullFrames = tmp_buffer.rejectNullFrames;
782 fifo_buffer_ptr[i].rejectStaticSegment = tmp_buffer.rejectStaticSegment;
783 fifo_buffer_ptr[i].msgBufferInterrupt = 0;
786 printf("frbtcfgfifo rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s\n",
800 int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
802 Fr_TMS570LS_BufferConfigType *cfg;
805 char buf_type, channel[3],rxtx[3], single_continuous[11];
806 unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
808 if (fr_initialized) {
809 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
810 return -CMDERR_BADCFG;
813 ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
826 printf("Error parsing parameter %d\n", ret+1);
827 return -CMDERR_BADPAR;
833 if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
834 return badpar("Buffer index too high\n");
835 cfg = &user_static_buffer_config[buffer];
838 if (buffer >= RPP_FR_MAX_DYNAMIC_BUF_CNT)
839 return badpar("Buffer index too high\n");
840 cfg = &user_dynamic_buffer_config[buffer];
843 return badpar("Invalid buffer type (S, D)\n");
846 if (slot < 1 || slot > 2047)
847 return badpar("Invalid slot number\n");
850 if (strcmp(channel, "A") == 0) cfg->channel = FR_CHANNEL_A;
851 else if (strcmp(channel, "B") == 0) cfg->channel = FR_CHANNEL_B;
852 else if (strcmp(channel, "AB") == 0) cfg->channel = FR_CHANNEL_AB;
853 else return badpar("Channel parsing error\n");
854 if (buf_type == 'D' && cfg->channel == FR_CHANNEL_AB)
855 return badpar("Dynamic segment buffers cannot have AB channels.\n");
857 if (cycleset >= 0x80)
858 return badpar("Cycle set must be less than 0x80.\n");
859 cfg->cycleCounterFiltering = cycleset;
861 if (strcmp(rxtx, "tx") == 0) cfg->isTx = true;
862 else if (strcmp(rxtx, "rx") == 0) cfg->isTx = false;
863 else return badpar("RX/TX parsing error\n");
865 if (maxpayload >= 128)
866 return badpar("Maximum payload in half-words must be less than 128\n");
867 cfg->maxPayload = maxpayload;
869 if (0 == strcmp(single_continuous, "single") ||
870 0 == strcmp(single_continuous, "s"))
871 cfg->singleTransmit = true;
872 else if (0 == strcmp(single_continuous, "continuous") ||
873 0 == strcmp(single_continuous, "c"))
874 cfg->singleTransmit = false;
875 else return badpar("Invalid single/continuous parameter");
878 return badpar("Payload preamble indicator must be 0 or 1");
879 cfg->payloadPreambleIndicatorTr = preamb;
882 return badpar("Interrupt parameter must be 0 or 1");
883 cfg->msgBufferInterrupt = intr;
887 if (buffer >= user_static_buffer_configured)
888 user_static_buffer_configured = buffer + 1;
891 if (buffer >= user_dynamic_buffer_configured)
892 user_dynamic_buffer_configured = buffer + 1;
896 printf("frbtcfgbuf%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i\n",
915 * @brief Do the user configuration of the FlexRay cluster parameters
917 * @param[in] cmd_io Pointer to IO stack
918 * @param[in] des Pointer to command descriptor
919 * @param[in] param Parameters of command
920 * @return 0 when OK or error code
922 int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
926 if (fr_initialized) {
927 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
928 return -CMDERR_BADCFG;
931 token = strtok(param[1], " ");
932 if (strcmp(token, "cluster") == 0) {
933 if (cmd_fr_config_cluster_params(param[2]) == FAILURE) {
934 rpp_sci_printf("FlexRay cluster configuration not accepted.\n");
935 return -CMDERR_BADPAR;
937 rpp_sci_printf("FlexRay cluster configuration accepted.\n");
939 else if (strcmp(token, "node") == 0) {
940 if (cmd_fr_config_node_params(param[2]) == FAILURE) {
941 rpp_sci_printf("FlexRay node configuration not accepted.\n");
942 return -CMDERR_BADPAR;
944 rpp_sci_printf("FlexRay node configuration accepted.\n");
947 return -CMDERR_BADPAR;
953 * @brief Initialize the device as FlexRay node.
955 * @param[in] cmd_io Pointer to IO stack
956 * @param[in] des Pointer to command descriptor
957 * @param[in] param Parameters of command
958 * @return 0 when OK or error code
960 int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
962 const Fr_ConfigType *Fr_ConfigPtr = NULL;
963 int8_t retVal = SUCCESS;
964 uint32_t error = ERR_PARAM_NO_ERROR;
966 if (*param[1] == 'A')
967 Fr_ConfigPtr = &Fr_config_node_A;
968 else if (*param[1] == 'B')
969 Fr_ConfigPtr = &Fr_config_node_B;
970 else if (*param[1] == 'U') { // Select the user configuration - call config commands first
971 user_msg_ram_config.statSegmentBufferCount = user_static_buffer_configured;
972 user_msg_ram_config.dynSegmentBufferCount = user_dynamic_buffer_configured;
973 user_msg_ram_config.fifoBufferCount = user_fifo_buffer_depth;
974 Fr_ConfigPtr = &user_configuration;
977 return -CMDERR_BADPAR;
979 retVal = rpp_fr_init_driver(Fr_ConfigPtr, &error);
980 if (retVal == SUCCESS) {
981 rpp_sci_printf("FlexRay driver initialized.\r\n");
982 fr_initialized = TRUE;
985 retVal = rpp_fr_init_controller(0, &error);
986 if (retVal == SUCCESS) {
987 rpp_sci_printf("FlexRay controller reinitialized.\r\n");
991 rpp_sci_printf("FlexRay needs to be configured before initialization.\r\n");
992 return -CMDERR_BADCFG;
996 retVal = rpp_fr_init_controller(0, &error);
997 if (retVal == SUCCESS)
998 rpp_sci_printf("FlexRay controller initialized.\r\n");
1000 if (error & FR_INIT_ERR_CLUSTER_CONFIG)
1001 rpp_sci_printf("Cluster configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1002 else if (error & FR_INIT_ERR_NODE_CONFIG)
1003 rpp_sci_printf("Node configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1004 else if (error & FR_INIT_ERR_MSGRAM_CONFIG)
1005 rpp_sci_printf("Message RAM configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1006 else if (error & FR_INIT_ERR_BUFFPARAM_CONFIG)
1007 rpp_sci_printf("Buffer configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1008 else if (error & (uint32_t)FR_INIT_ERR_BUFF_CONFIG)
1009 rpp_sci_printf("Buffer configuration error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
1011 rpp_sci_printf("POC state switching error.\r\n");
1012 return -CMDERR_BADCFG;
1018 * @brief Starts FlexRay communication
1020 * @param[in] cmd_io Pointer to IO stack
1021 * @param[in] des Pointer to command descriptor
1022 * @param[in] param Parameters of command
1023 * @return 0 when OK or error code
1025 int cmd_do_fr_start(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1027 int8_t retVal = SUCCESS;
1028 uint32_t error = ERR_PARAM_NO_ERROR;
1030 retVal = rpp_fr_start_communication(0, &error);
1031 if (retVal == SUCCESS)
1032 rpp_sci_printf("FlexRay communication is running.\r\n");
1034 if (error & FR_STARTUP_ERR_SW_STUP_FOLLOW)
1035 rpp_sci_printf("Can not switch POC to RUN state.\r\n");
1036 else if (error & FR_STARTUP_ERR_CSINH_DIS)
1037 rpp_sci_printf("Cold start inhibit disabled error.\r\n");
1038 else if (error & FR_STARTUP_ERR_SW_STUP_READY)
1039 rpp_sci_printf("Can not switch back to READY from STARTUP.\r\n");
1040 else if (error & FR_STARTUP_ERR_SW_STUP_AS_NCOLD)
1041 rpp_sci_printf("Can not switch to STARTUP as non-coldstarter.\r\n");
1043 rpp_sci_printf("General error.\r\n");
1044 return -CMDERR_BADCFG;
1050 * @brief Invokes POC command ALL_SLOTS
1052 * @param[in] cmd_io Pointer to IO stack
1053 * @param[in] des Pointer to command descriptor
1054 * @param[in] param Parameters of command
1055 * @return 0 when OK or error code
1057 int cmd_do_fr_allslots(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1059 int8_t retVal = ERR_PARAM_NO_ERROR;
1061 retVal = rpp_fr_all_slots(0);
1062 if (retVal == SUCCESS)
1063 rpp_sci_printf("FlexRay node started communication in all slots.\r\n");
1065 rpp_sci_printf("General error.\r\n");
1066 return -CMDERR_BADCFG;
1072 * @brief Halt FlexRay communication
1074 * @param[in] cmd_io Pointer to IO stack
1075 * @param[in] des Pointer to command descriptor
1076 * @param[in] param Parameters of command
1077 * @return 0 when OK or error code
1079 int cmd_do_fr_halt(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1081 int8_t retVal = ERR_PARAM_NO_ERROR;
1083 retVal = rpp_fr_halt_communication(0);
1084 if (retVal == SUCCESS)
1085 rpp_sci_printf("FlexRay node communication halted.\r\n");
1087 rpp_sci_printf("General error.\r\n");
1088 return -CMDERR_BADCFG;
1094 * @brief Abort FlexRay communication
1096 * @param[in] cmd_io Pointer to IO stack
1097 * @param[in] des Pointer to command descriptor
1098 * @param[in] param Parameters of command
1099 * @return 0 when OK or error code
1101 int cmd_do_fr_abort(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1103 int8_t retVal = ERR_PARAM_NO_ERROR;
1105 retVal = rpp_fr_abort_communication(0);
1106 if (retVal == SUCCESS)
1107 rpp_sci_printf("FlexRay node communication aborted.\r\n");
1109 rpp_sci_printf("General error.\r\n");
1110 return -CMDERR_BADCFG;
1116 * @brief Send wake up pattern
1118 * @param[in] cmd_io Pointer to IO stack
1119 * @param[in] des Pointer to command descriptor
1120 * @param[in] param Parameters of command
1121 * @return 0 when OK or error code
1123 int cmd_do_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1125 int8_t retVal = ERR_PARAM_NO_ERROR;
1127 retVal = rpp_fr_send_wup(0);
1128 if (retVal == SUCCESS)
1129 rpp_sci_printf("Wake up pattern has been sent.\r\n");
1131 rpp_sci_printf("General error.\r\n");
1132 return -CMDERR_BADCFG;
1138 * @brief Set channel for wake up pattern sending.
1140 * @param[in] cmd_io Pointer to IO stack
1141 * @param[in] des Pointer to command descriptor
1142 * @param[in] param Parameters of command
1143 * @return 0 when OK or error code
1145 int cmd_do_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1147 int8_t retVal = ERR_PARAM_NO_ERROR;
1148 Fr_ChannelType channel = FR_CHANNEL_A;
1150 if (*param[1] == 'A')
1151 channel = FR_CHANNEL_A;
1152 else if (*param[1] == 'B')
1153 channel = FR_CHANNEL_B;
1155 return -CMDERR_BADPAR;
1156 retVal = rpp_fr_set_wu_channel(0, channel);
1157 if (retVal == SUCCESS)
1158 rpp_sci_printf("Wake up channel has been set.\r\n");
1160 rpp_sci_printf("General error.\r\n");
1161 return -CMDERR_BADCFG;
1167 * @brief Get and print POC status of the FlexRay controller.
1169 * @param[in] cmd_io Pointer to IO stack
1170 * @param[in] des Pointer to command descriptor
1171 * @param[in] param Parameters of command
1172 * @return 0 when OK or error code
1174 int cmd_do_fr_getpocstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1176 int8_t retVal = ERR_PARAM_NO_ERROR;
1177 Fr_POCStatusType status;
1178 char *ErrorModeStrings[] = {"ACTIVE", "HALT", "PASSIVE"};
1179 char *SlotModeStrings[] = {"KEYSLOT", "ALL_PENDING", "ALL"};
1180 char *StartupStateStrings[] = {
1181 "UNDEFINED", "COLDSTART_LISTEN", "COLDSTART_CHECK", "COLDSTART_JOIN",
1182 "COLDSTART_CONSISTENCY_CHECK", "INTEGRATION_LISTEN", "INITIALIZE_SCHEDULE", "INTEGRATION_CONSISTENCY_CHECK",
1183 "COLDSTART_GAP", "EXTERNAL_STARTUP", "ABORT", "COLDSTART_COLLISION_RESOLUTION",
1186 char *StateStrings[] = {
1187 "CONFIG", "DEFAULT_CONFIG", "HALT", "NORMAL_ACTIVE",
1188 "NORMAL_PASSIVE", "READY", "STARTUP", "LOOPBACK",
1191 char *WakeupStatusStrings[] = {
1192 "UNDEFINED", "RECEIVED_HEADER", "RECEIVED_WUP", "COLLISION_HEADER",
1193 "COLLISION_WUP", "COLLISION_UNKNOWN", "TRANSMITTED"
1196 retVal = rpp_fr_get_poc_status(0, &status);
1197 if (retVal == SUCCESS) {
1198 rpp_sci_printf("POC status:\r\n");
1199 rpp_sci_printf("CHIHaltRequest: %s\r\n", (status.CHIHaltRequest == TRUE) ? "TRUE" : "FALSE");
1200 rpp_sci_printf("CHIReadyRequest: %s\r\n", (status.CHIReadyRequest == TRUE) ? "TRUE" : "FALSE");
1201 rpp_sci_printf("ColdstartNoise: %s\r\n", (status.ColdstartNoise == TRUE) ? "TRUE" : "FALSE");
1202 rpp_sci_printf("Freeze: %s\r\n", (status.Freeze == TRUE) ? "TRUE" : "FALSE");
1203 rpp_sci_printf("ErrorMode: %s\r\n", ErrorModeStrings[status.ErrorMode]);
1204 rpp_sci_printf("SlotMode: %s\r\n", SlotModeStrings[status.SlotMode]);
1205 rpp_sci_printf("StartupState: %s\r\n", StartupStateStrings[status.StartupState]);
1206 rpp_sci_printf("State: %s\r\n", StateStrings[status.State]);
1207 rpp_sci_printf("WakeupStatus: %s\r\n", WakeupStatusStrings[status.WakeupStatus]);
1210 rpp_sci_printf("General error.\r\n");
1211 return -CMDERR_BADCFG;
1217 * @brief Send given data through the FlexRay in selected slot.
1219 * @param[in] cmd_io Pointer to IO stack
1220 * @param[in] des Pointer to command descriptor
1221 * @param[in] param Parameters of command
1222 * @return 0 when OK or error code
1224 int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1226 int8_t retVal = ERR_PARAM_NO_ERROR;
1229 int values[MAX_PARAM_VALUES_NUM];
1230 uint8_t data[MAX_PARAM_VALUES_NUM];
1233 if (sscanf(param[1], "%d", &bufferID) != 1)
1234 return -CMDERR_BADPAR;
1235 if (sscanf(param[2], " %2x", &values[0]) != 1)
1236 return -CMDERR_BADPAR;
1237 data[0] = (uint8_t)values[0];
1238 token = strtok(param[2], " ");
1239 token = strtok(NULL, " ");
1241 while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
1242 if (sscanf(token, "%2x", &values[dataLength]) == EOF)
1244 data[dataLength] = (uint8_t)values[dataLength];
1245 token = strtok(NULL, " ");
1249 retVal = rpp_fr_transmit_lpdu(0, bufferID, data, dataLength);
1250 if (retVal == SUCCESS)
1251 rpp_sci_printf("Data were set for transmission.\r\n");
1253 rpp_sci_printf("General error.\r\n");
1254 return -CMDERR_BADCFG;
1260 * @brief Cancel the transmission in the selected slot.
1262 * @param[in] cmd_io Pointer to IO stack
1263 * @param[in] des Pointer to command descriptor
1264 * @param[in] param Parameters of command
1265 * @return 0 when OK or error code
1267 int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1269 int8_t retVal = ERR_PARAM_NO_ERROR;
1272 if (sscanf(param[1], "%d", &bufferID) != 1)
1273 return -CMDERR_BADPAR;
1274 if (param[2] != NULL)
1275 return -CMDERR_BADPAR;
1277 retVal = rpp_fr_cancel_transmit_lpdu(0, bufferID);
1278 if (retVal == SUCCESS)
1279 rpp_sci_printf("Transmission canceled.\r\n");
1281 rpp_sci_printf("General error.\r\n");
1282 return -CMDERR_BADCFG;
1288 * @brief Receive data from selected slot.
1290 * @param[in] cmd_io Pointer to IO stack
1291 * @param[in] des Pointer to command descriptor
1292 * @param[in] param Parameters of command
1293 * @return 0 when OK or error code
1295 int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1297 int8_t retVal = ERR_PARAM_NO_ERROR;
1299 uint8_t data[cPayloadLengthMax];
1300 Fr_RxLPduStatusType status;
1301 uint8_t receivedLength = 0;
1304 if (sscanf(param[1], "%d", &bufferID) != 1)
1305 return -CMDERR_BADPAR;
1306 if (param[2] != NULL)
1307 return -CMDERR_BADPAR;
1309 memset(data, 0, sizeof(data));
1311 retVal = rpp_fr_receive_lpdu(0, bufferID, data, &status, &receivedLength);
1312 if (retVal == SUCCESS) {
1314 case FR_RECEIVED_MORE_DATA_AVAILABLE:
1315 rpp_sci_printf("More messages are still in FIFO:\r\n");
1317 rpp_sci_printf("Received message (%d B):\r\n", receivedLength);
1318 for (i = 0; i < receivedLength; i++) {
1319 rpp_sci_printf(" %02x", data[i]);
1321 rpp_sci_printf("\r\n");
1324 rpp_sci_printf("No message received.\r\n");
1329 rpp_sci_printf("General error.\r\n");
1330 return -CMDERR_BADCFG;
1336 * @brief Returns TX LPdu status.
1338 * @param[in] cmd_io Pointer to IO stack
1339 * @param[in] des Pointer to command descriptor
1340 * @param[in] param Parameters of command
1341 * @return 0 when OK or error code
1343 int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1345 int8_t retVal = ERR_PARAM_NO_ERROR;
1347 Fr_TxLPduStatusType status;
1348 char *statusStrings[] = {"is not", "is"};
1350 if (sscanf(param[1], "%d", &bufferID) != 1)
1351 return -CMDERR_BADPAR;
1352 if (param[2] != NULL)
1353 return -CMDERR_BADPAR;
1355 retVal = rpp_fr_check_tx_lpdu_status(0, bufferID, &status);
1356 if (retVal == SUCCESS)
1357 rpp_sci_printf("Message transmission %s pending.\r\n", statusStrings[status]);
1359 rpp_sci_printf("General error.\r\n");
1360 return -CMDERR_BADCFG;
1366 * @brief Disable buffer.
1368 * @param[in] cmd_io Pointer to IO stack
1369 * @param[in] des Pointer to command descriptor
1370 * @param[in] param Parameters of command
1371 * @return 0 when OK or error code
1373 int cmd_do_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1375 int8_t retVal = ERR_PARAM_NO_ERROR;
1378 if (sscanf(param[1], "%d", &bufferID) != 1)
1379 return -CMDERR_BADPAR;
1380 if (param[2] != NULL)
1381 return -CMDERR_BADPAR;
1383 retVal = rpp_fr_disable_lpdu(0, bufferID);
1384 if (retVal == SUCCESS)
1385 rpp_sci_printf("Buffer disabled.\r\n");
1387 rpp_sci_printf("General error.\r\n");
1388 return -CMDERR_BADCFG;
1394 * @brief Print global time of the FlexRay network.
1396 * @param[in] cmd_io Pointer to IO stack
1397 * @param[in] des Pointer to command descriptor
1398 * @param[in] param Parameters of command
1399 * @return 0 when OK or error code
1401 int cmd_do_fr_getglobaltime(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1403 int8_t retVal = ERR_PARAM_NO_ERROR;
1405 uint16_t macroTick = 0;
1407 retVal = rpp_fr_get_global_time(0, &cycle, ¯oTick);
1408 if (retVal == SUCCESS)
1409 rpp_sci_printf("Cycle number: %d\r\nMacrotick number: %d\r\n", cycle, macroTick);
1411 rpp_sci_printf("General error.\r\n");
1412 return -CMDERR_BADCFG;
1418 * @brief Print network management vector of the FlexRay node.
1420 * @param[in] cmd_io Pointer to IO stack
1421 * @param[in] des Pointer to command descriptor
1422 * @param[in] param Parameters of command
1423 * @return 0 when OK or error code
1425 int cmd_do_fr_getnmvector(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1427 int8_t retVal = ERR_PARAM_NO_ERROR;
1428 uint8_t nmVector[12];
1431 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1432 if (retVal == SUCCESS) {
1433 rpp_sci_printf("Network management vector:");
1434 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1435 rpp_sci_printf(" %x", nmVector[i]);
1437 rpp_sci_printf("\r\n");
1440 rpp_sci_printf("General error.\r\n");
1441 return -CMDERR_BADCFG;
1446 int cmd_do_fr_nmwatch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1448 int8_t retVal = ERR_PARAM_NO_ERROR;
1449 uint8_t nmVector[12];
1452 // Calculate wait time in OS ticks
1453 static const portTickType freq_ticks = 100 /* ms */ / portTICK_RATE_MS;
1454 portTickType last_wake_time = xTaskGetTickCount();
1456 while (cmd_io->getc(cmd_io) < 0) {
1457 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1458 if (retVal == SUCCESS) {
1459 rpp_sci_printf("Network management vector:");
1460 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1461 rpp_sci_printf(" %02x", nmVector[i]);
1463 rpp_sci_printf("\r");
1466 rpp_sci_printf("General error.\r\n");
1467 return -CMDERR_BADCFG;
1469 vTaskDelayUntil(&last_wake_time, freq_ticks);
1471 rpp_sci_printf("\n");
1476 * @brief Print both channels status of the FlexRay node.
1478 * @param[in] cmd_io Pointer to IO stack
1479 * @param[in] des Pointer to command descriptor
1480 * @param[in] param Parameters of command
1481 * @return 0 when OK or error code
1483 int cmd_do_fr_getchannelstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1485 int8_t retVal = ERR_PARAM_NO_ERROR;
1488 char *decodeStrings[] = {
1489 "aggregated channel status vSS!ValidFrame",
1490 "aggregated channel status vSS!SyntaxError",
1491 "aggregated channel status vSS!ContentError",
1492 "aggregated channel status additional communication",
1493 "aggregated channel status vSS!Bviolation",
1494 "aggregated channel status vSS!TxConflict",
1497 "symbol window status data vSS!ValidMTS",
1498 "symbol window status data vSS!SyntaxError",
1499 "symbol window status data vSS!Bviolation",
1500 "symbol window status data vSS!TxConflict",
1501 "NIT status data vSS!SyntaxError",
1502 "NIT status data vSS!Bviolation",
1506 char *channelNames[] = {"A", "B"};
1507 char *boolStrings[] = {"FALSE", "TRUE"};
1508 uint16_t channelStatuses[2];
1510 retVal = rpp_fr_get_channel_status(0, &channelStatuses[0], &channelStatuses[1]);
1511 if (retVal == SUCCESS)
1512 for (channel = 0; channel < 2; channel++) {
1513 rpp_sci_printf("Channel %s status:\r\n", channelNames[channel]);
1514 for (index = 0; index < 16; index++) {
1515 rpp_sci_printf("\t%s: %s\r\n", decodeStrings[index], boolStrings[ (channelStatuses[channel] >> index) & 0x1 ] );
1519 rpp_sci_printf("General error.\r\n");
1520 return -CMDERR_BADCFG;
1526 * @brief Print clock correction of the FlexRay node
1528 * @param[in] cmd_io Pointer to IO stack
1529 * @param[in] des Pointer to command descriptor
1530 * @param[in] param Parameters of command
1531 * @return 0 when OK or error code
1533 int cmd_do_fr_getclockcorrection(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1535 int8_t retVal = ERR_PARAM_NO_ERROR;
1536 int16_t rateCorrection;
1537 int32_t offsetCorrection;
1539 retVal = rpp_fr_get_clock_correction(0, &rateCorrection, &offsetCorrection);
1540 if (retVal == SUCCESS)
1541 rpp_sci_printf("Rate correction: %d\r\nOffset correction: %d\r\n", rateCorrection, offsetCorrection);
1543 rpp_sci_printf("General error.\r\n");
1544 return -CMDERR_BADCFG;
1550 * @brief Print list of syncframec transmitted on both channels via the even and odd cycle.
1552 * @param[in] cmd_io Pointer to IO stack
1553 * @param[in] des Pointer to command descriptor
1554 * @param[in] param Parameters of command
1555 * @return 0 when OK or error code
1557 int cmd_do_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1559 int8_t retVal = ERR_PARAM_NO_ERROR;
1560 uint16_t channelAEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1561 uint16_t channelBEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1562 uint16_t channelAOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1563 uint16_t channelBOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1564 uint32_t listSize = 0;
1567 if (sscanf(param[1], "%d", &listSize) != 1)
1568 return -CMDERR_BADPAR;
1569 if (param[2] != NULL)
1570 return -CMDERR_BADPAR;
1571 if (listSize > FR_MAX_SYNC_FRAME_LIST_SIZE)
1572 return -CMDERR_BADPAR;
1574 retVal = rpp_fr_get_sync_frame_list(0, listSize, channelAEvenList, channelBEvenList, channelAOddList, channelBOddList);
1575 if (retVal == SUCCESS) {
1576 rpp_sci_printf("| Channel A even | channel B even | channel A odd | channel B odd |\r\n");
1577 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1578 for (i = 0; i < listSize; i++) {
1579 rpp_sci_printf("| %-14x | %-14x | %-14x | %-14x |\r\n", channelAEvenList[i], channelBEvenList[i], channelAOddList[i], channelBOddList[i]);
1581 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1585 rpp_sci_printf("General error.\r\n");
1586 return -CMDERR_BADCFG;
1592 * @brief Print status of wakeup on each channels (wakeup received on channel or not yet received).
1594 * @param[in] cmd_io Pointer to IO stack
1595 * @param[in] des Pointer to command descriptor
1596 * @param[in] param Parameters of command
1597 * @return 0 when OK or error code
1599 int cmd_do_fr_getwakeuprxstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1601 int8_t retVal = ERR_PARAM_NO_ERROR;
1603 char *statusStrings[] = {"was not yet", "was"};
1604 char *channelNames[] = {"A", "B"};
1607 retVal = rpp_fr_get_wakeup_rx_status(0, &status);
1608 if (retVal == SUCCESS)
1609 for (i = 0; i < 2; i++) {
1610 rpp_sci_printf("Wake up pattern %s received on channel %s.\r\n", statusStrings[(status >> i) & 0x1], channelNames[i]);
1613 rpp_sci_printf("General error.\r\n");
1614 return -CMDERR_BADCFG;
1620 * @brief Set and start absolute timer.
1622 * @param[in] cmd_io Pointer to IO stack
1623 * @param[in] des Pointer to command descriptor
1624 * @param[in] param Parameters of command
1625 * @return 0 when OK or error code
1627 int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1629 int8_t retVal = ERR_PARAM_NO_ERROR;
1634 if (sscanf(param[1], "%i %i %i", &timer, &cycle, &offset) != 3)
1635 return -CMDERR_BADPAR;
1637 retVal = rpp_fr_set_timer(0, timer, cycle, offset);
1638 if (retVal == SUCCESS) {
1640 while (i && (cycle & i) == 0)
1645 rpp_sci_printf("Timer was set for every %d-th cycle, offset %d, macrotick %d\n",
1646 i, cycle & ~i, offset);
1649 rpp_sci_printf("General error.\r\n");
1650 return -CMDERR_BADCFG;
1656 * @brief Cancel selected timer
1658 * @param[in] cmd_io Pointer to IO stack
1659 * @param[in] des Pointer to command descriptor
1660 * @param[in] param Parameters of command
1661 * @return 0 when OK or error code
1663 int cmd_do_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1665 int8_t retVal = ERR_PARAM_NO_ERROR;
1668 if (sscanf(param[1], "%d", &timer) != 1)
1669 return -CMDERR_BADPAR;
1671 if (param[2] != NULL)
1672 return -CMDERR_BADPAR;
1674 retVal = rpp_fr_cancel_timer(0, timer);
1675 if (retVal == SUCCESS)
1676 rpp_sci_printf("Timer was canceled.\r\n");
1678 rpp_sci_printf("General error.\r\n");
1679 return -CMDERR_BADCFG;
1685 * @brief Enable/disable, acknowledge, get timer IRQ
1687 * @param[in] cmd_io Pointer to IO stack
1688 * @param[in] des Pointer to command descriptor
1689 * @param[in] param Parameters of command
1690 * @return 0 when OK or error code
1692 int cmd_do_fr_timerirq(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1694 int8_t retVal = ERR_PARAM_NO_ERROR;
1697 boolean_t status = FALSE;
1698 char *boolStrings[] = {"FALSE", "TRUE"};
1701 if (sscanf(param[1], "%d", &timer) != 1)
1702 return -CMDERR_BADPAR;
1704 if (param[2] == NULL) { // Get timer IRQ
1705 retVal = rpp_fr_get_timer_irq_status(0, timer, &status);
1706 if (retVal == SUCCESS)
1707 rpp_sci_printf("IRQ = %s\r\n", boolStrings[status]);
1709 rpp_sci_printf("General error.\r\n");
1710 return -CMDERR_BADCFG;
1713 else { // Some set action
1714 if (sscanf(param[2], "%4s", str) != 1)
1715 return -CMDERR_BADPAR;
1716 if (strcmp(str, "EN") == 0) // Enable IRQ
1717 retVal = SUCCESS; // No interrupts imlemented
1718 else if (strcmp(str, "DIS") == 0) // Disable IRQ
1719 retVal = SUCCESS; // No interrupts implemented
1720 else if (strcmp(str, "ACK") == 0) // Clear IRQ
1721 retVal = rpp_fr_clear_timer_irq(0, timer);
1722 else // Bad argument
1723 return -CMDERR_BADPAR;
1725 if (retVal == SUCCESS)
1726 rpp_sci_printf("OK\r\n");
1728 rpp_sci_printf("General error.\r\n");
1729 return -CMDERR_BADCFG;
1736 * @brief Print FlexRay driver version info.
1738 * @param[in] cmd_io Pointer to IO stack
1739 * @param[in] des Pointer to command descriptor
1740 * @param[in] param Parameters of command
1741 * @return 0 when OK or error code
1743 int cmd_do_fr_getversioninfo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1745 Std_VersionInfoType versionInfo;
1747 rpp_fr_get_driver_version(&versionInfo);
1748 rpp_sci_printf("vendorID: %#x\r\n", versionInfo.vendorID);
1749 rpp_sci_printf("moduleID: %#x\r\n", versionInfo.moduleID);
1750 rpp_sci_printf("sw_major_version: %#x\r\n", versionInfo.sw_major_version);
1751 rpp_sci_printf("sw_minor_version: %#x\r\n", versionInfo.sw_minor_version);
1752 rpp_sci_printf("sw_patch_version: %#x\r\n", versionInfo.sw_patch_version);
1758 * @brief Print value of FlexRay configuratoin parameter.
1760 * @param[in] cmd_io Pointer to IO stack
1761 * @param[in] des Pointer to command descriptor
1762 * @param[in] param Parameters of command
1763 * @return 0 when OK or error code
1765 int cmd_do_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1767 int8_t retVal = ERR_PARAM_NO_ERROR;
1771 if (sscanf(param[1], "%d", &index) != 1)
1772 return -CMDERR_BADPAR;
1774 if (param[2] != NULL)
1775 return -CMDERR_BADPAR;
1777 retVal = rpp_fr_read_com_ctrl_config(0, index, &value);
1778 if (retVal == SUCCESS)
1779 rpp_sci_printf("Value = %#x\r\n", value);
1781 rpp_sci_printf("General error.\r\n");
1782 return -CMDERR_BADCFG;
1788 * @brief Reconfigure buffer
1790 * @param[in] cmd_io Pointer to IO stack
1791 * @param[in] des Pointer to command descriptor
1792 * @param[in] param Parameters of command
1793 * @return 0 when OK or error code
1795 int cmd_do_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1799 unsigned bufferID, slot, maxpayload, cycleset, cycleoffset;
1800 Fr_TMS570LS_BufferConfigType tmp_buffer;
1804 ret = sscanf(param[2], "id%i slot%i %2s cycset%i cycoffset%i max%i",
1813 printf("Error parsing parameter %d\n", ret+1);
1814 return -CMDERR_BADPAR;
1817 if (slot > 2047 || bufferID > FR_MAX_BUFFERS_CNT)
1818 return badpar("Invalid slot number\n");
1819 tmp_buffer.slotId = slot;
1820 if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
1821 else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
1822 else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
1823 else return badpar("Channel parsing error\n");
1824 if (cycleset == 0) cycleset = 1;
1825 for (pow2 = 1, is_pow2 = FALSE; pow2 < 128; pow2 *= 2) {
1826 if (cycleset == pow2) {
1832 return badpar("Cycle set must be one of 0, 1, 2, 4, 8, 16, 32, 64.\n");
1833 if (cycleoffset >= cycleset)
1834 return badpar("Cycle offset must in range 0 - cycset-1.\n");
1836 if (maxpayload >= 256)
1837 return badpar("Maximum payload in bytes must be less than 256\n");
1838 tmp_buffer.maxPayload = maxpayload;
1840 if (rpp_fr_reconfigure_lpdu(0, bufferID, tmp_buffer.slotId, tmp_buffer.channel, cycleset, cycleoffset, tmp_buffer.maxPayload, 0) == SUCCESS) {
1841 printf("id%i slot%i %2s cycset%i cycoffset%i max%i\n",
1852 printf("Reconfiguration failed.\n");
1853 return -CMDERR_BADPAR;
1858 /** Command descriptor for FlexRay user config cluster command */
1859 cmd_des_t const cmd_des_fr_user_config = {
1861 "frbtconfig*","Set the user configuration parameters",
1862 "### Command syntax ###\n"
1864 " frbtconfig<TYPE> <PARAMS>\n"
1867 "- `<TYPE>` is a string specifying the type of parameters to be set. It can be: \"cluster\" or \"node\"\n"
1868 "- `<PARAMS>` is a sequence of numbers separated by spaces. Each number stands for one parameter.\n"
1870 "### Description ###\n"
1872 "The command takes the configuration parameters in the form of a string\n"
1873 "and sets the appropriate type of the FlexRay parameters. It is\n"
1874 "necessary to configure parameters of at least cluster, and node and\n"
1875 "one static buffer (see frbtcfgbuf command). The parameters set by this\n"
1876 "command are applied by the frbtinitU command. Once frbtinit is called,\n"
1877 "it is no longer possible to change the parameters.\n"
1879 "The type of the parameters can be selected by the `<TYPE>` selector.\n"
1881 "Type \"cluster\" sets global FlexRay network parameters. It expects a\n"
1882 "sequence of 25 parameters in this order:\n"
1884 "- 1) gColdStartAttempts\n"
1885 "- 2) gListenNoise\n"
1886 "- 3) gMacroPerCycle\n"
1887 "- 4) gMaxWithoutClockCorrectionFatal\n"
1888 "- 5) gMaxWithoutClockCorrectionPassive\n"
1889 "- 6) gNetworkManagementVectorLength\n"
1890 "- 7) gNumberOfMinislots\n"
1891 "- 8) gNumberOfStaticSlots\n"
1892 "- 9) gOffsetCorrectionStart\n"
1893 "- 10) gPayloadLengthStatic\n"
1894 "- 11) gSyncNodeMax\n"
1895 "- 12) gdActionPointOffset\n"
1896 "- 13) gdCASRxLowMax\n"
1897 "- 14) gdDynamicSlotIdlePhase\n"
1898 "- 15) gdMinislot\n"
1899 "- 16) gdMinislotActionPointOffset\n"
1901 "- 18) gdSampleClockPeriod\n"
1902 "- 19) gdStaticSlot\n"
1903 "- 20) gdTSSTransmitter\n"
1904 "- 21) gdWakeupSymbolRxIdle\n"
1905 "- 22) gdWakeupSymbolRxLow\n"
1906 "- 23) gdWakeupSymbolRxWindow\n"
1907 "- 24) gdWakeupSymbolTxIdle\n"
1908 "- 25) gdWakeupSymbolTxLow\n"
1910 "Type \"node\" sets local FlexRay network parameters. It expects a\n"
1911 "sequence of 28 parameters in this order:\n"
1913 "- 1) pAllowHaltDueToClock\n"
1914 "- 2) pAllowPassiveToActive\n"
1915 "- 3) pChannels (0 - A, 1 - B, 2 - AB)\n"
1916 "- 4) pClusterDriftDamping\n"
1917 "- 5) pDelayCompensationA\n"
1918 "- 6) pDelayCompensationB\n"
1919 "- 7) pExternOffsetCorrection\n"
1920 "- 8) pExternRateCorrection\n"
1921 "- 9) pKeySlotUsedForStartup\n"
1922 "- 10) pKeySlotUsedForSync\n"
1924 "- 12) pMacroInitialOffsetA\n"
1925 "- 13) pMacroInitialOffsetB\n"
1926 "- 14) pMicroInitialOffsetA\n"
1927 "- 15) pMicroInitialOffsetB\n"
1928 "- 16) pMicroPerCycle\n"
1929 "- 17) pRateCorrectionOut\n"
1930 "- 18) pOffsetCorrectionOut\n"
1931 "- 19) pSamplesPerMicrotick\n"
1932 "- 20) pSingleSlotEnabled\n"
1933 "- 21) pWakeupChannel (0 - A, 1 - B)\n"
1934 "- 22) pWakeupPattern\n"
1935 "- 23) pdAcceptedStartupRange\n"
1936 "- 24) pdListenTimeout\n"
1937 "- 25) pdMaxDrift\n"
1938 "- 26) pDecodingCorrection\n"
1939 "- 27) syncFramePayloadMultiplexEnabled\n"
1940 "- 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"
1944 " --> 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"
1945 " FlexRay cluster configuration accepted.\n"
1946 " --> 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"
1947 " FlexRay node configuration accepted.\n",
1948 CMD_HANDLER(cmd_do_fr_user_config), (void *)&cmd_list_fr_basic_test
1951 cmd_des_t const cmd_des_fr_config_buffer = {
1953 "frbtcfgbuf?*","Configure a message buffer in the user configuration",
1954 "### Command syntax ###\n"
1956 " frbtcfgbuf<TYPE><BUFID> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\n"
1959 "- `<TYPE>` is 'S' for static segment buffers and 'D' for dynamic segment buffers,\n"
1960 "- `<BUFID>` is the number of the buffer. Both static and dynamic buffers are numbered independently starting from zero,\n"
1961 "- `<SLOT>` is the number of the slot,\n"
1962 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1963 "- `<CYC>` is the cycle set when to send the buffer,\n"
1964 "- `<RXTX>` is either string \"rx\" or \"tx\",\n"
1965 "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1966 "- `<REP>` is a string \"s\" or \"single\" for single transmission or \"c\" or \"continuous\" for continuous transmission,\n"
1967 "- `<PPI>` is 0 or 1 determining whether the payload preamble indicator is set,\n"
1968 "- `<INT>` is 0 or 1 and is currently ignored.\n"
1970 "### Description ###\n"
1972 "The command sets the configuration parameters for static or dynamic\n"
1973 "buffers in user configuration. The parameters set by this command are\n"
1974 "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1975 "longer possible to change the parameters.\n"
1979 " --> frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1980 " frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1981 " --> frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1982 " frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1983 " --> frbtcfgbufD0 slot9 A cyc0 rx max0x40 single ppi0 int0\n"
1984 " frbtcfgbufD0 slot9 A cyc0 rx max64 single ppi0 int0\n"
1985 " --> frbtcfgbufD1 slot10 A cyc0 tx max0x40 single ppi0 int0\n"
1986 " frbtcfgbufD1 slot10 A cyc0 tx max64 single ppi0 int0\n",
1987 CMD_HANDLER(cmd_do_fr_config_bufer), (void *)&cmd_list_fr_basic_test
1990 cmd_des_t const cmd_des_fr_config_fifo = {
1992 "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
1993 "### Command syntax ###\n"
1995 " frbtcfgfifo rejslot<SLOT> slotmask<MASK> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT>\n"
1997 "- `<SLOT>` is the number of the slot that will be rejected. If it is 0, no slot will be rejected,\n"
1998 "- `<MASK>` is a number specifying which bits of the `<SLOT>` will be ignored,"
1999 "- `<DEPTH>` is a number specifying the depth of the FIFO,\n"
2000 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
2001 "- `<CYC>` is the cycle set when to send the buffer,\n"
2002 "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
2003 "- `<REJNULL>` is a string \"rejnull\" for rejecting NULL frames or \"accnull\" for accepting NULL frames,\n"
2004 "- `<REJSTAT>` is a string \"rejstat\" for rejecting frames in static segment or \"accstat\" for accepting frames from static segment,\n"
2006 "### Description ###\n"
2008 "The command sets the configuration parameters for RX FIFO buffer\n"
2009 "in user configuration. The parameters set by this command are\n"
2010 "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
2011 "longer possible to change the parameters.\n"
2012 "Those messages, which are not accepted by any other buffer and pass the\n"
2013 "FIFO rejection filter will be stored in the RX FIFO buffer.\n"
2017 " --> frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n"
2018 " frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n",
2019 CMD_HANDLER(cmd_do_fr_config_fifo), (void *)&cmd_list_fr_basic_test
2022 /** Command descriptor for FlexRay init command */
2023 cmd_des_t const cmd_des_fr_init = {
2025 "frbtinit?","Initialize a FlexRay node",
2026 "### Command syntax ###\n"
2030 "where `<CFG>` identifies the configuration to use. It can be one of A, B\n"
2031 "or U. The A and B are predefined configurations. If U is specified,\n"
2032 "the user configuration previously set by frbtconfig command is used.\n"
2034 "### Description ###\n"
2036 "The command stands for Fr_Init and Fr_ControllerInit functions from\n"
2037 "the Autosar specification. It initializes the internal data structures\n"
2038 "of the driver and then, based on those data, the controller\n"
2039 "configuration is done. During the controller configuration the\n"
2040 "parameters of the cluster, node, message RAM and buffers are checked.\n"
2041 "If anything goes bad, the command returns an error number, which can\n"
2042 "be decoded by macros defined in driver header file fr_tms570.h with\n"
2043 "prefix ERR_PARAM. If all parameters are OK, all necessary registers of\n"
2044 "the controller are initialized according to the specified\n"
2045 "configuration parameters. At the end of the command, the FlexRay\n"
2046 "controller is switched into READY state and all buffers are configured\n"
2047 "to send NULL frames. This command should be called as the very first\n"
2048 "command, when trying to communicate over the FlexRay bus.\n"
2053 " FlexRay driver initialized.\n"
2054 " FlexRay controller initialized.\n",
2055 CMD_HANDLER(cmd_do_fr_init), (void *)&cmd_list_fr_basic_test
2058 /** Command descriptor for FlexRay controller init command */
2059 cmd_des_t const cmd_des_fr_start = {
2061 "frbtstart","Start a new FlexRay network or join to the existing one",
2062 "### Command syntax ###\n"
2066 "### Description ###\n"
2068 "The command stands for Fr_StartCommunication function from the Autosar\n"
2070 "If the FlexRay node is configured as a coldstarter node\n"
2071 "(as for example by frbtinitA/B command), then the command first listen\n"
2072 "on the bus. When it does not detect any existing bus communication, it\n"
2073 "tries to initiate a new network. If the initiation fails, the FlexRay\n"
2074 "controller is switched back to the ready state for another attempt\n"
2075 "(calling frbtstart again). If the FlexRay node is configured as\n"
2076 "non-coldstarter, it is listening on the bus until some existing\n"
2077 "communication is detected.\n"
2079 "The command should be called after the frbtinit command.\n"
2081 "You may also want to call frbtallslots command to allow the communication\n"
2082 "for all other slots besides the key slots.\n"
2087 " FlexRay communication is running.\n",
2088 CMD_HANDLER(cmd_do_fr_start), (void *)&cmd_list_fr_basic_test
2091 /** Command descriptor for FlexRay controller all slots command */
2092 cmd_des_t const cmd_des_fr_allslots = {
2094 "frbtallslots","Enables communication for all frames",
2095 "### Command syntax ###\n"
2099 "### Description ###\n"
2101 "The command stands for Fr_AllSlots function from the Autosar\n"
2104 "The node can be configured to communicate only on key frames by\n"
2105 "default (as in the case of frbtinitA/B). This command can be used to\n"
2106 "allow the communication on all configured frames. The command invokes\n"
2107 "the FlexRay POC command ALL_SLOTS which enables the communication on\n"
2108 "all frames. The command can be called after the controller\n"
2113 " --> frbtallslots\n"
2114 " FlexRay node started communication on all slots.\n",
2115 CMD_HANDLER(cmd_do_fr_allslots), (void *)&cmd_list_fr_basic_test
2118 /** Command descriptor for FlexRay controller halt command */
2119 cmd_des_t const cmd_des_fr_halt = {
2121 "frbthalt","Halt FlexRay communication after the end of the actual communication cycle",
2122 "### Command syntax ###\n"
2126 "### Description ###\n"
2128 "The command stands for Fr_HaltCommunication function from the Autosar\n"
2129 "specification. The command invokes the FlexRay POC command HALT, which\n"
2130 "means that communication is stopped after the end of the actual\n"
2131 "communication cycle. On the opposite side, there is a frbtfreeze\n"
2132 "command, which stops the communication immediately. To restart the\n"
2133 "communication, the frbtinit and frbtstart commands have to be called.\n"
2138 " FlexRay node communication halted.\n",
2139 CMD_HANDLER(cmd_do_fr_halt), (void *)&cmd_list_fr_basic_test
2142 /** Command descriptor for FlexRay controller abort command */
2143 cmd_des_t const cmd_des_fr_abort = {
2145 "frbtabort","Abort FlexRay communication immediately",
2146 "### Command syntax ###\n"
2150 "### Description ###\n"
2152 "The command stands for Fr_AbortCommunication function from the Autosar\n"
2153 "specification. The command invokes the FlexRay POC command FREEZE,\n"
2154 "which means that the communication is stopped immediately. On the\n"
2155 "opposite side there is a frbthalt command, which stops the\n"
2156 "communication after the end of the actual communication cycle. To\n"
2157 "restart the communication, the frbtinit and frbtstart commands have\n"
2163 " FlexRay node communication aborted.\n",
2164 CMD_HANDLER(cmd_do_fr_abort), (void *)&cmd_list_fr_basic_test
2167 /** Command descriptor for FlexRay controller send wake up pattern command */
2168 cmd_des_t const cmd_des_fr_sendwup = {
2170 "frbtwup","Initiate the wake up procedure",
2171 "### Command syntax ###\n"
2175 "### Description ###\n"
2177 "The command stands for Fr_SendWUP function from the Autosar\n"
2178 "specification. It initiates the wake up procedure by switching FlexRay\n"
2179 "controller state machine to WAKEUP state.\n"
2184 " Wake up pattern has been sent.\n",
2185 CMD_HANDLER(cmd_do_fr_sendwup), (void *)&cmd_list_fr_basic_test
2188 /** Command descriptor for FlexRay controller sent wake up pattern channel command */
2189 cmd_des_t const cmd_des_fr_setwuchannel = {
2191 "frbtsetwuch?","Set wake up channel",
2192 "### Command syntax ###\n"
2194 " frbtsetwuch<CHANNEL>\n"
2196 "where `<CHANNEL>` is a character A or B, specifying the channel.\n"
2198 "### Description ###\n"
2200 "The command stands for Fr_SetWakeupChannel function from the Autosar\n"
2201 "specification. Wake up channel is the channel, where Wake Up Pattern\n"
2202 "is sent. The channel can be set after the driver and controller are\n"
2203 "initialized and before the communication is running. The actual\n"
2204 "wake-up pattern is sent by the frbtwup command.\n"
2208 " --> frbtsetwuchA\n"
2209 " Wake up channel has been set.\n",
2210 CMD_HANDLER(cmd_do_fr_setwuchannel), (void *)&cmd_list_fr_basic_test
2213 /** Command descriptor for FlexRay controller get POC status command */
2214 cmd_des_t const cmd_des_fr_getpocstatus = {
2216 "frbtgetpocst","Print FlexRay POC status",
2217 "### Command syntax ###\n"
2221 "### Description ###\n"
2223 "The command stands for Fr_GetPOCStatus function from the Autosar\n"
2224 "specification. It prints the main FlexRay POC status values in the\n"
2225 "form of a table. The command should be called after the frbtinit\n"
2230 " --> frbtgetpocst\n"
2232 " CHIHaltRequest: FALSE\n"
2233 " CHIReadyRequest: FALSE\n"
2234 " ColdstartNoise: FALSE\n"
2236 " ErrorMode: ACTIVE\n"
2238 " StartupState: UNDEFINED\n"
2240 " WakeupStatus: UNDEFINED\n",
2241 CMD_HANDLER(cmd_do_fr_getpocstatus), (void *)&cmd_list_fr_basic_test
2244 /** Command descriptor for FlexRay transmit tx lpdu command */
2245 cmd_des_t const cmd_des_fr_transmittxlpdu = {
2247 "frbttransmit*","Transmit data from the selected frame buffer",
2248 "### Command syntax ###\n"
2250 " frbttransmit<BUFID> <DATA>\n"
2253 "- `<BUFID>` is a decimal number specifying the ID of the frame\n"
2254 " buffer configured for data transmission\n"
2255 "- `<DATA>` is a sequence of hexadecimal numbers separated by spaces.\n"
2256 " Each number represents one byte of the message.\n"
2258 "### Description ###\n"
2260 "The command stands for Fr_TransmitTxLPdu function from the Autosar\n"
2261 "specification. The command copies the given data into the buffers data\n"
2262 "section in the message RAM. Transmit request is set after the data are\n"
2263 "copied, so transmission starts at the next occurrence of the frame in the\n"
2264 "communication cycle.\n"
2268 " --> frbttransmit1 12 34 56 AA BB CC\n"
2269 " Data were set for transmission.\n",
2270 CMD_HANDLER(cmd_do_fr_transmittxlpdu), (void *)&cmd_list_fr_basic_test
2273 /** Command descriptor for FlexRay cancel tx lpdu command */
2274 cmd_des_t const cmd_des_fr_canceltxlpdu = {
2276 "frbtcanceltx*","Stop the transmission from the frame buffer",
2277 "### Command syntax ###\n"
2279 " frbtcanceltx<BUFID>\n"
2281 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2284 "### Description ###\n"
2286 "The command stands for Fr_CancelTxLPdu function from the Autosar\n"
2287 "specification. The command reconfigures the selected buffer to stop\n"
2288 "data transmission. The command finishes successfully only if the\n"
2289 "reconfiguration is allowed in message RAM configuration (secureBuffers\n"
2290 "configuration parameter). Only TX buffers and buffers not used for startup\n"
2291 "frames can be canceled.\n"
2295 " --> frbtcanceltx3\n"
2296 " Transmission canceled.\n",
2297 CMD_HANDLER(cmd_do_fr_canceltxlpdu), (void *)&cmd_list_fr_basic_test
2300 /** Command descriptor for FlexRay receive rx lpdu command */
2301 cmd_des_t const cmd_des_fr_receiverxlpdu = {
2303 "frbtreceive*","Receive a new message",
2304 "### Command syntax ###\n"
2306 " frbtreceive<BUFID>\n"
2308 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2311 "### Description ###\n"
2313 "The command stands for Fr_ReceiveRxLPdu function from the Autosar\n"
2314 "specification. The command tries to read a new message from the selected\n"
2315 "buffer. If new message is available, it is copied out of the buffer and\n"
2316 "printed. If no message is available, \"No message received\" is printed.\n"
2317 "If a new message was retrieved from a FIFO buffer and more messages are\n"
2318 "available in it, \"More messages are still in FIFO\" is printed.\n"
2322 " --> frbtreceive0\n"
2323 " More messages are still in FIFO:\n"
2324 " Received message (32 B):\n"
2325 " ee ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n"
2326 " 00 00 00 00 00 00 00 00 00\n",
2327 CMD_HANDLER(cmd_do_fr_receiverxlpdu), (void *)&cmd_list_fr_basic_test
2330 /** Command descriptor for FlexRay check TX LPdu status command */
2331 cmd_des_t const cmd_des_fr_checktxlpdustatus = {
2333 "frbtchecktx*","Print the status of the transmit buffer",
2334 "### Command syntax ###\n"
2336 " frbtchecktx<BUFID>\n"
2338 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2341 "### Description ###\n"
2343 "The command stands for Fr_CheckTxLPduStatus function from the Autosar\n"
2344 "specification. The command reads and prints status of the selected frame buffer.\n"
2345 "The buffer can be in one of the two states:\n"
2347 "- Message transmission is pending, which means that the buffer has not yet sent its\n"
2348 " message in single shot mode or that it is in continuous mode.\n"
2349 "- No message transmission is pending, which means that the buffer is in single shot\n"
2350 " mode and the message has already been sent.\n"
2354 " --> frbtchecktx1\n"
2355 " Message transmission is not pending.\n",
2356 CMD_HANDLER(cmd_do_fr_checktxlpdustatus), (void *)&cmd_list_fr_basic_test
2359 /** Command descriptor for FlexRay disable LPdu command */
2360 cmd_des_t const cmd_des_fr_disablelpdu = {
2362 "frbtdisable*","Disable the buffers assigned to the frame",
2363 "### Command syntax ###\n"
2365 " frbtdisable<BUFID>\n"
2367 "where `<BUFID>` is a decimal number specifying the ID of a frame buffer.\n"
2368 "The buffer configured will be disabled.\n"
2370 "### Description ###\n"
2372 "The command stands for Fr_DisableLPdu function from the Autosar\n"
2373 "specification. The command disables the selected buffer. This means\n"
2374 "that this buffer will be unavailable for the communication until\n"
2375 "their reconfiguration (which is not yet implemented). Buffers used\n"
2376 "for startup frames and FIFO RX buffers cannot be disabled.\n"
2380 " --> frbtdisable3\n"
2381 " Buffer disabled.\n",
2382 CMD_HANDLER(cmd_do_fr_disablelpdu), (void *)&cmd_list_fr_basic_test
2385 /** Command descriptor for FlexRay get global time command */
2386 cmd_des_t const cmd_des_fr_getglobaltime = {
2388 "frbtglobtime","Print actual global time of the network",
2389 "### Command syntax ###\n"
2393 "### Description ###\n"
2395 "The command stands for Fr_GetGlobalTime function from the Autosar\n"
2396 "specification. The command prints the time as a number of the current\n"
2397 "cycle and the offset in the cycle in macroticks.\n"
2401 " --> frbtglobtime\n"
2402 " Cycle number: 23\n"
2403 " Macrotick number: 6\n",
2404 CMD_HANDLER(cmd_do_fr_getglobaltime), (void *)&cmd_list_fr_basic_test
2407 /** Command descriptor for FlexRay get network management vector command */
2408 cmd_des_t const cmd_des_fr_getnmvector = {
2410 "frbtnmvector","Print network management vector of the node",
2411 "### Command syntax ###\n"
2415 "### Description ###\n"
2417 "The command stands for Fr_GetNmVector function from the Autosar\n"
2418 "specification. It prints the values of the network management vector\n"
2419 "as hexadecimal numbers.\n"
2423 " --> frbtnmvector\n"
2424 " Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2425 CMD_HANDLER(cmd_do_fr_getnmvector), (void *)&cmd_list_fr_basic_test
2428 /** Command descriptor for FlexRay get network management vector command */
2429 cmd_des_t const cmd_des_fr_nmwatch = {
2431 "frbtnmwatch","Watch the changes of the network managment vector in real-time",
2432 "### Command syntax ###\n"
2436 "### Description ###\n"
2438 "Reads the network management vector every 100 ms and prints it out.\n"
2442 " --> frbtnmwatch\n"
2443 " Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2444 CMD_HANDLER(cmd_do_fr_nmwatch), (void *)&cmd_list_fr_basic_test
2447 /** Command descriptor for FlexRay get channel status command */
2448 cmd_des_t const cmd_des_fr_getchannelstatus = {
2450 "frbtchstat","Print channel A and B status",
2451 "### Command syntax ###\n"
2455 "### Description ###\n"
2457 "The command stands for Fr_GetChannelStatus function from the Autosar\n"
2463 " Channel A status:\n"
2464 " aggregated channel status vSS!ValidFrame: TRUE\n"
2465 " aggregated channel status vSS!SyntaxError: FALSE\n"
2466 " aggregated channel status vSS!ContentError: FALSE\n"
2467 " aggregated channel status additional communication: FALSE\n"
2468 " aggregated channel status vSS!Bviolation: FALSE\n"
2469 " aggregated channel status vSS!TxConflict: FALSE\n"
2470 " Not used (0): FALSE\n"
2471 " Not used (0): FALSE\n"
2472 " symbol window status data vSS!ValidMTS: FALSE\n"
2473 " symbol window status data vSS!SyntaxError: FALSE\n"
2474 " symbol window status data vSS!Bviolation: FALSE\n"
2475 " symbol window status data vSS!TxConflict: FALSE\n"
2476 " NIT status data vSS!SyntaxError: FALSE\n"
2477 " NIT status data vSS!Bviolation: FALSE\n"
2478 " Not used (0): FALSE\n"
2479 " Not used (0): FALSE\n"
2480 " Channel B status:\n"
2481 " aggregated channel status vSS!ValidFrame: TRUE\n"
2482 " aggregated channel status vSS!SyntaxError: FALSE\n"
2483 " aggregated channel status vSS!ContentError: FALSE\n"
2484 " aggregated channel status additional communication: FALSE\n"
2485 " aggregated channel status vSS!Bviolation: FALSE\n"
2486 " aggregated channel status vSS!TxConflict: FALSE\n"
2487 " Not used (0): FALSE\n"
2488 " Not used (0): FALSE\n"
2489 " symbol window status data vSS!ValidMTS: FALSE\n"
2490 " symbol window status data vSS!SyntaxError: FALSE\n"
2491 " symbol window status data vSS!Bviolation: FALSE\n"
2492 " symbol window status data vSS!TxConflict: FALSE\n"
2493 " NIT status data vSS!SyntaxError: FALSE\n"
2494 " NIT status data vSS!Bviolation: FALSE\n"
2495 " Not used (0): FALSE\n"
2496 " Not used (0): FALSE\n",
2497 CMD_HANDLER(cmd_do_fr_getchannelstatus), (void *)&cmd_list_fr_basic_test
2500 /** Command descriptor for FlexRay get clock correction command */
2501 cmd_des_t const cmd_des_fr_getclockcorrection = {
2503 "frbtclkcor","Print clock correction (rate and offset)",
2504 "### Command syntax ###\n"
2508 "### Description ###\n"
2510 "The command stands for Fr_GetClockCorrection function from the Autosar\n"
2516 " Rate correction: 0\n"
2517 " Offset correction: 0\n",
2518 CMD_HANDLER(cmd_do_fr_getclockcorrection), (void *)&cmd_list_fr_basic_test
2521 /** Command descriptor for FlexRay get sync frame list command */
2522 cmd_des_t const cmd_des_fr_getsyncframelist = {
2524 "frbtgetsyncfrlist*","Print the list of sync frames transmitted on both channels via the odd and even communication cycle",
2525 "### Command syntax ###\n"
2527 " frbtgetsyncfrlist<LENGTH>\n"
2529 "where `<LENGTH>` is a decimal number in range 0 - 15, specifying the\n"
2530 "length of the list to be printed.\n"
2532 "### Description ###\n"
2534 "The command stands for Fr_GetSyncFrameList function from the Autosar\n"
2539 " --> frbtgetsyncfrlist2\n"
2540 " | Channel A even | channel B even | channel A odd | channel B odd |\n"
2541 " |----------------|----------------|----------------|----------------|\n"
2542 " | 1 | 1 | 1 | 1 |\n"
2543 " | 2 | 2 | 2 | 2 |\n"
2544 " |----------------|----------------|----------------|----------------|\n",
2545 CMD_HANDLER(cmd_do_fr_getsyncframelist), (void *)&cmd_list_fr_basic_test
2548 /** Command descriptor for FlexRay get sync frame list command */
2549 cmd_des_t const cmd_des_fr_getwakeuprxstatus = {
2551 "frbtgetwurxstat","Prints whether the wake up pattern has been or has not been received",
2552 "### Command syntax ###\n"
2554 " frbtgetwurxstat\n"
2556 "### Description ###\n"
2558 "The command stands for Fr_GetWakeupRxStatus function from the Autosar\n"
2559 "specification. The status of the wake up receiving is bitcoded in the\n"
2560 "controller. This command decodes and prints it in a readable format.\n"
2564 " --> frbtgetwurxstat\n"
2565 " Wake up pattern was not yet received on channel A.\n"
2566 " Wake up pattern was not yet received on channel B.\n",
2567 CMD_HANDLER(cmd_do_fr_getwakeuprxstatus), (void *)&cmd_list_fr_basic_test
2570 /** Command descriptor for FlexRay set absolute timer command */
2571 cmd_des_t const cmd_des_fr_settimer = {
2573 "frbtsettimer*","Set and start timer",
2574 "### Command syntax ###\n"
2576 " frbtsettimer<TMID> <CYCLE> <OFFSET>\n"
2579 "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2580 "- `<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"
2581 "- `<OFFSET>` is a decimal number (0 - 16383) specifying the offset in macroticks, where precisely in the cycle should be the timer interrupt requested.\n"
2583 "### Description ###\n"
2585 "The command is similar to Fr_SetAbsoluteTimer function from the\n"
2586 "Autosar specification. The difference is that the command allows to\n"
2587 "specify a set of cycles, not only one of 64 cycles. It sets the timer\n"
2588 "selected by the parameter and enables it.\n"
2590 "Before using this command, FlexRay communication has to be started\n"
2591 "(see frbtstart).\n"
2595 " --> frbtsettimer0 32 50\n"
2596 " Timer was set for every 32-th cycle, offset 0, macrotick 50\n"
2597 " --> frbtsettimer0 31 50\n"
2598 " Timer was set for every 16-th cycle, offset 15, macrotick 50\n"
2599 " --> frbtsettimer0 0x42 0\n"
2600 " Timer was set for every 64-th cycle, offset 2, macrotick 0\n",
2601 CMD_HANDLER(cmd_do_fr_settimer), (void *)&cmd_list_fr_basic_test
2604 /** Command descriptor for FlexRay cancel absolute timer command */
2605 cmd_des_t const cmd_des_fr_canceltimer = {
2607 "frbtcanceltimer*","Stop the timer",
2608 "### Command syntax ###\n"
2610 " frbtcanceltimer<TMID>\n"
2611 "where `<TMID>` is a number (0 or 1) specifying the timer.\n"
2613 "### Description ###\n"
2615 "The command stands for Fr_CancelAbsoluteTimer function from the\n"
2616 "Autosar specification. It stops the timer selected by the parameter.\n"
2620 " --> frbtcanceltimer0\n"
2621 " Timer was canceled.\n",
2622 CMD_HANDLER(cmd_do_fr_canceltimer), (void *)&cmd_list_fr_basic_test
2625 /** Command descriptor for FlexRay absolute timer irq manipulation command */
2626 cmd_des_t const cmd_des_fr_timerirq = {
2628 "frbttimerirq*","Perform selected action on the timer IRQ",
2629 "### Command syntax ###\n"
2631 " frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer\n"
2632 " frbttimerirq<TMID> - Get timer IRQ status\n"
2636 "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2637 "- where `<ACTION>` is a string specifying the action to be performed on the selected timer IRQ.\n"
2639 "`<ACTIONS>` can be one of:\n"
2641 "- EN - Enable the IRQ on the selected timer\n"
2642 "- DIS - Disable the IRQ on the selected timer\n"
2643 "- ACK - Acknowledge the IRQ on the selected timer (reset flag in the register).\n"
2645 "### Description ###\n"
2647 "The command stands for Fr_EnableAbsoluteTimerIRQ,\n"
2648 "Fr_AckAbsoluteTimerIRQ, Fr_DisableAbsoluteTimerIRQ and\n"
2649 "Fr_GetAbsoluteTimerIRQStatus functions from the Autosar specification.\n"
2650 "It masks or demasks the IRQ for the timer, or acknowledges the\n"
2651 "interrupt request. If no action is specified it prints whether the IRQ\n"
2652 "is pending for the timer.\n"
2656 " --> frbttimerirq0\n"
2659 " --> frbttimerirq0 EN\n"
2661 CMD_HANDLER(cmd_do_fr_timerirq), (void *)&cmd_list_fr_basic_test
2664 /** Command descriptor for FlexRay get version info command */
2665 cmd_des_t const cmd_des_fr_getversioninfo = {
2667 "frbtversion","Print FlexRay driver version information",
2668 "### Command syntax ###\n"
2672 "### Description ###\n"
2674 "The command stands for Fr_GetVersionInfo function from the Autosar\n"
2676 "It reads and prints the information about vendor, module and version of\n"
2677 "the FlexRay driver\n"
2681 " --> frbtversion\n"
2682 " vendorID: 0xAAAA\n"
2683 " moduleID: 0xBBBB\n"
2684 " sw_major_version: 0x1\n"
2685 " sw_minor_version: 0x2\n"
2686 " sw_patch_version: 0x4\n",
2687 CMD_HANDLER(cmd_do_fr_getversioninfo), (void *)&cmd_list_fr_basic_test
2690 /** Command descriptor for FlexRay get controller configuration command */
2691 cmd_des_t const cmd_des_fr_readcconfig = {
2693 "frbtccconfig*","Print value of a FlexRay cluster and node configuration parameter",
2694 "### Command syntax ###\n"
2696 " frbtccconfig<INDEX>\n"
2698 "where `<INDEX>` is an identifier of the parameter.\n"
2700 "### Description ###\n"
2702 "The command stands for Fr_ReadCCConfig function from the Autosar\n"
2703 "specification. The driver stores the configuration parameters as an\n"
2704 "array. Each parameter can be indexed and returned by this command. See\n"
2705 "Autosar specification of the FlexRay driver\n"
2706 "(http://www.autosar.org/download/R4.1/AUTOSAR_SWS_FlexRayDriver.pdf),\n"
2707 "section 8.2.1 for parameter indexes.\n"
2711 " --> frbtccconfig1\n"
2713 CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
2716 /** Command descriptor for FlexRay reconfigure buffer command */
2717 cmd_des_t const cmd_des_fr_reconfigure_buffer = {
2719 "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
2720 "### Command syntax ###\n"
2722 " frbtreconfigurebuf id<BUFID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> max<MAX>\n"
2725 "- `<BUFID>` is a number specifying a slot, where the buffer is currently communicating,\n"
2726 "- `<SLOT>` is a number, where buffer will be communicating after the reconfiguration,\n"
2727 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
2728 "- `<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"
2729 "- `<CYCO>` is the cycle offset. It has to be in range 0 - `<CYCS>`-1"
2730 "- `<MAX>` is the number determining the maximum payload (in hald-words).\n"
2732 "### Description ###\n"
2734 "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
2735 "specification. It reconfigures specified buffer to communicate in\n"
2737 "The reconfiguration must be allowed in node configuration parameter\n"
2738 "secureBuffers. Buffers used for synchronization or assigned to the FIFO\n"
2739 "are not reconfigurable.\n"
2740 "The command can be called any time when the communication is running.\n"
2744 " --> frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n"
2745 " frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n",
2746 CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
2750 /** List of commands for flexRay, defined as external */
2751 cmd_des_t const *cmd_list_fr_basic_test[] = {
2752 &cmd_des_fr_user_config,
2753 &cmd_des_fr_config_buffer,
2754 &cmd_des_fr_config_fifo,
2757 &cmd_des_fr_allslots,
2760 &cmd_des_fr_sendwup,
2761 &cmd_des_fr_setwuchannel,
2762 &cmd_des_fr_getpocstatus,
2763 &cmd_des_fr_transmittxlpdu,
2764 &cmd_des_fr_canceltxlpdu,
2765 &cmd_des_fr_receiverxlpdu,
2766 &cmd_des_fr_checktxlpdustatus,
2767 &cmd_des_fr_disablelpdu,
2768 &cmd_des_fr_getglobaltime,
2769 &cmd_des_fr_getnmvector,
2770 &cmd_des_fr_nmwatch,
2771 &cmd_des_fr_getchannelstatus,
2772 &cmd_des_fr_getclockcorrection,
2773 &cmd_des_fr_getsyncframelist,
2774 &cmd_des_fr_getwakeuprxstatus,
2775 &cmd_des_fr_settimer,
2776 &cmd_des_fr_canceltimer,
2777 &cmd_des_fr_timerirq,
2778 &cmd_des_fr_getversioninfo,
2779 &cmd_des_fr_readcconfig,
2780 &cmd_des_fr_reconfigure_buffer,