]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/tlc_c/sfunction_fraytransmit.tlc
TLC files modified to allow correct initialization of the FlexRay without specificati...
[pes-rpp/rpp-simulink.git] / rpp / blocks / tlc_c / sfunction_fraytransmit.tlc
1 %% Copyright (C) 2013 Czech Technical University in Prague
2 %%
3 %% Authors:
4 %%     - Michal Horn <hornmich@fel.cvut.cz>
5 %%
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.
10 %%
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.
15 %%
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/>.
18 %%
19 %% File : sfunction_fraytransmit.tlc
20 %% Abstract:
21 %%     TLC file for inlining RPP FlexRay node configuration.
22 %%
23 %% References:
24 %%     BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
25 %%     Outputs()        : refs/rtw_tlc.pdf p. 281
26
27
28 %implements sfunction_fraytransmit "C"
29
30 %include "common.tlc"
31
32 %% Function: BlockTypeSetup ====================================================
33 %function BlockTypeSetup(block, system) void
34
35     %% Ensure required header files are included
36     %<RppCommonBlockTypeSetup(block, system)>
37
38 %endfunction
39
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)
48
49   %openfile buffer
50   {
51         %if %<channel_val>==1
52           .channel = FR_CHANNEL_A,
53         %elseif %<channel_val>==2
54           .channel = FR_CHANNEL_B,
55         %else
56           .channel = FR_CHANNEL_AB,
57         %endif
58         .cycleCounterFiltering = %<cycleCounterFiltering_val>,
59         .isTx = TRUE,
60         .maxPayload = %<maxPayload_val>,
61         .msgBufferInterrupt = %<msgBufferInterrupt_val>,
62         .payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>,
63         .singleTransmit = %<singleTransmit_val>,
64         .slotId = %<slotId_val>
65   },
66   %closefile buffer
67
68   %if ISEQUAL(::fray_buffer_key_slot, "")
69         %assign ::fray_buffer_key_slot = "%<buffer>"
70   %else
71         %assign ::fray_buffer_config = "%<::fray_buffer_config> %<buffer>"
72   %endif
73   %assign ::fray_buffer_count = %<::fray_buffer_count> + 1      
74
75 %endfunction
76
77
78 %% Function: Start =============================================================
79 %function Start(block, system) Output
80
81     %if !SLibCodeGenForSim()
82
83           %if EXISTS(::rpp_fray_config_present) == 0
84                 LibBlockReportError([],"FlexRay config block not present!")
85           %endif
86     %endif
87 %endfunction
88
89 %% Function: Outputs ===========================================================
90 %function Outputs(block, system) Output
91
92         %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
93             %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
94                 int8_t retVal;
95         %endif
96
97
98     %if !SLibCodeGenForSim()
99                 %% Get parameters
100         %assign slotId_val = LibBlockParameterValue(slotId, 0)
101
102         %% Get IO signals
103         %assign message = LibBlockInputSignal(0, "", "", 0)
104         %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
105
106                 rpp_sci_printf("sending message %#x on slot %d.\n", %<message>, %<slotId_val>);
107
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>);
111                         %<err_flag> = TRUE;
112                 }
113     %endif
114 %endfunction
115
116
117 %% [EOF]