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 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.
53 - Compilation and general use.
55 - Faulty situation for the ErrFlag to set.
58 RPP API functions used:
66 #define S_FUNCTION_NAME sfunction_mout
70 static void mdlInitializeSizes(SimStruct *S)
73 * Configure parameters: 1
76 if (!rppSetNumParams(S, 1)) {
81 * Configure input ports: 1
84 if (!ssSetNumInputPorts(S, 1)) {
87 rppAddInputPort(S, 0, SS_BOOLEAN);
90 * Configure output ports: 1
93 if (!ssSetNumOutputPorts(S, 1)) {
96 rppAddOutputPort(S, 0, SS_BOOLEAN);
98 /* Set standard options for this block */
99 rppSetStandardOptions(S);
103 #ifdef MATLAB_MEX_FILE
104 #define MDL_CHECK_PARAMETERS
105 static void mdlCheckParameters(SimStruct *S)
107 /* Check the parameter 1 */
108 if (!rppValidParamRange(S, 0, 1, 6)) {
115 #ifdef MATLAB_MEX_FILE
116 #define MDL_SET_WORK_WIDTHS
117 static void mdlSetWorkWidths(SimStruct *S)
119 /* Set number of run-time parameters */
120 if (!ssSetNumRunTimeParams(S, 1)) {
124 /* Register the run-time parameter 1 */
125 ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
130 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
131 #define UNUSED_MDLOUTPUTS
132 #define UNUSED_MDLTERMINATE