]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/sfunction_lout.c
Coding style: Add space after if, for and while
[jenkicar/rpp-simulink.git] / rpp / blocks / sfunction_lout.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_lout.c
12  * Abstract:
13  *     C-MEX S-function block for RPP digital output.
14  *
15  * References:
16  *     header.c
17  *     trailer.c
18  *
19  * Compile with:
20  *     <matlabroot>/bin/mex sfunction_lout.c
21  */
22
23
24 #define S_FUNCTION_NAME sfunction_lout
25 #include "header.c"
26
27
28 static void mdlInitializeSizes(SimStruct *S)
29 {
30     /*
31      * Configure parameters: 1
32      *  - Pin number: [1-8]
33      */
34     if (!rppSetNumParams(S, 1)) {
35         return;
36     }
37
38     /*
39      * Configure input ports: 1
40      *  - Digital output.
41      */
42     if (!ssSetNumInputPorts(S, 1)) {
43         return;
44     }
45     rppAddInputPort(S, 0, SS_BOOLEAN);
46
47     /*
48      * Configure output ports: 1
49      *  - Error flag.
50      */
51     if (!ssSetNumOutputPorts(S, 1)) {
52         return;
53     }
54     rppAddOutputPort(S, 0, 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, 8)) {
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"