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"
34 #define printf rpp_sci_printf
36 static inline int badpar(const char *msg)
39 return -CMDERR_BADPAR;
43 * Flag to recognize whether the FlexRay driver was already initialized. If it was, no further configuration is allowed.
45 static boolean_t fr_initialized = FALSE;
48 * This structure contains global FlexRay configuration.
49 * All nodes in the network have to use the same values for
50 * all parameters of this structure.
52 static Fr_TMS570LS_ClusterConfigType Fr_cluster_config = {
53 .gColdStartAttempts = 0x2,
55 .gMacroPerCycle = 0x15E0, // (cycle period, 5.6us)
56 .gMaxWithoutClockCorrectionFatal = 0xF,
57 .gMaxWithoutClockCorrectionPassive = 0xF,
58 .gNetworkManagementVectorLength = 12,
59 .gNumberOfMinislots = 0x15A,
60 .gNumberOfStaticSlots = 0x8,
61 .gOffsetCorrectionStart = 0xAE4,
62 .gPayloadLengthStatic = 0x9,
64 .gdActionPointOffset = 0x4,
65 .gdCASRxLowMax = 0x43,
66 .gdDynamicSlotIdlePhase = 0x1,
68 .gdMinislotActionPointOffset = 0x2,
70 .gdSampleClockPeriod = 0, // 10mbit/sec
72 .gdTSSTransmitter = 0xA,
73 .gdWakeupSymbolRxIdle = 18,
74 .gdWakeupSymbolRxLow = 18,
75 .gdWakeupSymbolRxWindow = 76,
76 .gdWakeupSymbolTxIdle = 180,
77 .gdWakeupSymbolTxLow = 60
81 * This structure contains local configuration of the FlexRay node A.
82 * All nodes in the network shall have their own local configuraion,
83 * but it does not matters if they share some together, until their
84 * buffer configuration differs.
86 static Fr_TMS570LS_NodeConfigType Fr_node_A_config = {
87 .pAllowHaltDueToClock = 0,
88 .pAllowPassiveToActive = 0xF,
89 .pChannels = FR_CHANNEL_AB,
90 .pClusterDriftDamping = 0x1,
91 .pDelayCompensationA = 0x3,
92 .pDelayCompensationB = 0x3,
93 .pExternOffsetCorrection = 0,
94 .pExternRateCorrection = 0,
95 .pKeySlotUsedForStartup = TRUE,
96 .pKeySlotUsedForSync = TRUE,
98 .pMacroInitialOffsetA = 0x6,
99 .pMacroInitialOffsetB = 0x6,
100 .pMicroInitialOffsetA = 0x18,
101 .pMicroInitialOffsetB = 0x18,
102 .pMicroPerCycle = 0x36B00,
103 .pRateCorrectionOut = 0xCD,
104 .pOffsetCorrectionOut = 0x151,
105 .pSamplesPerMicrotick = 0, // 10 mbit/sec
106 .pSingleSlotEnabled = TRUE,
107 .pWakeupChannel = FR_CHANNEL_A,
109 .pdAcceptedStartupRange = 0x81,
110 .pdListenTimeout = 0x36DA2,
112 .pDecodingCorrection = 0x33
116 * This structure contains local configuration of the FlexRay node B.
117 * All nodes in the network shall have their own local configuraion,
118 * but it does not matters if they share some together, until their
119 * buffer configuration differs.
121 static Fr_TMS570LS_NodeConfigType Fr_node_B_config = {
122 .pAllowHaltDueToClock = 0,
123 .pAllowPassiveToActive = 0xF,
124 .pChannels = FR_CHANNEL_AB,
125 .pClusterDriftDamping = 0x1,
126 .pDelayCompensationA = 0x3,
127 .pDelayCompensationB = 0x3,
128 .pExternOffsetCorrection = 0,
129 .pExternRateCorrection = 0,
130 .pKeySlotUsedForStartup = TRUE,
131 .pKeySlotUsedForSync = TRUE,
133 .pMacroInitialOffsetA = 0x6,
134 .pMacroInitialOffsetB = 0x6,
135 .pMicroInitialOffsetA = 0x18,
136 .pMicroInitialOffsetB = 0x18,
137 .pMicroPerCycle = 0x36B00,
138 .pRateCorrectionOut = 0xCD,
139 .pOffsetCorrectionOut = 0x151,
140 .pSamplesPerMicrotick = 0, // 10 mbit/sec
141 .pSingleSlotEnabled = TRUE,
142 .pWakeupChannel = FR_CHANNEL_A,
144 .pdAcceptedStartupRange = 0x81,
145 .pdListenTimeout = 0x36DA2,
147 .pDecodingCorrection = 0x33
150 static Fr_TMS570LS_MsgRAMConfig Fr_node_A_msgRAM_config = {
151 .dynSegmentBufferCount = 3,
152 .fifoBufferCount = 5,
153 .secureBuffers = FR_SB_RECONFIG_ENABLED,
154 .statSegmentBufferCount = 5,
155 .syncFramePayloadMultiplexEnabled = 0
158 static Fr_TMS570LS_MsgRAMConfig Fr_node_B_msgRAM_config = {
159 .dynSegmentBufferCount = 3,
160 .fifoBufferCount = 5,
161 .secureBuffers = FR_SB_RECONFIG_ENABLED,
162 .statSegmentBufferCount = 5,
163 .syncFramePayloadMultiplexEnabled = 0
166 static Fr_TMS570LS_BufferConfigType Fr_node_A_static_buffers_config[] = {
168 .channel = FR_CHANNEL_AB,
169 .cycleCounterFiltering = 0,
173 .msgBufferInterrupt = TRUE,
174 .payloadPreambleIndicatorTr = FALSE,
175 .rejectNullFrames = FALSE,
176 .rejectStaticSegment = FALSE,
177 .singleTransmit = FALSE,
181 .channel = FR_CHANNEL_AB,
182 .cycleCounterFiltering = 0,
186 .msgBufferInterrupt = TRUE,
187 .payloadPreambleIndicatorTr = FALSE,
188 .rejectNullFrames = FALSE,
189 .rejectStaticSegment = FALSE,
190 .singleTransmit = FALSE,
194 .channel = FR_CHANNEL_AB,
195 .cycleCounterFiltering = 0,
199 .msgBufferInterrupt = TRUE,
200 .payloadPreambleIndicatorTr = FALSE,
201 .rejectNullFrames = FALSE,
202 .rejectStaticSegment = FALSE,
203 .singleTransmit = TRUE,
207 .channel = FR_CHANNEL_AB,
208 .cycleCounterFiltering = 0,
212 .msgBufferInterrupt = TRUE,
213 .payloadPreambleIndicatorTr = FALSE,
214 .rejectNullFrames = FALSE,
215 .rejectStaticSegment = FALSE,
216 .singleTransmit = TRUE,
220 .channel = FR_CHANNEL_AB,
221 .cycleCounterFiltering = 0,
225 .msgBufferInterrupt = TRUE,
226 .payloadPreambleIndicatorTr = TRUE,
227 .rejectNullFrames = FALSE,
228 .rejectStaticSegment = FALSE,
229 .singleTransmit = FALSE,
235 static Fr_TMS570LS_BufferConfigType Fr_node_B_static_buffers_config[] = {
237 .channel = FR_CHANNEL_AB,
238 .cycleCounterFiltering = 0,
242 .msgBufferInterrupt = TRUE,
243 .payloadPreambleIndicatorTr = FALSE,
244 .rejectNullFrames = FALSE,
245 .rejectStaticSegment = FALSE,
246 .singleTransmit = FALSE,
250 .channel = FR_CHANNEL_AB,
251 .cycleCounterFiltering = 0,
255 .msgBufferInterrupt = TRUE,
256 .payloadPreambleIndicatorTr = FALSE,
257 .rejectNullFrames = FALSE,
258 .rejectStaticSegment = FALSE,
259 .singleTransmit = FALSE,
263 .channel = FR_CHANNEL_AB,
264 .cycleCounterFiltering = 0,
268 .msgBufferInterrupt = TRUE,
269 .payloadPreambleIndicatorTr = FALSE,
270 .rejectNullFrames = FALSE,
271 .rejectStaticSegment = FALSE,
272 .singleTransmit = TRUE,
276 .channel = FR_CHANNEL_AB,
277 .cycleCounterFiltering = 0,
281 .msgBufferInterrupt = TRUE,
282 .payloadPreambleIndicatorTr = FALSE,
283 .rejectNullFrames = FALSE,
284 .rejectStaticSegment = FALSE,
285 .singleTransmit = TRUE,
289 .channel = FR_CHANNEL_AB,
290 .cycleCounterFiltering = 0,
294 .msgBufferInterrupt = TRUE,
295 .payloadPreambleIndicatorTr = TRUE,
296 .rejectNullFrames = FALSE,
297 .rejectStaticSegment = FALSE,
298 .singleTransmit = FALSE,
303 static Fr_TMS570LS_BufferConfigType Fr_node_A_dynamic_buffers_config[] = {
305 .channel = FR_CHANNEL_A,
306 .cycleCounterFiltering = 0,
310 .msgBufferInterrupt = TRUE,
311 .payloadPreambleIndicatorTr = FALSE,
312 .rejectNullFrames = FALSE,
313 .rejectStaticSegment = FALSE,
314 .singleTransmit = FALSE,
318 .channel = FR_CHANNEL_B,
319 .cycleCounterFiltering = 0,
323 .msgBufferInterrupt = TRUE,
324 .payloadPreambleIndicatorTr = FALSE,
325 .rejectNullFrames = FALSE,
326 .rejectStaticSegment = FALSE,
327 .singleTransmit = FALSE,
331 .channel = FR_CHANNEL_A,
332 .cycleCounterFiltering = 0,
336 .msgBufferInterrupt = TRUE,
337 .payloadPreambleIndicatorTr = FALSE,
338 .rejectNullFrames = FALSE,
339 .rejectStaticSegment = FALSE,
340 .singleTransmit = TRUE,
346 static Fr_TMS570LS_BufferConfigType Fr_node_B_dynamic_buffers_config[] = {
348 .channel = FR_CHANNEL_B,
349 .cycleCounterFiltering = 0,
353 .msgBufferInterrupt = TRUE,
354 .payloadPreambleIndicatorTr = FALSE,
355 .rejectNullFrames = FALSE,
356 .rejectStaticSegment = FALSE,
357 .singleTransmit = TRUE,
361 .channel = FR_CHANNEL_A,
362 .cycleCounterFiltering = 0,
366 .msgBufferInterrupt = TRUE,
367 .payloadPreambleIndicatorTr = FALSE,
368 .rejectNullFrames = FALSE,
369 .rejectStaticSegment = FALSE,
370 .singleTransmit = TRUE,
374 .channel = FR_CHANNEL_A,
375 .cycleCounterFiltering = 0,
379 .msgBufferInterrupt = TRUE,
380 .payloadPreambleIndicatorTr = FALSE,
381 .rejectNullFrames = FALSE,
382 .rejectStaticSegment = FALSE,
383 .singleTransmit = TRUE,
388 static Fr_TMS570LS_BufferConfigType Fr_node_A_fifo_buffers_config[] = {
390 .channel = FR_CHANNEL_AB,
391 .cycleCounterFiltering = 0,
395 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
396 .payloadPreambleIndicatorTr = FALSE,
397 .rejectNullFrames = TRUE,
398 .rejectStaticSegment = FALSE,
399 .singleTransmit = FALSE,
403 .channel = FR_CHANNEL_AB,
404 .cycleCounterFiltering = 0,
408 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
409 .payloadPreambleIndicatorTr = FALSE,
410 .rejectNullFrames = TRUE,
411 .rejectStaticSegment = FALSE,
412 .singleTransmit = FALSE,
416 .channel = FR_CHANNEL_AB,
417 .cycleCounterFiltering = 0,
421 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
422 .payloadPreambleIndicatorTr = FALSE,
423 .rejectNullFrames = TRUE,
424 .rejectStaticSegment = FALSE,
425 .singleTransmit = FALSE,
429 .channel = FR_CHANNEL_AB,
430 .cycleCounterFiltering = 0,
434 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
435 .payloadPreambleIndicatorTr = FALSE,
436 .rejectNullFrames = TRUE,
437 .rejectStaticSegment = FALSE,
438 .singleTransmit = FALSE,
442 .channel = FR_CHANNEL_AB,
443 .cycleCounterFiltering = 0,
447 .msgBufferInterrupt = FALSE, // Recomended for FIFO buffers
448 .payloadPreambleIndicatorTr = FALSE,
449 .rejectNullFrames = TRUE,
450 .rejectStaticSegment = FALSE,
451 .singleTransmit = FALSE,
456 static Fr_TMS570LS_BufferConfigType Fr_node_B_fifo_buffers_config[] = {
458 .channel = FR_CHANNEL_AB,
459 .cycleCounterFiltering = 0,
463 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
464 .payloadPreambleIndicatorTr = FALSE,
465 .rejectNullFrames = TRUE,
466 .rejectStaticSegment = FALSE,
467 .singleTransmit = FALSE,
468 .slotId = 0 // No Frame is rejected
471 .channel = FR_CHANNEL_AB,
472 .cycleCounterFiltering = 0,
476 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
477 .payloadPreambleIndicatorTr = FALSE,
478 .rejectNullFrames = TRUE,
479 .rejectStaticSegment = FALSE,
480 .singleTransmit = FALSE,
481 .slotId = 0 // No Frame is rejected
484 .channel = FR_CHANNEL_AB,
485 .cycleCounterFiltering = 0,
489 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
490 .payloadPreambleIndicatorTr = FALSE,
491 .rejectNullFrames = TRUE,
492 .rejectStaticSegment = FALSE,
493 .singleTransmit = FALSE,
494 .slotId = 0 // No Frame is rejected
497 .channel = FR_CHANNEL_AB,
498 .cycleCounterFiltering = 0,
502 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
503 .payloadPreambleIndicatorTr = FALSE,
504 .rejectNullFrames = TRUE,
505 .rejectStaticSegment = FALSE,
506 .singleTransmit = FALSE,
507 .slotId = 0 // No Frame is rejected
510 .channel = FR_CHANNEL_AB,
511 .cycleCounterFiltering = 0,
515 .msgBufferInterrupt = FALSE, // Recommended for FIFO buffers
516 .payloadPreambleIndicatorTr = FALSE,
517 .rejectNullFrames = TRUE,
518 .rejectStaticSegment = FALSE,
519 .singleTransmit = FALSE,
520 .slotId = 0 // No Frame is rejected
525 * This is an unifying configuration structure for the node A.
526 * It joins all the configuration structure together.
528 static Fr_ConfigType Fr_config_node_A = {
529 .clusterConfiguration = &Fr_cluster_config,
530 .dynamicBufferConfigs = Fr_node_A_dynamic_buffers_config,
531 .fifoBufferConfigs = Fr_node_A_fifo_buffers_config,
532 .msgRAMConfig = &Fr_node_A_msgRAM_config,
533 .nodeConfiguration = &Fr_node_A_config,
534 .staticBufferConfigs = Fr_node_A_static_buffers_config
538 * This is an unifying configuration structure for the node A.
539 * It joins all the configuration structure together.
541 static Fr_ConfigType Fr_config_node_B = {
542 .clusterConfiguration = &Fr_cluster_config,
543 .dynamicBufferConfigs = Fr_node_B_dynamic_buffers_config,
544 .fifoBufferConfigs = Fr_node_B_fifo_buffers_config,
545 .msgRAMConfig = &Fr_node_B_msgRAM_config,
546 .nodeConfiguration = &Fr_node_B_config,
547 .staticBufferConfigs = Fr_node_B_static_buffers_config
550 /* User configuration */
552 static Fr_TMS570LS_ClusterConfigType user_cluster_config;
553 static Fr_TMS570LS_NodeConfigType user_node_config;
554 static Fr_TMS570LS_MsgRAMConfig user_msg_ram_config;
555 static Fr_TMS570LS_BufferConfigType user_static_buffer_config[RPP_FR_MAX_STATIC_BUF_CNT];
556 static Fr_TMS570LS_BufferConfigType user_dynamic_buffer_config[RPP_FR_MAX_DYNAMIC_BUF_CNT];
557 static Fr_TMS570LS_BufferConfigType user_fifo_buffer_config[RPP_FR_MAX_FIFO_BUF_DEPTH];
558 static Fr_ConfigType user_configuration = {
559 .clusterConfiguration = &user_cluster_config,
560 .nodeConfiguration = &user_node_config,
561 .msgRAMConfig = &user_msg_ram_config,
562 .staticBufferConfigs = user_static_buffer_config,
563 .dynamicBufferConfigs = user_dynamic_buffer_config,
564 .fifoBufferConfigs = user_fifo_buffer_config,
568 #define USER_CONFIG_NOT_DONE 0x0
569 #define USER_CONFIG_CLUSTER 0x1
570 #define USER_CONFIG_NODE 0x2
572 static uint8_t user_configuration_state = USER_CONFIG_NOT_DONE;
573 static uint8_t user_static_buffer_configured = 0;
574 static uint8_t user_dynamic_buffer_configured = 0;
575 static uint8_t user_fifo_buffer_depth = 0;
578 * Split string into numbers
580 * The function takes a string with hexadecimal numbers,
581 * separated by spaces, and converts it into an array of numbers.
583 * For example "0x2 0xA 0XDD 0xABCD" -> {0x2, 0xA, 0XDD, 0xABCD}
585 * @param [in] params Address of the string which will be converted
586 * @param [in] params_cnt A number of parameters, which should be found and converted from the string params
587 * @param [out] tmp_params Address, where converted array of numbers will be stored
589 * @return SUCCESS when all parameters were converted to the array of numbers,
590 * FAILURE when the string was too short, too long or some other error occurred.
592 static int8_t cmd_fr_parse_params(const char *params, uint32_t params_cnt, uint32_t *tmp_params)
594 char cpy_params[256];
598 if (params == NULL || tmp_params == NULL)
600 strncpy(cpy_params, params, 256);
601 token = strtok(cpy_params, " ");
604 for (i = 0; i < params_cnt; i++) {
605 if (sscanf(token, "%i", &tmp_params[i]) == EOF) // No number found
607 if ((token = strtok(NULL, " ")) == NULL && i < params_cnt-1) // Not enough parameters in the string
613 int8_t cmd_fr_config_cluster_params(const char *params)
615 uint32_t tmp_params[FR_CLUSTER_PARAMS_CNT];
617 if (cmd_fr_parse_params(params, FR_CLUSTER_PARAMS_CNT, tmp_params) == FAILURE)
620 user_cluster_config.gColdStartAttempts = tmp_params[0];
621 user_cluster_config.gListenNoise = tmp_params[1];
622 user_cluster_config.gMacroPerCycle = tmp_params[2];
623 user_cluster_config.gMaxWithoutClockCorrectionFatal = tmp_params[3];
624 user_cluster_config.gMaxWithoutClockCorrectionPassive = tmp_params[4];
625 user_cluster_config.gNetworkManagementVectorLength = tmp_params[5];
626 user_cluster_config.gNumberOfMinislots = tmp_params[6];
627 user_cluster_config.gNumberOfStaticSlots = tmp_params[7];
628 user_cluster_config.gOffsetCorrectionStart = tmp_params[8];
629 user_cluster_config.gPayloadLengthStatic = tmp_params[9];
630 user_cluster_config.gSyncNodeMax = tmp_params[10];
631 user_cluster_config.gdActionPointOffset = tmp_params[11];
632 user_cluster_config.gdCASRxLowMax = tmp_params[12];
633 user_cluster_config.gdDynamicSlotIdlePhase = tmp_params[13];
634 user_cluster_config.gdMinislot = tmp_params[14];
635 user_cluster_config.gdMinislotActionPointOffset = tmp_params[15];
636 user_cluster_config.gdNIT = tmp_params[16];
637 user_cluster_config.gdSampleClockPeriod = tmp_params[17];
638 user_cluster_config.gdStaticSlot = tmp_params[18];
639 user_cluster_config.gdTSSTransmitter = tmp_params[19];
640 user_cluster_config.gdWakeupSymbolRxIdle = tmp_params[20];
641 user_cluster_config.gdWakeupSymbolRxLow = tmp_params[21];
642 user_cluster_config.gdWakeupSymbolRxWindow = tmp_params[22];
643 user_cluster_config.gdWakeupSymbolTxIdle = tmp_params[23];
644 user_cluster_config.gdWakeupSymbolTxLow = tmp_params[24];
646 user_configuration_state |= USER_CONFIG_CLUSTER;
650 int8_t cmd_fr_config_node_params(const char *params)
652 uint32_t tmp_params[FR_NODE_PARAMS_CNT+2]; // +2 because two more parameters from message RAM structure are expected in the string.
653 Fr_ChannelType channels[3] = {FR_CHANNEL_A, FR_CHANNEL_B, FR_CHANNEL_AB};
654 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};
656 if (cmd_fr_parse_params(params, FR_NODE_PARAMS_CNT+2, tmp_params) == FAILURE)
659 user_node_config.pAllowHaltDueToClock = tmp_params[0];
660 user_node_config.pAllowPassiveToActive = tmp_params[1];
661 if (tmp_params[2] > 2) return FAILURE;
662 user_node_config.pChannels = channels[ tmp_params[2] ];
663 user_node_config.pClusterDriftDamping = tmp_params[3];
664 user_node_config.pDelayCompensationA = tmp_params[4];
665 user_node_config.pDelayCompensationB = tmp_params[5];
666 user_node_config.pExternOffsetCorrection = tmp_params[6];
667 user_node_config.pExternRateCorrection = tmp_params[7];
668 user_node_config.pKeySlotUsedForStartup = tmp_params[8];
669 user_node_config.pKeySlotUsedForSync = tmp_params[9];
670 user_node_config.pLatestTx = tmp_params[10];
671 user_node_config.pMacroInitialOffsetA = tmp_params[11];
672 user_node_config.pMacroInitialOffsetB = tmp_params[12];
673 user_node_config.pMicroInitialOffsetA = tmp_params[13];
674 user_node_config.pMicroInitialOffsetB = tmp_params[14];
675 user_node_config.pMicroPerCycle = tmp_params[15];
676 user_node_config.pRateCorrectionOut = tmp_params[16];
677 user_node_config.pOffsetCorrectionOut = tmp_params[17];
678 user_node_config.pSamplesPerMicrotick = tmp_params[18];
679 user_node_config.pSingleSlotEnabled = tmp_params[19];
680 if (tmp_params[20] > 1) return FAILURE;
681 user_node_config.pWakeupChannel = channels[ tmp_params[20] ];
682 user_node_config.pWakeupPattern = tmp_params[21];
683 user_node_config.pdAcceptedStartupRange = tmp_params[22];
684 user_node_config.pdListenTimeout = tmp_params[23];
685 user_node_config.pdMaxDrift = tmp_params[24];
686 user_node_config.pDecodingCorrection = tmp_params[25];
687 user_msg_ram_config.syncFramePayloadMultiplexEnabled = tmp_params[26];
688 if (tmp_params[27] > 3) return FAILURE;
689 user_msg_ram_config.secureBuffers = secure[ tmp_params[27] ];
691 user_configuration_state |= USER_CONFIG_NODE;
695 int cmd_do_fr_config_fifo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
697 Fr_TMS570LS_BufferConfigType *fifo_buffer_ptr = &user_fifo_buffer_config[0];
699 char channel[3], rej_static_frames[8], rej_null_frames[8];
700 unsigned depth, slot, cycleset, maxpayload, mask;
701 Fr_TMS570LS_BufferConfigType tmp_buffer;
703 if (fr_initialized) {
704 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
705 return -CMDERR_BADCFG;
708 ret = sscanf(param[2], "rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s",
719 printf("Error parsing parameter %d\n", ret+1);
720 return -CMDERR_BADPAR;
723 if (depth < 1 || depth >= RPP_FR_MAX_FIFO_BUF_DEPTH)
724 return badpar("Depth too high\n");
725 user_fifo_buffer_depth = depth;
728 return badpar("Invalid slot number\n");
729 tmp_buffer.slotId = slot;
731 return badpar("Invalid mask\n");
732 tmp_buffer.fidMask = mask;
733 if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
734 else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
735 else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
736 else return badpar("Channel parsing error\n");
738 if (cycleset >= 0x80)
739 return badpar("Cycle set must be less than 0x80.\n");
740 tmp_buffer.cycleCounterFiltering = cycleset;
742 if (maxpayload >= 128)
743 return badpar("Maximum payload in half-words must be less than 128\n");
744 tmp_buffer.maxPayload = maxpayload;
746 if (strcmp(rej_null_frames, "rejnull") == 0) tmp_buffer.rejectNullFrames = true;
747 else if (strcmp(rej_null_frames, "accnull") == 0) tmp_buffer.rejectNullFrames = false;
748 else return badpar("Reject/accept NULL frames parsing error\n");
750 if (strcmp(rej_static_frames, "rejstat") == 0)
751 tmp_buffer.rejectStaticSegment = true;
752 else if (strcmp(rej_static_frames, "accstat") == 0)
753 tmp_buffer.rejectStaticSegment = false;
754 else return badpar("Invalid reject/accept static frame parameter");
756 for (i = 0; i < user_fifo_buffer_depth; i++) {
757 fifo_buffer_ptr[i].slotId = tmp_buffer.slotId;
758 fifo_buffer_ptr[i].fidMask = tmp_buffer.fidMask;
759 fifo_buffer_ptr[i].maxPayload = tmp_buffer.maxPayload;
760 fifo_buffer_ptr[i].channel = tmp_buffer.channel;
761 fifo_buffer_ptr[i].cycleCounterFiltering = tmp_buffer.cycleCounterFiltering;
762 fifo_buffer_ptr[i].isTx = FALSE;
763 fifo_buffer_ptr[i].singleTransmit = FALSE;
764 fifo_buffer_ptr[i].payloadPreambleIndicatorTr = FALSE;
765 fifo_buffer_ptr[i].rejectNullFrames = tmp_buffer.rejectNullFrames;
766 fifo_buffer_ptr[i].rejectStaticSegment = tmp_buffer.rejectStaticSegment;
767 fifo_buffer_ptr[i].msgBufferInterrupt = 0;
770 printf("frbtcfgfifo rejslot%i slotmask%i depth%i %2s cyc%i max%i %10s %10s\n",
784 int cmd_do_fr_config_bufer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
786 Fr_TMS570LS_BufferConfigType *cfg;
789 char buf_type, channel[3],rxtx[3], single_continuous[11];
790 unsigned buffer, slot, cycleset, maxpayload, intr, preamb;
792 if (fr_initialized) {
793 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
794 return -CMDERR_BADCFG;
797 ret = sscanf(param[1], "%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i",
810 printf("Error parsing parameter %d\n", ret+1);
811 return -CMDERR_BADPAR;
817 if (buffer >= RPP_FR_MAX_STATIC_BUF_CNT)
818 return badpar("Buffer index too high\n");
819 cfg = &user_static_buffer_config[buffer];
822 if (buffer >= RPP_FR_MAX_DYNAMIC_BUF_CNT)
823 return badpar("Buffer index too high\n");
824 cfg = &user_dynamic_buffer_config[buffer];
827 return badpar("Invalid buffer type (S, D)\n");
830 if (slot < 1 || slot > 2047)
831 return badpar("Invalid slot number\n");
834 if (strcmp(channel, "A") == 0) cfg->channel = FR_CHANNEL_A;
835 else if (strcmp(channel, "B") == 0) cfg->channel = FR_CHANNEL_B;
836 else if (strcmp(channel, "AB") == 0) cfg->channel = FR_CHANNEL_AB;
837 else return badpar("Channel parsing error\n");
838 if (buf_type == 'D' && cfg->channel == FR_CHANNEL_AB)
839 return badpar("Dynamic segment buffers cannot have AB channels.\n");
841 if (cycleset >= 0x80)
842 return badpar("Cycle set must be less than 0x80.\n");
843 cfg->cycleCounterFiltering = cycleset;
845 if (strcmp(rxtx, "tx") == 0) cfg->isTx = true;
846 else if (strcmp(rxtx, "rx") == 0) cfg->isTx = false;
847 else return badpar("RX/TX parsing error\n");
849 if (maxpayload >= 128)
850 return badpar("Maximum payload in half-words must be less than 128\n");
851 cfg->maxPayload = maxpayload;
853 if (0 == strcmp(single_continuous, "single") ||
854 0 == strcmp(single_continuous, "s"))
855 cfg->singleTransmit = true;
856 else if (0 == strcmp(single_continuous, "continuous") ||
857 0 == strcmp(single_continuous, "c"))
858 cfg->singleTransmit = false;
859 else return badpar("Invalid single/continuous parameter");
862 return badpar("Payload preamble indicator must be 0 or 1");
863 cfg->payloadPreambleIndicatorTr = preamb;
866 return badpar("Interrupt parameter must be 0 or 1");
867 cfg->msgBufferInterrupt = intr;
871 if (buffer >= user_static_buffer_configured)
872 user_static_buffer_configured = buffer + 1;
875 if (buffer >= user_dynamic_buffer_configured)
876 user_dynamic_buffer_configured = buffer + 1;
880 printf("frbtcfgbuf%c%i slot%i %2s cyc%i %2s max%i %10s ppi%i int%i\n",
899 * @brief Do the user configuration of the FlexRay cluster parameters
901 * @param[in] cmd_io Pointer to IO stack
902 * @param[in] des Pointer to command descriptor
903 * @param[in] param Parameters of command
904 * @return 0 when OK or error code
906 int cmd_do_fr_user_config(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
910 if (fr_initialized) {
911 rpp_sci_printf("FlexRay configuration can not be modified after frbtinit was called.\n");
912 return -CMDERR_BADCFG;
915 token = strtok(param[1], " ");
916 if (strcmp(token, "cluster") == 0) {
917 if (cmd_fr_config_cluster_params(param[2]) == FAILURE) {
918 rpp_sci_printf("FlexRay cluster configuration not accepted.\n");
919 return -CMDERR_BADPAR;
921 rpp_sci_printf("FlexRay cluster configuration accepted.\n");
923 else if (strcmp(token, "node") == 0) {
924 if (cmd_fr_config_node_params(param[2]) == FAILURE) {
925 rpp_sci_printf("FlexRay node configuration not accepted.\n");
926 return -CMDERR_BADPAR;
928 rpp_sci_printf("FlexRay node configuration accepted.\n");
931 return -CMDERR_BADPAR;
937 * @brief Initialize the device as FlexRay node.
939 * @param[in] cmd_io Pointer to IO stack
940 * @param[in] des Pointer to command descriptor
941 * @param[in] param Parameters of command
942 * @return 0 when OK or error code
944 int cmd_do_fr_init(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
946 const Fr_ConfigType *Fr_ConfigPtr = NULL;
947 int8_t retVal = SUCCESS;
948 uint32_t error = ERR_PARAM_NO_ERROR;
950 if (*param[1] == 'A')
951 Fr_ConfigPtr = &Fr_config_node_A;
952 else if (*param[1] == 'B')
953 Fr_ConfigPtr = &Fr_config_node_B;
954 else if (*param[1] == 'U') { // Select the user configuration - call config commands first
955 user_msg_ram_config.statSegmentBufferCount = user_static_buffer_configured;
956 user_msg_ram_config.dynSegmentBufferCount = user_dynamic_buffer_configured;
957 user_msg_ram_config.fifoBufferCount = user_fifo_buffer_depth;
958 Fr_ConfigPtr = &user_configuration;
961 return -CMDERR_BADPAR;
963 retVal = rpp_fr_init_driver(Fr_ConfigPtr, &error);
964 if (retVal == SUCCESS) {
965 rpp_sci_printf("FlexRay driver initialized.\r\n");
966 fr_initialized = TRUE;
969 retVal = rpp_fr_init_controller(0, &error);
970 if (retVal == SUCCESS) {
971 rpp_sci_printf("FlexRay controller reinitialized.\r\n");
975 rpp_sci_printf("FlexRay needs to be configured before initialization.\r\n");
976 return -CMDERR_BADCFG;
980 retVal = rpp_fr_init_controller(0, &error);
981 if (retVal == SUCCESS)
982 rpp_sci_printf("FlexRay controller initialized.\r\n");
984 if (error & FR_INIT_ERR_CLUSTER_CONFIG)
985 rpp_sci_printf("Cluster configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
986 else if (error & FR_INIT_ERR_NODE_CONFIG)
987 rpp_sci_printf("Node configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
988 else if (error & FR_INIT_ERR_MSGRAM_CONFIG)
989 rpp_sci_printf("Message RAM configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
990 else if (error & FR_INIT_ERR_BUFFPARAM_CONFIG)
991 rpp_sci_printf("Buffer configuration data error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
992 else if (error & (uint32_t)FR_INIT_ERR_BUFF_CONFIG)
993 rpp_sci_printf("Buffer configuration error: %x\r\n", (retVal & 0x3FFFFFE) >> 1 );
995 rpp_sci_printf("POC state switching error.\r\n");
996 return -CMDERR_BADCFG;
1002 * @brief Starts FlexRay communication
1004 * @param[in] cmd_io Pointer to IO stack
1005 * @param[in] des Pointer to command descriptor
1006 * @param[in] param Parameters of command
1007 * @return 0 when OK or error code
1009 int cmd_do_fr_start(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1011 int8_t retVal = SUCCESS;
1012 uint32_t error = ERR_PARAM_NO_ERROR;
1014 retVal = rpp_fr_start_communication(0, &error);
1015 if (retVal == SUCCESS)
1016 rpp_sci_printf("FlexRay communication is running.\r\n");
1018 if (error & FR_STARTUP_ERR_SW_STUP_FOLLOW)
1019 rpp_sci_printf("Can not switch POC to RUN state.\r\n");
1020 else if (error & FR_STARTUP_ERR_CSINH_DIS)
1021 rpp_sci_printf("Cold start inhibit disabled error.\r\n");
1022 else if (error & FR_STARTUP_ERR_SW_STUP_READY)
1023 rpp_sci_printf("Can not switch back to READY from STARTUP.\r\n");
1024 else if (error & FR_STARTUP_ERR_SW_STUP_AS_NCOLD)
1025 rpp_sci_printf("Can not switch to STARTUP as non-coldstarter.\r\n");
1027 rpp_sci_printf("General error.\r\n");
1028 return -CMDERR_BADCFG;
1034 * @brief Invokes POC command ALL_SLOTS
1036 * @param[in] cmd_io Pointer to IO stack
1037 * @param[in] des Pointer to command descriptor
1038 * @param[in] param Parameters of command
1039 * @return 0 when OK or error code
1041 int cmd_do_fr_allslots(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1043 int8_t retVal = ERR_PARAM_NO_ERROR;
1045 retVal = rpp_fr_all_slots(0);
1046 if (retVal == SUCCESS)
1047 rpp_sci_printf("FlexRay node started communication in all slots.\r\n");
1049 rpp_sci_printf("General error.\r\n");
1050 return -CMDERR_BADCFG;
1056 * @brief Halt FlexRay communication
1058 * @param[in] cmd_io Pointer to IO stack
1059 * @param[in] des Pointer to command descriptor
1060 * @param[in] param Parameters of command
1061 * @return 0 when OK or error code
1063 int cmd_do_fr_halt(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1065 int8_t retVal = ERR_PARAM_NO_ERROR;
1067 retVal = rpp_fr_halt_communication(0);
1068 if (retVal == SUCCESS)
1069 rpp_sci_printf("FlexRay node communication halted.\r\n");
1071 rpp_sci_printf("General error.\r\n");
1072 return -CMDERR_BADCFG;
1078 * @brief Abort FlexRay communication
1080 * @param[in] cmd_io Pointer to IO stack
1081 * @param[in] des Pointer to command descriptor
1082 * @param[in] param Parameters of command
1083 * @return 0 when OK or error code
1085 int cmd_do_fr_abort(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1087 int8_t retVal = ERR_PARAM_NO_ERROR;
1089 retVal = rpp_fr_abort_communication(0);
1090 if (retVal == SUCCESS)
1091 rpp_sci_printf("FlexRay node communication aborted.\r\n");
1093 rpp_sci_printf("General error.\r\n");
1094 return -CMDERR_BADCFG;
1100 * @brief Send wake up pattern
1102 * @param[in] cmd_io Pointer to IO stack
1103 * @param[in] des Pointer to command descriptor
1104 * @param[in] param Parameters of command
1105 * @return 0 when OK or error code
1107 int cmd_do_fr_sendwup(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1109 int8_t retVal = ERR_PARAM_NO_ERROR;
1111 retVal = rpp_fr_send_wup(0);
1112 if (retVal == SUCCESS)
1113 rpp_sci_printf("Wake up pattern has been sent.\r\n");
1115 rpp_sci_printf("General error.\r\n");
1116 return -CMDERR_BADCFG;
1122 * @brief Set channel for wake up pattern sending.
1124 * @param[in] cmd_io Pointer to IO stack
1125 * @param[in] des Pointer to command descriptor
1126 * @param[in] param Parameters of command
1127 * @return 0 when OK or error code
1129 int cmd_do_fr_setwuchannel(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1131 int8_t retVal = ERR_PARAM_NO_ERROR;
1132 Fr_ChannelType channel = FR_CHANNEL_A;
1134 if (*param[1] == 'A')
1135 channel = FR_CHANNEL_A;
1136 else if (*param[1] == 'B')
1137 channel = FR_CHANNEL_B;
1139 return -CMDERR_BADPAR;
1140 retVal = rpp_fr_set_wu_channel(0, channel);
1141 if (retVal == SUCCESS)
1142 rpp_sci_printf("Wake up channel has been set.\r\n");
1144 rpp_sci_printf("General error.\r\n");
1145 return -CMDERR_BADCFG;
1151 * @brief Get and print POC status of the FlexRay controller.
1153 * @param[in] cmd_io Pointer to IO stack
1154 * @param[in] des Pointer to command descriptor
1155 * @param[in] param Parameters of command
1156 * @return 0 when OK or error code
1158 int cmd_do_fr_getpocstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1160 int8_t retVal = ERR_PARAM_NO_ERROR;
1161 Fr_POCStatusType status;
1162 char *ErrorModeStrings[] = {"ACTIVE", "HALT", "PASSIVE"};
1163 char *SlotModeStrings[] = {"KEYSLOT", "ALL_PENDING", "ALL"};
1164 char *StartupStateStrings[] = {
1165 "UNDEFINED", "COLDSTART_LISTEN", "COLDSTART_CHECK", "COLDSTART_JOIN",
1166 "COLDSTART_CONSISTENCY_CHECK", "INTEGRATION_LISTEN", "INITIALIZE_SCHEDULE", "INTEGRATION_CONSISTENCY_CHECK",
1167 "COLDSTART_GAP", "EXTERNAL_STARTUP", "ABORT", "COLDSTART_COLLISION_RESOLUTION",
1170 char *StateStrings[] = {
1171 "CONFIG", "DEFAULT_CONFIG", "HALT", "NORMAL_ACTIVE",
1172 "NORMAL_PASSIVE", "READY", "STARTUP", "LOOPBACK",
1175 char *WakeupStatusStrings[] = {
1176 "UNDEFINED", "RECEIVED_HEADER", "RECEIVED_WUP", "COLLISION_HEADER",
1177 "COLLISION_WUP", "COLLISION_UNKNOWN", "TRANSMITTED"
1180 retVal = rpp_fr_get_poc_status(0, &status);
1181 if (retVal == SUCCESS) {
1182 rpp_sci_printf("POC status:\r\n");
1183 rpp_sci_printf("CHIHaltRequest: %s\r\n", (status.CHIHaltRequest == TRUE) ? "TRUE" : "FALSE");
1184 rpp_sci_printf("CHIReadyRequest: %s\r\n", (status.CHIReadyRequest == TRUE) ? "TRUE" : "FALSE");
1185 rpp_sci_printf("ColdstartNoise: %s\r\n", (status.ColdstartNoise == TRUE) ? "TRUE" : "FALSE");
1186 rpp_sci_printf("Freeze: %s\r\n", (status.Freeze == TRUE) ? "TRUE" : "FALSE");
1187 rpp_sci_printf("ErrorMode: %s\r\n", ErrorModeStrings[status.ErrorMode]);
1188 rpp_sci_printf("SlotMode: %s\r\n", SlotModeStrings[status.SlotMode]);
1189 rpp_sci_printf("StartupState: %s\r\n", StartupStateStrings[status.StartupState]);
1190 rpp_sci_printf("State: %s\r\n", StateStrings[status.State]);
1191 rpp_sci_printf("WakeupStatus: %s\r\n", WakeupStatusStrings[status.WakeupStatus]);
1194 rpp_sci_printf("General error.\r\n");
1195 return -CMDERR_BADCFG;
1201 * @brief Send given data through the FlexRay in selected slot.
1203 * @param[in] cmd_io Pointer to IO stack
1204 * @param[in] des Pointer to command descriptor
1205 * @param[in] param Parameters of command
1206 * @return 0 when OK or error code
1208 int cmd_do_fr_transmittxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1210 int8_t retVal = ERR_PARAM_NO_ERROR;
1213 int values[MAX_PARAM_VALUES_NUM];
1214 uint8_t data[MAX_PARAM_VALUES_NUM];
1217 if (sscanf(param[1], "%d", &bufferID) != 1)
1218 return -CMDERR_BADPAR;
1219 if (sscanf(param[2], " %2x", &values[0]) != 1)
1220 return -CMDERR_BADPAR;
1221 data[0] = (uint8_t)values[0];
1222 token = strtok(param[2], " ");
1223 token = strtok(NULL, " ");
1225 while (dataLength < MAX_PARAM_VALUES_NUM && token != NULL) {
1226 if (sscanf(token, "%2x", &values[dataLength]) == EOF)
1228 data[dataLength] = (uint8_t)values[dataLength];
1229 token = strtok(NULL, " ");
1233 retVal = rpp_fr_transmit_lpdu(0, bufferID, data, dataLength);
1234 if (retVal == SUCCESS)
1235 rpp_sci_printf("Data were set for transmission.\r\n");
1237 rpp_sci_printf("General error.\r\n");
1238 return -CMDERR_BADCFG;
1244 * @brief Cancel the transmission in the selected slot.
1246 * @param[in] cmd_io Pointer to IO stack
1247 * @param[in] des Pointer to command descriptor
1248 * @param[in] param Parameters of command
1249 * @return 0 when OK or error code
1251 int cmd_do_fr_canceltxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1253 int8_t retVal = ERR_PARAM_NO_ERROR;
1256 if (sscanf(param[1], "%d", &bufferID) != 1)
1257 return -CMDERR_BADPAR;
1258 if (param[2] != NULL)
1259 return -CMDERR_BADPAR;
1261 retVal = rpp_fr_cancel_transmit_lpdu(0, bufferID);
1262 if (retVal == SUCCESS)
1263 rpp_sci_printf("Transmission canceled.\r\n");
1265 rpp_sci_printf("General error.\r\n");
1266 return -CMDERR_BADCFG;
1272 * @brief Receive data from selected slot.
1274 * @param[in] cmd_io Pointer to IO stack
1275 * @param[in] des Pointer to command descriptor
1276 * @param[in] param Parameters of command
1277 * @return 0 when OK or error code
1279 int cmd_do_fr_receiverxlpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1281 int8_t retVal = ERR_PARAM_NO_ERROR;
1283 uint8_t data[cPayloadLengthMax];
1284 Fr_RxLPduStatusType status;
1285 uint8_t receivedLength = 0;
1288 if (sscanf(param[1], "%d", &bufferID) != 1)
1289 return -CMDERR_BADPAR;
1290 if (param[2] != NULL)
1291 return -CMDERR_BADPAR;
1293 memset(data, 0, sizeof(data));
1295 retVal = rpp_fr_receive_lpdu(0, bufferID, data, &status, &receivedLength);
1296 if (retVal == SUCCESS) {
1298 case FR_RECEIVED_MORE_DATA_AVAILABLE:
1299 rpp_sci_printf("More messages are still in FIFO:\r\n");
1301 rpp_sci_printf("Received message (%d B):\r\n", receivedLength);
1302 for (i = 0; i < receivedLength; i++) {
1303 rpp_sci_printf(" %02x", data[i]);
1305 rpp_sci_printf("\r\n");
1308 rpp_sci_printf("No message received.\r\n");
1313 rpp_sci_printf("General error.\r\n");
1314 return -CMDERR_BADCFG;
1320 * @brief Returns TX LPdu status.
1322 * @param[in] cmd_io Pointer to IO stack
1323 * @param[in] des Pointer to command descriptor
1324 * @param[in] param Parameters of command
1325 * @return 0 when OK or error code
1327 int cmd_do_fr_checktxlpdustatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1329 int8_t retVal = ERR_PARAM_NO_ERROR;
1331 Fr_TxLPduStatusType status;
1332 char *statusStrings[] = {"is not", "is"};
1334 if (sscanf(param[1], "%d", &bufferID) != 1)
1335 return -CMDERR_BADPAR;
1336 if (param[2] != NULL)
1337 return -CMDERR_BADPAR;
1339 retVal = rpp_fr_check_tx_lpdu_status(0, bufferID, &status);
1340 if (retVal == SUCCESS)
1341 rpp_sci_printf("Message transmission %s pending.\r\n", statusStrings[status]);
1343 rpp_sci_printf("General error.\r\n");
1344 return -CMDERR_BADCFG;
1350 * @brief Disable buffer.
1352 * @param[in] cmd_io Pointer to IO stack
1353 * @param[in] des Pointer to command descriptor
1354 * @param[in] param Parameters of command
1355 * @return 0 when OK or error code
1357 int cmd_do_fr_disablelpdu(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1359 int8_t retVal = ERR_PARAM_NO_ERROR;
1362 if (sscanf(param[1], "%d", &bufferID) != 1)
1363 return -CMDERR_BADPAR;
1364 if (param[2] != NULL)
1365 return -CMDERR_BADPAR;
1367 retVal = rpp_fr_disable_lpdu(0, bufferID);
1368 if (retVal == SUCCESS)
1369 rpp_sci_printf("Buffer disabled.\r\n");
1371 rpp_sci_printf("General error.\r\n");
1372 return -CMDERR_BADCFG;
1378 * @brief Print global time of the FlexRay network.
1380 * @param[in] cmd_io Pointer to IO stack
1381 * @param[in] des Pointer to command descriptor
1382 * @param[in] param Parameters of command
1383 * @return 0 when OK or error code
1385 int cmd_do_fr_getglobaltime(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1387 int8_t retVal = ERR_PARAM_NO_ERROR;
1389 uint16_t macroTick = 0;
1391 retVal = rpp_fr_get_global_time(0, &cycle, ¯oTick);
1392 if (retVal == SUCCESS)
1393 rpp_sci_printf("Cycle number: %d\r\nMacrotick number: %d\r\n", cycle, macroTick);
1395 rpp_sci_printf("General error.\r\n");
1396 return -CMDERR_BADCFG;
1402 * @brief Print network management vector of the FlexRay node.
1404 * @param[in] cmd_io Pointer to IO stack
1405 * @param[in] des Pointer to command descriptor
1406 * @param[in] param Parameters of command
1407 * @return 0 when OK or error code
1409 int cmd_do_fr_getnmvector(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1411 int8_t retVal = ERR_PARAM_NO_ERROR;
1412 uint8_t nmVector[12];
1415 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1416 if (retVal == SUCCESS) {
1417 rpp_sci_printf("Network management vector:");
1418 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1419 rpp_sci_printf(" %x", nmVector[i]);
1421 rpp_sci_printf("\r\n");
1424 rpp_sci_printf("General error.\r\n");
1425 return -CMDERR_BADCFG;
1430 int cmd_do_fr_nmwatch(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1432 int8_t retVal = ERR_PARAM_NO_ERROR;
1433 uint8_t nmVector[12];
1436 // Calculate wait time in OS ticks
1437 static const portTickType freq_ticks = 100 /* ms */ / portTICK_RATE_MS;
1438 portTickType last_wake_time = xTaskGetTickCount();
1440 while (cmd_io->getc(cmd_io) < 0) {
1441 retVal = rpp_fr_get_network_management_vector(0, nmVector);
1442 if (retVal == SUCCESS) {
1443 rpp_sci_printf("Network management vector:");
1444 for (i = 0; i < Fr_cluster_config.gNetworkManagementVectorLength; i++) {
1445 rpp_sci_printf(" %02x", nmVector[i]);
1447 rpp_sci_printf("\r");
1450 rpp_sci_printf("General error.\r\n");
1451 return -CMDERR_BADCFG;
1453 vTaskDelayUntil(&last_wake_time, freq_ticks);
1455 rpp_sci_printf("\n");
1460 * @brief Print both channels status of the FlexRay node.
1462 * @param[in] cmd_io Pointer to IO stack
1463 * @param[in] des Pointer to command descriptor
1464 * @param[in] param Parameters of command
1465 * @return 0 when OK or error code
1467 int cmd_do_fr_getchannelstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1469 int8_t retVal = ERR_PARAM_NO_ERROR;
1472 char *decodeStrings[] = {
1473 "aggregated channel status vSS!ValidFrame",
1474 "aggregated channel status vSS!SyntaxError",
1475 "aggregated channel status vSS!ContentError",
1476 "aggregated channel status additional communication",
1477 "aggregated channel status vSS!Bviolation",
1478 "aggregated channel status vSS!TxConflict",
1481 "symbol window status data vSS!ValidMTS",
1482 "symbol window status data vSS!SyntaxError",
1483 "symbol window status data vSS!Bviolation",
1484 "symbol window status data vSS!TxConflict",
1485 "NIT status data vSS!SyntaxError",
1486 "NIT status data vSS!Bviolation",
1490 char *channelNames[] = {"A", "B"};
1491 char *boolStrings[] = {"FALSE", "TRUE"};
1492 uint16_t channelStatuses[2];
1494 retVal = rpp_fr_get_channel_status(0, &channelStatuses[0], &channelStatuses[1]);
1495 if (retVal == SUCCESS)
1496 for (channel = 0; channel < 2; channel++) {
1497 rpp_sci_printf("Channel %s status:\r\n", channelNames[channel]);
1498 for (index = 0; index < 16; index++) {
1499 rpp_sci_printf("\t%s: %s\r\n", decodeStrings[index], boolStrings[ (channelStatuses[channel] >> index) & 0x1 ] );
1503 rpp_sci_printf("General error.\r\n");
1504 return -CMDERR_BADCFG;
1510 * @brief Print clock correction of the FlexRay node
1512 * @param[in] cmd_io Pointer to IO stack
1513 * @param[in] des Pointer to command descriptor
1514 * @param[in] param Parameters of command
1515 * @return 0 when OK or error code
1517 int cmd_do_fr_getclockcorrection(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1519 int8_t retVal = ERR_PARAM_NO_ERROR;
1520 int16_t rateCorrection;
1521 int32_t offsetCorrection;
1523 retVal = rpp_fr_get_clock_correction(0, &rateCorrection, &offsetCorrection);
1524 if (retVal == SUCCESS)
1525 rpp_sci_printf("Rate correction: %d\r\nOffset correction: %d\r\n", rateCorrection, offsetCorrection);
1527 rpp_sci_printf("General error.\r\n");
1528 return -CMDERR_BADCFG;
1534 * @brief Print list of syncframec transmitted on both channels via the even and odd cycle.
1536 * @param[in] cmd_io Pointer to IO stack
1537 * @param[in] des Pointer to command descriptor
1538 * @param[in] param Parameters of command
1539 * @return 0 when OK or error code
1541 int cmd_do_fr_getsyncframelist(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1543 int8_t retVal = ERR_PARAM_NO_ERROR;
1544 uint16_t channelAEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1545 uint16_t channelBEvenList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1546 uint16_t channelAOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1547 uint16_t channelBOddList[FR_MAX_SYNC_FRAME_LIST_SIZE];
1548 uint32_t listSize = 0;
1551 if (sscanf(param[1], "%d", &listSize) != 1)
1552 return -CMDERR_BADPAR;
1553 if (param[2] != NULL)
1554 return -CMDERR_BADPAR;
1555 if (listSize > FR_MAX_SYNC_FRAME_LIST_SIZE)
1556 return -CMDERR_BADPAR;
1558 retVal = rpp_fr_get_sync_frame_list(0, listSize, channelAEvenList, channelBEvenList, channelAOddList, channelBOddList);
1559 if (retVal == SUCCESS) {
1560 rpp_sci_printf("| Channel A even | channel B even | channel A odd | channel B odd |\r\n");
1561 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1562 for (i = 0; i < listSize; i++) {
1563 rpp_sci_printf("| %-14x | %-14x | %-14x | %-14x |\r\n", channelAEvenList[i], channelBEvenList[i], channelAOddList[i], channelBOddList[i]);
1565 rpp_sci_printf("|----------------|----------------|----------------|----------------|\r\n");
1569 rpp_sci_printf("General error.\r\n");
1570 return -CMDERR_BADCFG;
1576 * @brief Print status of wakeup on each channels (wakeup received on channel or not yet received).
1578 * @param[in] cmd_io Pointer to IO stack
1579 * @param[in] des Pointer to command descriptor
1580 * @param[in] param Parameters of command
1581 * @return 0 when OK or error code
1583 int cmd_do_fr_getwakeuprxstatus(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1585 int8_t retVal = ERR_PARAM_NO_ERROR;
1587 char *statusStrings[] = {"was not yet", "was"};
1588 char *channelNames[] = {"A", "B"};
1591 retVal = rpp_fr_get_wakeup_rx_status(0, &status);
1592 if (retVal == SUCCESS)
1593 for (i = 0; i < 2; i++) {
1594 rpp_sci_printf("Wake up pattern %s received on channel %s.\r\n", statusStrings[(status >> i) & 0x1], channelNames[i]);
1597 rpp_sci_printf("General error.\r\n");
1598 return -CMDERR_BADCFG;
1604 * @brief Set and start absolute timer.
1606 * @param[in] cmd_io Pointer to IO stack
1607 * @param[in] des Pointer to command descriptor
1608 * @param[in] param Parameters of command
1609 * @return 0 when OK or error code
1611 int cmd_do_fr_settimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1613 int8_t retVal = ERR_PARAM_NO_ERROR;
1618 if (sscanf(param[1], "%i %i %i", &timer, &cycle, &offset) != 3)
1619 return -CMDERR_BADPAR;
1621 retVal = rpp_fr_set_timer(0, timer, cycle, offset);
1622 if (retVal == SUCCESS) {
1624 while (i && (cycle & i) == 0)
1629 rpp_sci_printf("Timer was set for every %d-th cycle, offset %d, macrotick %d\n",
1630 i, cycle & ~i, offset);
1633 rpp_sci_printf("General error.\r\n");
1634 return -CMDERR_BADCFG;
1640 * @brief Cancel selected timer
1642 * @param[in] cmd_io Pointer to IO stack
1643 * @param[in] des Pointer to command descriptor
1644 * @param[in] param Parameters of command
1645 * @return 0 when OK or error code
1647 int cmd_do_fr_canceltimer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1649 int8_t retVal = ERR_PARAM_NO_ERROR;
1652 if (sscanf(param[1], "%d", &timer) != 1)
1653 return -CMDERR_BADPAR;
1655 if (param[2] != NULL)
1656 return -CMDERR_BADPAR;
1658 retVal = rpp_fr_cancel_timer(0, timer);
1659 if (retVal == SUCCESS)
1660 rpp_sci_printf("Timer was canceled.\r\n");
1662 rpp_sci_printf("General error.\r\n");
1663 return -CMDERR_BADCFG;
1669 * @brief Enable/disable, acknowledge, get timer IRQ
1671 * @param[in] cmd_io Pointer to IO stack
1672 * @param[in] des Pointer to command descriptor
1673 * @param[in] param Parameters of command
1674 * @return 0 when OK or error code
1676 int cmd_do_fr_timerirq(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1678 int8_t retVal = ERR_PARAM_NO_ERROR;
1681 boolean_t status = FALSE;
1682 char *boolStrings[] = {"FALSE", "TRUE"};
1685 if (sscanf(param[1], "%d", &timer) != 1)
1686 return -CMDERR_BADPAR;
1688 if (param[2] == NULL) { // Get timer IRQ
1689 retVal = rpp_fr_get_timer_irq_status(0, timer, &status);
1690 if (retVal == SUCCESS)
1691 rpp_sci_printf("IRQ = %s\r\n", boolStrings[status]);
1693 rpp_sci_printf("General error.\r\n");
1694 return -CMDERR_BADCFG;
1697 else { // Some set action
1698 if (sscanf(param[2], "%4s", str) != 1)
1699 return -CMDERR_BADPAR;
1700 if (strcmp(str, "EN") == 0) // Enable IRQ
1701 retVal = SUCCESS; // No interrupts imlemented
1702 else if (strcmp(str, "DIS") == 0) // Disable IRQ
1703 retVal = SUCCESS; // No interrupts implemented
1704 else if (strcmp(str, "ACK") == 0) // Clear IRQ
1705 retVal = rpp_fr_clear_timer_irq(0, timer);
1706 else // Bad argument
1707 return -CMDERR_BADPAR;
1709 if (retVal == SUCCESS)
1710 rpp_sci_printf("OK\r\n");
1712 rpp_sci_printf("General error.\r\n");
1713 return -CMDERR_BADCFG;
1720 * @brief Print FlexRay driver version info.
1722 * @param[in] cmd_io Pointer to IO stack
1723 * @param[in] des Pointer to command descriptor
1724 * @param[in] param Parameters of command
1725 * @return 0 when OK or error code
1727 int cmd_do_fr_getversioninfo(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1729 Std_VersionInfoType versionInfo;
1731 rpp_fr_get_driver_version(&versionInfo);
1732 rpp_sci_printf("vendorID: %#x\r\n", versionInfo.vendorID);
1733 rpp_sci_printf("moduleID: %#x\r\n", versionInfo.moduleID);
1734 rpp_sci_printf("sw_major_version: %#x\r\n", versionInfo.sw_major_version);
1735 rpp_sci_printf("sw_minor_version: %#x\r\n", versionInfo.sw_minor_version);
1736 rpp_sci_printf("sw_patch_version: %#x\r\n", versionInfo.sw_patch_version);
1742 * @brief Print value of FlexRay configuratoin parameter.
1744 * @param[in] cmd_io Pointer to IO stack
1745 * @param[in] des Pointer to command descriptor
1746 * @param[in] param Parameters of command
1747 * @return 0 when OK or error code
1749 int cmd_do_fr_readcconfig(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1751 int8_t retVal = ERR_PARAM_NO_ERROR;
1755 if (sscanf(param[1], "%d", &index) != 1)
1756 return -CMDERR_BADPAR;
1758 if (param[2] != NULL)
1759 return -CMDERR_BADPAR;
1761 retVal = rpp_fr_read_com_ctrl_config(0, index, &value);
1762 if (retVal == SUCCESS)
1763 rpp_sci_printf("Value = %#x\r\n", value);
1765 rpp_sci_printf("General error.\r\n");
1766 return -CMDERR_BADCFG;
1772 * @brief Reconfigure buffer
1774 * @param[in] cmd_io Pointer to IO stack
1775 * @param[in] des Pointer to command descriptor
1776 * @param[in] param Parameters of command
1777 * @return 0 when OK or error code
1779 int cmd_do_fr_reconfigure_buffer(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
1783 unsigned bufferID, slot, maxpayload, cycleset, cycleoffset;
1784 Fr_TMS570LS_BufferConfigType tmp_buffer;
1788 ret = sscanf(param[2], "id%i slot%i %2s cycset%i cycoffset%i max%i",
1797 printf("Error parsing parameter %d\n", ret+1);
1798 return -CMDERR_BADPAR;
1801 if (slot > 2047 || bufferID > FR_MAX_BUFFERS_CNT)
1802 return badpar("Invalid slot number\n");
1803 tmp_buffer.slotId = slot;
1804 if (strcmp(channel, "A") == 0) tmp_buffer.channel = FR_CHANNEL_A;
1805 else if (strcmp(channel, "B") == 0) tmp_buffer.channel = FR_CHANNEL_B;
1806 else if (strcmp(channel, "AB") == 0) tmp_buffer.channel = FR_CHANNEL_AB;
1807 else return badpar("Channel parsing error\n");
1808 if (cycleset == 0) cycleset = 1;
1809 for (pow2 = 1, is_pow2 = FALSE; pow2 < 128; pow2 *= 2) {
1810 if (cycleset == pow2) {
1816 return badpar("Cycle set must be one of 0, 1, 2, 4, 8, 16, 32, 64.\n");
1817 if (cycleoffset >= cycleset)
1818 return badpar("Cycle offset must in range 0 - cycset-1.\n");
1820 if (maxpayload >= 256)
1821 return badpar("Maximum payload in bytes must be less than 256\n");
1822 tmp_buffer.maxPayload = maxpayload;
1824 if (rpp_fr_reconfigure_lpdu(0, bufferID, tmp_buffer.slotId, tmp_buffer.channel, cycleset, cycleoffset, tmp_buffer.maxPayload, 0) == SUCCESS) {
1825 printf("id%i slot%i %2s cycset%i cycoffset%i max%i\n",
1836 printf("Reconfiguration failed.\n");
1837 return -CMDERR_BADPAR;
1842 /** Command descriptor for FlexRay user config cluster command */
1843 cmd_des_t const cmd_des_fr_user_config = {
1845 "frbtconfig*","Set the user configuration parameters",
1846 "### Command syntax ###\n"
1848 " frbtconfig<TYPE> <PARAMS>\n"
1851 "- `<TYPE>` is a string specifying the type of parameters to be set. It can be: \"cluster\" or \"node\"\n"
1852 "- `<PARAMS>` is a sequence of numbers separated by spaces. Each number stands for one parameter.\n"
1854 "### Description ###\n"
1856 "The command takes the configuration parameters in the form of a string\n"
1857 "and sets the appropriate type of the FlexRay parameters. It is\n"
1858 "necessary to configure parameters of at least cluster, and node and\n"
1859 "one static buffer (see frbtcfgbuf command). The parameters set by this\n"
1860 "command are applied by the frbtinitU command. Once frbtinit is called,\n"
1861 "it is no longer possible to change the parameters.\n"
1863 "The type of the parameters can be selected by the `<TYPE>` selector.\n"
1865 "Type \"cluster\" sets global FlexRay network parameters. It expects a\n"
1866 "sequence of 25 parameters in this order:\n"
1868 "- 1) gColdStartAttempts\n"
1869 "- 2) gListenNoise\n"
1870 "- 3) gMacroPerCycle\n"
1871 "- 4) gMaxWithoutClockCorrectionFatal\n"
1872 "- 5) gMaxWithoutClockCorrectionPassive\n"
1873 "- 6) gNetworkManagementVectorLength\n"
1874 "- 7) gNumberOfMinislots\n"
1875 "- 8) gNumberOfStaticSlots\n"
1876 "- 9) gOffsetCorrectionStart\n"
1877 "- 10) gPayloadLengthStatic\n"
1878 "- 11) gSyncNodeMax\n"
1879 "- 12) gdActionPointOffset\n"
1880 "- 13) gdCASRxLowMax\n"
1881 "- 14) gdDynamicSlotIdlePhase\n"
1882 "- 15) gdMinislot\n"
1883 "- 16) gdMinislotActionPointOffset\n"
1885 "- 18) gdSampleClockPeriod\n"
1886 "- 19) gdStaticSlot\n"
1887 "- 20) gdTSSTransmitter\n"
1888 "- 21) gdWakeupSymbolRxIdle\n"
1889 "- 22) gdWakeupSymbolRxLow\n"
1890 "- 23) gdWakeupSymbolRxWindow\n"
1891 "- 24) gdWakeupSymbolTxIdle\n"
1892 "- 25) gdWakeupSymbolTxLow\n"
1894 "Type \"node\" sets local FlexRay network parameters. It expects a\n"
1895 "sequence of 28 parameters in this order:\n"
1897 "- 1) pAllowHaltDueToClock\n"
1898 "- 2) pAllowPassiveToActive\n"
1899 "- 3) pChannels (0 - A, 1 - B, 2 - AB)\n"
1900 "- 4) pClusterDriftDamping\n"
1901 "- 5) pDelayCompensationA\n"
1902 "- 6) pDelayCompensationB\n"
1903 "- 7) pExternOffsetCorrection\n"
1904 "- 8) pExternRateCorrection\n"
1905 "- 9) pKeySlotUsedForStartup\n"
1906 "- 10) pKeySlotUsedForSync\n"
1908 "- 12) pMacroInitialOffsetA\n"
1909 "- 13) pMacroInitialOffsetB\n"
1910 "- 14) pMicroInitialOffsetA\n"
1911 "- 15) pMicroInitialOffsetB\n"
1912 "- 16) pMicroPerCycle\n"
1913 "- 17) pRateCorrectionOut\n"
1914 "- 18) pOffsetCorrectionOut\n"
1915 "- 19) pSamplesPerMicrotick\n"
1916 "- 20) pSingleSlotEnabled\n"
1917 "- 21) pWakeupChannel (0 - A, 1 - B)\n"
1918 "- 22) pWakeupPattern\n"
1919 "- 23) pdAcceptedStartupRange\n"
1920 "- 24) pdListenTimeout\n"
1921 "- 25) pdMaxDrift\n"
1922 "- 26) pDecodingCorrection\n"
1923 "- 27) syncFramePayloadMultiplexEnabled\n"
1924 "- 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"
1928 " --> 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"
1929 " FlexRay cluster configuration accepted.\n"
1930 " --> 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"
1931 " FlexRay node configuration accepted.\n",
1932 CMD_HANDLER(cmd_do_fr_user_config), (void *)&cmd_list_fr_basic_test
1935 cmd_des_t const cmd_des_fr_config_buffer = {
1937 "frbtcfgbuf?*","Configure a message buffer in the user configuration",
1938 "### Command syntax ###\n"
1940 " frbtcfgbuf<TYPE><BUFID> slot<SLOT> <CHN> cyc<CYC> <RXTX> max<MAX> <REP> ppi<PPI> int<INT>\n"
1943 "- `<TYPE>` is 'S' for static segment buffers and 'D' for dynamic segment buffers,\n"
1944 "- `<BUFID>` is the number of the buffer. Both static and dynamic buffers are numbered independently starting from zero,\n"
1945 "- `<SLOT>` is the number of the slot,\n"
1946 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1947 "- `<CYC>` is the cycle set when to send the buffer,\n"
1948 "- `<RXTX>` is either string \"rx\" or \"tx\",\n"
1949 "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1950 "- `<REP>` is a string \"s\" or \"single\" for single transmission or \"c\" or \"continuous\" for continuous transmission,\n"
1951 "- `<PPI>` is 0 or 1 determining whether the payload preamble indicator is set,\n"
1952 "- `<INT>` is 0 or 1 and is currently ignored.\n"
1954 "### Description ###\n"
1956 "The command sets the configuration parameters for static or dynamic\n"
1957 "buffers in user configuration. The parameters set by this command are\n"
1958 "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1959 "longer possible to change the parameters.\n"
1963 " --> frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1964 " frbtcfgbufS0 slot2 AB cyc0 tx max9 continous ppi0 int1\n"
1965 " --> frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1966 " frbtcfgbufS1 slot1 AB cyc0 rx max9 continuous ppi0 int1\n"
1967 " --> frbtcfgbufD0 slot9 A cyc0 rx max0x40 single ppi0 int0\n"
1968 " frbtcfgbufD0 slot9 A cyc0 rx max64 single ppi0 int0\n"
1969 " --> frbtcfgbufD1 slot10 A cyc0 tx max0x40 single ppi0 int0\n"
1970 " frbtcfgbufD1 slot10 A cyc0 tx max64 single ppi0 int0\n",
1971 CMD_HANDLER(cmd_do_fr_config_bufer), (void *)&cmd_list_fr_basic_test
1974 cmd_des_t const cmd_des_fr_config_fifo = {
1976 "frbtcfgfifo*","Configure a RX FIFO message buffer in the user configuration",
1977 "### Command syntax ###\n"
1979 " frbtcfgfifo rejslot<SLOT> slotmask<MASK> depth<DEPTH> <CHN> cyc<CYC> max<MAX> <REJNULL> <REJSTAT>\n"
1981 "- `<SLOT>` is the number of the slot that will be rejected. If it is 0, no slot will be rejected,\n"
1982 "- `<MASK>` is a number specifying which bits of the `<SLOT>` will be ignored,"
1983 "- `<DEPTH>` is a number specifying the depth of the FIFO,\n"
1984 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
1985 "- `<CYC>` is the cycle set when to send the buffer,\n"
1986 "- `<MAX>` is the number determining the maximum payload (in hald-words),\n"
1987 "- `<REJNULL>` is a string \"rejnull\" for rejecting NULL frames or \"accnull\" for accepting NULL frames,\n"
1988 "- `<REJSTAT>` is a string \"rejstat\" for rejecting frames in static segment or \"accstat\" for accepting frames from static segment,\n"
1990 "### Description ###\n"
1992 "The command sets the configuration parameters for RX FIFO buffer\n"
1993 "in user configuration. The parameters set by this command are\n"
1994 "applied by the frbtinitU command. Once frbtinit is called, it is no\n"
1995 "longer possible to change the parameters.\n"
1996 "Those messages, which are not accepted by any other buffer and pass the\n"
1997 "FIFO rejection filter will be stored in the RX FIFO buffer.\n"
2001 " --> frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n"
2002 " frbtcfgfifo rejslot6 slotmask6 depth5 AB cyc0 max0x20 rejnull accstat\n",
2003 CMD_HANDLER(cmd_do_fr_config_fifo), (void *)&cmd_list_fr_basic_test
2006 /** Command descriptor for FlexRay init command */
2007 cmd_des_t const cmd_des_fr_init = {
2009 "frbtinit?","Initialize a FlexRay node",
2010 "### Command syntax ###\n"
2014 "where `<CFG>` identifies the configuration to use. It can be one of A, B\n"
2015 "or U. The A and B are predefined configurations. If U is specified,\n"
2016 "the user configuration previously set by frbtconfig command is used.\n"
2018 "### Description ###\n"
2020 "The command stands for Fr_Init and Fr_ControllerInit functions from\n"
2021 "the Autosar specification. It initializes the internal data structures\n"
2022 "of the driver and then, based on those data, the controller\n"
2023 "configuration is done. During the controller configuration the\n"
2024 "parameters of the cluster, node, message RAM and buffers are checked.\n"
2025 "If anything goes bad, the command returns an error number, which can\n"
2026 "be decoded by macros defined in driver header file fr_tms570.h with\n"
2027 "prefix ERR_PARAM. If all parameters are OK, all necessary registers of\n"
2028 "the controller are initialized according to the specified\n"
2029 "configuration parameters. At the end of the command, the FlexRay\n"
2030 "controller is switched into READY state and all buffers are configured\n"
2031 "to send NULL frames. This command should be called as the very first\n"
2032 "command, when trying to communicate over the FlexRay bus.\n"
2037 " FlexRay driver initialized.\n"
2038 " FlexRay controller initialized.\n",
2039 CMD_HANDLER(cmd_do_fr_init), (void *)&cmd_list_fr_basic_test
2042 /** Command descriptor for FlexRay controller init command */
2043 cmd_des_t const cmd_des_fr_start = {
2045 "frbtstart","Start a new FlexRay network or join to the existing one",
2046 "### Command syntax ###\n"
2050 "### Description ###\n"
2052 "The command stands for Fr_StartCommunication function from the Autosar\n"
2054 "If the FlexRay node is configured as a coldstarter node\n"
2055 "(as for example by frbtinitA/B command), then the command first listen\n"
2056 "on the bus. When it does not detect any existing bus communication, it\n"
2057 "tries to initiate a new network. If the initiation fails, the FlexRay\n"
2058 "controller is switched back to the ready state for another attempt\n"
2059 "(calling frbtstart again). If the FlexRay node is configured as\n"
2060 "non-coldstarter, it is listening on the bus until some existing\n"
2061 "communication is detected.\n"
2063 "The command should be called after the frbtinit command.\n"
2065 "You may also want to call frbtallslots command to allow the communication\n"
2066 "for all other slots besides the key slots.\n"
2071 " FlexRay communication is running.\n",
2072 CMD_HANDLER(cmd_do_fr_start), (void *)&cmd_list_fr_basic_test
2075 /** Command descriptor for FlexRay controller all slots command */
2076 cmd_des_t const cmd_des_fr_allslots = {
2078 "frbtallslots","Enables communication for all frames",
2079 "### Command syntax ###\n"
2083 "### Description ###\n"
2085 "The command stands for Fr_AllSlots function from the Autosar\n"
2088 "The node can be configured to communicate only on key frames by\n"
2089 "default (as in the case of frbtinitA/B). This command can be used to\n"
2090 "allow the communication on all configured frames. The command invokes\n"
2091 "the FlexRay POC command ALL_SLOTS which enables the communication on\n"
2092 "all frames. The command can be called after the controller\n"
2097 " --> frbtallslots\n"
2098 " FlexRay node started communication on all slots.\n",
2099 CMD_HANDLER(cmd_do_fr_allslots), (void *)&cmd_list_fr_basic_test
2102 /** Command descriptor for FlexRay controller halt command */
2103 cmd_des_t const cmd_des_fr_halt = {
2105 "frbthalt","Halt FlexRay communication after the end of the actual communication cycle",
2106 "### Command syntax ###\n"
2110 "### Description ###\n"
2112 "The command stands for Fr_HaltCommunication function from the Autosar\n"
2113 "specification. The command invokes the FlexRay POC command HALT, which\n"
2114 "means that communication is stopped after the end of the actual\n"
2115 "communication cycle. On the opposite side, there is a frbtfreeze\n"
2116 "command, which stops the communication immediately. To restart the\n"
2117 "communication, the frbtinit and frbtstart commands have to be called.\n"
2122 " FlexRay node communication halted.\n",
2123 CMD_HANDLER(cmd_do_fr_halt), (void *)&cmd_list_fr_basic_test
2126 /** Command descriptor for FlexRay controller abort command */
2127 cmd_des_t const cmd_des_fr_abort = {
2129 "frbtabort","Abort FlexRay communication immediately",
2130 "### Command syntax ###\n"
2134 "### Description ###\n"
2136 "The command stands for Fr_AbortCommunication function from the Autosar\n"
2137 "specification. The command invokes the FlexRay POC command FREEZE,\n"
2138 "which means that the communication is stopped immediately. On the\n"
2139 "opposite side there is a frbthalt command, which stops the\n"
2140 "communication after the end of the actual communication cycle. To\n"
2141 "restart the communication, the frbtinit and frbtstart commands have\n"
2147 " FlexRay node communication aborted.\n",
2148 CMD_HANDLER(cmd_do_fr_abort), (void *)&cmd_list_fr_basic_test
2151 /** Command descriptor for FlexRay controller send wake up pattern command */
2152 cmd_des_t const cmd_des_fr_sendwup = {
2154 "frbtwup","Initiate the wake up procedure",
2155 "### Command syntax ###\n"
2159 "### Description ###\n"
2161 "The command stands for Fr_SendWUP function from the Autosar\n"
2162 "specification. It initiates the wake up procedure by switching FlexRay\n"
2163 "controller state machine to WAKEUP state.\n"
2168 " Wake up pattern has been sent.\n",
2169 CMD_HANDLER(cmd_do_fr_sendwup), (void *)&cmd_list_fr_basic_test
2172 /** Command descriptor for FlexRay controller sent wake up pattern channel command */
2173 cmd_des_t const cmd_des_fr_setwuchannel = {
2175 "frbtsetwuch?","Set wake up channel",
2176 "### Command syntax ###\n"
2178 " frbtsetwuch<CHANNEL>\n"
2180 "where `<CHANNEL>` is a character A or B, specifying the channel.\n"
2182 "### Description ###\n"
2184 "The command stands for Fr_SetWakeupChannel function from the Autosar\n"
2185 "specification. Wake up channel is the channel, where Wake Up Pattern\n"
2186 "is sent. The channel can be set after the driver and controller are\n"
2187 "initialized and before the communication is running. The actual\n"
2188 "wake-up pattern is sent by the frbtwup command.\n"
2192 " --> frbtsetwuchA\n"
2193 " Wake up channel has been set.\n",
2194 CMD_HANDLER(cmd_do_fr_setwuchannel), (void *)&cmd_list_fr_basic_test
2197 /** Command descriptor for FlexRay controller get POC status command */
2198 cmd_des_t const cmd_des_fr_getpocstatus = {
2200 "frbtgetpocst","Print FlexRay POC status",
2201 "### Command syntax ###\n"
2205 "### Description ###\n"
2207 "The command stands for Fr_GetPOCStatus function from the Autosar\n"
2208 "specification. It prints the main FlexRay POC status values in the\n"
2209 "form of a table. The command should be called after the frbtinit\n"
2214 " --> frbtgetpocst\n"
2216 " CHIHaltRequest: FALSE\n"
2217 " CHIReadyRequest: FALSE\n"
2218 " ColdstartNoise: FALSE\n"
2220 " ErrorMode: ACTIVE\n"
2222 " StartupState: UNDEFINED\n"
2224 " WakeupStatus: UNDEFINED\n",
2225 CMD_HANDLER(cmd_do_fr_getpocstatus), (void *)&cmd_list_fr_basic_test
2228 /** Command descriptor for FlexRay transmit tx lpdu command */
2229 cmd_des_t const cmd_des_fr_transmittxlpdu = {
2231 "frbttransmit*","Transmit data from the selected frame buffer",
2232 "### Command syntax ###\n"
2234 " frbttransmit<BUFID> <DATA>\n"
2237 "- `<BUFID>` is a decimal number specifying the ID of the frame\n"
2238 " buffer configured for data transmission\n"
2239 "- `<DATA>` is a sequence of hexadecimal numbers separated by spaces.\n"
2240 " Each number represents one byte of the message.\n"
2242 "### Description ###\n"
2244 "The command stands for Fr_TransmitTxLPdu function from the Autosar\n"
2245 "specification. The command copies the given data into the buffers data\n"
2246 "section in the message RAM. Transmit request is set after the data are\n"
2247 "copied, so transmission starts at the next occurrence of the frame in the\n"
2248 "communication cycle.\n"
2252 " --> frbttransmit1 12 34 56 AA BB CC\n"
2253 " Data were set for transmission.\n",
2254 CMD_HANDLER(cmd_do_fr_transmittxlpdu), (void *)&cmd_list_fr_basic_test
2257 /** Command descriptor for FlexRay cancel tx lpdu command */
2258 cmd_des_t const cmd_des_fr_canceltxlpdu = {
2260 "frbtcanceltx*","Stop the transmission from the frame buffer",
2261 "### Command syntax ###\n"
2263 " frbtcanceltx<BUFID>\n"
2265 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2268 "### Description ###\n"
2270 "The command stands for Fr_CancelTxLPdu function from the Autosar\n"
2271 "specification. The command reconfigures the selected buffer to stop\n"
2272 "data transmission. The command finishes successfully only if the\n"
2273 "reconfiguration is allowed in message RAM configuration (secureBuffers\n"
2274 "configuration parameter). Only TX buffers and buffers not used for startup\n"
2275 "frames can be canceled.\n"
2279 " --> frbtcanceltx3\n"
2280 " Transmission canceled.\n",
2281 CMD_HANDLER(cmd_do_fr_canceltxlpdu), (void *)&cmd_list_fr_basic_test
2284 /** Command descriptor for FlexRay receive rx lpdu command */
2285 cmd_des_t const cmd_des_fr_receiverxlpdu = {
2287 "frbtreceive*","Receive a new message",
2288 "### Command syntax ###\n"
2290 " frbtreceive<BUFID>\n"
2292 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2295 "### Description ###\n"
2297 "The command stands for Fr_ReceiveRxLPdu function from the Autosar\n"
2298 "specification. The command tries to read a new message from the selected\n"
2299 "buffer. If new message is available, it is copied out of the buffer and\n"
2300 "printed. If no message is available, \"No message received\" is printed.\n"
2301 "If a new message was retrieved from a FIFO buffer and more messages are\n"
2302 "available in it, \"More messages are still in FIFO\" is printed.\n"
2306 " --> frbtreceive0\n"
2307 " More messages are still in FIFO:\n"
2308 " Received message (32 B):\n"
2309 " ee ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n"
2310 " 00 00 00 00 00 00 00 00 00\n",
2311 CMD_HANDLER(cmd_do_fr_receiverxlpdu), (void *)&cmd_list_fr_basic_test
2314 /** Command descriptor for FlexRay check TX LPdu status command */
2315 cmd_des_t const cmd_des_fr_checktxlpdustatus = {
2317 "frbtchecktx*","Print the status of the transmit buffer",
2318 "### Command syntax ###\n"
2320 " frbtchecktx<BUFID>\n"
2322 "where `<BUFID>` is a decimal number specifying the ID of a configured\n"
2325 "### Description ###\n"
2327 "The command stands for Fr_CheckTxLPduStatus function from the Autosar\n"
2328 "specification. The command reads and prints status of the selected frame buffer.\n"
2329 "The buffer can be in one of the two states:\n"
2331 "- Message transmission is pending, which means that the buffer has not yet sent its\n"
2332 " message in single shot mode or that it is in continuous mode.\n"
2333 "- No message transmission is pending, which means that the buffer is in single shot\n"
2334 " mode and the message has already been sent.\n"
2338 " --> frbtchecktx1\n"
2339 " Message transmission is not pending.\n",
2340 CMD_HANDLER(cmd_do_fr_checktxlpdustatus), (void *)&cmd_list_fr_basic_test
2343 /** Command descriptor for FlexRay disable LPdu command */
2344 cmd_des_t const cmd_des_fr_disablelpdu = {
2346 "frbtdisable*","Disable the buffers assigned to the frame",
2347 "### Command syntax ###\n"
2349 " frbtdisable<BUFID>\n"
2351 "where `<BUFID>` is a decimal number specifying the ID of a frame buffer.\n"
2352 "The buffer configured will be disabled.\n"
2354 "### Description ###\n"
2356 "The command stands for Fr_DisableLPdu function from the Autosar\n"
2357 "specification. The command disables the selected buffer. This means\n"
2358 "that this buffer will be unavailable for the communication until\n"
2359 "their reconfiguration (which is not yet implemented). Buffers used\n"
2360 "for startup frames and FIFO RX buffers cannot be disabled.\n"
2364 " --> frbtdisable3\n"
2365 " Buffer disabled.\n",
2366 CMD_HANDLER(cmd_do_fr_disablelpdu), (void *)&cmd_list_fr_basic_test
2369 /** Command descriptor for FlexRay get global time command */
2370 cmd_des_t const cmd_des_fr_getglobaltime = {
2372 "frbtglobtime","Print actual global time of the network",
2373 "### Command syntax ###\n"
2377 "### Description ###\n"
2379 "The command stands for Fr_GetGlobalTime function from the Autosar\n"
2380 "specification. The command prints the time as a number of the current\n"
2381 "cycle and the offset in the cycle in macroticks.\n"
2385 " --> frbtglobtime\n"
2386 " Cycle number: 23\n"
2387 " Macrotick number: 6\n",
2388 CMD_HANDLER(cmd_do_fr_getglobaltime), (void *)&cmd_list_fr_basic_test
2391 /** Command descriptor for FlexRay get network management vector command */
2392 cmd_des_t const cmd_des_fr_getnmvector = {
2394 "frbtnmvector","Print network management vector of the node",
2395 "### Command syntax ###\n"
2399 "### Description ###\n"
2401 "The command stands for Fr_GetNmVector function from the Autosar\n"
2402 "specification. It prints the values of the network management vector\n"
2403 "as hexadecimal numbers.\n"
2407 " --> frbtnmvector\n"
2408 " Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2409 CMD_HANDLER(cmd_do_fr_getnmvector), (void *)&cmd_list_fr_basic_test
2412 /** Command descriptor for FlexRay get network management vector command */
2413 cmd_des_t const cmd_des_fr_nmwatch = {
2415 "frbtnmwatch","Watch the changes of the network managment vector in real-time",
2416 "### Command syntax ###\n"
2420 "### Description ###\n"
2422 "Reads the network management vector every 100 ms and prints it out.\n"
2426 " --> frbtnmwatch\n"
2427 " Network management vector: 0 0 0 0 0 0 0 0 0 0 0 0\n",
2428 CMD_HANDLER(cmd_do_fr_nmwatch), (void *)&cmd_list_fr_basic_test
2431 /** Command descriptor for FlexRay get channel status command */
2432 cmd_des_t const cmd_des_fr_getchannelstatus = {
2434 "frbtchstat","Print channel A and B status",
2435 "### Command syntax ###\n"
2439 "### Description ###\n"
2441 "The command stands for Fr_GetChannelStatus function from the Autosar\n"
2447 " Channel A status:\n"
2448 " aggregated channel status vSS!ValidFrame: TRUE\n"
2449 " aggregated channel status vSS!SyntaxError: FALSE\n"
2450 " aggregated channel status vSS!ContentError: FALSE\n"
2451 " aggregated channel status additional communication: FALSE\n"
2452 " aggregated channel status vSS!Bviolation: FALSE\n"
2453 " aggregated channel status vSS!TxConflict: FALSE\n"
2454 " Not used (0): FALSE\n"
2455 " Not used (0): FALSE\n"
2456 " symbol window status data vSS!ValidMTS: FALSE\n"
2457 " symbol window status data vSS!SyntaxError: FALSE\n"
2458 " symbol window status data vSS!Bviolation: FALSE\n"
2459 " symbol window status data vSS!TxConflict: FALSE\n"
2460 " NIT status data vSS!SyntaxError: FALSE\n"
2461 " NIT status data vSS!Bviolation: FALSE\n"
2462 " Not used (0): FALSE\n"
2463 " Not used (0): FALSE\n"
2464 " Channel B status:\n"
2465 " aggregated channel status vSS!ValidFrame: TRUE\n"
2466 " aggregated channel status vSS!SyntaxError: FALSE\n"
2467 " aggregated channel status vSS!ContentError: FALSE\n"
2468 " aggregated channel status additional communication: FALSE\n"
2469 " aggregated channel status vSS!Bviolation: FALSE\n"
2470 " aggregated channel status vSS!TxConflict: FALSE\n"
2471 " Not used (0): FALSE\n"
2472 " Not used (0): FALSE\n"
2473 " symbol window status data vSS!ValidMTS: FALSE\n"
2474 " symbol window status data vSS!SyntaxError: FALSE\n"
2475 " symbol window status data vSS!Bviolation: FALSE\n"
2476 " symbol window status data vSS!TxConflict: FALSE\n"
2477 " NIT status data vSS!SyntaxError: FALSE\n"
2478 " NIT status data vSS!Bviolation: FALSE\n"
2479 " Not used (0): FALSE\n"
2480 " Not used (0): FALSE\n",
2481 CMD_HANDLER(cmd_do_fr_getchannelstatus), (void *)&cmd_list_fr_basic_test
2484 /** Command descriptor for FlexRay get clock correction command */
2485 cmd_des_t const cmd_des_fr_getclockcorrection = {
2487 "frbtclkcor","Print clock correction (rate and offset)",
2488 "### Command syntax ###\n"
2492 "### Description ###\n"
2494 "The command stands for Fr_GetClockCorrection function from the Autosar\n"
2500 " Rate correction: 0\n"
2501 " Offset correction: 0\n",
2502 CMD_HANDLER(cmd_do_fr_getclockcorrection), (void *)&cmd_list_fr_basic_test
2505 /** Command descriptor for FlexRay get sync frame list command */
2506 cmd_des_t const cmd_des_fr_getsyncframelist = {
2508 "frbtgetsyncfrlist*","Print the list of sync frames transmitted on both channels via the odd and even communication cycle",
2509 "### Command syntax ###\n"
2511 " frbtgetsyncfrlist<LENGTH>\n"
2513 "where `<LENGTH>` is a decimal number in range 0 - 15, specifying the\n"
2514 "length of the list to be printed.\n"
2516 "### Description ###\n"
2518 "The command stands for Fr_GetSyncFrameList function from the Autosar\n"
2523 " --> frbtgetsyncfrlist2\n"
2524 " | Channel A even | channel B even | channel A odd | channel B odd |\n"
2525 " |----------------|----------------|----------------|----------------|\n"
2526 " | 1 | 1 | 1 | 1 |\n"
2527 " | 2 | 2 | 2 | 2 |\n"
2528 " |----------------|----------------|----------------|----------------|\n",
2529 CMD_HANDLER(cmd_do_fr_getsyncframelist), (void *)&cmd_list_fr_basic_test
2532 /** Command descriptor for FlexRay get sync frame list command */
2533 cmd_des_t const cmd_des_fr_getwakeuprxstatus = {
2535 "frbtgetwurxstat","Prints whether the wake up pattern has been or has not been received",
2536 "### Command syntax ###\n"
2538 " frbtgetwurxstat\n"
2540 "### Description ###\n"
2542 "The command stands for Fr_GetWakeupRxStatus function from the Autosar\n"
2543 "specification. The status of the wake up receiving is bitcoded in the\n"
2544 "controller. This command decodes and prints it in a readable format.\n"
2548 " --> frbtgetwurxstat\n"
2549 " Wake up pattern was not yet received on channel A.\n"
2550 " Wake up pattern was not yet received on channel B.\n",
2551 CMD_HANDLER(cmd_do_fr_getwakeuprxstatus), (void *)&cmd_list_fr_basic_test
2554 /** Command descriptor for FlexRay set absolute timer command */
2555 cmd_des_t const cmd_des_fr_settimer = {
2557 "frbtsettimer*","Set and start timer",
2558 "### Command syntax ###\n"
2560 " frbtsettimer<TMID> <CYCLE> <OFFSET>\n"
2563 "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2564 "- `<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"
2565 "- `<OFFSET>` is a decimal number (0 - 16383) specifying the offset in macroticks, where precisely in the cycle should be the timer interrupt requested.\n"
2567 "### Description ###\n"
2569 "The command is similar to Fr_SetAbsoluteTimer function from the\n"
2570 "Autosar specification. The difference is that the command allows to\n"
2571 "specify a set of cycles, not only one of 64 cycles. It sets the timer\n"
2572 "selected by the parameter and enables it.\n"
2574 "Before using this command, FlexRay communication has to be started\n"
2575 "(see frbtstart).\n"
2579 " --> frbtsettimer0 32 50\n"
2580 " Timer was set for every 32-th cycle, offset 0, macrotick 50\n"
2581 " --> frbtsettimer0 31 50\n"
2582 " Timer was set for every 16-th cycle, offset 15, macrotick 50\n"
2583 " --> frbtsettimer0 0x42 0\n"
2584 " Timer was set for every 64-th cycle, offset 2, macrotick 0\n",
2585 CMD_HANDLER(cmd_do_fr_settimer), (void *)&cmd_list_fr_basic_test
2588 /** Command descriptor for FlexRay cancel absolute timer command */
2589 cmd_des_t const cmd_des_fr_canceltimer = {
2591 "frbtcanceltimer*","Stop the timer",
2592 "### Command syntax ###\n"
2594 " frbtcanceltimer<TMID>\n"
2595 "where `<TMID>` is a number (0 or 1) specifying the timer.\n"
2597 "### Description ###\n"
2599 "The command stands for Fr_CancelAbsoluteTimer function from the\n"
2600 "Autosar specification. It stops the timer selected by the parameter.\n"
2604 " --> frbtcanceltimer0\n"
2605 " Timer was canceled.\n",
2606 CMD_HANDLER(cmd_do_fr_canceltimer), (void *)&cmd_list_fr_basic_test
2609 /** Command descriptor for FlexRay absolute timer irq manipulation command */
2610 cmd_des_t const cmd_des_fr_timerirq = {
2612 "frbttimerirq*","Perform selected action on the timer IRQ",
2613 "### Command syntax ###\n"
2615 " frbttimerirq<TMID> <ACTION> - Run the <ACTION> on specified timer\n"
2616 " frbttimerirq<TMID> - Get timer IRQ status\n"
2620 "- `<TMID>` is a number (0, 1) specifying the timer.\n"
2621 "- where `<ACTION>` is a string specifying the action to be performed on the selected timer IRQ.\n"
2623 "`<ACTIONS>` can be one of:\n"
2625 "- EN - Enable the IRQ on the selected timer\n"
2626 "- DIS - Disable the IRQ on the selected timer\n"
2627 "- ACK - Acknowledge the IRQ on the selected timer (reset flag in the register).\n"
2629 "### Description ###\n"
2631 "The command stands for Fr_EnableAbsoluteTimerIRQ,\n"
2632 "Fr_AckAbsoluteTimerIRQ, Fr_DisableAbsoluteTimerIRQ and\n"
2633 "Fr_GetAbsoluteTimerIRQStatus functions from the Autosar specification.\n"
2634 "It masks or demasks the IRQ for the timer, or acknowledges the\n"
2635 "interrupt request. If no action is specified it prints whether the IRQ\n"
2636 "is pending for the timer.\n"
2640 " --> frbttimerirq0\n"
2643 " --> frbttimerirq0 EN\n"
2645 CMD_HANDLER(cmd_do_fr_timerirq), (void *)&cmd_list_fr_basic_test
2648 /** Command descriptor for FlexRay get version info command */
2649 cmd_des_t const cmd_des_fr_getversioninfo = {
2651 "frbtversion","Print FlexRay driver version information",
2652 "### Command syntax ###\n"
2656 "### Description ###\n"
2658 "The command stands for Fr_GetVersionInfo function from the Autosar\n"
2660 "It reads and prints the information about vendor, module and version of\n"
2661 "the FlexRay driver\n"
2665 " --> frbtversion\n"
2666 " vendorID: 0xAAAA\n"
2667 " moduleID: 0xBBBB\n"
2668 " sw_major_version: 0x1\n"
2669 " sw_minor_version: 0x2\n"
2670 " sw_patch_version: 0x4\n",
2671 CMD_HANDLER(cmd_do_fr_getversioninfo), (void *)&cmd_list_fr_basic_test
2674 /** Command descriptor for FlexRay get controller configuration command */
2675 cmd_des_t const cmd_des_fr_readcconfig = {
2677 "frbtccconfig*","Print value of a FlexRay cluster and node configuration parameter",
2678 "### Command syntax ###\n"
2680 " frbtccconfig<INDEX>\n"
2682 "where `<INDEX>` is an identifier of the parameter.\n"
2684 "### Description ###\n"
2686 "The command stands for Fr_ReadCCConfig function from the Autosar\n"
2687 "specification. The driver stores the configuration parameters as an\n"
2688 "array. Each parameter can be indexed and returned by this command. See\n"
2689 "Autosar specification of the FlexRay driver\n"
2690 "(http://www.autosar.org/download/R4.1/AUTOSAR_SWS_FlexRayDriver.pdf),\n"
2691 "section 8.2.1 for parameter indexes.\n"
2695 " --> frbtccconfig1\n"
2697 CMD_HANDLER(cmd_do_fr_readcconfig), (void *)&cmd_list_fr_basic_test
2700 /** Command descriptor for FlexRay reconfigure buffer command */
2701 cmd_des_t const cmd_des_fr_reconfigure_buffer = {
2703 "frbtreconfigurebuf*","Reconfigure a buffer to communicate in another slot",
2704 "### Command syntax ###\n"
2706 " frbtreconfigurebuf id<BUFID> slot<SLOT> <CHN> cycset<CYCS> cycoffset<CYCO> max<MAX>\n"
2709 "- `<BUFID>` is a number specifying a slot, where the buffer is currently communicating,\n"
2710 "- `<SLOT>` is a number, where buffer will be communicating after the reconfiguration,\n"
2711 "- `<CHN>` is one of 'A', 'B' or 'AB' and identifies the used channel,\n"
2712 "- `<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"
2713 "- `<CYCO>` is the cycle offset. It has to be in range 0 - `<CYCS>`-1"
2714 "- `<MAX>` is the number determining the maximum payload (in hald-words).\n"
2716 "### Description ###\n"
2718 "The command stands for Fr_ReconfigLPDu function from the Autosar\n"
2719 "specification. It reconfigures specified buffer to communicate in\n"
2721 "The reconfiguration must be allowed in node configuration parameter\n"
2722 "secureBuffers. Buffers used for synchronization or assigned to the FIFO\n"
2723 "are not reconfigurable.\n"
2724 "The command can be called any time when the communication is running.\n"
2728 " --> frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n"
2729 " frbtreconfigurebuf id2 slot3 AB cycset1 cycoffset0 max9\n",
2730 CMD_HANDLER(cmd_do_fr_reconfigure_buffer), (void *)&cmd_list_fr_basic_test
2734 /** List of commands for flexRay, defined as external */
2735 cmd_des_t const *cmd_list_fr_basic_test[] = {
2736 &cmd_des_fr_user_config,
2737 &cmd_des_fr_config_buffer,
2738 &cmd_des_fr_config_fifo,
2741 &cmd_des_fr_allslots,
2744 &cmd_des_fr_sendwup,
2745 &cmd_des_fr_setwuchannel,
2746 &cmd_des_fr_getpocstatus,
2747 &cmd_des_fr_transmittxlpdu,
2748 &cmd_des_fr_canceltxlpdu,
2749 &cmd_des_fr_receiverxlpdu,
2750 &cmd_des_fr_checktxlpdustatus,
2751 &cmd_des_fr_disablelpdu,
2752 &cmd_des_fr_getglobaltime,
2753 &cmd_des_fr_getnmvector,
2754 &cmd_des_fr_nmwatch,
2755 &cmd_des_fr_getchannelstatus,
2756 &cmd_des_fr_getclockcorrection,
2757 &cmd_des_fr_getsyncframelist,
2758 &cmd_des_fr_getwakeuprxstatus,
2759 &cmd_des_fr_settimer,
2760 &cmd_des_fr_canceltimer,
2761 &cmd_des_fr_timerirq,
2762 &cmd_des_fr_getversioninfo,
2763 &cmd_des_fr_readcconfig,
2764 &cmd_des_fr_reconfigure_buffer,