-%% Copyright (C) 2013 Czech Technical University in Prague
+%% Copyright (C) 2013, 2014 Czech Technical University in Prague
%%
%% Authors:
%% - Michal Horn <hornmich@fel.cvut.cz>
%%
-%% 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 <http://www.gnu.org/licenses/>.
+%% 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_fraytransmit.tlc
%% Abstract:
%include "common.tlc"
-
%% Function: BlockTypeSetup ====================================================
%function BlockTypeSetup(block, system) void
%% Ensure required header files are included
%<RppCommonBlockTypeSetup(block, system)>
+ %<LibAddToCommonIncludes("rpp/rpp.h")>
+
+%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_%<bufferId_val>_flg) == 1
+ %<LibBlockReportError(block, "Buffer ID is already used by another FlexRay block.")>
+ %endif
+ %assign ::rpp_fr_bufferId_%<bufferId_val>_flg = 1
+
+ %openfile buffer
+ {
+ // Buffer %<bufferId_val>
+ %if channel_val == 1U
+ .channel = FR_CHANNEL_A,
+ %elseif channel_val == 2U
+ .channel = FR_CHANNEL_B,
+ %else
+ .channel = FR_CHANNEL_AB,
+ %endif
+ .cycleCounterFiltering = %<cycleCounterFiltering_val>,
+ .fidMask = 0,
+ .isTx = TRUE,
+ .maxPayload = %<maxPayload_val>,
+ .msgBufferInterrupt = %<msgBufferInterrupt_val>,
+ .payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>,
+ .rejectNullFrames = FALSE,
+ .rejectStaticSegment = FALSE,
+ .singleTransmit = %<singleTransmit_val>,
+ .slotId = %<slotId_val>
+ },
+ %closefile buffer
+
+ %if ISEQUAL(::rpp_fray_buffer_key_slot, "")
+ %assign ::rpp_fray_buffer_key_slot = "%<buffer>"
+ %else
+ %assign ::rpp_fray_buffer_config = "%<::rpp_fray_buffer_config> %<buffer>"
+ %endif
+ %assign ::rpp_fray_buffer_count = %<::rpp_fray_buffer_count> + 1
%endfunction
%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 EXISTS("_RPP_FRAY_TMP_VARS_") == 0
- %assign ::_RPP_FRAY_TMP_VARS_ = 1
- int8_t retVal;
- uint32_t error;
- %endif
- %if %<channel_val>==1
- static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_A;
- %elseif %<channel_val>==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 = %<cycleCounterFiltering_val>;
- static_buffers_cfg[static_buffers_cnt].isTx = TRUE;
- static_buffers_cfg[static_buffers_cnt].maxPayload = %<maxPayload_val>;
- static_buffers_cfg[static_buffers_cnt].msgBufferInterrupt = %<msgBufferInterrupt_val>;
- static_buffers_cfg[static_buffers_cnt].payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>;
- static_buffers_cfg[static_buffers_cnt].singleTransmit = %<singleTransmit_val>;
- static_buffers_cfg[static_buffers_cnt].slotId = %<slotId_val>;
- static_buffers_cnt++;
- rpp_sci_printf("Buffer %d added.\n", static_buffers_cnt);
+ %if EXISTS(::rpp_fray_config_present) == 0
+ %<LibBlockReportError(block, "FlexRay config block not present!")>
+ %endif
%endif
%endfunction
%if !SLibCodeGenForSim()
%% Get parameters
%assign slotId_val = LibBlockParameterValue(slotId, 0)
+ %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
+ %assign bufferId_val = LibBlockParameterValue(bufferId, 0)
%% Get IO signals
%assign message = LibBlockInputSignal(0, "", "", 0)
%assign err_flag = LibBlockOutputSignal(0, "", "", 0)
- rpp_sci_printf("sending message %#x on slot %d.\n", %<message>, %<slotId_val>);
+ rpp_sci_printf("sending message %#x on slot %d from buffer %d.\n", %<message>, %<slotId_val>, %<bufferId_val>);
- retVal = rpp_fr_transmit_lpdu(0, %<slotId_val>, &%<message>, 1);
+ retVal = rpp_fr_transmit_lpdu(0, %<bufferId_val>, &%<message>, %<maxPayload_val>*2);
if (retVal == FAILURE) {
- rpp_sci_printf("Sending a message to slot %#x failed.\n", %<slotId_val>);
+ rpp_sci_printf("Sending a message from buffer %#x failed.\n", %<bufferId_val>);
%<err_flag> = TRUE;
}
%endif