]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/sfunction_scic.c
Merge branch 'master' of rtime:jenkicar/rpp-simulink
[pes-rpp/rpp-simulink.git] / rpp / blocks / sfunction_scic.c
1 /* Copyright (C) 2013 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_scic.c
12  * Abstract:
13  *     C-MEX S-function block for configuring RPP Serial Communication.
14  *
15  * References:
16  *     header.c
17  *     trailer.c
18  *
19  * Compile with:
20  *     <matlabroot>/bin/mex sfunction_scic.c
21  */
22
23
24 #define S_FUNCTION_NAME sfunction_scic
25 #include "header.c"
26
27
28 static void mdlInitializeSizes(SimStruct *S)
29 {
30     /*
31      * Configure parameters: 1
32      *  - Baud rate.
33      */
34     if (!rppSetNumParams(S, 1)) {
35         return;
36     }
37
38     /*
39      * Configure input ports: 0
40      */
41     if (!ssSetNumInputPorts(S, 0)) {
42         return;
43     }
44
45     /*
46      * Configure output ports: 0
47      */
48     if (!ssSetNumOutputPorts(S, 0)) {
49         return;
50     }
51
52     /* Set standard options for this block */
53     rppSetStandardOptions(S);
54 }
55
56
57 #ifdef MATLAB_MEX_FILE
58 #define MDL_CHECK_PARAMETERS
59 static void mdlCheckParameters(SimStruct *S)
60 {
61     /* Check the parameter 1 (top baud rate is arbitrary) */
62     if (!rppValidParamRange(S, 0, 0, 1000000)) {
63         return;
64     }
65 }
66 #endif
67
68
69 #ifdef MATLAB_MEX_FILE
70 #define MDL_SET_WORK_WIDTHS
71 static void mdlSetWorkWidths(SimStruct *S)
72 {
73     /* Set number of run-time parameters */
74     if (!ssSetNumRunTimeParams(S, 1)) {
75         return;
76     }
77
78     /* Register the run-time parameter 1 */
79     ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT32);
80 }
81 #endif
82
83
84 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
85 #define UNUSED_MDLOUTPUTS
86 #define UNUSED_MDLTERMINATE
87 #include "trailer.c"
88