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_sdrw.c
21 * C-MEX S-function block for RPP SD-RAM log write.
28 * <matlabroot>/bin/mex sfunction_sdrw.c
32 #define S_FUNCTION_NAME sfunction_sdrw
36 static void mdlInitializeSizes(SimStruct *S)
39 * Configure parameters: 2
41 * - Printf format [setting].
43 if(!rppSetNumParams(S, 2)) {
48 * Configure input ports: 1
51 if(!ssSetNumInputPorts(S, 1)) {
54 rppAddInputPort(S, 0, SS_DOUBLE);
57 * Configure output ports: 1
60 if(!ssSetNumOutputPorts(S, 1)) {
63 rppAddOutputPort(S, 0, 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, 255)) {
82 #ifdef MATLAB_MEX_FILE
83 #define MDL_SET_WORK_WIDTHS
84 static void mdlSetWorkWidths(SimStruct *S)
86 /* Set number of run-time parameters */
87 if(!ssSetNumRunTimeParams(S, 1)) {
91 /* Register the run-time parameter 1 */
92 ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
97 #ifdef MATLAB_MEX_FILE
99 static void mdlRTW(SimStruct* S)
101 /* Register parameter 2 as a parameter setting */
102 static char_T str[128];
103 mxGetString(ssGetSFcnParam(S, 1), (char*)&str, sizeof(str)); // Get string
104 if(!ssWriteRTWParamSettings(S, 1,
105 SSWRITE_VALUE_QSTR, "PrintfFormat", (const char_T*)&str)) {
113 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
114 #define UNUSED_MDLOUTPUTS
115 #define UNUSED_MDLTERMINATE