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