]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/sfunction_ain.c
Change the license from GPL to proprietary
[jenkicar/rpp-simulink.git] / rpp / blocks / sfunction_ain.c
1 /* Copyright (C) 2013 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Carlos Jenkins <carlos@jenkins.co.cr>
5  *
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.
10  *
11  * File : sfunction_ain.c
12  * Abstract:
13  *     C-MEX S-function block for RPP analog input.
14  *
15  * References:
16  *     header.c
17  *     trailer.c
18  *
19  * Compile with:
20  *     <matlabroot>/bin/mex sfunction_ain.c
21  */
22
23
24 #define S_FUNCTION_NAME sfunction_ain
25 #include "header.c"
26
27
28 static void mdlInitializeSizes(SimStruct *S)
29 {
30     /*
31      * Configure parameters: 1
32      *  - Pin number: [1-12]
33      */
34     if(!rppSetNumParams(S, 1)) {
35         return;
36     }
37
38     /*
39      * Configure input ports: 0
40      */
41     if(!ssSetNumInputPorts(S, 0)) {
42         return;
43     }
44
45     /*
46      * Configure output ports: 2
47      *  - Analog input.
48      *  - Error flag.
49      */
50     if(!ssSetNumOutputPorts(S, 2)) {
51         return;
52     }
53     rppAddOutputPort(S, 0, SS_UINT16);
54     rppAddOutputPort(S, 1, SS_BOOLEAN);
55
56     /* Set standard options for this block */
57     rppSetStandardOptions(S);
58 }
59
60
61 #ifdef MATLAB_MEX_FILE
62 #define MDL_CHECK_PARAMETERS
63 static void mdlCheckParameters(SimStruct *S)
64 {
65     /* Check the parameter 1 */
66     if(!rppValidParamRange(S, 0, 1, 12)) {
67         return;
68     }
69 }
70 #endif
71
72
73 #ifdef MATLAB_MEX_FILE
74 #define MDL_SET_WORK_WIDTHS
75 static void mdlSetWorkWidths(SimStruct *S)
76 {
77     /* Set number of run-time parameters */
78     if(!ssSetNumRunTimeParams(S, 1)) {
79         return;
80     }
81
82     /* Register the run-time parameter 1 */
83     ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
84 }
85 #endif
86
87
88 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
89 #define UNUSED_MDLOUTPUTS
90 #define UNUSED_MDLTERMINATE
91 #include "trailer.c"