1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Michal Horn <hornimch@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.c
21 * C-MEX S-function block for RPP FlexRay RX buffer configuration and message receiving.
28 * <matlabroot>/bin/mex sfunction_frayreceive.c
32 #define S_FUNCTION_NAME sfunction_frayreceive
37 #define cycleCounterFiltering_IDX 1
38 #define maxPayload_IDX 2
39 #define msgBufferInterrupt_IDX 3
40 #define payloadPreambleIndicatorTr_IDX 4
41 #define singleTransmit_IDX 5
45 static void mdlInitializeSizes(SimStruct *S)
48 * Configure parameters: 25
49 * channel (0 - A, 1 - B, 2 - AB)
50 * cycleCounterFiltering
53 * payloadPreambleIndicatorTr
57 if(!rppSetNumParams(S, 7)) {
62 * Configure input ports: 0
64 if(!ssSetNumInputPorts(S, 0)) {
70 * Configure output ports: 4
73 * - Length (number of received bytes)
76 if(!ssSetNumOutputPorts(S, 4U)) {
79 rppAddOutputPort(S, 0, SS_BOOLEAN);
80 rppAddOutputPort(S, 1, SS_UINT8);
81 rppAddOutputPort(S, 2, SS_UINT8);
82 rppAddOutputPort(S, 3, SS_BOOLEAN);
84 /* Set standard options for this block */
85 rppSetStandardOptions(S);
89 #ifdef MATLAB_MEX_FILE
90 #define MDL_CHECK_PARAMETERS
91 static void mdlCheckParameters(SimStruct *S)
98 #ifdef MATLAB_MEX_FILE
99 #define MDL_SET_WORK_WIDTHS
100 static void mdlSetWorkWidths(SimStruct *S)
102 /* Set number of run-time parameters */
103 if(!ssSetNumRunTimeParams(S, 7)) {
107 /* Register the run-time parameter 1 */
108 ssRegDlgParamAsRunTimeParam(S, channel_IDX, channel_IDX, "channel", SS_UINT8);
109 ssRegDlgParamAsRunTimeParam(S, cycleCounterFiltering_IDX, cycleCounterFiltering_IDX, "cycleCounterFiltering", SS_UINT8);
110 ssRegDlgParamAsRunTimeParam(S, maxPayload_IDX, maxPayload_IDX, "maxPayload", SS_UINT8);
111 ssRegDlgParamAsRunTimeParam(S, msgBufferInterrupt_IDX, msgBufferInterrupt_IDX, "msgBufferInterrupt", SS_BOOLEAN);
112 ssRegDlgParamAsRunTimeParam(S, payloadPreambleIndicatorTr_IDX, payloadPreambleIndicatorTr_IDX, "payloadPreambleIndicatorTr", SS_BOOLEAN);
113 ssRegDlgParamAsRunTimeParam(S, singleTransmit_IDX, singleTransmit_IDX, "singleTransmit", SS_BOOLEAN);
114 ssRegDlgParamAsRunTimeParam(S, slotId_IDX, slotId_IDX, "slotId", SS_UINT32);
119 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
120 #define UNUSED_MDLOUTPUTS
121 #define UNUSED_MDLTERMINATE