]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/sfunction_dinc.c
doc: Introduce Help field in YAML doc
[jenkicar/rpp-simulink.git] / rpp / blocks / sfunction_dinc.c
1 /* Copyright (C) 2013-2014 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Karel Kočí
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_dinc.c
12  * Abstract:
13  *     C-MEX S-function block for RPP digital input configuration.
14  *
15  * References:
16  *     header.c
17  *     trailer.c
18  *
19  * Compile with:
20  *     <matlabroot>/bin/mex sfunction_dinc.c
21  */
22
23 /*
24 %YAML 1.2
25 ---
26 Name: Digital Input Configure
27 Category: IO blocks
28 Header: rpp/din.h
29 Mnemonic: DINC
30
31 Inputs:
32
33 Outputs:
34
35 Parameters:
36   - { name: "Reference voltage for pins 8-11 [0-4095]", type: "uint16" }
37   - { name: "Reference voltage for pins 12-15 [0-4095]", type: "uint16" }
38
39 # Description and Help is in Markdown mark-up
40 Description: &desc |
41
42   This block allows one to set reference voltage (threshold) for DIN pins. The block have two parameters,
43   one for pins 8 - 11 and the other for pins 12 - 15.
44
45 Help: *desc
46
47 Status:
48   Tested:
49     - Changing reference voltage.
50     - Compilation and general use.
51   Untested:
52     - Using more than one block in a model.
53   Not working:
54
55 RPP API functions used:
56     - rpp_din_ref()
57
58 Relevant demos:
59 ...
60 */
61
62 #define S_FUNCTION_NAME sfunction_dinc
63 #include "header.c"
64
65
66 static void mdlInitializeSizes(SimStruct *S)
67 {
68     /*
69      * Configure parameters: 2
70      *  - Reference voltage for pins 8-11:  [0-4095]
71      *  - Reference voltage for pins 12-15: [0-4095]
72      */
73     if (!rppSetNumParams(S, 2)) {
74         return;
75     }
76
77     /*
78      * Configure input ports: 0
79      */
80     if (!ssSetNumInputPorts(S, 0)) {
81         return;
82     }
83
84     /*
85      * Configure output ports: 0
86      */
87     if (!ssSetNumOutputPorts(S, 0)) {
88         return;
89     }
90     
91     /* Set standard options for this block */
92     rppSetStandardOptions(S);
93 }
94
95
96 #ifdef MATLAB_MEX_FILE
97 #define MDL_CHECK_PARAMETERS
98 static void mdlCheckParameters(SimStruct *S)
99 {
100     /* Check the parameter 1 */
101     if (!rppValidParamRange(S, 0, 0, 4095)) {
102         return;
103     }
104     
105     /* Check the parameter 2 */
106     if (!rppValidParamRange(S, 1, 0, 4095)) {
107         return;
108     }
109 }
110 #endif
111
112
113 #ifdef MATLAB_MEX_FILE
114 #define MDL_SET_WORK_WIDTHS
115 static void mdlSetWorkWidths(SimStruct *S)
116 {
117     /* Set number of run-time parameters */
118     if (!ssSetNumRunTimeParams(S, 2)) {
119         return;
120     }
121
122     /* Register the run-time parameter 1 */
123     ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT16);
124     ssRegDlgParamAsRunTimeParam(S, 1, 1, "p2", SS_UINT16);
125 }
126 #endif
127
128
129 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
130 #define UNUSED_MDLOUTPUTS
131 #define UNUSED_MDLTERMINATE
132 #include "trailer.c"