1 /* Copyright (C) 2013-2014 Czech Technical University in Prague
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation
8 * files (the "Software"), to deal in the Software without
9 * restriction, including without limitation the rights to use,
10 * copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following
15 * The above copyright notice and this permission notice shall be
16 * included in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
27 * File : sfunction_dinc.c
29 * C-MEX S-function block for RPP digital input configuration.
36 * <matlabroot>/bin/mex sfunction_dinc.c
42 Name: Digital Input Configure
52 - { name: "Reference voltage for pins 8-11", type: "uint16", range: "[0-4095]" }
53 - { name: "Reference voltage for pins 12-15", type: "uint16", range: "[0-4095]" }
55 # Description and Help is in Markdown mark-up
58 This block allows one to set reference voltage (threshold) for DIN pins. The block have two parameters,
59 one for pins 8 - 11 and the other for pins 12 - 15.
65 RPP API functions used:
72 #define S_FUNCTION_NAME sfunction_dinc
76 static void mdlInitializeSizes(SimStruct *S)
79 * Configure parameters: 2
80 * - Reference voltage for pins 8-11: [0-4095]
81 * - Reference voltage for pins 12-15: [0-4095]
83 if (!rppSetNumParams(S, 2)) {
88 * Configure input ports: 0
90 if (!ssSetNumInputPorts(S, 0)) {
95 * Configure output ports: 0
97 if (!ssSetNumOutputPorts(S, 0)) {
101 /* Set standard options for this block */
102 rppSetStandardOptions(S);
106 #ifdef MATLAB_MEX_FILE
107 #define MDL_CHECK_PARAMETERS
108 static void mdlCheckParameters(SimStruct *S)
110 /* Check the parameter 1 */
111 if (!rppValidParamRange(S, 0, 0, 4095)) {
115 /* Check the parameter 2 */
116 if (!rppValidParamRange(S, 1, 0, 4095)) {
123 #ifdef MATLAB_MEX_FILE
124 #define MDL_SET_WORK_WIDTHS
125 static void mdlSetWorkWidths(SimStruct *S)
127 /* Set number of run-time parameters */
128 if (!ssSetNumRunTimeParams(S, 2)) {
132 /* Register the run-time parameter 1 */
133 ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT16);
134 ssRegDlgParamAsRunTimeParam(S, 1, 1, "p2", SS_UINT16);
139 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
140 #define UNUSED_MDLOUTPUTS
141 #define UNUSED_MDLTERMINATE