]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/commitdiff
Implemented SD-RAM Simulink block.
authorCarlos Jenkins <carlos@jenkins.co.cr>
Thu, 6 Jun 2013 21:38:52 +0000 (23:38 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Thu, 6 Jun 2013 21:38:52 +0000 (23:38 +0200)
rpp/blocks/README.txt
rpp/blocks/sfunction_sdrw.c [new file with mode: 0644]

index b4b60895c85f5c63cf2cf0772be345a5b9eb62fc..2ffd49dd265206e8239a23959fe95650a9ed788e 100644 (file)
@@ -279,11 +279,11 @@ The following are the currently specified Simulink blocks.
 
 [SDRW] SD-RAM Write (Logging) ==================================================
     Inputs      : 1
-        uint8   Data (?)
+        double  Data
 
     Outputs     : 1
-        bool    ErrFlag (?)
+        bool    ErrFlag
 
-    Parameters  : 0
-        None (?)
+    Parameters  : 1
+        uint8   Block ID
 
diff --git a/rpp/blocks/sfunction_sdrw.c b/rpp/blocks/sfunction_sdrw.c
new file mode 100644 (file)
index 0000000..72b849d
--- /dev/null
@@ -0,0 +1,99 @@
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Carlos Jenkins <carlos@jenkins.co.cr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * File : sfunction_sdrw.c
+ * Abstract:
+ *     C-MEX S-function block for RPP SD-RAM log write.
+ *
+ * References:
+ *     header.c
+ *     trailer.c
+ *
+ * Compile with:
+ *     <matlabroot>/bin/mex sfunction_sdrw.c
+ */
+
+
+#define S_FUNCTION_NAME sfunction_sdrw
+#include "header.c"
+
+
+static void mdlInitializeSizes(SimStruct *S)
+{
+    /*
+     * Configure parameters: 1
+     *  - Block ID.
+     */
+    if(!rppSetNumParams(S, 1)) {
+        return;
+    }
+
+    /*
+     * Configure input ports: 1
+     *  - Data.
+     */
+    if(!ssSetNumInputPorts(S, 1)) {
+        return;
+    }
+    rppAddInputPort(S, 0, SS_DOUBLE);
+
+    /*
+     * Configure output ports: 1
+     *  - Error flag.
+     */
+    if(!ssSetNumOutputPorts(S, 1)) {
+        return;
+    }
+    rppAddOutputPort(S, 0, SS_BOOLEAN);
+
+    /* Set standard options for this block */
+    rppSetStandardOptions(S);
+}
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_CHECK_PARAMETERS
+static void mdlCheckParameters(SimStruct *S)
+{
+    /* Check the parameter 1 */
+    if(!rppValidParamRange(S, 0, 0, 255)) {
+        return;
+    }
+}
+#endif
+
+
+#ifdef MATLAB_MEX_FILE
+#define MDL_SET_WORK_WIDTHS
+static void mdlSetWorkWidths(SimStruct *S)
+{
+    /* Set number of run-time parameters */
+    if(!ssSetNumRunTimeParams(S, 1)) {
+        return;
+    }
+
+    /* Register the run-time parameter 1 */
+    ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
+}
+#endif
+
+
+#define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
+#define UNUSED_MDLOUTPUTS
+#define UNUSED_MDLTERMINATE
+#include "trailer.c"