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