]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/blob - rpp/blocks/sfunction_fraysbc.c
Change license to MIT
[pes-rpp/rpp-simulink.git] / rpp / blocks / sfunction_fraysbc.c
1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
2  *
3  * Authors:
4  *     - Michal Horn <hornimch@fel.cvut.cz>
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_fraysbc.c
28  * Abstract:
29  *     C-MEX S-function block for RPP FlexRay static buffer configuration.
30  *
31  * References:
32  *     header.c
33  *     trailer.c
34  *
35  * Compile with:
36  *     <matlabroot>/bin/mex sfunction_fraysbc.c
37  */
38
39 /*
40 %YAML 1.2
41 ---
42 Name: FlexRay static buffer configuration
43 Category: FlexRay
44 Header: rpp/fr.h
45 Mnemonic: FRC
46
47 Inputs:
48
49 Outputs:
50
51 Parameters:
52
53 # Description and Help is in Markdown mark-up
54 Description: &desc |
55
56   This block ...
57
58 Help: *desc
59
60 Status: Beta
61
62 RPP API functions used:
63
64 Relevant demos:
65 ...
66 */
67
68 #define S_FUNCTION_NAME sfunction_fraysbc
69 #include "header.c"
70 #include <stdio.h>
71
72 #define channel_IDX                                             0
73 #define cycleCounterFiltering_IDX               1
74 #define isTx_IDX                                                2
75 #define maxPayload_IDX                                  3
76 #define msgBufferInterrupt_IDX                  4
77 #define payloadPreambleIndicatorTr_IDX  5
78 #define singleTransmit_IDX                              6
79 #define slotId_IDX                                              7
80
81
82 static void mdlInitializeSizes(SimStruct *S)
83 {
84     /*
85      * Configure parameters: 25
86          * channel (0 - A, 1 - B, 2 - AB)
87          * cycleCounterFiltering
88          * isTx
89          * maxPayload
90          * msgBufferInterrupt
91          * payloadPreambleIndicatorTr
92          * singleTransmit
93          * slotId
94      */
95     if (!rppSetNumParams(S, 8)) {
96         return;
97     }
98
99     /*
100      * Configure input ports: 0
101      */
102     if (!ssSetNumInputPorts(S, 0)) {
103         return;
104     }
105
106     /*
107      * Configure output ports: 0
108      */
109     if (!ssSetNumOutputPorts(S, 0)) {
110         return;
111     }
112
113     /* Set standard options for this block */
114     rppSetStandardOptions(S);
115 }
116
117
118 #ifdef MATLAB_MEX_FILE
119 #define MDL_CHECK_PARAMETERS
120 static void mdlCheckParameters(SimStruct *S)
121 {
122
123 }
124 #endif
125
126
127 #ifdef MATLAB_MEX_FILE
128 #define MDL_SET_WORK_WIDTHS
129 static void mdlSetWorkWidths(SimStruct *S)
130 {
131     /* Set number of run-time parameters */
132     if (!ssSetNumRunTimeParams(S, 8)) {
133         return;
134     }
135
136     /* Register the run-time parameter 1 */
137         ssRegDlgParamAsRunTimeParam(S, channel_IDX, channel_IDX, "channel", SS_UINT8);
138         ssRegDlgParamAsRunTimeParam(S, cycleCounterFiltering_IDX, cycleCounterFiltering_IDX, "cycleCounterFiltering", SS_UINT8);
139         ssRegDlgParamAsRunTimeParam(S, isTx_IDX, isTx_IDX, "isTx", SS_BOOLEAN);
140         ssRegDlgParamAsRunTimeParam(S, maxPayload_IDX, maxPayload_IDX, "maxPayload", SS_UINT8);
141         ssRegDlgParamAsRunTimeParam(S, msgBufferInterrupt_IDX, msgBufferInterrupt_IDX, "msgBufferInterrupt", SS_BOOLEAN);
142         ssRegDlgParamAsRunTimeParam(S, payloadPreambleIndicatorTr_IDX, payloadPreambleIndicatorTr_IDX, "payloadPreambleIndicatorTr", SS_BOOLEAN);
143         ssRegDlgParamAsRunTimeParam(S, singleTransmit_IDX, singleTransmit_IDX, "singleTransmit", SS_BOOLEAN);
144         ssRegDlgParamAsRunTimeParam(S, slotId_IDX, slotId_IDX, "slotId", SS_UINT32);
145 }
146 #endif
147
148
149 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
150 #define UNUSED_MDLOUTPUTS
151 #define UNUSED_MDLTERMINATE
152 #include "trailer.c"