%% Copyright (C) 2013 Czech Technical University in Prague %% %% Authors: %% - Michal Horn %% %% This program is free software; you can redistribute it and/or modify %% it under the terms of the GNU General Public License as published by %% the Free Software Foundation; either version 2 of the License, or %% (at your option) any later version. %% %% This program is distributed in the hope that it will be useful, %% but WITHOUT ANY WARRANTY; without even the implied warranty of %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %% GNU General Public License for more details. %% %% You should have received a copy of the GNU General Public License %% along with this program. If not, see . %% %% 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: Start ============================================================= %function Start(block, system) Output %if !SLibCodeGenForSim() %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) %% Declare temporal variables %if EXISTS("_RPP_FRAYCONFIG_TMP_VARS_") == 0 %assign ::_RPP_FRAYCONFIG_TMP_VARS_ = 1 #define MAX_ST_BUF_CFG 62 Fr_TMS570LS_ClusterConfigType cluster_cfg; Fr_TMS570LS_NodeConfigType node_cfg; Fr_TMS570LS_BufferConfigType static_buffers_cfg[MAX_ST_BUF_CFG]; Fr_TMS570LS_MsgRAMConfig msg_ram_cfg; Fr_ConfigType flexray_cfg; uint8_t static_buffers_cnt = 0; %endif %if %==1 static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_A; %elseif %==2 static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_B; %else static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_AB; %endif static_buffers_cfg[static_buffers_cnt].cycleCounterFiltering = %; static_buffers_cfg[static_buffers_cnt].isTx = FALSE; static_buffers_cfg[static_buffers_cnt].maxPayload = %; static_buffers_cfg[static_buffers_cnt].msgBufferInterrupt = %; static_buffers_cfg[static_buffers_cnt].payloadPreambleIndicatorTr = %; static_buffers_cfg[static_buffers_cnt].singleTransmit = %; static_buffers_cfg[static_buffers_cnt].slotId = %; static_buffers_cnt++; rpp_sci_printf("RX buffer %d added.\n", static_buffers_cnt); %endif %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 !SLibCodeGenForSim() %% Get parameters %assign slotId_val = LibBlockParameterValue(slotId, 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) uint8_t rec_msg[16]; uint8_t rec_length; Fr_RxLPduStatusType rec_status; 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 { % = 1; % = rec_msg[0]; % = rec_length; } } %endif %endfunction %% [EOF]