1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
4 * - Michal Horn <hornimch@fel.cvut.cz>
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.
11 * File : sfunction_frayreceive.c
13 * C-MEX S-function block for RPP FlexRay RX buffer configuration and message receiving.
20 * <matlabroot>/bin/mex sfunction_frayreceive.c
26 Name: Configure RX buffer
34 - { name: "ErrFlag", type: "bool" }
35 - { name: "Receive", type: "uint8 vector" }
36 - { name: "Length", type: "uint8" }
37 - { name: "Trigger", type: "bool" }
40 - { name: "channel", type: "uint8" }
41 - { name: "cycleCounterFiltering", type: "uint8" }
42 - { name: "maxPayload", type: "uint8", range: "(in half-words)" }
43 - { name: "msgBufferInterrupt", type: "bool" }
44 - { name: "payloadPreambleIndicatorTr", type: "bool" }
45 - { name: "singleTransmit", type: "bool" }
46 - { name: "slotId", type: "uint32" }
47 - { name: "bufferId", type: "uint32" }
49 # Description and Help is in Markdown mark-up
58 RPP API functions used:
64 #define S_FUNCTION_NAME sfunction_frayreceive
70 cycleCounterFiltering_IDX = 1,
72 msgBufferInterrupt_IDX = 3,
73 payloadPreambleIndicatorTr_IDX = 4,
74 singleTransmit_IDX = 5,
89 static void mdlInitializeSizes(SimStruct *S)
91 if (!rppSetNumParams(S, PARAM_COUNT)) {
96 * Configure input ports: 0
98 if (!ssSetNumInputPorts(S, 0)) {
104 * Configure output ports: 4
107 * - Length (number of received bytes)
110 if (!ssSetNumOutputPorts(S, OUTPUT_COUNT)) {
113 rppAddOutputPort(S, OUTPUT_ERROR_FLAG, SS_BOOLEAN);
114 rppAddOutputVectorPort(S, OUTPUT_MESSAGE, SS_UINT8, 2*(int_T)mxGetPr(ssGetSFcnParam(S, 2))[0]);
115 rppAddOutputPort(S, OUTPUT_LENGTH, SS_UINT8);
116 rppAddOutputPort(S, OUTPUT_TRIGGER, SS_BOOLEAN);
118 /* Set standard options for this block */
119 rppSetStandardOptions(S);
123 #ifdef MATLAB_MEX_FILE
124 #define MDL_CHECK_PARAMETERS
125 static void mdlCheckParameters(SimStruct *S)
132 #ifdef MATLAB_MEX_FILE
133 #define MDL_SET_WORK_WIDTHS
134 static void mdlSetWorkWidths(SimStruct *S)
136 /* Set number of run-time parameters */
137 if (!ssSetNumRunTimeParams(S, PARAM_COUNT)) {
141 /* Register the run-time parameter 1 */
142 ssRegDlgParamAsRunTimeParam(S, channel_IDX, channel_IDX, "channel", SS_UINT8);
143 ssRegDlgParamAsRunTimeParam(S, cycleCounterFiltering_IDX, cycleCounterFiltering_IDX, "cycleCounterFiltering", SS_UINT8);
144 ssRegDlgParamAsRunTimeParam(S, maxPayload_IDX, maxPayload_IDX, "maxPayload", SS_UINT8);
145 ssRegDlgParamAsRunTimeParam(S, msgBufferInterrupt_IDX, msgBufferInterrupt_IDX, "msgBufferInterrupt", SS_BOOLEAN);
146 ssRegDlgParamAsRunTimeParam(S, payloadPreambleIndicatorTr_IDX, payloadPreambleIndicatorTr_IDX, "payloadPreambleIndicatorTr", SS_BOOLEAN);
147 ssRegDlgParamAsRunTimeParam(S, singleTransmit_IDX, singleTransmit_IDX, "singleTransmit", SS_BOOLEAN);
148 ssRegDlgParamAsRunTimeParam(S, slotId_IDX, slotId_IDX, "slotId", SS_UINT32);
149 ssRegDlgParamAsRunTimeParam(S, bufferId_IDX, bufferId_IDX, "bufferId", SS_UINT32);
154 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
155 #define UNUSED_MDLOUTPUTS
156 #define UNUSED_MDLTERMINATE