]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/sfunction_scis.c
Change license to MIT
[pes-rpp/rpp-simulink.git] / rpp / blocks / sfunction_scis.c
1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Carlos Jenkins <carlos@jenkins.co.cr>
5  *
6  * Permission is hereby granted, free of charge, to any person
7  * obtaining a copy of this software and associated documentation
8  * files (the "Software"), to deal in the Software without
9  * restriction, including without limitation the rights to use,
10  * copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following
13  * conditions:
14  *
15  * The above copyright notice and this permission notice shall be
16  * included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * File : sfunction_scis.c
28  * Abstract:
29  *     C-MEX S-function block for RPP Serial Communication send.
30  *
31  * References:
32  *     header.c
33  *     trailer.c
34  *
35  * Compile with:
36  *     <matlabroot>/bin/mex sfunction_scis.c
37  */
38
39 /*
40 %YAML 1.2
41 ---
42 Name: Serial Send
43 Category: Communication
44 Header: rpp/sci.h
45 Mnemonic: SCIS
46
47 Inputs:
48   - { name: "Send", type: "uint8" }
49
50 Outputs:
51   - { name: "ErrFlag", type: "bool" }
52
53 Parameters:
54
55 # Description and Help is in Markdown mark-up
56 Description: &desc |
57
58   This block sends a byte to the SCI.
59
60   The ErrFlag is set to true `rpp_sci_write_nb()` returns an error, to
61   false otherwise.
62
63 Help: *desc
64
65 Status: Stable
66
67 RPP API functions used:
68     - rpp_sci_write_nb()
69
70 Relevant demos:
71     - echo_char
72     - hello_world
73 ...
74 */
75
76 #define S_FUNCTION_NAME sfunction_scis
77 #include "header.c"
78
79
80 static void mdlInitializeSizes(SimStruct *S)
81 {
82     /*
83      * Configure parameters: 0
84      */
85     if (!rppSetNumParams(S, 0)) {
86         return;
87     }
88
89     /*
90      * Configure input ports: 1
91      *  - Data send.
92      */
93     if (!ssSetNumInputPorts(S, 1)) {
94         return;
95     }
96     rppAddInputPort(S, 0, SS_UINT8);
97
98     /*
99      * Configure output ports: 1
100      *  - Error flag.
101      */
102     if (!ssSetNumOutputPorts(S, 1)) {
103         return;
104     }
105     rppAddOutputPort(S, 0, SS_BOOLEAN);
106
107     /* Set standard options for this block */
108     rppSetStandardOptions(S);
109 }
110
111
112 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
113 #define UNUSED_MDLCHECKPARAMETERS
114 #define UNUSED_MDLOUTPUTS
115 #define UNUSED_MDLTERMINATE
116 #include "trailer.c"