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
38 cycleCounterFiltering_IDX = 1,
40 msgBufferInterrupt_IDX = 3,
41 payloadPreambleIndicatorTr_IDX = 4,
42 singleTransmit_IDX = 5,
56 static void mdlInitializeSizes(SimStruct *S)
58 if(!rppSetNumParams(S, PARAM_COUNT)) {
63 * Configure input ports: 0
65 if(!ssSetNumInputPorts(S, 0)) {
71 * Configure output ports: 4
74 * - Length (number of received bytes)
77 if(!ssSetNumOutputPorts(S, OUTPUT_COUNT)) {
80 rppAddOutputPort(S, OUTPUT_ERROR_FLAG, SS_BOOLEAN);
81 rppAddOutputVectorPort(S, OUTPUT_MESSAGE, SS_UINT8, 2*(int_T)mxGetPr(ssGetSFcnParam(S, 2))[0]);
82 rppAddOutputPort(S, OUTPUT_LENGTH, SS_UINT8);
83 rppAddOutputPort(S, OUTPUT_TRIGGER, SS_BOOLEAN);
85 /* Set standard options for this block */
86 rppSetStandardOptions(S);
90 #ifdef MATLAB_MEX_FILE
91 #define MDL_CHECK_PARAMETERS
92 static void mdlCheckParameters(SimStruct *S)
99 #ifdef MATLAB_MEX_FILE
100 #define MDL_SET_WORK_WIDTHS
101 static void mdlSetWorkWidths(SimStruct *S)
103 /* Set number of run-time parameters */
104 if(!ssSetNumRunTimeParams(S, PARAM_COUNT)) {
108 /* Register the run-time parameter 1 */
109 ssRegDlgParamAsRunTimeParam(S, channel_IDX, channel_IDX, "channel", SS_UINT8);
110 ssRegDlgParamAsRunTimeParam(S, cycleCounterFiltering_IDX, cycleCounterFiltering_IDX, "cycleCounterFiltering", SS_UINT8);
111 ssRegDlgParamAsRunTimeParam(S, maxPayload_IDX, maxPayload_IDX, "maxPayload", SS_UINT8);
112 ssRegDlgParamAsRunTimeParam(S, msgBufferInterrupt_IDX, msgBufferInterrupt_IDX, "msgBufferInterrupt", SS_BOOLEAN);
113 ssRegDlgParamAsRunTimeParam(S, payloadPreambleIndicatorTr_IDX, payloadPreambleIndicatorTr_IDX, "payloadPreambleIndicatorTr", SS_BOOLEAN);
114 ssRegDlgParamAsRunTimeParam(S, singleTransmit_IDX, singleTransmit_IDX, "singleTransmit", SS_BOOLEAN);
115 ssRegDlgParamAsRunTimeParam(S, slotId_IDX, slotId_IDX, "slotId", SS_UINT32);
120 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
121 #define UNUSED_MDLOUTPUTS
122 #define UNUSED_MDLTERMINATE