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