]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/tlc_c/sfunction_fraytransmit.tlc
Don't fail because of CCS_UTILS_DIR not being set
[jenkicar/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     %<LibAddToCommonIncludes("rpp/rpp.h")>
30
31 %endfunction
32
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
42   %openfile buffer
43   {
44         %if channel_val == 1U
45           .channel = FR_CHANNEL_A,
46         %elseif channel_val == 2U
47           .channel = FR_CHANNEL_B,
48         %else
49           .channel = FR_CHANNEL_AB,       
50         %endif
51         .cycleCounterFiltering = %<cycleCounterFiltering_val>,
52         .fidMask = 0,
53         .isTx = TRUE,
54         .maxPayload = %<maxPayload_val>,
55         .msgBufferInterrupt = %<msgBufferInterrupt_val>,
56         .payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>,
57         .rejectNullFrames = FALSE,
58         .rejectStaticSegment = FALSE,
59         .singleTransmit = %<singleTransmit_val>,
60         .slotId = %<slotId_val>
61   },
62   %closefile buffer
63
64   %if ISEQUAL(::rpp_fray_buffer_key_slot, "")
65         %assign ::rpp_fray_buffer_key_slot = "%<buffer>"
66   %else
67         %assign ::rpp_fray_buffer_config = "%<::rpp_fray_buffer_config> %<buffer>"
68   %endif
69   %assign ::rpp_fray_buffer_count = %<::rpp_fray_buffer_count> + 1      
70
71 %endfunction
72
73
74 %% Function: Start =============================================================
75 %function Start(block, system) Output
76
77     %if !SLibCodeGenForSim()
78
79           %if EXISTS(::rpp_fray_config_present) == 0
80                 %<LibBlockReportError(block, "FlexRay config block not present!")>
81           %endif
82     %endif
83 %endfunction
84
85 %% Function: Outputs ===========================================================
86 %function Outputs(block, system) Output
87
88         %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
89             %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
90                 int8_t retVal;
91         %endif
92
93
94     %if !SLibCodeGenForSim()
95                 %% Get parameters
96         %assign slotId_val = LibBlockParameterValue(slotId, 0)
97         %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
98
99         %% Get IO signals
100         %assign message = LibBlockInputSignal(0, "", "", 0)
101         %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
102
103                 rpp_sci_printf("sending message %#x on slot %d.\n", %<message>, %<slotId_val>);
104
105                 retVal = rpp_fr_transmit_lpdu(0, %<slotId_val>, &%<message>, %<maxPayload_val>*2);
106                 if (retVal == FAILURE) {
107                         rpp_sci_printf("Sending a message to slot %#x failed.\n", %<slotId_val>);
108                         %<err_flag> = TRUE;
109                 }
110     %endif
111 %endfunction
112
113
114 %% [EOF]