1 /* Copyright (C) 2013 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
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_din.c
21 * C-MEX S-function block for RPP digital input.
28 * <matlabroot>/bin/mex sfunction_din.c
32 #define S_FUNCTION_NAME sfunction_din
36 static void mdlInitializeSizes(SimStruct *S)
39 * Configure parameters: 1
40 * - Pin number: [1-16]
41 * - Use variable threshold: [true|false]
43 if(!rppSetNumParams(S, 2)) {
48 * Configure input ports: 0
50 if(!ssSetNumInputPorts(S, 0)) {
55 * Configure output ports: 2
59 if(!ssSetNumOutputPorts(S, 2)) {
62 rppAddOutputPort(S, 0, SS_BOOLEAN);
63 rppAddOutputPort(S, 1, SS_BOOLEAN);
65 /* Set standard options for this block */
66 rppSetStandardOptions(S);
70 #ifdef MATLAB_MEX_FILE
71 #define MDL_CHECK_PARAMETERS
72 static void mdlCheckParameters(SimStruct *S)
74 /* Check the parameter 1 */
75 if(!rppValidParamRange(S, 0, 0, 15)) {
79 /* Check the parameter 2 */
80 if(!rppValidParamBoolean(S, 1)) {
87 #ifdef MATLAB_MEX_FILE
88 #define MDL_SET_WORK_WIDTHS
89 static void mdlSetWorkWidths(SimStruct *S)
91 /* Set number of run-time parameters */
92 if(!ssSetNumRunTimeParams(S, 2)) {
96 /* Register the run-time parameter 1 */
97 ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
99 /* Register the run-time parameter 2 */
100 ssRegDlgParamAsRunTimeParam(S, 1, 1, "p2", SS_BOOLEAN);
105 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
106 #define UNUSED_MDLOUTPUTS
107 #define UNUSED_MDLTERMINATE