1 %% Copyright (C) 2013 Czech Technical University in Prague
4 %% - Michal Horn <hornmich@fel.cvut.cz>
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.
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.
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/>.
19 %% File : sfunction_frayreceive.tlc
21 %% TLC file for inlining RPP FlexRay node configuration.
24 %% BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
25 %% Outputs() : refs/rtw_tlc.pdf p. 281
28 %implements sfunction_frayreceive "C"
33 %% Function: BlockTypeSetup ====================================================
34 %function BlockTypeSetup(block, system) void
36 %% Ensure required header files are included
37 %<RppCommonBlockTypeSetup(block, system)>
42 %% Function: Start =============================================================
43 %function Start(block, system) Output
45 %if !SLibCodeGenForSim()
46 %assign channel_val = LibBlockParameterValue(channel, 0)
47 %assign cycleCounterFiltering_val = LibBlockParameterValue(cycleCounterFiltering, 0)
48 %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
49 %assign msgBufferInterrupt_val = LibBlockParameterValue(msgBufferInterrupt, 0)
50 %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0)
51 %assign singleTransmit_val = LibBlockParameterValue(singleTransmit, 0)
52 %assign slotId_val = LibBlockParameterValue(slotId, 0)
54 %% Declare temporal variables
55 %if EXISTS("_RPP_FRAYCONFIG_TMP_VARS_") == 0
56 %assign ::_RPP_FRAYCONFIG_TMP_VARS_ = 1
57 #define MAX_ST_BUF_CFG 62
58 Fr_TMS570LS_ClusterConfigType cluster_cfg;
59 Fr_TMS570LS_NodeConfigType node_cfg;
60 Fr_TMS570LS_BufferConfigType static_buffers_cfg[MAX_ST_BUF_CFG];
61 Fr_TMS570LS_MsgRAMConfig msg_ram_cfg;
62 Fr_ConfigType flexray_cfg;
63 uint8_t static_buffers_cnt = 0;
66 static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_A;
67 %elseif %<channel_val>==2
68 static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_B;
70 static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_AB;
72 static_buffers_cfg[static_buffers_cnt].cycleCounterFiltering = %<cycleCounterFiltering_val>;
73 static_buffers_cfg[static_buffers_cnt].isTx = FALSE;
74 static_buffers_cfg[static_buffers_cnt].maxPayload = %<maxPayload_val>;
75 static_buffers_cfg[static_buffers_cnt].msgBufferInterrupt = %<msgBufferInterrupt_val>;
76 static_buffers_cfg[static_buffers_cnt].payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>;
77 static_buffers_cfg[static_buffers_cnt].singleTransmit = %<singleTransmit_val>;
78 static_buffers_cfg[static_buffers_cnt].slotId = %<slotId_val>;
80 rpp_sci_printf("RX buffer %d added.\n", static_buffers_cnt);
84 %% Function: Outputs ===========================================================
85 %function Outputs(block, system) Output
87 %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
88 %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
92 %if !SLibCodeGenForSim()
94 %assign slotId_val = LibBlockParameterValue(slotId, 0)
97 %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
98 %assign message = LibBlockOutputSignal(1, "", "", 0)
99 %assign length = LibBlockOutputSignal(2, "", "", 0)
100 %assign trigger = LibBlockOutputSignal(3, "", "", 0)
104 Fr_RxLPduStatusType rec_status;
106 retVal = rpp_fr_receive_lpdu(0, %<slotId_val>, rec_msg, &rec_status, &rec_length);
107 if (retVal == FAILURE) {
108 rpp_sci_printf("Receiving a message from slot %#x failed.\n", %<slotId_val>);
115 if (rec_status == FR_NOT_RECEIVED) {
121 rpp_sci_printf("Message from slot %#x received:%#x\n", %<slotId_val>, rec_msg[0]);
123 %<message> = rec_msg[0];
124 %<length> = rec_length;