1 %% Copyright (C) 2013, 2014 Czech Technical University in Prague
4 %% - Michal Horn <hornmich@fel.cvut.cz>
6 %% Permission is hereby granted, free of charge, to any person
7 %% obtaining a copy of this software and associated documentation
8 %% files (the "Software"), to deal in the Software without
9 %% restriction, including without limitation the rights to use,
10 %% copy, modify, merge, publish, distribute, sublicense, and/or sell
11 %% copies of the Software, and to permit persons to whom the
12 %% Software is furnished to do so, subject to the following
15 %% The above copyright notice and this permission notice shall be
16 %% included in all copies or substantial portions of the Software.
18 %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 %% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 %% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 %% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 %% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 %% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 %% OTHER DEALINGS IN THE SOFTWARE.
27 %% File : sfunction_fraytransmit.tlc
29 %% TLC file for inlining RPP FlexRay node configuration.
32 %% BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
33 %% Outputs() : refs/rtw_tlc.pdf p. 281
36 %implements sfunction_fraytransmit "C"
40 %% Function: BlockTypeSetup ====================================================
41 %function BlockTypeSetup(block, system) void
43 %% Ensure required header files are included
44 %<RppCommonBlockTypeSetup(block, system)>
45 %<LibAddToCommonIncludes("rpp/rpp.h")>
49 %function BlockInstanceSetup(block, system) void
50 %assign channel_val = LibBlockParameterValue(channel, 0)
51 %assign cycleCounterFiltering_val = LibBlockParameterValue(cycleCounterFiltering, 0)
52 %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
53 %assign msgBufferInterrupt_val = LibBlockParameterValue(msgBufferInterrupt, 0)
54 %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0)
55 %assign singleTransmit_val = LibBlockParameterValue(singleTransmit, 0)
56 %assign slotId_val = LibBlockParameterValue(slotId, 0)
57 %assign bufferId_val = LibBlockParameterValue(bufferId, 0)
59 %if EXISTS(::rpp_fr_bufferId_%<bufferId_val>_flg) == 1
60 %<LibBlockReportError(block, "Buffer ID is already used by another FlexRay block.")>
62 %assign ::rpp_fr_bufferId_%<bufferId_val>_flg = 1
66 // Buffer %<bufferId_val>
68 .channel = FR_CHANNEL_A,
69 %elseif channel_val == 2U
70 .channel = FR_CHANNEL_B,
72 .channel = FR_CHANNEL_AB,
74 .cycleCounterFiltering = %<cycleCounterFiltering_val>,
77 .maxPayload = %<maxPayload_val>,
78 .msgBufferInterrupt = %<msgBufferInterrupt_val>,
79 .payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>,
80 .rejectNullFrames = FALSE,
81 .rejectStaticSegment = FALSE,
82 .singleTransmit = %<singleTransmit_val>,
83 .slotId = %<slotId_val>
87 %if ISEQUAL(::rpp_fray_buffer_key_slot, "")
88 %assign ::rpp_fray_buffer_key_slot = "%<buffer>"
90 %assign ::rpp_fray_buffer_config = "%<::rpp_fray_buffer_config> %<buffer>"
92 %assign ::rpp_fray_buffer_count = %<::rpp_fray_buffer_count> + 1
97 %% Function: Start =============================================================
98 %function Start(block, system) Output
100 %if !SLibCodeGenForSim()
102 %if EXISTS(::rpp_fray_config_present) == 0
103 %<LibBlockReportError(block, "FlexRay config block not present!")>
108 %% Function: Outputs ===========================================================
109 %function Outputs(block, system) Output
111 %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
112 %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
117 %if !SLibCodeGenForSim()
119 %assign slotId_val = LibBlockParameterValue(slotId, 0)
120 %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
121 %assign bufferId_val = LibBlockParameterValue(bufferId, 0)
124 %assign message = LibBlockInputSignal(0, "", "", 0)
125 %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
127 rpp_sci_printf("sending message %#x on slot %d from buffer %d.\n", %<message>, %<slotId_val>, %<bufferId_val>);
129 retVal = rpp_fr_transmit_lpdu(0, %<bufferId_val>, &%<message>, %<maxPayload_val>*2);
130 if (retVal == FAILURE) {
131 rpp_sci_printf("Sending a message from buffer %#x failed.\n", %<bufferId_val>);