1 /* Copyright (C) 2013, 2014 Czech Technical University in Prague
4 * - Michal Horn <hornimch@fel.cvut.cz>
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.
11 * File : sfunction_frayc.c
13 * C-MEX S-function block for RPP FlexRay cluster configuration.
20 * <matlabroot>/bin/mex sfunction_frayconfig.c
26 Name: Configure FlexRay Node
34 - { name: "ErrFlag", type: "bool" }
37 - { name: "gColdStartAttempts", type: "uint8" }
38 - { name: "gListenNoise", type: "uint8" }
39 - { name: "gMacroPerCycle", type: "uint16" }
40 - { name: "gMaxWithoutClockCorrectionFatal", type: "uint8" }
41 - { name: "gMaxWithoutClockCorrectionPassive", type: "uint8" }
42 - { name: "gNetworkManagementVectorLength", type: "uint8" }
43 - { name: "gNumberOfMinislots", type: "uint16" }
44 - { name: "gNumberOfStaticSlots", type: "uint16" }
45 - { name: "gOffsetCorrectionStart", type: "uint16" }
46 - { name: "gPayloadLengthStatic", type: "uint8" }
47 - { name: "gSyncNodeMax", type: "uint8" }
48 - { name: "gdActionPointOffset", type: "uint8" }
49 - { name: "gdCASRxLowMax", type: "uint8" }
50 - { name: "gdDynamicSlotIdlePhase", type: "uint8" }
51 - { name: "gdMinislot", type: "uint8" }
52 - { name: "gdMinislotActionPointOffset", type: "uint8" }
53 - { name: "gdNIT", type: "uint16" }
54 - { name: "gdSampleClockPeriod", type: "uint8" }
55 - { name: "gdStaticSlot", type: "uint16" }
56 - { name: "gdTSSTransmitter", type: "uint8" }
57 - { name: "gdWakeupSymbolRxIdle", type: "uint8" }
58 - { name: "gdWakeupSymbolRxLow", type: "uint8" }
59 - { name: "gdWakeupSymbolRxWindow", type: "uint16" }
60 - { name: "gdWakeupSymbolTxIdle", type: "uint8" }
61 - { name: "gdWakeupSymbolTxLow", type: "uint8" }
62 - { name: "pAllowHaltDueToClock", type: "bool" }
63 - { name: "pAllowPassiveToActive", type: "uint8" }
64 - { name: "pChannels", type: "uint8" }
65 - { name: "pClusterDriftDamping", type: "uint8" }
66 - { name: "pDelayCompensationA", type: "uint16" }
67 - { name: "pDelayCompensationB", type: "uint16" }
68 - { name: "pExternOffsetCorrection", type: "uint8" }
69 - { name: "pExternRateCorrection", type: "uint8" }
70 - { name: "pKeySlotUsedForStartup", type: "bool" }
71 - { name: "pKeySlotUsedForSync", type: "bool" }
72 - { name: "pLatestTx", type: "uint16" }
73 - { name: "pMacroInitialOffsetA", type: "uint8" }
74 - { name: "pMacroInitialOffsetB", type: "uint8" }
75 - { name: "pMicroInitialOffsetA", type: "uint8" }
76 - { name: "pMicroInitialOffsetB", type: "uint8" }
77 - { name: "pMicroPerCycle", type: "uint32" }
78 - { name: "pRateCorrectionOut", type: "uint16" }
79 - { name: "pOffsetCorrectionOut", type: "uint16" }
80 - { name: "pSamplesPerMicrotick", type: "uint8" }
81 - { name: "pSingleSlotEnabled", type: "uint8" }
82 - { name: "pWakeupChannel", type: "uint8" }
83 - { name: "pWakeupPattern", type: "uint8" }
84 - { name: "pdAcceptedStartupRange", type: "uint16" }
85 - { name: "pdListenTimeout", type: "uint32" }
86 - { name: "pdMaxDrift", type: "uint16" }
87 - { name: "pDecodingCorrection", type: "uint8" }
88 - { name: "syncFramePayloadMultiplexEnabled", type: "bool" }
89 - { name: "secureBuffers", type: "uint8" }
91 # Description and Help is in Markdown mark-up
104 RPP API functions used:
110 #define S_FUNCTION_NAME sfunction_frayconfig
115 gColdStartAttempts_IDX = 0,
116 gListenNoise_IDX = 1,
117 gMacroPerCycle_IDX = 2,
118 gMaxWithoutClockCorrectionFatal_IDX = 3,
119 gMaxWithoutClockCorrectionPassive_IDX = 4,
120 gNetworkManagementVectorLength_IDX = 5,
121 gNumberOfMinislots_IDX = 6,
122 gNumberOfStaticSlots_IDX = 7,
123 gOffsetCorrectionStart_IDX = 8,
124 gPayloadLengthStatic_IDX = 9,
125 gSyncNodeMax_IDX = 10,
126 gdActionPointOffset_IDX = 11,
127 gdCASRxLowMax_IDX = 12,
128 gdDynamicSlotIdlePhase_IDX = 13,
130 gdMinislotActionPointOffset_IDX = 15,
132 gdSampleClockPeriod_IDX = 17,
133 gdStaticSlot_IDX = 18,
134 gdTSSTransmitter_IDX = 19,
135 gdWakeupSymbolRxIdle_IDX = 20,
136 gdWakeupSymbolRxLow_IDX = 21,
137 gdWakeupSymbolRxWindow_IDX = 22,
138 gdWakeupSymbolTxIdle_IDX = 23,
139 gdWakeupSymbolTxLow_IDX = 24,
141 pAllowHaltDueToClock_IDX = 25,
142 pAllowPassiveToActive_IDX = 26,
144 pClusterDriftDamping_IDX = 28,
145 pDelayCompensationA_IDX = 29,
146 pDelayCompensationB_IDX = 30,
147 pExternOffsetCorrection_IDX = 31,
148 pExternRateCorrection_IDX = 32,
149 pKeySlotUsedForStartup_IDX = 33,
150 pKeySlotUsedForSync_IDX = 34,
152 pMacroInitialOffsetA_IDX = 36,
153 pMacroInitialOffsetB_IDX = 37,
154 pMicroInitialOffsetA_IDX = 38,
155 pMicroInitialOffsetB_IDX = 39,
156 pMicroPerCycle_IDX = 40,
157 pRateCorrectionOut_IDX = 41,
158 pOffsetCorrectionOut_IDX = 42,
159 pSamplesPerMicrotick_IDX = 43,
160 pSingleSlotEnabled_IDX = 44,
161 pWakeupChannel_IDX = 45,
162 pWakeupPattern_IDX = 46,
163 pdAcceptedStartupRange_IDX = 47,
164 pdListenTimeout_IDX = 48,
166 pDecodingCorrection_IDX = 50,
167 syncFramePayloadMultiplexEnabled_IDX = 51,
168 secureBuffers_IDX = 52,
173 static void mdlInitializeSizes(SimStruct *S)
176 if (!rppSetNumParams(S, PARAM_COUNT)) {
181 * Configure input ports: 0
183 if (!ssSetNumInputPorts(S, 0)) {
188 * Configure output ports: 1
191 if (!ssSetNumOutputPorts(S, 1)) {
194 rppAddOutputPort(S, 0, SS_BOOLEAN);
196 /* Set standard options for this block */
197 rppSetStandardOptions(S);
201 #ifdef MATLAB_MEX_FILE
202 #define MDL_CHECK_PARAMETERS
203 static void mdlCheckParameters(SimStruct *S)
210 #ifdef MATLAB_MEX_FILE
211 #define MDL_SET_WORK_WIDTHS
212 static void mdlSetWorkWidths(SimStruct *S)
214 /* Set number of run-time parameters */
215 if (!ssSetNumRunTimeParams(S, PARAM_COUNT)) {
219 /* Register the run-time parameter 1 */
220 ssRegDlgParamAsRunTimeParam(S, gColdStartAttempts_IDX, gColdStartAttempts_IDX, "gColdStartAttempts", SS_UINT8);
221 ssRegDlgParamAsRunTimeParam(S, gListenNoise_IDX, gListenNoise_IDX, "gListenNoise", SS_UINT8);
222 ssRegDlgParamAsRunTimeParam(S, gMacroPerCycle_IDX, gMacroPerCycle_IDX, "gMacroPerCycle", SS_UINT16);
223 ssRegDlgParamAsRunTimeParam(S, gMaxWithoutClockCorrectionFatal_IDX, gMaxWithoutClockCorrectionFatal_IDX, "gMaxWithoutClockCorrectionFatal", SS_UINT8);
224 ssRegDlgParamAsRunTimeParam(S, gMaxWithoutClockCorrectionPassive_IDX, gMaxWithoutClockCorrectionPassive_IDX, "gMaxWithoutClockCorrectionPassive", SS_UINT8);
225 ssRegDlgParamAsRunTimeParam(S, gNetworkManagementVectorLength_IDX, gNetworkManagementVectorLength_IDX, "gNetworkManagementVectorLength", SS_UINT8);
226 ssRegDlgParamAsRunTimeParam(S, gNumberOfMinislots_IDX, gNumberOfMinislots_IDX, "gNumberOfMinislots", SS_UINT16);
227 ssRegDlgParamAsRunTimeParam(S, gNumberOfStaticSlots_IDX, gNumberOfStaticSlots_IDX, "gNumberOfStaticSlots", SS_UINT16);
228 ssRegDlgParamAsRunTimeParam(S, gOffsetCorrectionStart_IDX, gOffsetCorrectionStart_IDX, "gOffsetCorrectionStart", SS_UINT16);
229 ssRegDlgParamAsRunTimeParam(S, gPayloadLengthStatic_IDX, gPayloadLengthStatic_IDX, "gPayloadLengthStatic", SS_UINT8);
230 ssRegDlgParamAsRunTimeParam(S, gSyncNodeMax_IDX, gSyncNodeMax_IDX, "gSyncNodeMax", SS_UINT8);
231 ssRegDlgParamAsRunTimeParam(S, gdActionPointOffset_IDX, gdActionPointOffset_IDX, "gdActionPointOffset", SS_UINT8);
232 ssRegDlgParamAsRunTimeParam(S, gdCASRxLowMax_IDX, gdCASRxLowMax_IDX, "gdCASRxLowMax", SS_UINT8);
233 ssRegDlgParamAsRunTimeParam(S, gdDynamicSlotIdlePhase_IDX, gdDynamicSlotIdlePhase_IDX, "gdDynamicSlotIdlePhase", SS_UINT8);
234 ssRegDlgParamAsRunTimeParam(S, gdMinislot_IDX, gdMinislot_IDX, "gdMinislot", SS_UINT8);
235 ssRegDlgParamAsRunTimeParam(S, gdMinislotActionPointOffset_IDX, gdMinislotActionPointOffset_IDX, "gdMinislotActionPointOffset", SS_UINT8);
236 ssRegDlgParamAsRunTimeParam(S, gdNIT_IDX, gdNIT_IDX, "gdNIT", SS_UINT16);
237 ssRegDlgParamAsRunTimeParam(S, gdSampleClockPeriod_IDX, gdSampleClockPeriod_IDX, "gdSampleClockPeriod", SS_UINT8);
238 ssRegDlgParamAsRunTimeParam(S, gdStaticSlot_IDX, gdStaticSlot_IDX, "gdStaticSlot", SS_UINT16);
239 ssRegDlgParamAsRunTimeParam(S, gdTSSTransmitter_IDX, gdTSSTransmitter_IDX, "gdTSSTransmitter", SS_UINT8);
240 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolRxIdle_IDX, gdWakeupSymbolRxIdle_IDX, "gdWakeupSymbolRxIdle", SS_UINT8);
241 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolRxLow_IDX, gdWakeupSymbolRxLow_IDX, "gdWakeupSymbolRxLow", SS_UINT8);
242 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolRxWindow_IDX, gdWakeupSymbolRxWindow_IDX, "gdWakeupSymbolRxWindow", SS_UINT16);
243 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolTxIdle_IDX, gdWakeupSymbolTxIdle_IDX, "gdWakeupSymbolTxIdle", SS_UINT8);
244 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolTxLow_IDX, gdWakeupSymbolTxLow_IDX, "gdWakeupSymbolTxLow", SS_UINT8);
246 ssRegDlgParamAsRunTimeParam(S, pAllowHaltDueToClock_IDX, pAllowHaltDueToClock_IDX, "pAllowHaltDueToClock", SS_BOOLEAN);
247 ssRegDlgParamAsRunTimeParam(S, pAllowPassiveToActive_IDX, pAllowPassiveToActive_IDX, "pAllowPassiveToActive", SS_UINT8);
248 ssRegDlgParamAsRunTimeParam(S, pChannels_IDX, pChannels_IDX, "pChannels", SS_UINT8);
249 ssRegDlgParamAsRunTimeParam(S, pClusterDriftDamping_IDX, pClusterDriftDamping_IDX, "pClusterDriftDamping", SS_UINT8);
250 ssRegDlgParamAsRunTimeParam(S, pDelayCompensationA_IDX, pDelayCompensationA_IDX, "pDelayCompensationA", SS_UINT16);
251 ssRegDlgParamAsRunTimeParam(S, pDelayCompensationB_IDX, pDelayCompensationB_IDX, "pDelayCompensationB", SS_UINT16);
252 ssRegDlgParamAsRunTimeParam(S, pExternOffsetCorrection_IDX, pExternOffsetCorrection_IDX, "pExternOffsetCorrection", SS_UINT8);
253 ssRegDlgParamAsRunTimeParam(S, pExternRateCorrection_IDX, pExternRateCorrection_IDX, "pExternRateCorrection", SS_UINT8);
254 ssRegDlgParamAsRunTimeParam(S, pKeySlotUsedForStartup_IDX, pKeySlotUsedForStartup_IDX, "pKeySlotUsedForStartup", SS_BOOLEAN);
255 ssRegDlgParamAsRunTimeParam(S, pKeySlotUsedForSync_IDX, pKeySlotUsedForSync_IDX, "pKeySlotUsedForSync", SS_BOOLEAN);
256 ssRegDlgParamAsRunTimeParam(S, pLatestTx_IDX, pLatestTx_IDX, "pLatestTx", SS_UINT16);
257 ssRegDlgParamAsRunTimeParam(S, pMacroInitialOffsetA_IDX, pMacroInitialOffsetA_IDX, "pMacroInitialOffsetA", SS_UINT8);
258 ssRegDlgParamAsRunTimeParam(S, pMacroInitialOffsetB_IDX, pMacroInitialOffsetB_IDX, "pMacroInitialOffsetB", SS_UINT8);
259 ssRegDlgParamAsRunTimeParam(S, pMicroInitialOffsetA_IDX, pMicroInitialOffsetA_IDX, "pMicroInitialOffsetA", SS_UINT8);
260 ssRegDlgParamAsRunTimeParam(S, pMicroInitialOffsetB_IDX, pMicroInitialOffsetB_IDX, "pMicroInitialOffsetB", SS_UINT8);
261 ssRegDlgParamAsRunTimeParam(S, pMicroPerCycle_IDX, pMicroPerCycle_IDX, "pMicroPerCycle", SS_UINT32);
262 ssRegDlgParamAsRunTimeParam(S, pRateCorrectionOut_IDX, pRateCorrectionOut_IDX, "pRateCorrectionOut", SS_UINT16);
263 ssRegDlgParamAsRunTimeParam(S, pOffsetCorrectionOut_IDX, pOffsetCorrectionOut_IDX, "pOffsetCorrectionOut", SS_UINT16);
264 ssRegDlgParamAsRunTimeParam(S, pSamplesPerMicrotick_IDX, pSamplesPerMicrotick_IDX, "pSamplesPerMicrotick", SS_UINT8);
265 ssRegDlgParamAsRunTimeParam(S, pSingleSlotEnabled_IDX, pSingleSlotEnabled_IDX, "pSingleSlotEnabled", SS_UINT8);
266 ssRegDlgParamAsRunTimeParam(S, pWakeupChannel_IDX, pWakeupChannel_IDX, "pWakeupChannel", SS_UINT8);
267 ssRegDlgParamAsRunTimeParam(S, pWakeupPattern_IDX, pWakeupPattern_IDX, "pWakeupPattern", SS_UINT8);
268 ssRegDlgParamAsRunTimeParam(S, pdAcceptedStartupRange_IDX, pdAcceptedStartupRange_IDX, "pdAcceptedStartupRange", SS_UINT16);
269 ssRegDlgParamAsRunTimeParam(S, pdListenTimeout_IDX, pdListenTimeout_IDX, "pdListenTimeout", SS_UINT32);
270 ssRegDlgParamAsRunTimeParam(S, pdMaxDrift_IDX, pdMaxDrift_IDX, "pdMaxDrift", SS_UINT16);
271 ssRegDlgParamAsRunTimeParam(S, pDecodingCorrection_IDX, pDecodingCorrection_IDX, "pDecodingCorrection", SS_UINT8);
272 ssRegDlgParamAsRunTimeParam(S, syncFramePayloadMultiplexEnabled_IDX, syncFramePayloadMultiplexEnabled_IDX, "syncFramePayloadMultiplexEnabled", SS_BOOLEAN);
273 ssRegDlgParamAsRunTimeParam(S, secureBuffers_IDX, secureBuffers_IDX, "secureBuffers", SS_UINT8);
278 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
279 #define UNUSED_MDLOUTPUTS
280 #define UNUSED_MDLTERMINATE