2 * Copyright (C) 2012-2013 Czech Technical University in Prague
9 * This document contains proprietary information belonging to Czech
10 * Technical University in Prague. Passing on and copying of this
11 * document, and communication of its contents is not permitted
12 * without prior written authorization.
14 * File : cmd_fr_basic_test.c
17 * The file contains a set of commands to control the FlexRay driver.
18 * Those commands can be used to configure RPP board as a FlexRay node,
19 * configure a set of TX and RX buffers, get status of the buffers and
20 * the FlexRay controller, manipulate with timers and control the transmission
25 #include "cmd_fr_basic_test.h"
30 #include "cmdproc_utils.h"
36 #define printf rpp_sci_printf
38 static inline int badpar(const char *msg)
41 return -CMDERR_BADPAR;
45 * Flag to recognize whether the FlexRay driver was already initialized. If it was, no further configuration is allowed.
47 static boolean_t fr_initialized = FALSE;
50 * This structure contains global FlexRay configuration.
51 * All nodes in the network have to use the same values for
52 * all parameters of this structure.
54 static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
55 .gColdStartAttempts = 0x2,
57 .gMacroPerCycle = 0x15E0, // (cycle period, 5.6us)
58 .gMaxWithoutClockCorrectionFatal = 0xF,
59 .gMaxWithoutClockCorrectionPassive = 0xF,
60 .gNetworkManagementVectorLength = 12,
61 .gNumberOfMinislots = 0x15A,
62 .gNumberOfStaticSlots = 0x8,
63 .gOffsetCorrectionStart = 0xAE4,
64 .gPayloadLengthStatic = 0x9,
66 .gdActionPointOffset = 0x4,
67 .gdCASRxLowMax = 0x43,
68 .gdDynamicSlotIdlePhase = 0x1,
70 .gdMinislotActionPointOffset = 0x2,
72 .gdSampleClockPeriod = 0, // 10mbit/sec
74 .gdTSSTransmitter = 0xA,
75 .gdWakeupSymbolRxIdle = 18,
76 .gdWakeupSymbolRxLow = 18,
77 .gdWakeupSymbolRxWindow = 76,
78 .gdWakeupSymbolTxIdle = 180,
79 .gdWakeupSymbolTxLow = 60
83 * This structure contains local configuration of the FlexRay node A.
84 * All nodes in the network shall have their own local configuraion,
85 * but it does not matters if they share some together, until their
86 * buffer configuration differs.
88 static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
89 .pAllowHaltDueToClock = 0,
90 .pAllowPassiveToActive = 0xF,
91 .pChannels = FR_CHANNEL_AB,
92 .pClusterDriftDamping = 0x1,
93 .pDelayCompensationA = 0x3,
94 .pDelayCompensationB = 0x3,
95 .pExternOffsetCorrection = 0,
96 .pExternRateCorrection = 0,
97 .pKeySlotUsedForStartup = TRUE,
98 .pKeySlotUsedForSync = TRUE,
100 .pMacroInitialOffsetA = 0x6,
101 .pMacroInitialOffsetB = 0x6,
102 .pMicroInitialOffsetA = 0x18,
103 .pMicroInitialOffsetB = 0x18,
104 .pMicroPerCycle = 0x36B00,
105 .pRateCorrectionOut = 0xCD,
106 .pOffsetCorrectionOut = 0x151,
107 .pSamplesPerMicrotick = 0, // 10 mbit/sec
108 .pSingleSlotEnabled = TRUE,
109 .pWakeupChannel = FR_CHANNEL_A,
111 .pdAcceptedStartupRange = 0x81,
112 .pdListenTimeout = 0x36DA2,
114 .pDecodingCorrection = 0x33
118 * This structure contains local configuration of the FlexRay node B.
119 * All nodes in the network shall have their own local configuraion,
120 * but it does not matters if they share some together, until their
121 * buffer configuration differs.
123 static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
124 .pAllowHaltDueToClock = 0,
125 .pAllowPassiveToActive = 0xF,
126 .pChannels = FR_CHANNEL_AB,
127 .pClusterDriftDamping = 0x1,
128 .pDelayCompensationA = 0x3,
129 .pDelayCompensationB = 0x3,
130 .pExternOffsetCorrection = 0,
131 .pExternRateCorrection = 0,
132 .pKeySlotUsedForStartup = TRUE,
133 .pKeySlotUsedForSync = TRUE,
135 .pMacroInitialOffsetA = 0x6,
136 .pMacroInitialOffsetB = 0x6,
137 .pMicroInitialOffsetA = 0x18,
138 .pMicroInitialOffsetB = 0x18,
139 .pMicroPerCycle = 0x36B00,
140 .pRateCorrectionOut = 0xCD,
141 .pOffsetCorrectionOut = 0x151,
142 .pSamplesPerMicrotick = 0, // 10 mbit/sec
143 .pSingleSlotEnabled = TRUE,
144 .pWakeupChannel = FR_CHANNEL_A,
146 .pdAcceptedStartupRange = 0x81,
147 .pdListenTimeout = 0x36DA2,
149 .pDecodingCorrection = 0x33
152 static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
153 .dynSegmentBufferCount = 3,
154 .fifoBufferCount = 5,
155 .secureBuffers = FR_SB_RECONFIG_ENABLED,
156 .statSegmentBufferCount = 5,
157 .syncFramePayloadMultiplexEnabled = 0
160 static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
161 .dynSegmentBufferCount = 3,
162 .fifoBufferCount = 5,
163 .secureBuffers = FR_SB_RECONFIG_ENABLED,
164 .statSegmentBufferCount = 5,
165 .syncFramePayloadMultiplexEnabled = 0
168 static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
170 .channel = FR_CHANNEL_AB,
171 .cycleCounterFiltering = 0,
175 .msgBufferInterrupt = TRUE,
176 .payloadPreambleIndicatorTr = FALSE,
177 .rejectNullFrames = FALSE,
178 .rejectStaticSegment = FALSE,
179 .singleTransmit = FALSE,
183 .channel = FR_CHANNEL_AB,
184 .cycleCounterFiltering = 0,
188 .msgBufferInterrupt = TRUE,
189 .payloadPreambleIndicatorTr = FALSE,
190 .rejectNullFrames = FALSE,
191 .rejectStaticSegment = FALSE,
192 .singleTransmit = FALSE,
196 .channel = FR_CHANNEL_AB,
197 .cycleCounterFiltering = 0,
201 .msgBufferInterrupt = TRUE,
202 .payloadPreambleIndicatorTr = FALSE,
203 .rejectNullFrames = FALSE,
204 .rejectStaticSegment = FALSE,
205 .singleTransmit = TRUE,
209 .channel = FR_CHANNEL_AB,
210 .cycleCounterFiltering = 0,
214 .msgBufferInterrupt = TRUE,
215 .payloadPreambleIndicatorTr = FALSE,
216 .rejectNullFrames = FALSE,
217 .rejectStaticSegment = FALSE,
218 .singleTransmit = TRUE,
222 .channel = FR_CHANNEL_AB,
223 .cycleCounterFiltering = 0,
227 .msgBufferInterrupt = TRUE,
228 .payloadPreambleIndicatorTr = TRUE,
229 .rejectNullFrames = FALSE,
230 .rejectStaticSegment = FALSE,
231 .singleTransmit = FALSE,
237 static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
239 .channel = FR_CHANNEL_AB,
240 .cycleCounterFiltering = 0,
244 .msgBufferInterrupt = TRUE,
245 .payloadPreambleIndicatorTr = FALSE,
246 .rejectNullFrames = FALSE,
247 .rejectStaticSegment = FALSE,
248 .singleTransmit = FALSE,
252 .channel = FR_CHANNEL_AB,
253 .cycleCounterFiltering = 0,
257 .msgBufferInterrupt = TRUE,
258 .payloadPreambleIndicatorTr = FALSE,
259 .rejectNullFrames = FALSE,
260 .rejectStaticSegment = FALSE,
261 .singleTransmit = FALSE,
265 .channel = FR_CHANNEL_AB,
266 .cycleCounterFiltering = 0,
270 .msgBufferInterrupt = TRUE,
271 .payloadPreambleIndicatorTr = FALSE,
272 .rejectNullFrames = FALSE,
273 .rejectStaticSegment = FALSE,
274 .singleTransmit = TRUE,
278 .channel = FR_CHANNEL_AB,
279 .cycleCounterFiltering = 0,
283 .msgBufferInterrupt = TRUE,
284 .payloadPreambleIndicatorTr = FALSE,
285 .rejectNullFrames = FALSE,
286 .rejectStaticSegment = FALSE,
287 .singleTransmit = TRUE,
291 .channel = FR_CHANNEL_AB,
292 .cycleCounterFiltering = 0,
296 .msgBufferInterrupt = TRUE,
297 .payloadPreambleIndicatorTr = TRUE,
298 .rejectNullFrames = FALSE,
299 .rejectStaticSegment = FALSE,
300 .singleTransmit = FALSE,
305 static Fr_TMS570LS_BufferConfigType Fr_node_A_dynamic_buffers_config[] = {
307 .channel = FR_CHANNEL_A,
308 .cycleCounterFiltering = 0,
312 .msgBufferInterrupt = TRUE,
313 .payloadPreambleIndicatorTr = FALSE,
314 .rejectNullFrames = FALSE,
315 .rejectStaticSegment = FALSE,
316 .singleTransmit = FALSE,
320 .channel = FR_CHANNEL_B,
321 .cycleCounterFiltering = 0,
325 .msgBufferInterrupt = TRUE,
326 .payloadPreambleIndicatorTr = FALSE,
327 .rejectNullFrames = FALSE,
328 .rejectStaticSegment = FALSE,
329 .singleTransmit = FALSE,
333 .channel = FR_CHANNEL_A,
334 .cycleCounterFiltering = 0,
338 .msgBufferInterrupt = TRUE,
339 .payloadPreambleIndicatorTr = FALSE,
340 .rejectNullFrames = FALSE,
341 .rejectStaticSegment = FALSE,
342 .singleTransmit = TRUE,
348 static Fr_TMS570LS_BufferConfigType Fr_node_B_dynamic_buffers_config[] = {
350 .channel = FR_CHANNEL_B,
351 .cycleCounterFiltering = 0,
355 .msgBufferInterrupt = TRUE,
356 .payloadPreambleIndicatorTr = FALSE,
357 .rejectNullFrames = FALSE,
358 .rejectStaticSegment = FALSE,
359 .singleTransmit = TRUE,
363 .channel = FR_CHANNEL_A,
364 .cycleCounterFiltering = 0,
368 .msgBufferInterrupt = TRUE,
369 .payloadPreambleIndicatorTr = FALSE,
370 .rejectNullFrames = FALSE,
371 .rejectStaticSegment = FALSE,
372 .singleTransmit = TRUE,
376 .channel = FR_CHANNEL_A,
377 .cycleCounterFiltering = 0,
381 .msgBufferInterrupt = TRUE,
382 .payloadPreambleIndicatorTr = FALSE,
383 .rejectNullFrames = FALSE,
384 .rejectStaticSegment = FALSE,
385 .singleTransmit = TRUE,
390 static Fr_TMS570LS_BufferConfigType Fr_node_A_fifo_buffers_config[] = {
392 .channel = FR_CHANNEL_AB,
393 .cycleCounterFiltering = 0,
397 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
398 .payloadPreambleIndicatorTr = FALSE,
399 .rejectNullFrames = TRUE,
400 .rejectStaticSegment = FALSE,
401 .singleTransmit = FALSE,
405 .channel = FR_CHANNEL_AB,
406 .cycleCounterFiltering = 0,
410 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
411 .payloadPreambleIndicatorTr = FALSE,
412 .rejectNullFrames = TRUE,
413 .rejectStaticSegment = FALSE,
414 .singleTransmit = FALSE,
418 .channel = FR_CHANNEL_AB,
419 .cycleCounterFiltering = 0,
423 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
424 .payloadPreambleIndicatorTr = FALSE,
425 .rejectNullFrames = TRUE,
426 .rejectStaticSegment = FALSE,
427 .singleTransmit = FALSE,
431 .channel = FR_CHANNEL_AB,
432 .cycleCounterFiltering = 0,
436 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
437 .payloadPreambleIndicatorTr = FALSE,
438 .rejectNullFrames = TRUE,
439 .rejectStaticSegment = FALSE,
440 .singleTransmit = FALSE,
444 .channel = FR_CHANNEL_AB,
445 .cycleCounterFiltering = 0,
449 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
450 .payloadPreambleIndicatorTr = FALSE,
451 .rejectNullFrames = TRUE,
452 .rejectStaticSegment = FALSE,
453 .singleTransmit = FALSE,
458 static Fr_TMS570LS_BufferConfigType Fr_node_B_fifo_buffers_config[] = {
460 .channel = FR_CHANNEL_AB,
461 .cycleCounterFiltering = 0,
465 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
466 .payloadPreambleIndicatorTr = FALSE,
467 .rejectNullFrames = TRUE,
468 .rejectStaticSegment = FALSE,
469 .singleTransmit = FALSE,
470 .slotId = 0 // No Frame is rejected
473 .channel = FR_CHANNEL_AB,
474 .cycleCounterFiltering = 0,
478 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
479 .payloadPreambleIndicatorTr = FALSE,
480 .rejectNullFrames = TRUE,
481 .rejectStaticSegment = FALSE,
482 .singleTransmit = FALSE,
483 .slotId = 0 // No Frame is rejected
486 .channel = FR_CHANNEL_AB,
487 .cycleCounterFiltering = 0,
491 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
492 .payloadPreambleIndicatorTr = FALSE,
493 .rejectNullFrames = TRUE,
494 .rejectStaticSegment = FALSE,
495 .singleTransmit = FALSE,
496 .slotId = 0 // No Frame is rejected
499 .channel = FR_CHANNEL_AB,
500 .cycleCounterFiltering = 0,
504 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
505 .payloadPreambleIndicatorTr = FALSE,
506 .rejectNullFrames = TRUE,
507 .rejectStaticSegment = FALSE,
508 .singleTransmit = FALSE,
509 .slotId = 0 // No Frame is rejected
512 .channel = FR_CHANNEL_AB,
513 .cycleCounterFiltering = 0,
517 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
518 .payloadPreambleIndicatorTr = FALSE,
519 .rejectNullFrames = TRUE,
520 .rejectStaticSegment = FALSE,
521 .singleTransmit = FALSE,
522 .slotId = 0 // No Frame is rejected
527 * This is an unifying configuration structure for the node A.
528 * It joins all the configuration structure together.
530 static Fr_ConfigType Fr_config_node_A = {
531 .clusterConfiguration = &Fr_cluster_config,
532 .dynamicBufferConfigs = Fr_node_A_dynamic_buffers_config,
533 .fifoBufferConfigs = Fr_node_A_fifo_buffers_config,
534 .msgRAMConfig = &Fr_node_A_msgRAM_config,
535 .nodeConfiguration = &Fr_node_A_config,
536 .staticBufferConfigs = Fr_node_A_static_buffers_config
540 * This is an unifying configuration structure for the node A.
541 * It joins all the configuration structure together.
543 static Fr_ConfigType Fr_config_node_B = {
544 .clusterConfiguration = &Fr_cluster_config,
545 .dynamicBufferConfigs = Fr_node_B_dynamic_buffers_config,
546 .fifoBufferConfigs = Fr_node_B_fifo_buffers_config,
547 .msgRAMConfig = &Fr_node_B_msgRAM_config,
548 .nodeConfiguration = &Fr_node_B_config,
549 .staticBufferConfigs = Fr_node_B_static_buffers_config
552 /* User configuration */
554 static Fr_TMS570LS_ClusterConfigType user_cluster_config;
555 static Fr_TMS570LS_NodeConfigType user_node_config;
556 static Fr_TMS570LS_MsgRAMConfig user_msg_ram_config;
557 static Fr_TMS570LS_BufferConfigType user_static_buffer_config[RPP_FR_MAX_STATIC_BUF_CNT];
558 static Fr_TMS570LS_BufferConfigType user_dynamic_buffer_config[RPP_FR_MAX_DYNAMIC_BUF_CNT];
559 static Fr_TMS570LS_BufferConfigType user_fifo_buffer_config[RPP_FR_MAX_FIFO_BUF_DEPTH];
560 static Fr_ConfigType user_configuration = {
561 .clusterConfiguration = &user_cluster_config,
562 .nodeConfiguration = &user_node_config,
563 .msgRAMConfig = &user_msg_ram_config,
564 .staticBufferConfigs = user_static_buffer_config,
565 .dynamicBufferConfigs = user_dynamic_buffer_config,
566 .fifoBufferConfigs = user_fifo_buffer_config,
570 #define USER_CONFIG_NOT_DONE 0x0
571 #define USER_CONFIG_CLUSTER 0x1
572 #define USER_CONFIG_NODE 0x2
574 static uint8_t user_configuration_state = USER_CONFIG_NOT_DONE;
575 static uint8_t user_static_buffer_configured = 0;
576 static uint8_t user_dynamic_buffer_configured = 0;
577 static uint8_t user_fifo_buffer_depth = 0;
580 * Split string into numbers
582 * The function takes a string with hexadecimal numbers,
583 * separated by spaces, and converts it into an array of numbers.
585 * For example "0x2 0xA 0XDD 0xABCD" -> {0x2, 0xA, 0XDD, 0xABCD}
587 * @param [in] params Address of the string which will be converted
588 * @param [in] params_cnt A number of parameters, which should be found and converted from the string params
589 * @param [out] tmp_params Address, where converted array of numbers will be stored
591 * @return SUCCESS when all parameters were converted to the array of numbers,
592 * FAILURE when the string was too short, too long or some other error occurred.
594 static int8_t cmd_fr_parse_params(const char *params, uint32_t params_cnt, uint32_t *tmp_params)
596 char cpy_params[256];
600 if (params == NULL || tmp_params == NULL)
602 strncpy(cpy_params, params, 256);
603 token = strtok(cpy_params, " ");
606 for (i = 0; i < params_cnt; i++) {
607 if (sscanf(token, "%i", &tmp_params[i]) == EOF) // No number found
609 if ((token = strtok(NULL, " ")) == NULL && i < params_cnt-1) // Not enough parameters in the string
615 int8_t cmd_fr_config_cluster_params(const char *params)
617 uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
619 if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE)
622 user_cluster_config.gColdStartAttempts = tmp_params[0];
623 user_cluster_config.gListenNoise = tmp_params[1];
624 user_cluster_config.gMacroPerCycle = tmp_params[2];
625 user_cluster_config.gMaxWithoutClockCorrectionFatal = tmp_params[3];
626 user_cluster_config.gMaxWithoutClockCorrectionPassive = tmp_params[4];
627 user_cluster_config.gNetworkManagementVectorLength = tmp_params[5];
628 user_cluster_config.gNumberOfMinislots = tmp_params[6];
629 user_cluster_config.gNumberOfStaticSlots = tmp_params[7];
630 user_cluster_config.gOffsetCorrectionStart = tmp_params[8];
631 user_cluster_config.gPayloadLengthStatic = tmp_params[9];
632 user_cluster_config.gSyncNodeMax = tmp_params[10];
633 user_cluster_config.gdActionPointOffset = tmp_params[11];
634 user_cluster_config.gdCASRxLowMax = tmp_params[12];
635 user_cluster_config.gdDynamicSlotIdlePhase = tmp_params[13];
636 user_cluster_config.gdMinislot = tmp_params[14];
637 user_cluster_config.gdMinislotActionPointOffset = tmp_params[15];
638 user_cluster_config.gdNIT = tmp_params[16];
639 user_cluster_config.gdSampleClockPeriod = tmp_params[17];
640 user_cluster_config.gdStaticSlot = tmp_params[18];
641 user_cluster_config.gdTSSTransmitter = tmp_params[19];
642 user_cluster_config.gdWakeupSymbolRxIdle = tmp_params[20];
643 user_cluster_config.gdWakeupSymbolRxLow = tmp_params[21];
644 user_cluster_config.gdWakeupSymbolRxWindow = tmp_params[22];
645 user_cluster_config.gdWakeupSymbolTxIdle = tmp_params[23];
646 user_cluster_config.gdWakeupSymbolTxLow = tmp_params[24];
648 user_configuration_state |= USER_CONFIG_CLUSTER;
652 int8_t cmd_fr_config_node_params(const char *params)
654 uint32_t tmp_params[FR_NODE_PARAMS_CNT+2]; // +2 because two more parameters from message RAM structure are expected in the string.
655 Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
656 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};
658 if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE)
661 user_node_config.pAllowHaltDueToClock = tmp_params[0];
662 user_node_config.pAllowPassiveToActive = tmp_params[1];
663 if (tmp_params[2] > 2) return FAILURE;
664 user_node_config.pChannels = channels[ tmp_params[2] ];
665 user_node_config.pClusterDriftDamping = tmp_params[3];
666 user_node_config.pDelayCompensationA = tmp_params[4];
667 user_node_config.pDelayCompensationB = tmp_params[5];
668 user_node_config.pExternOffsetCorrection = tmp_params[6];
669 user_node_config.pExternRateCorrection = tmp_params[7];
670 user_node_config.pKeySlotUsedForStartup = tmp_params[8];
671 user_node_config.pKeySlotUsedForSync = tmp_params[9];
672 user_node_config.pLatestTx = tmp_params[10];
673 user_node_config.pMacroInitialOffsetA = tmp_params[11];
674 user_node_config.pMacroInitialOffsetB = tmp_params[12];
675 user_node_config.pMicroInitialOffsetA = tmp_params[13];
676 user_node_config.pMicroInitialOffsetB = tmp_params[14];
677 user_node_config.pMicroPerCycle = tmp_params[15];
678 user_node_config.pRateCorrectionOut = tmp_params[16];
679 user_node_config.pOffsetCorrectionOut = tmp_params[17];
680 user_node_config.pSamplesPerMicrotick = tmp_params[18];
681 user_node_config.pSingleSlotEnabled = tmp_params[19];
682 if (tmp_params[20] > 1) return FAILURE;
683 user_node_config.pWakeupChannel = channels[ tmp_params[20] ];
684 user_node_config.pWakeupPattern = tmp_params[21];
685 user_node_config.pdAcceptedStartupRange = tmp_params[22];
686 user_node_config.pdListenTimeout = tmp_params[23];
687 user_node_config.pdMaxDrift = tmp_params[24];
688 user_node_config.pDecodingCorrection = tmp_params[25];
689 user_msg_ram_config.syncFramePayloadMultiplexEnabled = tmp_params[26];
690 if (tmp_params[27] > 3) return FAILURE;
691 user_msg_ram_config.secureBuffers = secure[ tmp_params[27] ];
693 user_configuration_state |= USER_CONFIG_NODE;
697 int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
699 Fr_TMS570LS_BufferConfigType *fifo_buffer_ptr = &user_fifo_buffer_config[0];
701 char channel[3], rej_static_frames[8], rej_null_frames[8];
702 unsigned depth, slot, cycleset, maxpayload, mask;
703 Fr_TMS570LS_BufferConfigType tmp_buffer;
705 if (fr_initialized) {
706 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
707 return -CMDERR_BADCFG;
710 ret = sscanf(param[2], "rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s",
721 printf("Error parsing parameter %d\n", ret+1);
722 return -CMDERR_BADPAR;
725 if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
726 return badpar("Depth too high\n");
727 user_fifo_buffer_depth = depth;
730 return badpar("Invalid slot number\n");
731 tmp_buffer.slotId = slot;
733 return badpar("Invalid mask\n");
734 tmp_buffer.fidMask = mask;
735 if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
736 else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
737 else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
738 else return badpar("Channel parsing error\n");
740 if (cycleset >= 0x80)
741 return badpar("Cycle set must be less than 0x80.\n");
742 tmp_buffer.cycleCounterFiltering = cycleset;
744 if (maxpayload >= 128)
745 return badpar("Maximum payload in half-words must be less than 128\n");
746 tmp_buffer.maxPayload = maxpayload;
748 if (strcmp(rej_null_frames, "rejnull") == 0) tmp_buffer.rejectNullFrames = true;
749 else if (strcmp(rej_null_frames, "accnull") == 0) tmp_buffer.rejectNullFrames = false;
750 else return badpar("Reject/accept NULL frames parsing error\n");
752 if (strcmp(rej_static_frames, "rejstat") == 0)
753 tmp_buffer.rejectStaticSegment = true;
754 else if (strcmp(rej_static_frames, "accstat") == 0)
755 tmp_buffer.rejectStaticSegment = false;
756 else return badpar("Invalid reject/accept static frame parameter");
758 for (i = 0; i < user_fifo_buffer_depth; i++) {
759 fifo_buffer_ptr[i].slotId = tmp_buffer.slotId;
760 fifo_buffer_ptr[i].fidMask = tmp_buffer.fidMask;
761 fifo_buffer_ptr[i].maxPayload = tmp_buffer.maxPayload;
762 fifo_buffer_ptr[i].channel = tmp_buffer.channel;
763 fifo_buffer_ptr[i].cycleCounterFiltering = tmp_buffer.cycleCounterFiltering;
764 fifo_buffer_ptr[i].isTx = FALSE;
765 fifo_buffer_ptr[i].singleTransmit = FALSE;
766 fifo_buffer_ptr[i].payloadPreambleIndicatorTr = FALSE;
767 fifo_buffer_ptr[i].rejectNullFrames = tmp_buffer.rejectNullFrames;
768 fifo_buffer_ptr[i].rejectStaticSegment = tmp_buffer.rejectStaticSegment;
769 fifo_buffer_ptr[i].msgBufferInterrupt = 0;
772 printf("frbtcfgfifo rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s\n",
786 int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
788 Fr_TMS570LS_BufferConfigType *cfg;
791 char buf_type, channel[3],rxtx[3], single_continuous[11];
792 unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
794 if (fr_initialized) {
795 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
796 return -CMDERR_BADCFG;
799 ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
812 printf("Error parsing parameter %d\n", ret+1);
813 return -CMDERR_BADPAR;
819 if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
820 return badpar("Buffer index too high\n");
821 cfg = &user_static_buffer_config[buffer];
824 if (buffer >= RPP_FR_MAX_DYNAMIC_BUF_CNT)
825 return badpar("Buffer index too high\n");
826 cfg = &user_dynamic_buffer_config[buffer];
829 return badpar("Invalid buffer type (S, D)\n");
832 if (slot < 1 || slot > 2047)
833 return badpar("Invalid slot number\n");
836 if (strcmp(channel, "A") == 0) cfg->channel = FR_CHANNEL_A;
837 else if (strcmp(channel, "B") == 0) cfg->channel = FR_CHANNEL_B;
838 else if (strcmp(channel, "AB") == 0) cfg->channel = FR_CHANNEL_AB;
839 else return badpar("Channel parsing error\n");
840 if (buf_type == 'D' && cfg->channel == FR_CHANNEL_AB)
841 return badpar("Dynamic segment buffers cannot have AB channels.\n");
843 if (cycleset >= 0x80)
844 return badpar("Cycle set must be less than 0x80.\n");
845 cfg->cycleCounterFiltering = cycleset;
847 if (strcmp(rxtx, "tx") == 0) cfg->isTx = true;
848 else if (strcmp(rxtx, "rx") == 0) cfg->isTx = false;
849 else return badpar("RX/TX parsing error\n");
851 if (maxpayload >= 128)
852 return badpar("Maximum payload in half-words must be less than 128\n");
853 cfg->maxPayload = maxpayload;
855 if (0 == strcmp(single_continuous, "single") ||
856 0 == strcmp(single_continuous, "s"))
857 cfg->singleTransmit = true;
858 else if (0 == strcmp(single_continuous, "continuous") ||
859 0 == strcmp(single_continuous, "c"))
860 cfg->singleTransmit = false;
861 else return badpar("Invalid single/continuous parameter");
864 return badpar("Payload preamble indicator must be 0 or 1");
865 cfg->payloadPreambleIndicatorTr = preamb;
868 return badpar("Interrupt parameter must be 0 or 1");
869 cfg->msgBufferInterrupt = intr;
873 if (buffer >= user_static_buffer_configured)
874 user_static_buffer_configured = buffer + 1;
877 if (buffer >= user_dynamic_buffer_configured)
878 user_dynamic_buffer_configured = buffer + 1;
882 printf("frbtcfgbuf%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i\n",
901 * @brief Do the user configuration of the FlexRay cluster parameters
903 * @param[in] cmd_io Pointer to IO stack
904 * @param[in] des Pointer to command descriptor
905 * @param[in] param Parameters of command
906 * @return 0 when OK or error code
908 int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
912 if (fr_initialized) {
913 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
914 return -CMDERR_BADCFG;
917 token = strtok(param[1], " ");
918 if (strcmp(token, "cluster") == 0) {
919 if (cmd_fr_config_cluster_params(param[2]) == FAILURE) {
920 rpp_sci_printf("FlexRay cluster configuration not accepted.\n");
921 return -CMDERR_BADPAR;
923 rpp_sci_printf("FlexRay cluster configuration accepted.\n");
925 else if (strcmp(token, "node") == 0) {
926 if (cmd_fr_config_node_params(param[2]) == FAILURE) {
927 rpp_sci_printf("FlexRay node configuration not accepted.\n");
928 return -CMDERR_BADPAR;
930 rpp_sci_printf("FlexRay node configuration accepted.\n");
933 return -CMDERR_BADPAR;
939 * @brief Initialize the device as FlexRay node.
941 * @param[in] cmd_io Pointer to IO stack
942 * @param[in] des Pointer to command descriptor
943 * @param[in] param Parameters of command
944 * @return 0 when OK or error code
946 int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
948 const Fr_ConfigType *Fr_ConfigPtr = NULL;
949 int8_t retVal = SUCCESS;
950 uint32_t error = ERR_PARAM_NO_ERROR;
952 if (*param[1] == 'A')
953 Fr_ConfigPtr = &Fr_config_node_A;
954 else if (*param[1] == 'B')
955 Fr_ConfigPtr = &Fr_config_node_B;
956 else if (*param[1] == 'U') { // Select the user configuration - call config commands first
957 user_msg_ram_config.statSegmentBufferCount = user_static_buffer_configured;
958 user_msg_ram_config.dynSegmentBufferCount = user_dynamic_buffer_configured;
959 user_msg_ram_config.fifoBufferCount = user_fifo_buffer_depth;
960 Fr_ConfigPtr = &user_configuration;
963 return -CMDERR_BADPAR;
965 retVal = rpp_fr_init_driver(Fr_ConfigPtr, &error);
966 if (retVal == SUCCESS) {
967 rpp_sci_printf("FlexRay driver initialized.\r\n");
968 fr_initialized = TRUE;
971 retVal = rpp_fr_init_controller(0, &error);
972 if (retVal == SUCCESS) {
973 rpp_sci_printf("FlexRay controller reinitialized.\r\n");
977 rpp_sci_printf("FlexRay needs to be configured before initialization.\r\n");
978 return -CMDERR_BADCFG;
982 retVal = rpp_fr_init_controller(0, &error);
983 if (retVal == SUCCESS)
984 rpp_sci_printf("FlexRay controller initialized.\r\n");
986 if (error & FR_INIT_ERR_CLUSTER_CONFIG)
987 rpp_sci_printf("Cluster configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
988 else if (error & FR_INIT_ERR_NODE_CONFIG)
989 rpp_sci_printf("Node configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
990 else if (error & FR_INIT_ERR_MSGRAM_CONFIG)
991 rpp_sci_printf("Message RAM configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
992 else if (error & FR_INIT_ERR_BUFFPARAM_CONFIG)
993 rpp_sci_printf("Buffer configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
994 else if (error & (uint32_t)FR_INIT_ERR_BUFF_CONFIG)
995 rpp_sci_printf("Buffer configuration error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
997 rpp_sci_printf("POC state switching error.\r\n");
998 return -CMDERR_BADCFG;
1004 * @brief Starts FlexRay communication
1006 * @param[in] cmd_io Pointer to IO stack
1007 * @param[in] des Pointer to command descriptor
1008 * @param[in] param Parameters of command
1009 * @return 0 when OK or error code
1011 int cmd_do_fr_start(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1013 int8_t retVal = SUCCESS;
1014 uint32_t error = ERR_PARAM_NO_ERROR;
1016 retVal = rpp_fr_start_communication(0, &error);
1017 if (retVal == SUCCESS)
1018 rpp_sci_printf("FlexRay communication is running.\r\n");
1020 if (error & FR_STARTUP_ERR_SW_STUP_FOLLOW)
1021 rpp_sci_printf("Can not switch POC to RUN state.\r\n");
1022 else if (error & FR_STARTUP_ERR_CSINH_DIS)
1023 rpp_sci_printf("Cold start inhibit disabled error.\r\n");
1024 else if (error & FR_STARTUP_ERR_SW_STUP_READY)
1025 rpp_sci_printf("Can not switch back to READY from STARTUP.\r\n");
1026 else if (error & FR_STARTUP_ERR_SW_STUP_AS_NCOLD)
1027 rpp_sci_printf("Can not switch to STARTUP as non-coldstarter.\r\n");
1029 rpp_sci_printf("General error.\r\n");
1030 return -CMDERR_BADCFG;
1036 * @brief Invokes POC command ALL_SLOTS
1038 * @param[in] cmd_io Pointer to IO stack
1039 * @param[in] des Pointer to command descriptor
1040 * @param[in] param Parameters of command
1041 * @return 0 when OK or error code
1043 int cmd_do_fr_allslots(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1045 int8_t retVal = ERR_PARAM_NO_ERROR;
1047 retVal = rpp_fr_all_slots(0);
1048 if (retVal == SUCCESS)
1049 rpp_sci_printf("FlexRay node started communication in all slots.\r\n");
1051 rpp_sci_printf("General error.\r\n");
1052 return -CMDERR_BADCFG;
1058 * @brief Halt FlexRay communication
1060 * @param[in] cmd_io Pointer to IO stack
1061 * @param[in] des Pointer to command descriptor
1062 * @param[in] param Parameters of command
1063 * @return 0 when OK or error code
1065 int cmd_do_fr_halt(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1067 int8_t retVal = ERR_PARAM_NO_ERROR;
1069 retVal = rpp_fr_halt_communication(0);
1070 if (retVal == SUCCESS)
1071 rpp_sci_printf("FlexRay node communication halted.\r\n");
1073 rpp_sci_printf("General error.\r\n");
1074 return -CMDERR_BADCFG;
1080 * @brief Abort FlexRay communication
1082 * @param[in] cmd_io Pointer to IO stack
1083 * @param[in] des Pointer to command descriptor
1084 * @param[in] param Parameters of command
1085 * @return 0 when OK or error code
1087 int cmd_do_fr_abort(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1089 int8_t retVal = ERR_PARAM_NO_ERROR;
1091 retVal = rpp_fr_abort_communication(0);
1092 if (retVal == SUCCESS)
1093 rpp_sci_printf("FlexRay node communication aborted.\r\n");
1095 rpp_sci_printf("General error.\r\n");
1096 return -CMDERR_BADCFG;
1102 * @brief Send wake up pattern
1104 * @param[in] cmd_io Pointer to IO stack
1105 * @param[in] des Pointer to command descriptor
1106 * @param[in] param Parameters of command
1107 * @return 0 when OK or error code
1109 int cmd_do_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1111 int8_t retVal = ERR_PARAM_NO_ERROR;
1113 retVal = rpp_fr_send_wup(0);
1114 if (retVal == SUCCESS)
1115 rpp_sci_printf("Wake up pattern has been sent.\r\n");
1117 rpp_sci_printf("General error.\r\n");
1118 return -CMDERR_BADCFG;
1124 * @brief Set channel for wake up pattern sending.
1126 * @param[in] cmd_io Pointer to IO stack
1127 * @param[in] des Pointer to command descriptor
1128 * @param[in] param Parameters of command
1129 * @return 0 when OK or error code
1131 int cmd_do_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1133 int8_t retVal = ERR_PARAM_NO_ERROR;
1134 Fr_ChannelType channel = FR_CHANNEL_A;
1136 if (*param[1] == 'A')
1137 channel = FR_CHANNEL_A;
1138 else if (*param[1] == 'B')
1139 channel = FR_CHANNEL_B;
1141 return -CMDERR_BADPAR;
1142 retVal = rpp_fr_set_wu_channel(0, channel);
1143 if (retVal == SUCCESS)
1144 rpp_sci_printf("Wake up channel has been set.\r\n");
1146 rpp_sci_printf("General error.\r\n");
1147 return -CMDERR_BADCFG;
1153 * @brief Get and print POC status of the FlexRay controller.
1155 * @param[in] cmd_io Pointer to IO stack
1156 * @param[in] des Pointer to command descriptor
1157 * @param[in] param Parameters of command
1158 * @return 0 when OK or error code
1160 int cmd_do_fr_getpocstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1162 int8_t retVal = ERR_PARAM_NO_ERROR;
1163 Fr_POCStatusType status;
1164 char *ErrorModeStrings[] = {"ACTIVE", "HALT", "PASSIVE"};
1165 char *SlotModeStrings[] = {"KEYSLOT", "ALL_PENDING", "ALL"};
1166 char *StartupStateStrings[] = {
1167 "UNDEFINED", "COLDSTART_LISTEN", "COLDSTART_CHECK", "COLDSTART_JOIN",
1168 "COLDSTART_CONSISTENCY_CHECK", "INTEGRATION_LISTEN", "INITIALIZE_SCHEDULE", "INTEGRATION_CONSISTENCY_CHECK",
1169 "COLDSTART_GAP", "EXTERNAL_STARTUP", "ABORT", "COLDSTART_COLLISION_RESOLUTION",
1172 char *StateStrings[] = {
1173 "CONFIG", "DEFAULT_CONFIG", "HALT", "NORMAL_ACTIVE",
1174 "NORMAL_PASSIVE", "READY", "STARTUP", "LOOPBACK",
1177 char *WakeupStatusStrings[] = {
1178 "UNDEFINED", "RECEIVED_HEADER", "RECEIVED_WUP", "COLLISION_HEADER",
1179 "COLLISION_WUP", "COLLISION_UNKNOWN", "TRANSMITTED"
1182 retVal = rpp_fr_get_poc_status(0, &status);
1183 if (retVal == SUCCESS) {
1184 rpp_sci_printf("POC status:\r\n");
1185 rpp_sci_printf("CHIHaltRequest: %s\r\n", (status.CHIHaltRequest == TRUE) ? "TRUE" : "FALSE");
1186 rpp_sci_printf("CHIReadyRequest: %s\r\n", (status.CHIReadyRequest == TRUE) ? "TRUE" : "FALSE");
1187 rpp_sci_printf("ColdstartNoise: %s\r\n", (status.ColdstartNoise == TRUE) ? "TRUE" : "FALSE");
1188 rpp_sci_printf("Freeze: %s\r\n", (status.Freeze == TRUE) ? "TRUE" : "FALSE");
1189 rpp_sci_printf("ErrorMode: %s\r\n", ErrorModeStrings[status.ErrorMode]);
1190 rpp_sci_printf("SlotMode: %s\r\n", SlotModeStrings[status.SlotMode]);
1191 rpp_sci_printf("StartupState: %s\r\n", StartupStateStrings[status.StartupState]);
1192 rpp_sci_printf("State: %s\r\n", StateStrings[status.State]);
1193 rpp_sci_printf("WakeupStatus: %s\r\n", WakeupStatusStrings[status.WakeupStatus]);
1196 rpp_sci_printf("General error.\r\n");
1197 return -CMDERR_BADCFG;
1203 * @brief Send given data through the FlexRay in selected slot.
1205 * @param[in] cmd_io Pointer to IO stack
1206 * @param[in] des Pointer to command descriptor
1207 * @param[in] param Parameters of command
1208 * @return 0 when OK or error code
1210 int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1212 int8_t retVal = ERR_PARAM_NO_ERROR;
1215 int values[MAX_PARAM_VALUES_NUM];
1216 uint8_t data[MAX_PARAM_VALUES_NUM];
1219 if (sscanf(param[1], "%d", &bufferID) != 1)
1220 return -CMDERR_BADPAR;
1221 if (sscanf(param[2], " %2x", &values[0]) != 1)
1222 return -CMDERR_BADPAR;
1223 data[0] = (uint8_t)values[0];
1224 token = strtok(param[2], " ");
1225 token = strtok(NULL, " ");
1227 while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
1228 if (sscanf(token, "%2x", &values[dataLength]) == EOF)
1230 data[dataLength] = (uint8_t)values[dataLength];
1231 token = strtok(NULL, " ");
1235 retVal = rpp_fr_transmit_lpdu(0, bufferID, data, dataLength);
1236 if (retVal == SUCCESS)
1237 rpp_sci_printf("Data were set for transmission.\r\n");
1239 rpp_sci_printf("General error.\r\n");
1240 return -CMDERR_BADCFG;
1246 * @brief Cancel the transmission in the selected slot.
1248 * @param[in] cmd_io Pointer to IO stack
1249 * @param[in] des Pointer to command descriptor
1250 * @param[in] param Parameters of command
1251 * @return 0 when OK or error code
1253 int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1255 int8_t retVal = ERR_PARAM_NO_ERROR;
1258 if (sscanf(param[1], "%d", &bufferID) != 1)
1259 return -CMDERR_BADPAR;
1260 if (param[2] != NULL)
1261 return -CMDERR_BADPAR;
1263 retVal = rpp_fr_cancel_transmit_lpdu(0, bufferID);
1264 if (retVal == SUCCESS)
1265 rpp_sci_printf("Transmission canceled.\r\n");
1267 rpp_sci_printf("General error.\r\n");
1268 return -CMDERR_BADCFG;
1274 * @brief Receive data from selected slot.
1276 * @param[in] cmd_io Pointer to IO stack
1277 * @param[in] des Pointer to command descriptor
1278 * @param[in] param Parameters of command
1279 * @return 0 when OK or error code
1281 int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1283 int8_t retVal = ERR_PARAM_NO_ERROR;
1285 uint8_t data[cPayloadLengthMax];
1286 Fr_RxLPduStatusType status;
1287 uint8_t receivedLength = 0;
1290 if (sscanf(param[1], "%d", &bufferID) != 1)
1291 return -CMDERR_BADPAR;
1292 if (param[2] != NULL)
1293 return -CMDERR_BADPAR;
1295 memset(data, 0, sizeof(data));
1297 retVal = rpp_fr_receive_lpdu(0, bufferID, data, &status, &receivedLength);
1298 if (retVal == SUCCESS) {
1300 case FR_RECEIVED_MORE_DATA_AVAILABLE:
1301 rpp_sci_printf("More messages are still in FIFO:\r\n");
1303 rpp_sci_printf("Received message (%d B):\r\n", receivedLength);
1304 for (i = 0; i < receivedLength; i++) {
1305 rpp_sci_printf(" %02x", data[i]);
1307 rpp_sci_printf("\r\n");
1310 rpp_sci_printf("No message received.\r\n");
1315 rpp_sci_printf("General error.\r\n");
1316 return -CMDERR_BADCFG;
1322 * @brief Returns TX LPdu status.
1324 * @param[in] cmd_io Pointer to IO stack
1325 * @param[in] des Pointer to command descriptor
1326 * @param[in] param Parameters of command
1327 * @return 0 when OK or error code
1329 int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1331 int8_t retVal = ERR_PARAM_NO_ERROR;
1333 Fr_TxLPduStatusType status;
1334 char *statusStrings[] = {"is not", "is"};
1336 if (sscanf(param[1], "%d", &bufferID) != 1)
1337 return -CMDERR_BADPAR;
1338 if (param[2] != NULL)
1339 return -CMDERR_BADPAR;
1341 retVal = rpp_fr_check_tx_lpdu_status(0, bufferID, &status);
1342 if (retVal == SUCCESS)
1343 rpp_sci_printf("Message transmission %s pending.\r\n", statusStrings[status]);
1345 rpp_sci_printf("General error.\r\n");
1346 return -CMDERR_BADCFG;
1352 * @brief Disable buffer.
1354 * @param[in] cmd_io Pointer to IO stack
1355 * @param[in] des Pointer to command descriptor
1356 * @param[in] param Parameters of command
1357 * @return 0 when OK or error code
1359 int cmd_do_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1361 int8_t retVal = ERR_PARAM_NO_ERROR;
1364 if (sscanf(param[1], "%d", &bufferID) != 1)
1365 return -CMDERR_BADPAR;
1366 if (param[2] != NULL)
1367 return -CMDERR_BADPAR;
1369 retVal = rpp_fr_disable_lpdu(0, bufferID);
1370 if (retVal == SUCCESS)
1371 rpp_sci_printf("Buffer disabled.\r\n");
1373 rpp_sci_printf("General error.\r\n");
1374 return -CMDERR_BADCFG;
1380 * @brief Print global time of the FlexRay network.
1382 * @param[in] cmd_io Pointer to IO stack
1383 * @param[in] des Pointer to command descriptor
1384 * @param[in] param Parameters of command
1385 * @return 0 when OK or error code
1387 int cmd_do_fr_getglobaltime(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1389 int8_t retVal = ERR_PARAM_NO_ERROR;
1391 uint16_t macroTick = 0;
1393 retVal = rpp_fr_get_global_time(0, &cycle, ¯oTick);
1394 if (retVal == SUCCESS)
1395 rpp_sci_printf("Cycle number: %d\r\nMacrotick number: %d\r\n", cycle, macroTick);
1397 rpp_sci_printf("General error.\r\n");
1398 return -CMDERR_BADCFG;
1404 * @brief Print network management vector of the FlexRay node.
1406 * @param[in] cmd_io Pointer to IO stack
1407 * @param[in] des Pointer to command descriptor
1408 * @param[in] param Parameters of command
1409 * @return 0 when OK or error code
1411 int cmd_do_fr_getnmvector(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1413 int8_t retVal = ERR_PARAM_NO_ERROR;
1414 uint8_t nmVector[12];
1417 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1418 if (retVal == SUCCESS) {
1419 rpp_sci_printf("Network management vector:");
1420 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1421 rpp_sci_printf(" %x", nmVector[i]);
1423 rpp_sci_printf("\r\n");
1426 rpp_sci_printf("General error.\r\n");
1427 return -CMDERR_BADCFG;
1432 int cmd_do_fr_nmwatch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1434 int8_t retVal = ERR_PARAM_NO_ERROR;
1435 uint8_t nmVector[12];
1438 // Calculate wait time in OS ticks
1439 static const portTickType freq_ticks = 100 /* ms */ / portTICK_RATE_MS;
1440 portTickType last_wake_time = xTaskGetTickCount();
1442 while (cmd_io->getc(cmd_io) < 0) {
1443 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1444 if (retVal == SUCCESS) {
1445 rpp_sci_printf("Network management vector:");
1446 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1447 rpp_sci_printf(" %02x", nmVector[i]);
1449 rpp_sci_printf("\r");
1452 rpp_sci_printf("General error.\r\n");
1453 return -CMDERR_BADCFG;
1455 vTaskDelayUntil(&last_wake_time, freq_ticks);
1457 rpp_sci_printf("\n");
1462 * @brief Print both channels status of the FlexRay node.
1464 * @param[in] cmd_io Pointer to IO stack
1465 * @param[in] des Pointer to command descriptor
1466 * @param[in] param Parameters of command
1467 * @return 0 when OK or error code
1469 int cmd_do_fr_getchannelstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1471 int8_t retVal = ERR_PARAM_NO_ERROR;
1474 char *decodeStrings[] = {
1475 "aggregated channel status vSS!ValidFrame",
1476 "aggregated channel status vSS!SyntaxError",
1477 "aggregated channel status vSS!ContentError",
1478 "aggregated channel status additional communication",
1479 "aggregated channel status vSS!Bviolation",
1480 "aggregated channel status vSS!TxConflict",
1483 "symbol window status data vSS!ValidMTS",
1484 "symbol window status data vSS!SyntaxError",
1485 "symbol window status data vSS!Bviolation",
1486 "symbol window status data vSS!TxConflict",
1487 "NIT status data vSS!SyntaxError",
1488 "NIT status data vSS!Bviolation",
1492 char *channelNames[] = {"A", "B"};
1493 char *boolStrings[] = {"FALSE", "TRUE"};
1494 uint16_t channelStatuses[2];
1496 retVal = rpp_fr_get_channel_status(0, &channelStatuses[0], &channelStatuses[1]);
1497 if (retVal == SUCCESS)
1498 for (channel = 0; channel < 2; channel++) {
1499 rpp_sci_printf("Channel %s status:\r\n", channelNames[channel]);
1500 for (index = 0; index < 16; index++) {
1501 rpp_sci_printf("\t%s: %s\r\n", decodeStrings[index], boolStrings[ (channelStatuses[channel] >> index) & 0x1 ] );
1505 rpp_sci_printf("General error.\r\n");
1506 return -CMDERR_BADCFG;
1512 * @brief Print clock correction of the FlexRay node
1514 * @param[in] cmd_io Pointer to IO stack
1515 * @param[in] des Pointer to command descriptor
1516 * @param[in] param Parameters of command
1517 * @return 0 when OK or error code
1519 int cmd_do_fr_getclockcorrection(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1521 int8_t retVal = ERR_PARAM_NO_ERROR;
1522 int16_t rateCorrection;
1523 int32_t offsetCorrection;
1525 retVal = rpp_fr_get_clock_correction(0, &rateCorrection, &offsetCorrection);
1526 if (retVal == SUCCESS)
1527 rpp_sci_printf("Rate correction: %d\r\nOffset correction: %d\r\n", rateCorrection, offsetCorrection);
1529 rpp_sci_printf("General error.\r\n");
1530 return -CMDERR_BADCFG;
1536 * @brief Print list of syncframec transmitted on both channels via the even and odd cycle.
1538 * @param[in] cmd_io Pointer to IO stack
1539 * @param[in] des Pointer to command descriptor
1540 * @param[in] param Parameters of command
1541 * @return 0 when OK or error code
1543 int cmd_do_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1545 int8_t retVal = ERR_PARAM_NO_ERROR;
1546 uint16_t channelAEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1547 uint16_t channelBEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1548 uint16_t channelAOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1549 uint16_t channelBOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1550 uint32_t listSize = 0;
1553 if (sscanf(param[1], "%d", &listSize) != 1)
1554 return -CMDERR_BADPAR;
1555 if (param[2] != NULL)
1556 return -CMDERR_BADPAR;
1557 if (listSize > FR_MAX_SYNC_FRAME_LIST_SIZE)
1558 return -CMDERR_BADPAR;
1560 retVal = rpp_fr_get_sync_frame_list(0, listSize, channelAEvenList, channelBEvenList, channelAOddList, channelBOddList);
1561 if (retVal == SUCCESS) {
1562 rpp_sci_printf("| Channel A even | channel B even | channel A odd | channel B odd |\r\n");
1563 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1564 for (i = 0; i < listSize; i++) {
1565 rpp_sci_printf("| %-14x | %-14x | %-14x | %-14x |\r\n", channelAEvenList[i], channelBEvenList[i], channelAOddList[i], channelBOddList[i]);
1567 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1571 rpp_sci_printf("General error.\r\n");
1572 return -CMDERR_BADCFG;
1578 * @brief Print status of wakeup on each channels (wakeup received on channel or not yet received).
1580 * @param[in] cmd_io Pointer to IO stack
1581 * @param[in] des Pointer to command descriptor
1582 * @param[in] param Parameters of command
1583 * @return 0 when OK or error code
1585 int cmd_do_fr_getwakeuprxstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1587 int8_t retVal = ERR_PARAM_NO_ERROR;
1589 char *statusStrings[] = {"was not yet", "was"};
1590 char *channelNames[] = {"A", "B"};
1593 retVal = rpp_fr_get_wakeup_rx_status(0, &status);
1594 if (retVal == SUCCESS)
1595 for (i = 0; i < 2; i++) {
1596 rpp_sci_printf("Wake up pattern %s received on channel %s.\r\n", statusStrings[(status >> i) & 0x1], channelNames[i]);
1599 rpp_sci_printf("General error.\r\n");
1600 return -CMDERR_BADCFG;
1606 * @brief Set and start absolute timer.
1608 * @param[in] cmd_io Pointer to IO stack
1609 * @param[in] des Pointer to command descriptor
1610 * @param[in] param Parameters of command
1611 * @return 0 when OK or error code
1613 int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1615 int8_t retVal = ERR_PARAM_NO_ERROR;
1620 if (sscanf(param[1], "%i %i %i", &timer, &cycle, &offset) != 3)
1621 return -CMDERR_BADPAR;
1623 retVal = rpp_fr_set_timer(0, timer, cycle, offset);
1624 if (retVal == SUCCESS) {
1626 while (i && (cycle & i) == 0)
1631 rpp_sci_printf("Timer was set for every %d-th cycle, offset %d, macrotick %d\n",
1632 i, cycle & ~i, offset);
1635 rpp_sci_printf("General error.\r\n");
1636 return -CMDERR_BADCFG;
1642 * @brief Cancel selected timer
1644 * @param[in] cmd_io Pointer to IO stack
1645 * @param[in] des Pointer to command descriptor
1646 * @param[in] param Parameters of command
1647 * @return 0 when OK or error code
1649 int cmd_do_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1651 int8_t retVal = ERR_PARAM_NO_ERROR;
1654 if (sscanf(param[1], "%d", &timer) != 1)
1655 return -CMDERR_BADPAR;
1657 if (param[2] != NULL)
1658 return -CMDERR_BADPAR;
1660 retVal = rpp_fr_cancel_timer(0, timer);
1661 if (retVal == SUCCESS)
1662 rpp_sci_printf("Timer was canceled.\r\n");
1664 rpp_sci_printf("General error.\r\n");
1665 return -CMDERR_BADCFG;
1671 * @brief Enable/disable, acknowledge, get timer IRQ
1673 * @param[in] cmd_io Pointer to IO stack
1674 * @param[in] des Pointer to command descriptor
1675 * @param[in] param Parameters of command
1676 * @return 0 when OK or error code
1678 int cmd_do_fr_timerirq(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1680 int8_t retVal = ERR_PARAM_NO_ERROR;
1683 boolean_t status = FALSE;
1684 char *boolStrings[] = {"FALSE", "TRUE"};
1687 if (sscanf(param[1], "%d", &timer) != 1)
1688 return -CMDERR_BADPAR;
1690 if (param[2] == NULL) { // Get timer IRQ
1691 retVal = rpp_fr_get_timer_irq_status(0, timer, &status);
1692 if (retVal == SUCCESS)
1693 rpp_sci_printf("IRQ = %s\r\n", boolStrings[status]);
1695 rpp_sci_printf("General error.\r\n");
1696 return -CMDERR_BADCFG;
1699 else { // Some set action
1700 if (sscanf(param[2], "%4s", str) != 1)
1701 return -CMDERR_BADPAR;
1702 if (strcmp(str, "EN") == 0) // Enable IRQ
1703 retVal = SUCCESS; // No interrupts imlemented
1704 else if (strcmp(str, "DIS") == 0) // Disable IRQ
1705 retVal = SUCCESS; // No interrupts implemented
1706 else if (strcmp(str, "ACK") == 0) // Clear IRQ
1707 retVal = rpp_fr_clear_timer_irq(0, timer);
1708 else // Bad argument
1709 return -CMDERR_BADPAR;
1711 if (retVal == SUCCESS)
1712 rpp_sci_printf("OK\r\n");
1714 rpp_sci_printf("General error.\r\n");
1715 return -CMDERR_BADCFG;
1722 * @brief Print FlexRay driver version info.
1724 * @param[in] cmd_io Pointer to IO stack
1725 * @param[in] des Pointer to command descriptor
1726 * @param[in] param Parameters of command
1727 * @return 0 when OK or error code
1729 int cmd_do_fr_getversioninfo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1731 Std_VersionInfoType versionInfo;
1733 rpp_fr_get_driver_version(&versionInfo);
1734 rpp_sci_printf("vendorID: %#x\r\n", versionInfo.vendorID);
1735 rpp_sci_printf("moduleID: %#x\r\n", versionInfo.moduleID);
1736 rpp_sci_printf("sw_major_version: %#x\r\n", versionInfo.sw_major_version);
1737 rpp_sci_printf("sw_minor_version: %#x\r\n", versionInfo.sw_minor_version);
1738 rpp_sci_printf("sw_patch_version: %#x\r\n", versionInfo.sw_patch_version);
1744 * @brief Print value of FlexRay configuratoin parameter.
1746 * @param[in] cmd_io Pointer to IO stack
1747 * @param[in] des Pointer to command descriptor
1748 * @param[in] param Parameters of command
1749 * @return 0 when OK or error code
1751 int cmd_do_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1753 int8_t retVal = ERR_PARAM_NO_ERROR;
1757 if (sscanf(param[1], "%d", &index) != 1)
1758 return -CMDERR_BADPAR;
1760 if (param[2] != NULL)
1761 return -CMDERR_BADPAR;
1763 retVal = rpp_fr_read_com_ctrl_config(0, index, &value);
1764 if (retVal == SUCCESS)
1765 rpp_sci_printf("Value = %#x\r\n", value);
1767 rpp_sci_printf("General error.\r\n");
1768 return -CMDERR_BADCFG;
1774 * @brief Reconfigure buffer
1776 * @param[in] cmd_io Pointer to IO stack
1777 * @param[in] des Pointer to command descriptor
1778 * @param[in] param Parameters of command
1779 * @return 0 when OK or error code
1781 int cmd_do_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1785 unsigned bufferID, slot, maxpayload, cycleset, cycleoffset;
1786 Fr_TMS570LS_BufferConfigType tmp_buffer;
1790 ret = sscanf(param[2], "id%i slot%i %2s cycset%i cycoffset%i max%i",
1799 printf("Error parsing parameter %d\n", ret+1);
1800 return -CMDERR_BADPAR;
1803 if (slot > 2047 || bufferID > FR_MAX_BUFFERS_CNT)
1804 return badpar("Invalid slot number\n");
1805 tmp_buffer.slotId = slot;
1806 if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
1807 else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
1808 else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
1809 else return badpar("Channel parsing error\n");
1810 if (cycleset == 0) cycleset = 1;
1811 for (pow2 = 1, is_pow2 = FALSE; pow2 < 128; pow2 *= 2) {
1812 if (cycleset == pow2) {
1818 return badpar("Cycle set must be one of 0, 1, 2, 4, 8, 16, 32, 64.\n");
1819 if (cycleoffset >= cycleset)
1820 return badpar("Cycle offset must in range 0 - cycset-1.\n");
1822 if (maxpayload >= 256)
1823 return badpar("Maximum payload in bytes must be less than 256\n");
1824 tmp_buffer.maxPayload = maxpayload;
1826 if (rpp_fr_reconfigure_lpdu(0, bufferID, tmp_buffer.slotId, tmp_buffer.channel, cycleset, cycleoffset, tmp_buffer.maxPayload, 0) == SUCCESS) {
1827 printf("id%i slot%i %2s cycset%i cycoffset%i max%i\n",
1838 printf("Reconfiguration failed.\n");
1839 return -CMDERR_BADPAR;
1844 /** Command descriptor for FlexRay user config cluster command */
1845 cmd_des_t const cmd_des_fr_user_config = {
1847 "frbtconfig*","Set the user configuration parameters",
1848 "### Command syntax ###\n"
1850 " frbtconfig<TYPE> <PARAMS>\n"
1853 "- `<TYPE>` is a string specifying the type of parameters to be set. It can be: \"cluster\" or \"node\"\n"
1854 "- `<PARAMS>` is a sequence of numbers separated by spaces. Each number stands for one parameter.\n"
1856 "### Description ###\n"
1858 "The command takes the configuration parameters in the form of a string\n"
1859 "and sets the appropriate type of the FlexRay parameters. It is\n"
1860 "necessary to configure parameters of at least cluster, and node and\n"
1861 "one static buffer (see frbtcfgbuf command). The parameters set by this\n"
1862 "command are applied by the frbtinitU command. Once frbtinit is called,\n"
1863 "it is no longer possible to change the parameters.\n"
1865 "The type of the parameters can be selected by the `<TYPE>` selector.\n"
1867 "Type \"cluster\" sets global FlexRay network parameters. It expects a\n"
1868 "sequence of 25 parameters in this order:\n"
1870 "- 1) gColdStartAttempts\n"
1871 "- 2) gListenNoise\n"
1872 "- 3) gMacroPerCycle\n"
1873 "- 4) gMaxWithoutClockCorrectionFatal\n"
1874 "- 5) gMaxWithoutClockCorrectionPassive\n"
1875 "- 6) gNetworkManagementVectorLength\n"
1876 "- 7) gNumberOfMinislots\n"
1877 "- 8) gNumberOfStaticSlots\n"
1878 "- 9) gOffsetCorrectionStart\n"
1879 "- 10) gPayloadLengthStatic\n"
1880 "- 11) gSyncNodeMax\n"
1881 "- 12) gdActionPointOffset\n"
1882 "- 13) gdCASRxLowMax\n"
1883 "- 14) gdDynamicSlotIdlePhase\n"
1884 "- 15) gdMinislot\n"
1885 "- 16) gdMinislotActionPointOffset\n"
1887 "- 18) gdSampleClockPeriod\n"
1888 "- 19) gdStaticSlot\n"
1889 "- 20) gdTSSTransmitter\n"
1890 "- 21) gdWakeupSymbolRxIdle\n"
1891 "- 22) gdWakeupSymbolRxLow\n"
1892 "- 23) gdWakeupSymbolRxWindow\n"
1893 "- 24) gdWakeupSymbolTxIdle\n"
1894 "- 25) gdWakeupSymbolTxLow\n"
1896 "Type \"node\" sets local FlexRay network parameters. It expects a\n"
1897 "sequence of 28 parameters in this order:\n"
1899 "- 1) pAllowHaltDueToClock\n"
1900 "- 2) pAllowPassiveToActive\n"
1901 "- 3) pChannels (0 - A, 1 - B, 2 - AB)\n"
1902 "- 4) pClusterDriftDamping\n"
1903 "- 5) pDelayCompensationA\n"
1904 "- 6) pDelayCompensationB\n"
1905 "- 7) pExternOffsetCorrection\n"
1906 "- 8) pExternRateCorrection\n"
1907 "- 9) pKeySlotUsedForStartup\n"
1908 "- 10) pKeySlotUsedForSync\n"
1910 "- 12) pMacroInitialOffsetA\n"
1911 "- 13) pMacroInitialOffsetB\n"
1912 "- 14) pMicroInitialOffsetA\n"
1913 "- 15) pMicroInitialOffsetB\n"
1914 "- 16) pMicroPerCycle\n"
1915 "- 17) pRateCorrectionOut\n"
1916 "- 18) pOffsetCorrectionOut\n"
1917 "- 19) pSamplesPerMicrotick\n"
1918 "- 20) pSingleSlotEnabled\n"
1919 "- 21) pWakeupChannel (0 - A, 1 - B)\n"
1920 "- 22) pWakeupPattern\n"
1921 "- 23) pdAcceptedStartupRange\n"
1922 "- 24) pdListenTimeout\n"
1923 "- 25) pdMaxDrift\n"
1924 "- 26) pDecodingCorrection\n"
1925 "- 27) syncFramePayloadMultiplexEnabled\n"
1926 "- 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"
1930 " --> 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"
1931 " FlexRay cluster configuration accepted.\n"
1932 " --> 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"
1933 " FlexRay node configuration accepted.\n",
1934 CMD_HANDLER(cmd_do_fr_user_config), (void *)&cmd_list_fr_basic_test
1937 cmd_des_t const cmd_des_fr_config_buffer = {
1939 "frbtcfgbuf?*","Configure a message buffer in the user configuration",
1940 "### Command syntax ###\n"
1942 " frbtcfgbuf<TYPE><BUFID> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\n"
1945 "- `<TYPE>` is 'S' for static segment buffers and 'D' for dynamic segment buffers,\n"
1946 "- `<BUFID>` is the number of the buffer. Both static and dynamic buffers are numbered independently starting from zero,\n"
1947 "- `<SLOT>` is the number of the slot,\n"
1948 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1949 "- `<CYC>` is the cycle set when to send the buffer,\n"
1950 "- `<RXTX>` is either string \"rx\" or \"tx\",\n"
1951 "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1952 "- `<REP>` is a string \"s\" or \"single\" for single transmission or \"c\" or \"continuous\" for continuous transmission,\n"
1953 "- `<PPI>` is 0 or 1 determining whether the payload preamble indicator is set,\n"
1954 "- `<INT>` is 0 or 1 and is currently ignored.\n"
1956 "### Description ###\n"
1958 "The command sets the configuration parameters for static or dynamic\n"
1959 "buffers in user configuration. The parameters set by this command are\n"
1960 "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1961 "longer possible to change the parameters.\n"
1965 " --> frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1966 " frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1967 " --> frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1968 " frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1969 " --> frbtcfgbufD0 slot9 A cyc0 rx max0x40 single ppi0 int0\n"
1970 " frbtcfgbufD0 slot9 A cyc0 rx max64 single ppi0 int0\n"
1971 " --> frbtcfgbufD1 slot10 A cyc0 tx max0x40 single ppi0 int0\n"
1972 " frbtcfgbufD1 slot10 A cyc0 tx max64 single ppi0 int0\n",
1973 CMD_HANDLER(cmd_do_fr_config_bufer), (void *)&cmd_list_fr_basic_test
1976 cmd_des_t const cmd_des_fr_config_fifo = {
1978 "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
1979 "### Command syntax ###\n"
1981 " frbtcfgfifo rejslot<SLOT> slotmask<MASK> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT>\n"
1983 "- `<SLOT>` is the number of the slot that will be rejected. If it is 0, no slot will be rejected,\n"
1984 "- `<MASK>` is a number specifying which bits of the `<SLOT>` will be ignored,"
1985 "- `<DEPTH>` is a number specifying the depth of the FIFO,\n"
1986 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1987 "- `<CYC>` is the cycle set when to send the buffer,\n"
1988 "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1989 "- `<REJNULL>` is a string \"rejnull\" for rejecting NULL frames or \"accnull\" for accepting NULL frames,\n"
1990 "- `<REJSTAT>` is a string \"rejstat\" for rejecting frames in static segment or \"accstat\" for accepting frames from static segment,\n"
1992 "### Description ###\n"
1994 "The command sets the configuration parameters for RX FIFO buffer\n"
1995 "in user configuration. The parameters set by this command are\n"
1996 "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1997 "longer possible to change the parameters.\n"
1998 "Those messages, which are not accepted by any other buffer and pass the\n"
1999 "FIFO rejection filter will be stored in the RX FIFO buffer.\n"
2003 " --> frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n"
2004 " frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n",
2005 CMD_HANDLER(cmd_do_fr_config_fifo), (void *)&cmd_list_fr_basic_test
2008 /** Command descriptor for FlexRay init command */
2009 cmd_des_t const cmd_des_fr_init = {
2011 "frbtinit?","Initialize a FlexRay node",
2012 "### Command syntax ###\n"
2016 "where `<CFG>` identifies the configuration to use. It can be one of A, B\n"
2017 "or U. The A and B are predefined configurations. If U is specified,\n"
2018 "the user configuration previously set by frbtconfig command is used.\n"
2020 "### Description ###\n"
2022 "The command stands for Fr_Init and Fr_ControllerInit functions from\n"
2023 "the Autosar specification. It initializes the internal data structures\n"
2024 "of the driver and then, based on those data, the controller\n"
2025 "configuration is done. During the controller configuration the\n"
2026 "parameters of the cluster, node, message RAM and buffers are checked.\n"
2027 "If anything goes bad, the command returns an error number, which can\n"
2028 "be decoded by macros defined in driver header file fr_tms570.h with\n"
2029 "prefix ERR_PARAM. If all parameters are OK, all necessary registers of\n"
2030 "the controller are initialized according to the specified\n"
2031 "configuration parameters. At the end of the command, the FlexRay\n"
2032 "controller is switched into READY state and all buffers are configured\n"
2033 "to send NULL frames. This command should be called as the very first\n"
2034 "command, when trying to communicate over the FlexRay bus.\n"
2039 " FlexRay driver initialized.\n"
2040 " FlexRay controller initialized.\n",
2041 CMD_HANDLER(cmd_do_fr_init), (void *)&cmd_list_fr_basic_test
2044 /** Command descriptor for FlexRay controller init command */
2045 cmd_des_t const cmd_des_fr_start = {
2047 "frbtstart","Start a new FlexRay network or join to the existing one",
2048 "### Command syntax ###\n"
2052 "### Description ###\n"
2054 "The command stands for Fr_StartCommunication function from the Autosar\n"
2056 "If the FlexRay node is configured as a coldstarter node\n"
2057 "(as for example by frbtinitA/B command), then the command first listen\n"
2058 "on the bus. When it does not detect any existing bus communication, it\n"
2059 "tries to initiate a new network. If the initiation fails, the FlexRay\n"
2060 "controller is switched back to the ready state for another attempt\n"
2061 "(calling frbtstart again). If the FlexRay node is configured as\n"
2062 "non-coldstarter, it is listening on the bus until some existing\n"
2063 "communication is detected.\n"
2065 "The command should be called after the frbtinit command.\n"
2067 "You may also want to call frbtallslots command to allow the communication\n"
2068 "for all other slots besides the key slots.\n"
2073 " FlexRay communication is running.\n",
2074 CMD_HANDLER(cmd_do_fr_start), (void *)&cmd_list_fr_basic_test
2077 /** Command descriptor for FlexRay controller all slots command */
2078 cmd_des_t const cmd_des_fr_allslots = {
2080 "frbtallslots","Enables communication for all frames",
2081 "### Command syntax ###\n"
2085 "### Description ###\n"
2087 "The command stands for Fr_AllSlots function from the Autosar\n"
2090 "The node can be configured to communicate only on key frames by\n"
2091 "default (as in the case of frbtinitA/B). This command can be used to\n"
2092 "allow the communication on all configured frames. The command invokes\n"
2093 "the FlexRay POC command ALL_SLOTS which enables the communication on\n"
2094 "all frames. The command can be called after the controller\n"
2099 " --> frbtallslots\n"
2100 " FlexRay node started communication on all slots.\n",
2101 CMD_HANDLER(cmd_do_fr_allslots), (void *)&cmd_list_fr_basic_test
2104 /** Command descriptor for FlexRay controller halt command */
2105 cmd_des_t const cmd_des_fr_halt = {
2107 "frbthalt","Halt FlexRay communication after the end of the actual communication cycle",
2108 "### Command syntax ###\n"
2112 "### Description ###\n"
2114 "The command stands for Fr_HaltCommunication function from the Autosar\n"
2115 "specification. The command invokes the FlexRay POC command HALT, which\n"
2116 "means that communication is stopped after the end of the actual\n"
2117 "communication cycle. On the opposite side, there is a frbtfreeze\n"
2118 "command, which stops the communication immediately. To restart the\n"
2119 "communication, the frbtinit and frbtstart commands have to be called.\n"
2124 " FlexRay node communication halted.\n",
2125 CMD_HANDLER(cmd_do_fr_halt), (void *)&cmd_list_fr_basic_test
2128 /** Command descriptor for FlexRay controller abort command */
2129 cmd_des_t const cmd_des_fr_abort = {
2131 "frbtabort","Abort FlexRay communication immediately",
2132 "### Command syntax ###\n"
2136 "### Description ###\n"
2138 "The command stands for Fr_AbortCommunication function from the Autosar\n"
2139 "specification. The command invokes the FlexRay POC command FREEZE,\n"
2140 "which means that the communication is stopped immediately. On the\n"
2141 "opposite side there is a frbthalt command, which stops the\n"
2142 "communication after the end of the actual communication cycle. To\n"
2143 "restart the communication, the frbtinit and frbtstart commands have\n"
2149 " FlexRay node communication aborted.\n",
2150 CMD_HANDLER(cmd_do_fr_abort), (void *)&cmd_list_fr_basic_test
2153 /** Command descriptor for FlexRay controller send wake up pattern command */
2154 cmd_des_t const cmd_des_fr_sendwup = {
2156 "frbtwup","Initiate the wake up procedure",
2157 "### Command syntax ###\n"
2161 "### Description ###\n"
2163 "The command stands for Fr_SendWUP function from the Autosar\n"
2164 "specification. It initiates the wake up procedure by switching FlexRay\n"
2165 "controller state machine to WAKEUP state.\n"
2170 " Wake up pattern has been sent.\n",
2171 CMD_HANDLER(cmd_do_fr_sendwup), (void *)&cmd_list_fr_basic_test
2174 /** Command descriptor for FlexRay controller sent wake up pattern channel command */
2175 cmd_des_t const cmd_des_fr_setwuchannel = {
2177 "frbtsetwuch?","Set wake up channel",
2178 "### Command syntax ###\n"
2180 " frbtsetwuch<CHANNEL>\n"
2182 "where `<CHANNEL>` is a character A or B, specifying the channel.\n"
2184 "### Description ###\n"
2186 "The command stands for Fr_SetWakeupChannel function from the Autosar\n"
2187 "specification. Wake up channel is the channel, where Wake Up Pattern\n"
2188 "is sent. The channel can be set after the driver and controller are\n"
2189 "initialized and before the communication is running. The actual\n"
2190 "wake-up pattern is sent by the frbtwup command.\n"
2194 " --> frbtsetwuchA\n"
2195 " Wake up channel has been set.\n",
2196 CMD_HANDLER(cmd_do_fr_setwuchannel), (void *)&cmd_list_fr_basic_test
2199 /** Command descriptor for FlexRay controller get POC status command */
2200 cmd_des_t const cmd_des_fr_getpocstatus = {
2202 "frbtgetpocst","Print FlexRay POC status",
2203 "### Command syntax ###\n"
2207 "### Description ###\n"
2209 "The command stands for Fr_GetPOCStatus function from the Autosar\n"
2210 "specification. It prints the main FlexRay POC status values in the\n"
2211 "form of a table. The command should be called after the frbtinit\n"
2216 " --> frbtgetpocst\n"
2218 " CHIHaltRequest: FALSE\n"
2219 " CHIReadyRequest: FALSE\n"
2220 " ColdstartNoise: FALSE\n"
2222 " ErrorMode: ACTIVE\n"
2224 " StartupState: UNDEFINED\n"
2226 " WakeupStatus: UNDEFINED\n",
2227 CMD_HANDLER(cmd_do_fr_getpocstatus), (void *)&cmd_list_fr_basic_test
2230 /** Command descriptor for FlexRay transmit tx lpdu command */
2231 cmd_des_t const cmd_des_fr_transmittxlpdu = {
2233 "frbttransmit*","Transmit data from the selected frame buffer",
2234 "### Command syntax ###\n"
2236 " frbttransmit<BUFID> <DATA>\n"
2239 "- `<BUFID>` is a decimal number specifying the ID of the frame\n"
2240 " buffer configured for data transmission\n"
2241 "- `<DATA>` is a sequence of hexadecimal numbers separated by spaces.\n"
2242 " Each number represents one byte of the message.\n"
2244 "### Description ###\n"
2246 "The command stands for Fr_TransmitTxLPdu function from the Autosar\n"
2247 "specification. The command copies the given data into the buffers data\n"
2248 "section in the message RAM. Transmit request is set after the data are\n"
2249 "copied, so transmission starts at the next occurrence of the frame in the\n"
2250 "communication cycle.\n"
2254 " --> frbttransmit1 12 34 56 AA BB CC\n"
2255 " Data were set for transmission.\n",
2256 CMD_HANDLER(cmd_do_fr_transmittxlpdu), (void *)&cmd_list_fr_basic_test
2259 /** Command descriptor for FlexRay cancel tx lpdu command */
2260 cmd_des_t const cmd_des_fr_canceltxlpdu = {
2262 "frbtcanceltx*","Stop the transmission from the frame buffer",
2263 "### Command syntax ###\n"
2265 " frbtcanceltx<BUFID>\n"
2267 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2270 "### Description ###\n"
2272 "The command stands for Fr_CancelTxLPdu function from the Autosar\n"
2273 "specification. The command reconfigures the selected buffer to stop\n"
2274 "data transmission. The command finishes successfully only if the\n"
2275 "reconfiguration is allowed in message RAM configuration (secureBuffers\n"
2276 "configuration parameter). Only TX buffers and buffers not used for startup\n"
2277 "frames can be canceled.\n"
2281 " --> frbtcanceltx3\n"
2282 " Transmission canceled.\n",
2283 CMD_HANDLER(cmd_do_fr_canceltxlpdu), (void *)&cmd_list_fr_basic_test
2286 /** Command descriptor for FlexRay receive rx lpdu command */
2287 cmd_des_t const cmd_des_fr_receiverxlpdu = {
2289 "frbtreceive*","Receive a new message",
2290 "### Command syntax ###\n"
2292 " frbtreceive<BUFID>\n"
2294 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2297 "### Description ###\n"
2299 "The command stands for Fr_ReceiveRxLPdu function from the Autosar\n"
2300 "specification. The command tries to read a new message from the selected\n"
2301 "buffer. If new message is available, it is copied out of the buffer and\n"
2302 "printed. If no message is available, \"No message received\" is printed.\n"
2303 "If a new message was retrieved from a FIFO buffer and more messages are\n"
2304 "available in it, \"More messages are still in FIFO\" is printed.\n"
2308 " --> frbtreceive0\n"
2309 " More messages are still in FIFO:\n"
2310 " Received message (32 B):\n"
2311 " ee ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n"
2312 " 00 00 00 00 00 00 00 00 00\n",
2313 CMD_HANDLER(cmd_do_fr_receiverxlpdu), (void *)&cmd_list_fr_basic_test
2316 /** Command descriptor for FlexRay check TX LPdu status command */
2317 cmd_des_t const cmd_des_fr_checktxlpdustatus = {
2319 "frbtchecktx*","Print the status of the transmit buffer",
2320 "### Command syntax ###\n"
2322 " frbtchecktx<BUFID>\n"
2324 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2327 "### Description ###\n"
2329 "The command stands for Fr_CheckTxLPduStatus function from the Autosar\n"
2330 "specification. The command reads and prints status of the selected frame buffer.\n"
2331 "The buffer can be in one of the two states:\n"
2333 "- Message transmission is pending, which means that the buffer has not yet sent its\n"
2334 " message in single shot mode or that it is in continuous mode.\n"
2335 "- No message transmission is pending, which means that the buffer is in single shot\n"
2336 " mode and the message has already been sent.\n"
2340 " --> frbtchecktx1\n"
2341 " Message transmission is not pending.\n",
2342 CMD_HANDLER(cmd_do_fr_checktxlpdustatus), (void *)&cmd_list_fr_basic_test
2345 /** Command descriptor for FlexRay disable LPdu command */
2346 cmd_des_t const cmd_des_fr_disablelpdu = {
2348 "frbtdisable*","Disable the buffers assigned to the frame",
2349 "### Command syntax ###\n"
2351 " frbtdisable<BUFID>\n"
2353 "where `<BUFID>` is a decimal number specifying the ID of a frame buffer.\n"
2354 "The buffer configured will be disabled.\n"
2356 "### Description ###\n"
2358 "The command stands for Fr_DisableLPdu function from the Autosar\n"
2359 "specification. The command disables the selected buffer. This means\n"
2360 "that this buffer will be unavailable for the communication until\n"
2361 "their reconfiguration (which is not yet implemented). Buffers used\n"
2362 "for startup frames and FIFO RX buffers cannot be disabled.\n"
2366 " --> frbtdisable3\n"
2367 " Buffer disabled.\n",
2368 CMD_HANDLER(cmd_do_fr_disablelpdu), (void *)&cmd_list_fr_basic_test
2371 /** Command descriptor for FlexRay get global time command */
2372 cmd_des_t const cmd_des_fr_getglobaltime = {
2374 "frbtglobtime","Print actual global time of the network",
2375 "### Command syntax ###\n"
2379 "### Description ###\n"
2381 "The command stands for Fr_GetGlobalTime function from the Autosar\n"
2382 "specification. The command prints the time as a number of the current\n"
2383 "cycle and the offset in the cycle in macroticks.\n"
2387 " --> frbtglobtime\n"
2388 " Cycle number: 23\n"
2389 " Macrotick number: 6\n",
2390 CMD_HANDLER(cmd_do_fr_getglobaltime), (void *)&cmd_list_fr_basic_test
2393 /** Command descriptor for FlexRay get network management vector command */
2394 cmd_des_t const cmd_des_fr_getnmvector = {
2396 "frbtnmvector","Print network management vector of the node",
2397 "### Command syntax ###\n"
2401 "### Description ###\n"
2403 "The command stands for Fr_GetNmVector function from the Autosar\n"
2404 "specification. It prints the values of the network management vector\n"
2405 "as hexadecimal numbers.\n"
2409 " --> frbtnmvector\n"
2410 " Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2411 CMD_HANDLER(cmd_do_fr_getnmvector), (void *)&cmd_list_fr_basic_test
2414 /** Command descriptor for FlexRay get network management vector command */
2415 cmd_des_t const cmd_des_fr_nmwatch = {
2417 "frbtnmwatch","Watch the changes of the network managment vector in real-time",
2418 "### Command syntax ###\n"
2422 "### Description ###\n"
2424 "Reads the network management vector every 100 ms and prints it out.\n"
2428 " --> frbtnmwatch\n"
2429 " Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2430 CMD_HANDLER(cmd_do_fr_nmwatch), (void *)&cmd_list_fr_basic_test
2433 /** Command descriptor for FlexRay get channel status command */
2434 cmd_des_t const cmd_des_fr_getchannelstatus = {
2436 "frbtchstat","Print channel A and B status",
2437 "### Command syntax ###\n"
2441 "### Description ###\n"
2443 "The command stands for Fr_GetChannelStatus function from the Autosar\n"
2449 " Channel A status:\n"
2450 " aggregated channel status vSS!ValidFrame: TRUE\n"
2451 " aggregated channel status vSS!SyntaxError: FALSE\n"
2452 " aggregated channel status vSS!ContentError: FALSE\n"
2453 " aggregated channel status additional communication: FALSE\n"
2454 " aggregated channel status vSS!Bviolation: FALSE\n"
2455 " aggregated channel status vSS!TxConflict: FALSE\n"
2456 " Not used (0): FALSE\n"
2457 " Not used (0): FALSE\n"
2458 " symbol window status data vSS!ValidMTS: FALSE\n"
2459 " symbol window status data vSS!SyntaxError: FALSE\n"
2460 " symbol window status data vSS!Bviolation: FALSE\n"
2461 " symbol window status data vSS!TxConflict: FALSE\n"
2462 " NIT status data vSS!SyntaxError: FALSE\n"
2463 " NIT status data vSS!Bviolation: FALSE\n"
2464 " Not used (0): FALSE\n"
2465 " Not used (0): FALSE\n"
2466 " Channel B status:\n"
2467 " aggregated channel status vSS!ValidFrame: TRUE\n"
2468 " aggregated channel status vSS!SyntaxError: FALSE\n"
2469 " aggregated channel status vSS!ContentError: FALSE\n"
2470 " aggregated channel status additional communication: FALSE\n"
2471 " aggregated channel status vSS!Bviolation: FALSE\n"
2472 " aggregated channel status vSS!TxConflict: FALSE\n"
2473 " Not used (0): FALSE\n"
2474 " Not used (0): FALSE\n"
2475 " symbol window status data vSS!ValidMTS: FALSE\n"
2476 " symbol window status data vSS!SyntaxError: FALSE\n"
2477 " symbol window status data vSS!Bviolation: FALSE\n"
2478 " symbol window status data vSS!TxConflict: FALSE\n"
2479 " NIT status data vSS!SyntaxError: FALSE\n"
2480 " NIT status data vSS!Bviolation: FALSE\n"
2481 " Not used (0): FALSE\n"
2482 " Not used (0): FALSE\n",
2483 CMD_HANDLER(cmd_do_fr_getchannelstatus), (void *)&cmd_list_fr_basic_test
2486 /** Command descriptor for FlexRay get clock correction command */
2487 cmd_des_t const cmd_des_fr_getclockcorrection = {
2489 "frbtclkcor","Print clock correction (rate and offset)",
2490 "### Command syntax ###\n"
2494 "### Description ###\n"
2496 "The command stands for Fr_GetClockCorrection function from the Autosar\n"
2502 " Rate correction: 0\n"
2503 " Offset correction: 0\n",
2504 CMD_HANDLER(cmd_do_fr_getclockcorrection), (void *)&cmd_list_fr_basic_test
2507 /** Command descriptor for FlexRay get sync frame list command */
2508 cmd_des_t const cmd_des_fr_getsyncframelist = {
2510 "frbtgetsyncfrlist*","Print the list of sync frames transmitted on both channels via the odd and even communication cycle",
2511 "### Command syntax ###\n"
2513 " frbtgetsyncfrlist<LENGTH>\n"
2515 "where `<LENGTH>` is a decimal number in range 0 - 15, specifying the\n"
2516 "length of the list to be printed.\n"
2518 "### Description ###\n"
2520 "The command stands for Fr_GetSyncFrameList function from the Autosar\n"
2525 " --> frbtgetsyncfrlist2\n"
2526 " | Channel A even | channel B even | channel A odd | channel B odd |\n"
2527 " |----------------|----------------|----------------|----------------|\n"
2528 " | 1 | 1 | 1 | 1 |\n"
2529 " | 2 | 2 | 2 | 2 |\n"
2530 " |----------------|----------------|----------------|----------------|\n",
2531 CMD_HANDLER(cmd_do_fr_getsyncframelist), (void *)&cmd_list_fr_basic_test
2534 /** Command descriptor for FlexRay get sync frame list command */
2535 cmd_des_t const cmd_des_fr_getwakeuprxstatus = {
2537 "frbtgetwurxstat","Prints whether the wake up pattern has been or has not been received",
2538 "### Command syntax ###\n"
2540 " frbtgetwurxstat\n"
2542 "### Description ###\n"
2544 "The command stands for Fr_GetWakeupRxStatus function from the Autosar\n"
2545 "specification. The status of the wake up receiving is bitcoded in the\n"
2546 "controller. This command decodes and prints it in a readable format.\n"
2550 " --> frbtgetwurxstat\n"
2551 " Wake up pattern was not yet received on channel A.\n"
2552 " Wake up pattern was not yet received on channel B.\n",
2553 CMD_HANDLER(cmd_do_fr_getwakeuprxstatus), (void *)&cmd_list_fr_basic_test
2556 /** Command descriptor for FlexRay set absolute timer command */
2557 cmd_des_t const cmd_des_fr_settimer = {
2559 "frbtsettimer*","Set and start timer",
2560 "### Command syntax ###\n"
2562 " frbtsettimer<TMID> <CYCLE> <OFFSET>\n"
2565 "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2566 "- `<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"
2567 "- `<OFFSET>` is a decimal number (0 - 16383) specifying the offset in macroticks, where precisely in the cycle should be the timer interrupt requested.\n"
2569 "### Description ###\n"
2571 "The command is similar to Fr_SetAbsoluteTimer function from the\n"
2572 "Autosar specification. The difference is that the command allows to\n"
2573 "specify a set of cycles, not only one of 64 cycles. It sets the timer\n"
2574 "selected by the parameter and enables it.\n"
2576 "Before using this command, FlexRay communication has to be started\n"
2577 "(see frbtstart).\n"
2581 " --> frbtsettimer0 32 50\n"
2582 " Timer was set for every 32-th cycle, offset 0, macrotick 50\n"
2583 " --> frbtsettimer0 31 50\n"
2584 " Timer was set for every 16-th cycle, offset 15, macrotick 50\n"
2585 " --> frbtsettimer0 0x42 0\n"
2586 " Timer was set for every 64-th cycle, offset 2, macrotick 0\n",
2587 CMD_HANDLER(cmd_do_fr_settimer), (void *)&cmd_list_fr_basic_test
2590 /** Command descriptor for FlexRay cancel absolute timer command */
2591 cmd_des_t const cmd_des_fr_canceltimer = {
2593 "frbtcanceltimer*","Stop the timer",
2594 "### Command syntax ###\n"
2596 " frbtcanceltimer<TMID>\n"
2597 "where `<TMID>` is a number (0 or 1) specifying the timer.\n"
2599 "### Description ###\n"
2601 "The command stands for Fr_CancelAbsoluteTimer function from the\n"
2602 "Autosar specification. It stops the timer selected by the parameter.\n"
2606 " --> frbtcanceltimer0\n"
2607 " Timer was canceled.\n",
2608 CMD_HANDLER(cmd_do_fr_canceltimer), (void *)&cmd_list_fr_basic_test
2611 /** Command descriptor for FlexRay absolute timer irq manipulation command */
2612 cmd_des_t const cmd_des_fr_timerirq = {
2614 "frbttimerirq*","Perform selected action on the timer IRQ",
2615 "### Command syntax ###\n"
2617 " frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer\n"
2618 " frbttimerirq<TMID> - Get timer IRQ status\n"
2622 "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2623 "- where `<ACTION>` is a string specifying the action to be performed on the selected timer IRQ.\n"
2625 "`<ACTIONS>` can be one of:\n"
2627 "- EN - Enable the IRQ on the selected timer\n"
2628 "- DIS - Disable the IRQ on the selected timer\n"
2629 "- ACK - Acknowledge the IRQ on the selected timer (reset flag in the register).\n"
2631 "### Description ###\n"
2633 "The command stands for Fr_EnableAbsoluteTimerIRQ,\n"
2634 "Fr_AckAbsoluteTimerIRQ, Fr_DisableAbsoluteTimerIRQ and\n"
2635 "Fr_GetAbsoluteTimerIRQStatus functions from the Autosar specification.\n"
2636 "It masks or demasks the IRQ for the timer, or acknowledges the\n"
2637 "interrupt request. If no action is specified it prints whether the IRQ\n"
2638 "is pending for the timer.\n"
2642 " --> frbttimerirq0\n"
2645 " --> frbttimerirq0 EN\n"
2647 CMD_HANDLER(cmd_do_fr_timerirq), (void *)&cmd_list_fr_basic_test
2650 /** Command descriptor for FlexRay get version info command */
2651 cmd_des_t const cmd_des_fr_getversioninfo = {
2653 "frbtversion","Print FlexRay driver version information",
2654 "### Command syntax ###\n"
2658 "### Description ###\n"
2660 "The command stands for Fr_GetVersionInfo function from the Autosar\n"
2662 "It reads and prints the information about vendor, module and version of\n"
2663 "the FlexRay driver\n"
2667 " --> frbtversion\n"
2668 " vendorID: 0xAAAA\n"
2669 " moduleID: 0xBBBB\n"
2670 " sw_major_version: 0x1\n"
2671 " sw_minor_version: 0x2\n"
2672 " sw_patch_version: 0x4\n",
2673 CMD_HANDLER(cmd_do_fr_getversioninfo), (void *)&cmd_list_fr_basic_test
2676 /** Command descriptor for FlexRay get controller configuration command */
2677 cmd_des_t const cmd_des_fr_readcconfig = {
2679 "frbtccconfig*","Print value of a FlexRay cluster and node configuration parameter",
2680 "### Command syntax ###\n"
2682 " frbtccconfig<INDEX>\n"
2684 "where `<INDEX>` is an identifier of the parameter.\n"
2686 "### Description ###\n"
2688 "The command stands for Fr_ReadCCConfig function from the Autosar\n"
2689 "specification. The driver stores the configuration parameters as an\n"
2690 "array. Each parameter can be indexed and returned by this command. See\n"
2691 "Autosar specification of the FlexRay driver\n"
2692 "(http://www.autosar.org/download/R4.1/AUTOSAR_SWS_FlexRayDriver.pdf),\n"
2693 "section 8.2.1 for parameter indexes.\n"
2697 " --> frbtccconfig1\n"
2699 CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
2702 /** Command descriptor for FlexRay reconfigure buffer command */
2703 cmd_des_t const cmd_des_fr_reconfigure_buffer = {
2705 "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
2706 "### Command syntax ###\n"
2708 " frbtreconfigurebuf id<BUFID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> max<MAX>\n"
2711 "- `<BUFID>` is a number specifying a slot, where the buffer is currently communicating,\n"
2712 "- `<SLOT>` is a number, where buffer will be communicating after the reconfiguration,\n"
2713 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
2714 "- `<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"
2715 "- `<CYCO>` is the cycle offset. It has to be in range 0 - `<CYCS>`-1"
2716 "- `<MAX>` is the number determining the maximum payload (in hald-words).\n"
2718 "### Description ###\n"
2720 "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
2721 "specification. It reconfigures specified buffer to communicate in\n"
2723 "The reconfiguration must be allowed in node configuration parameter\n"
2724 "secureBuffers. Buffers used for synchronization or assigned to the FIFO\n"
2725 "are not reconfigurable.\n"
2726 "The command can be called any time when the communication is running.\n"
2730 " --> frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n"
2731 " frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n",
2732 CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
2736 /** List of commands for flexRay, defined as external */
2737 cmd_des_t const *cmd_list_fr_basic_test[] = {
2738 &cmd_des_fr_user_config,
2739 &cmd_des_fr_config_buffer,
2740 &cmd_des_fr_config_fifo,
2743 &cmd_des_fr_allslots,
2746 &cmd_des_fr_sendwup,
2747 &cmd_des_fr_setwuchannel,
2748 &cmd_des_fr_getpocstatus,
2749 &cmd_des_fr_transmittxlpdu,
2750 &cmd_des_fr_canceltxlpdu,
2751 &cmd_des_fr_receiverxlpdu,
2752 &cmd_des_fr_checktxlpdustatus,
2753 &cmd_des_fr_disablelpdu,
2754 &cmd_des_fr_getglobaltime,
2755 &cmd_des_fr_getnmvector,
2756 &cmd_des_fr_nmwatch,
2757 &cmd_des_fr_getchannelstatus,
2758 &cmd_des_fr_getclockcorrection,
2759 &cmd_des_fr_getsyncframelist,
2760 &cmd_des_fr_getwakeuprxstatus,
2761 &cmd_des_fr_settimer,
2762 &cmd_des_fr_canceltimer,
2763 &cmd_des_fr_timerirq,
2764 &cmd_des_fr_getversioninfo,
2765 &cmd_des_fr_readcconfig,
2766 &cmd_des_fr_reconfigure_buffer,