1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
4 * - Carlos Jenkins <carlos@jenkins.co.cr>
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.
11 * File : sfunction_mout.c
13 * C-MEX S-function block for RPP power output.
20 * <matlabroot>/bin/mex sfunction_mout.c
27 Category: Power output blocks
32 - { name: "Power Output", type: "bool" }
35 - { name: "ErrFlag", type: "bool" }
38 - { name: "Pin number [1-6]", type: "uint8" }
40 # Description and Help is in Markdown mark-up
43 This block allows to write the power outputs (2A) on the RPP board. The ErrFlag should raise only
44 if `rpp_mout_set()` returns error. Note that `rpp_mout_set()` returns error only if some bad
45 parameter or in case it could detect a faulty condition on the pin in a very very short period of
46 time after setting the value, see the function API for details. If the faulty condition persist on
47 the next step the call will successfully detect the faulty condition and ErrFlag should set.
48 Because the ErrFlag should never set, once set the following steps will never clear it back.
54 RPP API functions used:
62 #define S_FUNCTION_NAME sfunction_mout
66 static void mdlInitializeSizes(SimStruct *S)
69 * Configure parameters: 1
72 if (!rppSetNumParams(S, 1)) {
77 * Configure input ports: 1
80 if (!ssSetNumInputPorts(S, 1)) {
83 rppAddInputPort(S, 0, SS_BOOLEAN);
86 * Configure output ports: 1
89 if (!ssSetNumOutputPorts(S, 1)) {
92 rppAddOutputPort(S, 0, SS_BOOLEAN);
94 /* Set standard options for this block */
95 rppSetStandardOptions(S);
99 #ifdef MATLAB_MEX_FILE
100 #define MDL_CHECK_PARAMETERS
101 static void mdlCheckParameters(SimStruct *S)
103 /* Check the parameter 1 */
104 if (!rppValidParamRange(S, 0, 1, 6)) {
111 #ifdef MATLAB_MEX_FILE
112 #define MDL_SET_WORK_WIDTHS
113 static void mdlSetWorkWidths(SimStruct *S)
115 /* Set number of run-time parameters */
116 if (!ssSetNumRunTimeParams(S, 1)) {
120 /* Register the run-time parameter 1 */
121 ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
126 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
127 #define UNUSED_MDLOUTPUTS
128 #define UNUSED_MDLTERMINATE