]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/sfunction_scic.c
10ae1b55e2bb827ec9b46d4a5734ecc371ce8703
[pes-rpp/rpp-simulink.git] / rpp / blocks / sfunction_scic.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_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 %YAML 1.2
25 ---
26 Name: Serial Configure
27 Category: Communication
28 Header: rpp/sci.h
29 Mnemonic: SCIC
30
31 Inputs:
32
33 Outputs:
34
35 Parameters:
36   - { name: "Baud rate", type: "uint32" }
37
38 # Description and Help is in Markdown mark-up
39 Description: &desc |
40
41   This block configures the baud rate of the Serial Communication
42   Interface (SCI). Only one block of this type per model is alloved.
43
44 Help: *desc
45
46 Status: Stable
47
48 RPP API functions used:
49     - rpp_sci_setup()
50
51 Relevant demos:
52     - echo_char
53     - hello_world
54     - irc_input
55 ...
56 */
57
58 #define S_FUNCTION_NAME sfunction_scic
59 #include "header.c"
60
61
62 static void mdlInitializeSizes(SimStruct *S)
63 {
64     /*
65      * Configure parameters: 1
66      *  - Baud rate.
67      */
68     if (!rppSetNumParams(S, 1)) {
69         return;
70     }
71
72     /*
73      * Configure input ports: 0
74      */
75     if (!ssSetNumInputPorts(S, 0)) {
76         return;
77     }
78
79     /*
80      * Configure output ports: 0
81      */
82     if (!ssSetNumOutputPorts(S, 0)) {
83         return;
84     }
85
86     /* Set standard options for this block */
87     rppSetStandardOptions(S);
88 }
89
90
91 #ifdef MATLAB_MEX_FILE
92 #define MDL_CHECK_PARAMETERS
93 static void mdlCheckParameters(SimStruct *S)
94 {
95     /* Check the parameter 1 (top baud rate is arbitrary) */
96     if (!rppValidParamRange(S, 0, 0, 1000000)) {
97         return;
98     }
99 }
100 #endif
101
102
103 #ifdef MATLAB_MEX_FILE
104 #define MDL_SET_WORK_WIDTHS
105 static void mdlSetWorkWidths(SimStruct *S)
106 {
107     /* Set number of run-time parameters */
108     if (!ssSetNumRunTimeParams(S, 1)) {
109         return;
110     }
111
112     /* Register the run-time parameter 1 */
113     ssRegDlgParamAsRunTimeParam(S, 0, 0, "p1", SS_UINT32);
114 }
115 #endif
116
117
118 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
119 #define UNUSED_MDLOUTPUTS
120 #define UNUSED_MDLTERMINATE
121 #include "trailer.c"