1 %% Copyright (C) 2013 Czech Technical University in Prague
4 %% - Michal Horn <hornmich@fel.cvut.cz>
6 %% This program is free software; you can redistribute it and/or modify
7 %% it under the terms of the GNU General Public License as published by
8 %% the Free Software Foundation; either version 2 of the License, or
9 %% (at your option) any later version.
11 %% This program is distributed in the hope that it will be useful,
12 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
13 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 %% GNU General Public License for more details.
16 %% You should have received a copy of the GNU General Public License
17 %% along with this program. If not, see <http://www.gnu.org/licenses/>.
19 %% File : sfunction_fraytransmit.tlc
21 %% TLC file for inlining RPP FlexRay node configuration.
24 %% BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
25 %% Outputs() : refs/rtw_tlc.pdf p. 281
28 %implements sfunction_fraytransmit "C"
32 %% Function: BlockTypeSetup ====================================================
33 %function BlockTypeSetup(block, system) void
35 %% Ensure required header files are included
36 %<RppCommonBlockTypeSetup(block, system)>
40 %function BlockInstanceSetup(block, system) void
41 %assign channel_val = LibBlockParameterValue(channel, 0)
42 %assign cycleCounterFiltering_val = LibBlockParameterValue(cycleCounterFiltering, 0)
43 %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
44 %assign msgBufferInterrupt_val = LibBlockParameterValue(msgBufferInterrupt, 0)
45 %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0)
46 %assign singleTransmit_val = LibBlockParameterValue(singleTransmit, 0)
47 %assign slotId_val = LibBlockParameterValue(slotId, 0)
52 .channel = FR_CHANNEL_A,
53 %elseif %<channel_val>==2
54 .channel = FR_CHANNEL_B,
56 .channel = FR_CHANNEL_AB,
58 .cycleCounterFiltering = %<cycleCounterFiltering_val>,
60 .maxPayload = %<maxPayload_val>,
61 .msgBufferInterrupt = %<msgBufferInterrupt_val>,
62 .payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>,
63 .singleTransmit = %<singleTransmit_val>,
64 .slotId = %<slotId_val>
68 %if ISEQUAL(::fray_buffer_key_slot, "")
69 %assign ::fray_buffer_key_slot = "%<buffer>"
71 %assign ::fray_buffer_config = "%<::fray_buffer_config> %<buffer>"
73 %assign ::fray_buffer_count = %<::fray_buffer_count> + 1
78 %% Function: Start =============================================================
79 %function Start(block, system) Output
81 %if !SLibCodeGenForSim()
83 %if EXISTS(::rpp_fray_config_present) == 0
84 LibBlockReportError([],"FlexRay config block not present!")
89 %% Function: Outputs ===========================================================
90 %function Outputs(block, system) Output
92 %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
93 %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
98 %if !SLibCodeGenForSim()
100 %assign slotId_val = LibBlockParameterValue(slotId, 0)
103 %assign message = LibBlockInputSignal(0, "", "", 0)
104 %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
106 rpp_sci_printf("sending message %#x on slot %d.\n", %<message>, %<slotId_val>);
108 retVal = rpp_fr_transmit_lpdu(0, %<slotId_val>, &%<message>, 1);
109 if (retVal == FAILURE) {
110 rpp_sci_printf("Sending a message to slot %#x failed.\n", %<slotId_val>);