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 is in Markdown mark-up
102 RPP API functions used:
108 #define S_FUNCTION_NAME sfunction_frayconfig
113 gColdStartAttempts_IDX = 0,
114 gListenNoise_IDX = 1,
115 gMacroPerCycle_IDX = 2,
116 gMaxWithoutClockCorrectionFatal_IDX = 3,
117 gMaxWithoutClockCorrectionPassive_IDX = 4,
118 gNetworkManagementVectorLength_IDX = 5,
119 gNumberOfMinislots_IDX = 6,
120 gNumberOfStaticSlots_IDX = 7,
121 gOffsetCorrectionStart_IDX = 8,
122 gPayloadLengthStatic_IDX = 9,
123 gSyncNodeMax_IDX = 10,
124 gdActionPointOffset_IDX = 11,
125 gdCASRxLowMax_IDX = 12,
126 gdDynamicSlotIdlePhase_IDX = 13,
128 gdMinislotActionPointOffset_IDX = 15,
130 gdSampleClockPeriod_IDX = 17,
131 gdStaticSlot_IDX = 18,
132 gdTSSTransmitter_IDX = 19,
133 gdWakeupSymbolRxIdle_IDX = 20,
134 gdWakeupSymbolRxLow_IDX = 21,
135 gdWakeupSymbolRxWindow_IDX = 22,
136 gdWakeupSymbolTxIdle_IDX = 23,
137 gdWakeupSymbolTxLow_IDX = 24,
139 pAllowHaltDueToClock_IDX = 25,
140 pAllowPassiveToActive_IDX = 26,
142 pClusterDriftDamping_IDX = 28,
143 pDelayCompensationA_IDX = 29,
144 pDelayCompensationB_IDX = 30,
145 pExternOffsetCorrection_IDX = 31,
146 pExternRateCorrection_IDX = 32,
147 pKeySlotUsedForStartup_IDX = 33,
148 pKeySlotUsedForSync_IDX = 34,
150 pMacroInitialOffsetA_IDX = 36,
151 pMacroInitialOffsetB_IDX = 37,
152 pMicroInitialOffsetA_IDX = 38,
153 pMicroInitialOffsetB_IDX = 39,
154 pMicroPerCycle_IDX = 40,
155 pRateCorrectionOut_IDX = 41,
156 pOffsetCorrectionOut_IDX = 42,
157 pSamplesPerMicrotick_IDX = 43,
158 pSingleSlotEnabled_IDX = 44,
159 pWakeupChannel_IDX = 45,
160 pWakeupPattern_IDX = 46,
161 pdAcceptedStartupRange_IDX = 47,
162 pdListenTimeout_IDX = 48,
164 pDecodingCorrection_IDX = 50,
165 syncFramePayloadMultiplexEnabled_IDX = 51,
166 secureBuffers_IDX = 52,
171 static void mdlInitializeSizes(SimStruct *S)
174 if (!rppSetNumParams(S, PARAM_COUNT)) {
179 * Configure input ports: 0
181 if (!ssSetNumInputPorts(S, 0)) {
186 * Configure output ports: 1
189 if (!ssSetNumOutputPorts(S, 1)) {
192 rppAddOutputPort(S, 0, SS_BOOLEAN);
194 /* Set standard options for this block */
195 rppSetStandardOptions(S);
199 #ifdef MATLAB_MEX_FILE
200 #define MDL_CHECK_PARAMETERS
201 static void mdlCheckParameters(SimStruct *S)
208 #ifdef MATLAB_MEX_FILE
209 #define MDL_SET_WORK_WIDTHS
210 static void mdlSetWorkWidths(SimStruct *S)
212 /* Set number of run-time parameters */
213 if (!ssSetNumRunTimeParams(S, PARAM_COUNT)) {
217 /* Register the run-time parameter 1 */
218 ssRegDlgParamAsRunTimeParam(S, gColdStartAttempts_IDX, gColdStartAttempts_IDX, "gColdStartAttempts", SS_UINT8);
219 ssRegDlgParamAsRunTimeParam(S, gListenNoise_IDX, gListenNoise_IDX, "gListenNoise", SS_UINT8);
220 ssRegDlgParamAsRunTimeParam(S, gMacroPerCycle_IDX, gMacroPerCycle_IDX, "gMacroPerCycle", SS_UINT16);
221 ssRegDlgParamAsRunTimeParam(S, gMaxWithoutClockCorrectionFatal_IDX, gMaxWithoutClockCorrectionFatal_IDX, "gMaxWithoutClockCorrectionFatal", SS_UINT8);
222 ssRegDlgParamAsRunTimeParam(S, gMaxWithoutClockCorrectionPassive_IDX, gMaxWithoutClockCorrectionPassive_IDX, "gMaxWithoutClockCorrectionPassive", SS_UINT8);
223 ssRegDlgParamAsRunTimeParam(S, gNetworkManagementVectorLength_IDX, gNetworkManagementVectorLength_IDX, "gNetworkManagementVectorLength", SS_UINT8);
224 ssRegDlgParamAsRunTimeParam(S, gNumberOfMinislots_IDX, gNumberOfMinislots_IDX, "gNumberOfMinislots", SS_UINT16);
225 ssRegDlgParamAsRunTimeParam(S, gNumberOfStaticSlots_IDX, gNumberOfStaticSlots_IDX, "gNumberOfStaticSlots", SS_UINT16);
226 ssRegDlgParamAsRunTimeParam(S, gOffsetCorrectionStart_IDX, gOffsetCorrectionStart_IDX, "gOffsetCorrectionStart", SS_UINT16);
227 ssRegDlgParamAsRunTimeParam(S, gPayloadLengthStatic_IDX, gPayloadLengthStatic_IDX, "gPayloadLengthStatic", SS_UINT8);
228 ssRegDlgParamAsRunTimeParam(S, gSyncNodeMax_IDX, gSyncNodeMax_IDX, "gSyncNodeMax", SS_UINT8);
229 ssRegDlgParamAsRunTimeParam(S, gdActionPointOffset_IDX, gdActionPointOffset_IDX, "gdActionPointOffset", SS_UINT8);
230 ssRegDlgParamAsRunTimeParam(S, gdCASRxLowMax_IDX, gdCASRxLowMax_IDX, "gdCASRxLowMax", SS_UINT8);
231 ssRegDlgParamAsRunTimeParam(S, gdDynamicSlotIdlePhase_IDX, gdDynamicSlotIdlePhase_IDX, "gdDynamicSlotIdlePhase", SS_UINT8);
232 ssRegDlgParamAsRunTimeParam(S, gdMinislot_IDX, gdMinislot_IDX, "gdMinislot", SS_UINT8);
233 ssRegDlgParamAsRunTimeParam(S, gdMinislotActionPointOffset_IDX, gdMinislotActionPointOffset_IDX, "gdMinislotActionPointOffset", SS_UINT8);
234 ssRegDlgParamAsRunTimeParam(S, gdNIT_IDX, gdNIT_IDX, "gdNIT", SS_UINT16);
235 ssRegDlgParamAsRunTimeParam(S, gdSampleClockPeriod_IDX, gdSampleClockPeriod_IDX, "gdSampleClockPeriod", SS_UINT8);
236 ssRegDlgParamAsRunTimeParam(S, gdStaticSlot_IDX, gdStaticSlot_IDX, "gdStaticSlot", SS_UINT16);
237 ssRegDlgParamAsRunTimeParam(S, gdTSSTransmitter_IDX, gdTSSTransmitter_IDX, "gdTSSTransmitter", SS_UINT8);
238 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolRxIdle_IDX, gdWakeupSymbolRxIdle_IDX, "gdWakeupSymbolRxIdle", SS_UINT8);
239 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolRxLow_IDX, gdWakeupSymbolRxLow_IDX, "gdWakeupSymbolRxLow", SS_UINT8);
240 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolRxWindow_IDX, gdWakeupSymbolRxWindow_IDX, "gdWakeupSymbolRxWindow", SS_UINT16);
241 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolTxIdle_IDX, gdWakeupSymbolTxIdle_IDX, "gdWakeupSymbolTxIdle", SS_UINT8);
242 ssRegDlgParamAsRunTimeParam(S, gdWakeupSymbolTxLow_IDX, gdWakeupSymbolTxLow_IDX, "gdWakeupSymbolTxLow", SS_UINT8);
244 ssRegDlgParamAsRunTimeParam(S, pAllowHaltDueToClock_IDX, pAllowHaltDueToClock_IDX, "pAllowHaltDueToClock", SS_BOOLEAN);
245 ssRegDlgParamAsRunTimeParam(S, pAllowPassiveToActive_IDX, pAllowPassiveToActive_IDX, "pAllowPassiveToActive", SS_UINT8);
246 ssRegDlgParamAsRunTimeParam(S, pChannels_IDX, pChannels_IDX, "pChannels", SS_UINT8);
247 ssRegDlgParamAsRunTimeParam(S, pClusterDriftDamping_IDX, pClusterDriftDamping_IDX, "pClusterDriftDamping", SS_UINT8);
248 ssRegDlgParamAsRunTimeParam(S, pDelayCompensationA_IDX, pDelayCompensationA_IDX, "pDelayCompensationA", SS_UINT16);
249 ssRegDlgParamAsRunTimeParam(S, pDelayCompensationB_IDX, pDelayCompensationB_IDX, "pDelayCompensationB", SS_UINT16);
250 ssRegDlgParamAsRunTimeParam(S, pExternOffsetCorrection_IDX, pExternOffsetCorrection_IDX, "pExternOffsetCorrection", SS_UINT8);
251 ssRegDlgParamAsRunTimeParam(S, pExternRateCorrection_IDX, pExternRateCorrection_IDX, "pExternRateCorrection", SS_UINT8);
252 ssRegDlgParamAsRunTimeParam(S, pKeySlotUsedForStartup_IDX, pKeySlotUsedForStartup_IDX, "pKeySlotUsedForStartup", SS_BOOLEAN);
253 ssRegDlgParamAsRunTimeParam(S, pKeySlotUsedForSync_IDX, pKeySlotUsedForSync_IDX, "pKeySlotUsedForSync", SS_BOOLEAN);
254 ssRegDlgParamAsRunTimeParam(S, pLatestTx_IDX, pLatestTx_IDX, "pLatestTx", SS_UINT16);
255 ssRegDlgParamAsRunTimeParam(S, pMacroInitialOffsetA_IDX, pMacroInitialOffsetA_IDX, "pMacroInitialOffsetA", SS_UINT8);
256 ssRegDlgParamAsRunTimeParam(S, pMacroInitialOffsetB_IDX, pMacroInitialOffsetB_IDX, "pMacroInitialOffsetB", SS_UINT8);
257 ssRegDlgParamAsRunTimeParam(S, pMicroInitialOffsetA_IDX, pMicroInitialOffsetA_IDX, "pMicroInitialOffsetA", SS_UINT8);
258 ssRegDlgParamAsRunTimeParam(S, pMicroInitialOffsetB_IDX, pMicroInitialOffsetB_IDX, "pMicroInitialOffsetB", SS_UINT8);
259 ssRegDlgParamAsRunTimeParam(S, pMicroPerCycle_IDX, pMicroPerCycle_IDX, "pMicroPerCycle", SS_UINT32);
260 ssRegDlgParamAsRunTimeParam(S, pRateCorrectionOut_IDX, pRateCorrectionOut_IDX, "pRateCorrectionOut", SS_UINT16);
261 ssRegDlgParamAsRunTimeParam(S, pOffsetCorrectionOut_IDX, pOffsetCorrectionOut_IDX, "pOffsetCorrectionOut", SS_UINT16);
262 ssRegDlgParamAsRunTimeParam(S, pSamplesPerMicrotick_IDX, pSamplesPerMicrotick_IDX, "pSamplesPerMicrotick", SS_UINT8);
263 ssRegDlgParamAsRunTimeParam(S, pSingleSlotEnabled_IDX, pSingleSlotEnabled_IDX, "pSingleSlotEnabled", SS_UINT8);
264 ssRegDlgParamAsRunTimeParam(S, pWakeupChannel_IDX, pWakeupChannel_IDX, "pWakeupChannel", SS_UINT8);
265 ssRegDlgParamAsRunTimeParam(S, pWakeupPattern_IDX, pWakeupPattern_IDX, "pWakeupPattern", SS_UINT8);
266 ssRegDlgParamAsRunTimeParam(S, pdAcceptedStartupRange_IDX, pdAcceptedStartupRange_IDX, "pdAcceptedStartupRange", SS_UINT16);
267 ssRegDlgParamAsRunTimeParam(S, pdListenTimeout_IDX, pdListenTimeout_IDX, "pdListenTimeout", SS_UINT32);
268 ssRegDlgParamAsRunTimeParam(S, pdMaxDrift_IDX, pdMaxDrift_IDX, "pdMaxDrift", SS_UINT16);
269 ssRegDlgParamAsRunTimeParam(S, pDecodingCorrection_IDX, pDecodingCorrection_IDX, "pDecodingCorrection", SS_UINT8);
270 ssRegDlgParamAsRunTimeParam(S, syncFramePayloadMultiplexEnabled_IDX, syncFramePayloadMultiplexEnabled_IDX, "syncFramePayloadMultiplexEnabled", SS_BOOLEAN);
271 ssRegDlgParamAsRunTimeParam(S, secureBuffers_IDX, secureBuffers_IDX, "secureBuffers", SS_UINT8);
276 #define COMMON_MDLINITIALIZESAMPLETIMES_INHERIT
277 #define UNUSED_MDLOUTPUTS
278 #define UNUSED_MDLTERMINATE