]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/sfunction_dinc.c
doc: Change YAML field Status to simple string
[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 Reference Voltage Configuration
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",  type: "uint16", range: "[0-4095]" }
37   - { name: "Reference voltage for pins 12-15", type: "uint16", range: "[0-4095]" }
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: Stable
48
49 RPP API functions used:
50     - rpp_din_ref()
51
52 Relevant demos:
53 ...
54 */
55
56 #define S_FUNCTION_NAME sfunction_dinc
57 #include "header.c"
58
59
60 static void mdlInitializeSizes(SimStruct *S)
61 {
62     /*
63      * Configure parameters: 2
64      *  - Reference voltage for pins 8-11:  [0-4095]
65      *  - Reference voltage for pins 12-15: [0-4095]
66      */
67     if (!rppSetNumParams(S, 2)) {
68         return;
69     }
70
71     /*
72      * Configure input ports: 0
73      */
74     if (!ssSetNumInputPorts(S, 0)) {
75         return;
76     }
77
78     /*
79      * Configure output ports: 0
80      */
81     if (!ssSetNumOutputPorts(S, 0)) {
82         return;
83     }
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, 0, 4095)) {
96         return;
97     }
98     
99     /* Check the parameter 2 */
100     if (!rppValidParamRange(S, 1, 0, 4095)) {
101         return;
102     }
103 }
104 #endif
105
106
107 #ifdef MATLAB_MEX_FILE
108 #define MDL_SET_WORK_WIDTHS
109 static void mdlSetWorkWidths(SimStruct *S)
110 {
111     /* Set number of run-time parameters */
112     if (!ssSetNumRunTimeParams(S, 2)) {
113         return;
114     }
115
116     /* Register the run-time parameter 1 */
117     ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT16);
118     ssRegDlgParamAsRunTimeParam(S, 1, 1, "p2", SS_UINT16);
119 }
120 #endif
121
122
123 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
124 #define UNUSED_MDLOUTPUTS
125 #define UNUSED_MDLTERMINATE
126 #include "trailer.c"