1 %% Copyright (C) 2013, 2014 Czech Technical University in Prague
4 %% - Michal Horn <hornmich@fel.cvut.cz>
6 %% This document contains proprietary information belonging to Czech
7 %% Technical University in Prague. Passing on and copying of this
8 %% document, and communication of its contents is not permitted
9 %% without prior written authorization.
11 %% File : sfunction_fraytransmit.tlc
13 %% TLC file for inlining RPP FlexRay node configuration.
16 %% BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
17 %% Outputs() : refs/rtw_tlc.pdf p. 281
20 %implements sfunction_fraytransmit "C"
24 %% Function: BlockTypeSetup ====================================================
25 %function BlockTypeSetup(block, system) void
27 %% Ensure required header files are included
28 %<RppCommonBlockTypeSetup(block, system)>
29 %<LibAddToCommonIncludes("rpp/rpp.h")>
33 %function BlockInstanceSetup(block, system) void
34 %assign channel_val = LibBlockParameterValue(channel, 0)
35 %assign cycleCounterFiltering_val = LibBlockParameterValue(cycleCounterFiltering, 0)
36 %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
37 %assign msgBufferInterrupt_val = LibBlockParameterValue(msgBufferInterrupt, 0)
38 %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0)
39 %assign singleTransmit_val = LibBlockParameterValue(singleTransmit, 0)
40 %assign slotId_val = LibBlockParameterValue(slotId, 0)
41 %assign bufferId_val = LibBlockParameterValue(bufferId, 0)
43 %if EXISTS(::rpp_fr_bufferId_%<bufferId_val>_flg) == 1
44 %<LibBlockReportError(block, "Buffer ID is already used by another FlexRay block.")>
46 %assign ::rpp_fr_bufferId_%<bufferId_val>_flg = 1
50 // Buffer %<bufferId_val>
52 .channel = FR_CHANNEL_A,
53 %elseif channel_val == 2U
54 .channel = FR_CHANNEL_B,
56 .channel = FR_CHANNEL_AB,
58 .cycleCounterFiltering = %<cycleCounterFiltering_val>,
61 .maxPayload = %<maxPayload_val>,
62 .msgBufferInterrupt = %<msgBufferInterrupt_val>,
63 .payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>,
64 .rejectNullFrames = FALSE,
65 .rejectStaticSegment = FALSE,
66 .singleTransmit = %<singleTransmit_val>,
67 .slotId = %<slotId_val>
71 %if ISEQUAL(::rpp_fray_buffer_key_slot, "")
72 %assign ::rpp_fray_buffer_key_slot = "%<buffer>"
74 %assign ::rpp_fray_buffer_config = "%<::rpp_fray_buffer_config> %<buffer>"
76 %assign ::rpp_fray_buffer_count = %<::rpp_fray_buffer_count> + 1
81 %% Function: Start =============================================================
82 %function Start(block, system) Output
84 %if !SLibCodeGenForSim()
86 %if EXISTS(::rpp_fray_config_present) == 0
87 %<LibBlockReportError(block, "FlexRay config block not present!")>
92 %% Function: Outputs ===========================================================
93 %function Outputs(block, system) Output
95 %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
96 %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
101 %if !SLibCodeGenForSim()
103 %assign slotId_val = LibBlockParameterValue(slotId, 0)
104 %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
105 %assign bufferId_val = LibBlockParameterValue(bufferId, 0)
108 %assign message = LibBlockInputSignal(0, "", "", 0)
109 %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
111 rpp_sci_printf("sending message %#x on slot %d from buffer %d.\n", %<message>, %<slotId_val>, %<bufferId_val>);
113 retVal = rpp_fr_transmit_lpdu(0, %<bufferId_val>, &%<message>, %<maxPayload_val>*2);
114 if (retVal == FAILURE) {
115 rpp_sci_printf("Sending a message from buffer %#x failed.\n", %<bufferId_val>);