%% 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_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) %assign bufferId_val = LibBlockParameterValue(bufferId, 0) %if EXISTS(::rpp_fr_bufferId_%_flg) == 1 % %endif %assign ::rpp_fr_bufferId_%_flg = 1 %openfile buffer // 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 maxPayload_val = LibBlockParameterValue(maxPayload, 0) %assign bufferId_val = LibBlockParameterValue(bufferId, 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 buffer %#x failed.\n", %); % = TRUE; % = 0; % = 0; % = 0; } else { if (rec_status == FR_NOT_RECEIVED) { % = 0; % = 0; % = 0; } else { rpp_sci_printf("Message from buffer %#x received:%#x\n", %, rec_msg[0]); % = 1; for (i = 0; i < %*2; i++) { *(&%+i) = rec_msg[i]; } % = rec_length; } } %endif %endfunction %% [EOF]