]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/sfunction_lout.c
Merge branch 'master' of rtime.felk.cvut.cz:jenkicar/rpp-simulink
[jenkicar/rpp-simulink.git] / rpp / blocks / sfunction_lout.c
1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Carlos Jenkins <carlos@jenkins.co.cr>
5  *
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.
10  *
11  * File : sfunction_lout.c
12  * Abstract:
13  *     C-MEX S-function block for RPP digital output.
14  *
15  * References:
16  *     header.c
17  *     trailer.c
18  *
19  * Compile with:
20  *     <matlabroot>/bin/mex sfunction_lout.c
21  */
22
23 /*
24 %YAML 1.2
25 ---
26 Name: xxx
27 Category: Xxxx
28 Header: xxx.h
29 Mnemonic: XXX
30
31 Inputs:
32
33 Outputs:
34
35 Parameters:
36
37 # Description is in Markdown mark-up
38 Description: >
39
40   This block ...
41
42 Status:
43   Tested:
44   Untested:
45   Not working:
46
47 RPP API functions used:
48
49 Relevant demos:
50 ...
51 */
52
53 #define S_FUNCTION_NAME sfunction_lout
54 #include "header.c"
55
56
57 static void mdlInitializeSizes(SimStruct *S)
58 {
59     /*
60      * Configure parameters: 1
61      *  - Pin number: [1-8]
62      */
63     if (!rppSetNumParams(S, 1)) {
64         return;
65     }
66
67     /*
68      * Configure input ports: 1
69      *  - Digital output.
70      */
71     if (!ssSetNumInputPorts(S, 1)) {
72         return;
73     }
74     rppAddInputPort(S, 0, SS_BOOLEAN);
75
76     /*
77      * Configure output ports: 1
78      *  - Error flag.
79      */
80     if (!ssSetNumOutputPorts(S, 1)) {
81         return;
82     }
83     rppAddOutputPort(S, 0, SS_BOOLEAN);
84
85     /* Set standard options for this block */
86     rppSetStandardOptions(S);
87 }
88
89
90 #ifdef MATLAB_MEX_FILE
91 #define MDL_CHECK_PARAMETERS
92 static void mdlCheckParameters(SimStruct *S)
93 {
94     /* Check the parameter 1 */
95     if (!rppValidParamRange(S, 0, 1, 8)) {
96         return;
97     }
98 }
99 #endif
100
101
102 #ifdef MATLAB_MEX_FILE
103 #define MDL_SET_WORK_WIDTHS
104 static void mdlSetWorkWidths(SimStruct *S)
105 {
106     /* Set number of run-time parameters */
107     if (!ssSetNumRunTimeParams(S, 1)) {
108         return;
109     }
110
111     /* Register the run-time parameter 1 */
112     ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT8);
113 }
114 #endif
115
116
117 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
118 #define UNUSED_MDLOUTPUTS
119 #define UNUSED_MDLTERMINATE
120 #include "trailer.c"