%% Copyright (C) 2013 Czech Technical University in Prague %% %% Authors: %% - Michal Horn %% %% This document contains proprietary information belonging to Czech %% Technical University in Prague. Passing on and copying of this %% document, and communication of its contents is not permitted %% without prior written authorization. %% %% File : sfunction_frayreceive.tlc %% Abstract: %% TLC file for inlining RPP FlexRay node configuration. %% %% References: %% BlockTypeSetup() : refs/rtw_tlc.pdf p. 277 %% Outputs() : refs/rtw_tlc.pdf p. 281 %implements sfunction_frayreceive "C" %include "common.tlc" %% Function: BlockTypeSetup ==================================================== %function BlockTypeSetup(block, system) void %% Ensure required header files are included % % %endfunction %function BlockInstanceSetup(block, system) void %assign channel_val = LibBlockParameterValue(channel, 0) %assign cycleCounterFiltering_val = LibBlockParameterValue(cycleCounterFiltering, 0) %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0) %assign msgBufferInterrupt_val = LibBlockParameterValue(msgBufferInterrupt, 0) %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0) %assign singleTransmit_val = LibBlockParameterValue(singleTransmit, 0) %assign slotId_val = LibBlockParameterValue(slotId, 0) %openfile buffer { %if %==1 .channel = FR_CHANNEL_A, %elseif %==2 .channel = FR_CHANNEL_B, %else .channel = FR_CHANNEL_AB, %endif .cycleCounterFiltering = %, .fidMask = 0, .isTx = FALSE, .maxPayload = %, .msgBufferInterrupt = %, .payloadPreambleIndicatorTr = %, .rejectNullFrames = FALSE, .rejectStaticSegment = FALSE, .singleTransmit = %, .slotId = % }, %closefile buffer %assign ::rpp_fray_buffer_config = "%<::rpp_fray_buffer_config> %" %assign ::rpp_fray_buffer_count = %<::rpp_fray_buffer_count> + 1 %endfunction %% Function: Outputs =========================================================== %function Outputs(block, system) Output %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0 %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1 int8_t retVal; %endif %if EXISTS("_RPP_FRAYREC_TMP_VARS_") == 0 %assign ::_RPP_FRAYREC_TMP_VARS_ = 1 int8_t i; %endif %if !SLibCodeGenForSim() %% Get parameters %assign slotId_val = LibBlockParameterValue(slotId, 0) %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0) %% Get IO signals %assign err_flag = LibBlockOutputSignal(0, "", "", 0) %assign message = LibBlockOutputSignal(1, "", "", 0) %assign length = LibBlockOutputSignal(2, "", "", 0) %assign trigger = LibBlockOutputSignal(3, "", "", 0) %if EXISTS("_RPP_FRAYSTEP_RX_VARS_") == 0 %assign ::_RPP_FRAYSTEP_RX_VARS_ = 1 uint8_t rec_msg[%*2]; uint8_t rec_length; Fr_RxLPduStatusType rec_status; %endif retVal = rpp_fr_receive_lpdu(0, %, rec_msg, &rec_status, &rec_length); if (retVal == FAILURE) { rpp_sci_printf("Receiving a message from slot %#x failed.\n", %); % = TRUE; % = 0; % = 0; % = 0; } else { if (rec_status == FR_NOT_RECEIVED) { % = 0; % = 0; % = 0; } else { rpp_sci_printf("Message from slot %#x received:%#x\n", %, rec_msg[0]); % = 1; for (i = 0; i < %*2; i++) { *(&%+i) = rec_msg[i]; } % = rec_length; } } %endif %endfunction %% [EOF]