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