%% Copyright (C) 2013 Czech Technical University in Prague %% %% Authors: %% - Michal Horn %% %% Permission is hereby granted, free of charge, to any person %% obtaining a copy of this software and associated documentation %% files (the "Software"), to deal in the Software without %% restriction, including without limitation the rights to use, %% copy, modify, merge, publish, distribute, sublicense, and/or sell %% copies of the Software, and to permit persons to whom the %% Software is furnished to do so, subject to the following %% conditions: %% The above copyright notice and this permission notice shall be %% included in all copies or substantial portions of the Software. %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR %% OTHER DEALINGS IN THE SOFTWARE. %% %% File : sfunction_frayconfig.tlc %% Abstract: %% TLC file for inlining RPP FlexRay TX buffer configuration and message transmittion. %% %% References: %% BlockTypeSetup() : refs/rtw_tlc.pdf p. 277 %% Outputs() : refs/rtw_tlc.pdf p. 281 %implements sfunction_frayconfig "C" %include "common.tlc" %% Function: BlockTypeSetup ==================================================== %function BlockTypeSetup(block, system) void %% Ensure required header files are included % % %assign ::rpp_fray_config_present = 1 %assign ::rpp_fray_present=1 %endfunction %function BlockInstanceSetup(block, system) void %endfunction %% Function: Start ============================================================= %function Start(block, system) Output %openfile buffer static const Fr_TMS570LS_ClusterConfigType fray_cluster_cfg = { .gColdStartAttempts = %, .gListenNoise = %, .gMacroPerCycle = %, .gMaxWithoutClockCorrectionFatal = %, .gMaxWithoutClockCorrectionPassive = %, .gNetworkManagementVectorLength = %, .gNumberOfMinislots = %, .gNumberOfStaticSlots = %, .gOffsetCorrectionStart = %, .gPayloadLengthStatic = %, .gSyncNodeMax = %, .gdActionPointOffset = %, .gdCASRxLowMax = %, .gdDynamicSlotIdlePhase = %, .gdMinislot = %, .gdMinislotActionPointOffset = %, .gdNIT = %, .gdSampleClockPeriod = %, .gdStaticSlot = %, .gdTSSTransmitter = %, .gdWakeupSymbolRxIdle = %, .gdWakeupSymbolRxLow = %, .gdWakeupSymbolRxWindow = %, .gdWakeupSymbolTxIdle = %, .gdWakeupSymbolTxLow = %, }; static const Fr_TMS570LS_NodeConfigType fray_node_cfg = { .pAllowHaltDueToClock = %, .pAllowPassiveToActive = %, %if %==1 .pChannels = FR_CHANNEL_A, %elseif %==2 .pChannels = FR_CHANNEL_B, %else .pChannels = FR_CHANNEL_AB, %endif .pClusterDriftDamping = %, .pDelayCompensationA = %, .pDelayCompensationB = %, .pExternOffsetCorrection = %, .pExternRateCorrection = %, .pKeySlotUsedForStartup = %, .pKeySlotUsedForSync = %, .pLatestTx = %, .pMacroInitialOffsetA = %, .pMacroInitialOffsetB = %, .pMicroInitialOffsetA = %, .pMicroInitialOffsetB = %, .pMicroPerCycle = %, .pRateCorrectionOut = %, .pOffsetCorrectionOut = %, .pSamplesPerMicrotick = %, .pSingleSlotEnabled = %, %if %==1 .pWakeupChannel = FR_CHANNEL_A, %else .pWakeupChannel = FR_CHANNEL_B, %endif .pWakeupPattern = %, .pdAcceptedStartupRange = %, .pdListenTimeout = %, .pdMaxDrift = %, .pDecodingCorrection = %, }; #define FRAY_STATIC_BUFFER_COUNT %<::rpp_fray_buffer_count> static const Fr_TMS570LS_BufferConfigType fray_static_buffers_cfg[FRAY_STATIC_BUFFER_COUNT] = { %<::rpp_fray_buffer_key_slot> %<::rpp_fray_buffer_config> }; static const Fr_TMS570LS_MsgRAMConfig fray_msg_ram_cfg = { .syncFramePayloadMultiplexEnabled = %, %if %==1 .secureBuffers = FR_SB_RECONFIG_ENABLED, %elseif %==2 .secureBuffers = FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED, %elseif %==3 .secureBuffers = FR_SB_ALL_REC_DISABLED, %else .secureBuffers = FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED, %endif .statSegmentBufferCount = FRAY_STATIC_BUFFER_COUNT, .dynSegmentBufferCount = 0, .fifoBufferCount = 0 }; static const Fr_ConfigType flexray_cfg = { .clusterConfiguration = &fray_cluster_cfg, .nodeConfiguration = &fray_node_cfg, .msgRAMConfig = &fray_msg_ram_cfg, .staticBufferConfigs = fray_static_buffers_cfg, .dynamicBufferConfigs = NULL, .fifoBufferConfigs = NULL, }; %closefile buffer % %if !SLibCodeGenForSim() %% Error flag %assign err_flag = LibBlockOutputSignal(0, "", "", 0) %% Declare temporal variables %if EXISTS("_RPP_FRAYCONFIG_TMP_VARS_") == 0 %assign ::_RPP_FRAYCONFIG_TMP_VARS_ = 1 %endif int8_t retVal; uint32_t error; retVal = rpp_fr_init_driver(&flexray_cfg, &error); if (retVal == FAILURE) { rpp_sci_printf("FlexRay driver init error.\n"); % = TRUE; } else { rpp_sci_printf("FlexRay driver initialized.\n"); } retVal = rpp_fr_init_controller(0, &error); if (retVal == FAILURE) { rpp_sci_printf("FlexRay controller init error: %#x.\n", error); % = TRUE; } else { rpp_sci_printf("FlexRay controller initialized.\n"); } retVal = rpp_fr_start_communication(0, &error); if (retVal == FAILURE) { rpp_sci_printf("FlexRay start communication failed: %#x.\n", error); % = TRUE; } else { rpp_sci_printf("FlexRay communication started.\n"); } retVal = rpp_fr_all_slots(0); if (retVal == FAILURE) { rpp_sci_printf("FlexRay all slots failed: %#x.\n", error); % = TRUE; } else { rpp_sci_printf("FlexRay is communicating on all slots.\n"); } %endif %endfunction %% [EOF]