]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/commitdiff
FlexRay basic library add, demo for basic communication add
authorMichal Horn <hornmich@fel.cvut.cz>
Wed, 28 Aug 2013 09:58:55 +0000 (11:58 +0200)
committerMichal Horn <hornmich@fel.cvut.cz>
Wed, 28 Aug 2013 09:58:55 +0000 (11:58 +0200)
The library supports cluster configuration, node configuration and static buffers configuration.
A priority has to be assigned to the block before loading into the device. Static buffers have to
have the highest priority, then configuration and in the end the sending and receiving.
This is because generator of the C code has to place the configuration in the right orded.

Sending and receiving functions can receive and transmit only a single byte so far.

The demo configures a node to receive a message from the FlexRay and print it to the SCI. String
Hello Simulink is sent repeatedly on the FlexRay.

rpp/blocks/rpp_fr_lib.slx [new file with mode: 0644]
rpp/blocks/sfunction_frayconfig.c
rpp/blocks/sfunction_frayreceive.c [new file with mode: 0644]
rpp/blocks/sfunction_fraytransmit.c [new file with mode: 0644]
rpp/blocks/tlc_c/sfunction_frayconfig.tlc
rpp/blocks/tlc_c/sfunction_frayreceive.tlc [new file with mode: 0644]
rpp/blocks/tlc_c/sfunction_fraytransmit.tlc [new file with mode: 0644]
rpp/demos/fray_basic_demo.slx [new file with mode: 0644]

diff --git a/rpp/blocks/rpp_fr_lib.slx b/rpp/blocks/rpp_fr_lib.slx
new file mode 100644 (file)
index 0000000..5f37c61
Binary files /dev/null and b/rpp/blocks/rpp_fr_lib.slx differ
index ffdebb01e4245d05b5f97f97546131255d65141b..ac8ef1062632cabab6c06c32fe8ecd3a9550ce3c 100644 (file)
 #define gdWakeupSymbolTxIdle_IDX               23
 #define gdWakeupSymbolTxLow_IDX                        24
 
-#define pAllowHaltDueToClock_IDX               0
-#define pAllowPassiveToActive_IDX              1
-#define pChannels_IDX                          2
-#define pClusterDriftDamping_IDX               3
-#define pDelayCompensationA_IDX                        4
-#define pDelayCompensationB_IDX                        5
-#define pExternOffsetCorrection_IDX            6
-#define pExternRateCorrection_IDX              7
-#define pKeySlotUsedForStartup_IDX             8
-#define pKeySlotUsedForSync_IDX                        9
-#define pLatestTx_IDX                          10
-#define pMacroInitialOffsetA_IDX               11
-#define pMacroInitialOffsetB_IDX               12
-#define pMicroInitialOffsetA_IDX               13
-#define pMicroInitialOffsetB_IDX               14
-#define pMicroPerCycle_IDX                     15
-#define pRateCorrectionOut_IDX                 16
-#define pOffsetCorrectionOut_IDX               17
-#define pSamplesPerMicrotick_IDX               18
-#define pSingleSlotEnabled_IDX                 19
-#define pWakeupChannel_IDX                     20
-#define pWakeupPattern_IDX                     21
-#define pdAcceptedStartupRange_IDX             22
-#define pdListenTimeout_IDX                    23
-#define pdMaxDrift_IDX                         24
-#define pDecodingCorrection_IDX                        25
-#define syncFramePayloadMultiplexEnabled_IDX   26
-#define secureBuffers_IDX                      27
+#define pAllowHaltDueToClock_IDX               25
+#define pAllowPassiveToActive_IDX              26
+#define pChannels_IDX                          27
+#define pClusterDriftDamping_IDX               28
+#define pDelayCompensationA_IDX                        29
+#define pDelayCompensationB_IDX                        30
+#define pExternOffsetCorrection_IDX            31
+#define pExternRateCorrection_IDX              32
+#define pKeySlotUsedForStartup_IDX             33
+#define pKeySlotUsedForSync_IDX                        34
+#define pLatestTx_IDX                          35
+#define pMacroInitialOffsetA_IDX               36
+#define pMacroInitialOffsetB_IDX               37
+#define pMicroInitialOffsetA_IDX               38
+#define pMicroInitialOffsetB_IDX               39
+#define pMicroPerCycle_IDX                     40
+#define pRateCorrectionOut_IDX                 41
+#define pOffsetCorrectionOut_IDX               42
+#define pSamplesPerMicrotick_IDX               43
+#define pSingleSlotEnabled_IDX                 44
+#define pWakeupChannel_IDX                     45
+#define pWakeupPattern_IDX                     46
+#define pdAcceptedStartupRange_IDX             47
+#define pdListenTimeout_IDX                    48
+#define pdMaxDrift_IDX                         49
+#define pDecodingCorrection_IDX                        50
+#define syncFramePayloadMultiplexEnabled_IDX   51
+#define secureBuffers_IDX                      52
 
 
 
diff --git a/rpp/blocks/sfunction_frayreceive.c b/rpp/blocks/sfunction_frayreceive.c
new file mode 100644 (file)
index 0000000..e140e68
--- /dev/null
@@ -0,0 +1,122 @@
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Michal Horn <hornimch@fel.cvut.cz>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * File : sfunction_frayreceive.c
+ * Abstract:
+ *     C-MEX S-function block for RPP FlexRay RX buffer configuration and message receiving.
+ *
+ * References:
+ *     header.c
+ *     trailer.c
+ *
+ * Compile with:
+ *     <matlabroot>/bin/mex sfunction_frayreceive.c
+ */
+
+
+#define S_FUNCTION_NAME sfunction_frayreceive
+#include "header.c"
+#include <stdio.h>
+
+#define channel_IDX                                            0
+#define cycleCounterFiltering_IDX              1
+#define maxPayload_IDX                                 2
+#define msgBufferInterrupt_IDX                 3
+#define payloadPreambleIndicatorTr_IDX 4
+#define singleTransmit_IDX                             5
+#define slotId_IDX                                             6
+
+
+static void mdlInitializeSizes(SimStruct *S)
+{
+    /*
+     * Configure parameters: 25
+        * channel (0 - A, 1 - B, 2 - AB)
+        * cycleCounterFiltering
+        * maxPayload
+        * msgBufferInterrupt
+        * payloadPreambleIndicatorTr
+        * singleTransmit
+        * slotId
+     */
+    if(!rppSetNumParams(S, 7)) {
+        return;
+    }
+
+    /*
+     * Configure input ports: 0
+     */
+    if(!ssSetNumInputPorts(S, 0)) {
+        return;
+    }
+
+
+    /*
+     * Configure output ports: 4
+     *  - Error flag.
+        *  - Message
+        *  - Length (number of received bytes)
+        *  - Trigger
+     */
+    if(!ssSetNumOutputPorts(S, 4U)) {
+        return;
+    }
+    rppAddOutputPort(S, 0, SS_BOOLEAN);
+    rppAddOutputPort(S, 1, SS_UINT8);
+    rppAddOutputPort(S, 2, SS_UINT8);
+    rppAddOutputPort(S, 3, SS_BOOLEAN);
+
+    /* Set standard options for this block */
+    rppSetStandardOptions(S);
+}
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_CHECK_PARAMETERS
+static void mdlCheckParameters(SimStruct *S)
+{
+
+}
+#endif
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_SET_WORK_WIDTHS
+static void mdlSetWorkWidths(SimStruct *S)
+{
+    /* Set number of run-time parameters */
+    if(!ssSetNumRunTimeParams(S, 7)) {
+        return;
+    }
+
+    /* Register the run-time parameter 1 */
+       ssRegDlgParamAsRunTimeParam(S, channel_IDX, channel_IDX, "channel", SS_UINT8);
+       ssRegDlgParamAsRunTimeParam(S, cycleCounterFiltering_IDX, cycleCounterFiltering_IDX, "cycleCounterFiltering", SS_UINT8);
+       ssRegDlgParamAsRunTimeParam(S, maxPayload_IDX, maxPayload_IDX, "maxPayload", SS_UINT8);
+       ssRegDlgParamAsRunTimeParam(S, msgBufferInterrupt_IDX, msgBufferInterrupt_IDX, "msgBufferInterrupt", SS_BOOLEAN);
+       ssRegDlgParamAsRunTimeParam(S, payloadPreambleIndicatorTr_IDX, payloadPreambleIndicatorTr_IDX, "payloadPreambleIndicatorTr", SS_BOOLEAN);
+       ssRegDlgParamAsRunTimeParam(S, singleTransmit_IDX, singleTransmit_IDX, "singleTransmit", SS_BOOLEAN);
+       ssRegDlgParamAsRunTimeParam(S, slotId_IDX, slotId_IDX, "slotId", SS_UINT32);
+}
+#endif
+
+
+#define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
+#define UNUSED_MDLOUTPUTS
+#define UNUSED_MDLTERMINATE
+#include "trailer.c"
diff --git a/rpp/blocks/sfunction_fraytransmit.c b/rpp/blocks/sfunction_fraytransmit.c
new file mode 100644 (file)
index 0000000..7b1b987
--- /dev/null
@@ -0,0 +1,116 @@
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Michal Horn <hornimch@fel.cvut.cz>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * File : sfunction_fraytransmit.c
+ * Abstract:
+ *     C-MEX S-function block for RPP FlexRay TX buffer configuration and message transmittion.
+ *
+ * References:
+ *     header.c
+ *     trailer.c
+ *
+ * Compile with:
+ *     <matlabroot>/bin/mex sfunction_fraytransmit.c
+ */
+
+
+#define S_FUNCTION_NAME sfunction_fraytransmit
+#include "header.c"
+#include <stdio.h>
+
+#define channel_IDX                                            0
+#define cycleCounterFiltering_IDX              1
+#define maxPayload_IDX                                 2
+#define msgBufferInterrupt_IDX                 3
+#define payloadPreambleIndicatorTr_IDX 4
+#define singleTransmit_IDX                             5
+#define slotId_IDX                                             6
+
+
+static void mdlInitializeSizes(SimStruct *S)
+{
+    /*
+     * Configure parameters: 25
+        * channel (0 - A, 1 - B, 2 - AB)
+        * cycleCounterFiltering
+        * maxPayload
+        * msgBufferInterrupt
+        * payloadPreambleIndicatorTr
+        * singleTransmit
+        * slotId
+     */
+    if(!rppSetNumParams(S, 7)) {
+        return;
+    }
+
+    /*
+     * Configure input ports: 1
+     */
+    if(!ssSetNumInputPorts(S, 1)) {
+        return;
+    }
+    rppAddInputPort(S, 0, SS_UINT8);
+
+    /*
+     * Configure output ports: 1
+     *  - Error flag.
+     */
+    if(!ssSetNumOutputPorts(S, 1)) {
+        return;
+    }
+    rppAddOutputPort(S, 0, SS_BOOLEAN);
+
+    /* Set standard options for this block */
+    rppSetStandardOptions(S);
+}
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_CHECK_PARAMETERS
+static void mdlCheckParameters(SimStruct *S)
+{
+
+}
+#endif
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_SET_WORK_WIDTHS
+static void mdlSetWorkWidths(SimStruct *S)
+{
+    /* Set number of run-time parameters */
+    if(!ssSetNumRunTimeParams(S, 7)) {
+        return;
+    }
+
+    /* Register the run-time parameter 1 */
+       ssRegDlgParamAsRunTimeParam(S, channel_IDX, channel_IDX, "channel", SS_UINT8);
+       ssRegDlgParamAsRunTimeParam(S, cycleCounterFiltering_IDX, cycleCounterFiltering_IDX, "cycleCounterFiltering", SS_UINT8);
+       ssRegDlgParamAsRunTimeParam(S, maxPayload_IDX, maxPayload_IDX, "maxPayload", SS_UINT8);
+       ssRegDlgParamAsRunTimeParam(S, msgBufferInterrupt_IDX, msgBufferInterrupt_IDX, "msgBufferInterrupt", SS_BOOLEAN);
+       ssRegDlgParamAsRunTimeParam(S, payloadPreambleIndicatorTr_IDX, payloadPreambleIndicatorTr_IDX, "payloadPreambleIndicatorTr", SS_BOOLEAN);
+       ssRegDlgParamAsRunTimeParam(S, singleTransmit_IDX, singleTransmit_IDX, "singleTransmit", SS_BOOLEAN);
+       ssRegDlgParamAsRunTimeParam(S, slotId_IDX, slotId_IDX, "slotId", SS_UINT32);
+}
+#endif
+
+
+#define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
+#define UNUSED_MDLOUTPUTS
+#define UNUSED_MDLTERMINATE
+#include "trailer.c"
index 554f4811532c12e849af577db1dff952e074a151..b90999a5261a9be8e50ca7dc3ef87cc73768097f 100644 (file)
@@ -18,7 +18,7 @@
 %%
 %% File : sfunction_frayconfig.tlc
 %% Abstract:
-%%     TLC file for inlining RPP FlexRay cluster configuration.
+%%     TLC file for inlining RPP FlexRay TX buffer configuration and message transmittion.
 %%
 %% References:
 %%     BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
 
                node_cfg.pAllowHaltDueToClock =  %<pAllowHaltDueToClock_val>;
         node_cfg.pAllowPassiveToActive =  %<pAllowPassiveToActive_val>;
-        node_cfg.pChannels =  %<pChannels_val>;
+               %if %<pChannels_val>==1
+                       node_cfg.pChannels = FR_CHANNEL_A;
+               %elseif %<pChannels_val>==2
+                       node_cfg.pChannels = FR_CHANNEL_B;
+               %else
+                       node_cfg.pChannels = FR_CHANNEL_AB;
+               %endif
         node_cfg.pClusterDriftDamping =  %<pClusterDriftDamping_val>;
         node_cfg.pDelayCompensationA =  %<pDelayCompensationA_val>;
         node_cfg.pDelayCompensationB =  %<pDelayCompensationB_val>;
         node_cfg.pOffsetCorrectionOut =  %<pOffsetCorrectionOut_val>;
         node_cfg.pSamplesPerMicrotick =  %<pSamplesPerMicrotick_val>;
         node_cfg.pSingleSlotEnabled =  %<pSingleSlotEnabled_val>;
-        node_cfg.pWakeupChannel =  %<pWakeupChannel_val>;
+               %if %<pWakeupChannel_val>==1
+                       node_cfg.pWakeupChannel = FR_CHANNEL_A;
+               %else
+                       node_cfg.pWakeupChannel = FR_CHANNEL_B;
+               %endif
         node_cfg.pWakeupPattern =  %<pWakeupPattern_val>;
         node_cfg.pdAcceptedStartupRange =  %<pdAcceptedStartupRange_val>;
         node_cfg.pdListenTimeout =  %<pdListenTimeout_val>;
                node_cfg.pdMaxDrift =  %<pdMaxDrift_val>;
                node_cfg.pDecodingCorrection =  %<pDecodingCorrection_val>;
                msg_ram_cfg.syncFramePayloadMultiplexEnabled = %<syncFramePayloadMultiplexEnabled_val>;
-               msg_ram_cfg.secureBuffers = %<secureBuffers_val>;
-
+               %if %<secureBuffers_val>==1
+                       msg_ram_cfg.secureBuffers = FR_SB_RECONFIG_ENABLED;
+               %elseif %<secureBuffers_val>==2
+                       msg_ram_cfg.secureBuffers = FR_SB_STAT_REC_DISABLED_STAT_TR_DISABLED;
+               %elseif %<secureBuffers_val>==3
+                       msg_ram_cfg.secureBuffers = FR_SB_ALL_REC_DISABLED;
+               %else
+                       msg_ram_cfg.secureBuffers = FR_SB_ALL_REC_DISABLED_STAT_TR_DISABLED;
+               %endif
                msg_ram_cfg.statSegmentBufferCount = static_buffers_cnt;
                msg_ram_cfg.dynSegmentBufferCount = 0;
                msg_ram_cfg.fifoBufferCount = 0;
diff --git a/rpp/blocks/tlc_c/sfunction_frayreceive.tlc b/rpp/blocks/tlc_c/sfunction_frayreceive.tlc
new file mode 100644 (file)
index 0000000..ab87ad0
--- /dev/null
@@ -0,0 +1,130 @@
+%% Copyright (C) 2013 Czech Technical University in Prague
+%%
+%% Authors:
+%%     - Michal Horn <hornmich@fel.cvut.cz>
+%%
+%% This program is free software; you can redistribute it and/or modify
+%% it under the terms of the GNU General Public License as published by
+%% the Free Software Foundation; either version 2 of the License, or
+%% (at your option) any later version.
+%%
+%% This program is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%% GNU General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this program.  If not, see <http://www.gnu.org/licenses/>.
+%%
+%% File : sfunction_frayreceive.tlc
+%% Abstract:
+%%     TLC file for inlining RPP FlexRay node configuration.
+%%
+%% References:
+%%     BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
+%%     Outputs()        : refs/rtw_tlc.pdf p. 281
+
+
+%implements sfunction_frayreceive "C"
+
+%include "common.tlc"
+
+
+%% Function: BlockTypeSetup ====================================================
+%function BlockTypeSetup(block, system) void
+
+    %% Ensure required header files are included
+    %<RppCommonBlockTypeSetup(block, system)>
+
+%endfunction
+
+
+%% Function: Start =============================================================
+%function Start(block, system) Output
+
+    %if !SLibCodeGenForSim()
+        %assign channel_val = LibBlockParameterValue(channel, 0)
+        %assign cycleCounterFiltering_val = LibBlockParameterValue(cycleCounterFiltering, 0)
+        %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
+        %assign msgBufferInterrupt_val = LibBlockParameterValue(msgBufferInterrupt, 0)
+        %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0)
+        %assign singleTransmit_val = LibBlockParameterValue(singleTransmit, 0)
+        %assign slotId_val = LibBlockParameterValue(slotId, 0)
+
+        %% Declare temporal variables
+        %if EXISTS("_RPP_FRAYCONFIG_TMP_VARS_") == 0
+            %assign ::_RPP_FRAYCONFIG_TMP_VARS_ = 1
+                       #define MAX_ST_BUF_CFG 62
+                       Fr_TMS570LS_ClusterConfigType cluster_cfg;
+                       Fr_TMS570LS_NodeConfigType node_cfg;
+                       Fr_TMS570LS_BufferConfigType static_buffers_cfg[MAX_ST_BUF_CFG];
+                       Fr_TMS570LS_MsgRAMConfig msg_ram_cfg;
+                       Fr_ConfigType flexray_cfg;
+                       uint8_t static_buffers_cnt = 0;
+        %endif
+               %if %<channel_val>==1
+                       static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_A;
+               %elseif %<channel_val>==2
+                       static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_B;
+               %else
+                       static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_AB;
+               %endif
+           static_buffers_cfg[static_buffers_cnt].cycleCounterFiltering = %<cycleCounterFiltering_val>;
+           static_buffers_cfg[static_buffers_cnt].isTx = FALSE;
+           static_buffers_cfg[static_buffers_cnt].maxPayload = %<maxPayload_val>;
+           static_buffers_cfg[static_buffers_cnt].msgBufferInterrupt = %<msgBufferInterrupt_val>;
+           static_buffers_cfg[static_buffers_cnt].payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>;
+           static_buffers_cfg[static_buffers_cnt].singleTransmit = %<singleTransmit_val>;
+           static_buffers_cfg[static_buffers_cnt].slotId = %<slotId_val>;
+               static_buffers_cnt++;
+               rpp_sci_printf("RX buffer %d added.\n", static_buffers_cnt);
+    %endif
+%endfunction
+
+%% Function: Outputs ===========================================================
+%function Outputs(block, system) Output
+
+       %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
+           %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
+               int8_t retVal;
+       %endif
+
+    %if !SLibCodeGenForSim()
+               %% Get parameters
+        %assign slotId_val = LibBlockParameterValue(slotId, 0)
+
+        %% Get IO signals
+        %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
+        %assign message = LibBlockOutputSignal(1, "", "", 0)
+        %assign length = LibBlockOutputSignal(2, "", "", 0)
+        %assign trigger = LibBlockOutputSignal(3, "", "", 0)
+
+               uint8_t rec_msg[16];
+               uint8_t rec_length;
+               Fr_RxLPduStatusType rec_status;
+
+               retVal = rpp_fr_receive_lpdu(0, %<slotId_val>, rec_msg, &rec_status, &rec_length);
+               if (retVal == FAILURE) {
+                       rpp_sci_printf("Receiving a message from slot %#x failed.\n", %<slotId_val>);
+                       %<err_flag> = TRUE;
+                       %<message> = 0;
+                       %<length> = 0;
+                       %<trigger> = 0;
+               }
+               else {
+                       if (rec_status == FR_NOT_RECEIVED) {
+                               %<trigger> = 0;
+                               %<message> = 0;
+                               %<length> = 0;
+                       }
+                       else {
+                               %<trigger> = 1;
+                               %<message> = rec_msg[0];
+                               %<length> = rec_length;
+                       }
+               }
+    %endif
+%endfunction
+
+
+%% [EOF]
diff --git a/rpp/blocks/tlc_c/sfunction_fraytransmit.tlc b/rpp/blocks/tlc_c/sfunction_fraytransmit.tlc
new file mode 100644 (file)
index 0000000..06620bd
--- /dev/null
@@ -0,0 +1,117 @@
+%% Copyright (C) 2013 Czech Technical University in Prague
+%%
+%% Authors:
+%%     - Michal Horn <hornmich@fel.cvut.cz>
+%%
+%% This program is free software; you can redistribute it and/or modify
+%% it under the terms of the GNU General Public License as published by
+%% the Free Software Foundation; either version 2 of the License, or
+%% (at your option) any later version.
+%%
+%% This program is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%% GNU General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this program.  If not, see <http://www.gnu.org/licenses/>.
+%%
+%% File : sfunction_fraytransmit.tlc
+%% Abstract:
+%%     TLC file for inlining RPP FlexRay node configuration.
+%%
+%% References:
+%%     BlockTypeSetup() : refs/rtw_tlc.pdf p. 277
+%%     Outputs()        : refs/rtw_tlc.pdf p. 281
+
+
+%implements sfunction_fraytransmit "C"
+
+%include "common.tlc"
+
+
+%% Function: BlockTypeSetup ====================================================
+%function BlockTypeSetup(block, system) void
+
+    %% Ensure required header files are included
+    %<RppCommonBlockTypeSetup(block, system)>
+
+%endfunction
+
+
+%% Function: Start =============================================================
+%function Start(block, system) Output
+
+    %if !SLibCodeGenForSim()
+        %assign channel_val = LibBlockParameterValue(channel, 0)
+        %assign cycleCounterFiltering_val = LibBlockParameterValue(cycleCounterFiltering, 0)
+        %assign maxPayload_val = LibBlockParameterValue(maxPayload, 0)
+        %assign msgBufferInterrupt_val = LibBlockParameterValue(msgBufferInterrupt, 0)
+        %assign payloadPreambleIndicatorTr_val = LibBlockParameterValue(payloadPreambleIndicatorTr, 0)
+        %assign singleTransmit_val = LibBlockParameterValue(singleTransmit, 0)
+        %assign slotId_val = LibBlockParameterValue(slotId, 0)
+
+        %% Declare temporal variables
+        %if EXISTS("_RPP_FRAYCONFIG_TMP_VARS_") == 0
+            %assign ::_RPP_FRAYCONFIG_TMP_VARS_ = 1
+                       #define MAX_ST_BUF_CFG 62
+                       Fr_TMS570LS_ClusterConfigType cluster_cfg;
+                       Fr_TMS570LS_NodeConfigType node_cfg;
+                       Fr_TMS570LS_BufferConfigType static_buffers_cfg[MAX_ST_BUF_CFG];
+                       Fr_TMS570LS_MsgRAMConfig msg_ram_cfg;
+                       Fr_ConfigType flexray_cfg;
+                       uint8_t static_buffers_cnt = 0;
+        %endif
+               %if EXISTS("_RPP_FRAY_TMP_VARS_") == 0
+                   %assign ::_RPP_FRAY_TMP_VARS_ = 1
+                       int8_t retVal;
+                       uint32_t error;
+               %endif
+               %if %<channel_val>==1
+                       static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_A;
+               %elseif %<channel_val>==2
+                       static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_B;
+               %else
+                       static_buffers_cfg[static_buffers_cnt].channel = FR_CHANNEL_AB;
+               %endif
+           static_buffers_cfg[static_buffers_cnt].cycleCounterFiltering = %<cycleCounterFiltering_val>;
+           static_buffers_cfg[static_buffers_cnt].isTx = TRUE;
+           static_buffers_cfg[static_buffers_cnt].maxPayload = %<maxPayload_val>;
+           static_buffers_cfg[static_buffers_cnt].msgBufferInterrupt = %<msgBufferInterrupt_val>;
+           static_buffers_cfg[static_buffers_cnt].payloadPreambleIndicatorTr = %<payloadPreambleIndicatorTr_val>;
+           static_buffers_cfg[static_buffers_cnt].singleTransmit = %<singleTransmit_val>;
+           static_buffers_cfg[static_buffers_cnt].slotId = %<slotId_val>;
+               static_buffers_cnt++;
+               rpp_sci_printf("Buffer %d added.\n", static_buffers_cnt);
+    %endif
+%endfunction
+
+%% Function: Outputs ===========================================================
+%function Outputs(block, system) Output
+
+       %if EXISTS("_RPP_FRAYSTEP_TMP_VARS_") == 0
+           %assign ::_RPP_FRAYSTEP_TMP_VARS_ = 1
+               int8_t retVal;
+       %endif
+
+
+    %if !SLibCodeGenForSim()
+               %% Get parameters
+        %assign slotId_val = LibBlockParameterValue(slotId, 0)
+
+        %% Get IO signals
+        %assign message = LibBlockInputSignal(0, "", "", 0)
+        %assign err_flag = LibBlockOutputSignal(0, "", "", 0)
+
+               rpp_sci_printf("sending message %#x on slot %d.\n", %<message>, %<slotId_val>);
+
+               retVal = rpp_fr_transmit_lpdu(0, %<slotId_val>, &%<message>, 1);
+               if (retVal == FAILURE) {
+                       rpp_sci_printf("Sending a message to slot %#x failed.\n", %<slotId_val>);
+                       %<err_flag> = TRUE;
+               }
+    %endif
+%endfunction
+
+
+%% [EOF]
diff --git a/rpp/demos/fray_basic_demo.slx b/rpp/demos/fray_basic_demo.slx
new file mode 100644 (file)
index 0000000..055962f
Binary files /dev/null and b/rpp/demos/fray_basic_demo.slx differ