]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/blob - rpp/blocks/sfunction_fraytransmit.c
doc: Introduce Help field in YAML doc
[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 and Help is in Markdown mark-up
47 Description: &desc |
48
49   This block ...
50
51 Help: *desc
52
53 Status:
54   Tested:
55   Untested:
56   Not working:
57     - Unknown status
58
59 RPP API functions used:
60
61 Relevant demos:
62 ...
63 */
64
65 #define S_FUNCTION_NAME sfunction_fraytransmit
66 #include "header.c"
67 #include <stdio.h>
68
69 enum params {
70         channel_IDX                                             = 0,
71         cycleCounterFiltering_IDX               = 1,
72         maxPayload_IDX                                  = 2,
73         msgBufferInterrupt_IDX                  = 3,
74         payloadPreambleIndicatorTr_IDX  = 4,
75         singleTransmit_IDX                              = 5,
76         slotId_IDX                                              = 6,
77         PARAM_COUNT
78 };
79
80 static void mdlInitializeSizes(SimStruct *S)
81 {
82     if (!rppSetNumParams(S, PARAM_COUNT)) {
83         return;
84     }
85
86     /*
87      * Configure input ports: 1
88      */
89     if (!ssSetNumInputPorts(S, 1)) {
90         return;
91     }
92         rppAddInputVectorPort(S, 0, SS_UINT8, 2*(int_T)mxGetPr(ssGetSFcnParam(S, 2))[0]);
93
94     /*
95      * Configure output ports: 1
96      *  - Error flag.
97      */
98     if (!ssSetNumOutputPorts(S, 1)) {
99         return;
100     }
101     rppAddOutputPort(S, 0, SS_BOOLEAN);
102
103     /* Set standard options for this block */
104     rppSetStandardOptions(S);
105 }
106
107
108 #ifdef MATLAB_MEX_FILE
109 #define MDL_CHECK_PARAMETERS
110 static void mdlCheckParameters(SimStruct *S)
111 {
112
113 }
114 #endif
115
116
117 #ifdef MATLAB_MEX_FILE
118 #define MDL_SET_WORK_WIDTHS
119 static void mdlSetWorkWidths(SimStruct *S)
120 {
121     /* Set number of run-time parameters */
122     if (!ssSetNumRunTimeParams(S, PARAM_COUNT)) {
123         return;
124     }
125
126     /* Register the run-time parameter 1 */
127         ssRegDlgParamAsRunTimeParam(S, channel_IDX, channel_IDX, "channel", SS_UINT8);
128         ssRegDlgParamAsRunTimeParam(S, cycleCounterFiltering_IDX, cycleCounterFiltering_IDX, "cycleCounterFiltering", SS_UINT8);
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"