*/
#include "simstruc.h"
+#ifndef WITHOUT_HW
#include "mf624_SIMULINK.h"
+#endif /*WITHOUT_HW*/
/* Error handling
* --------------
*/
static void mdlStart(SimStruct *S)
{
+ #ifndef WITHOUT_HW
if (mf624_init(NULL) != 0)
return;
/*Start counters 0,1,2, tehy are gated with their inputs so no worries about premature start*/
mf624_write32(CTR_START,MFST2REG(mfst,4,CTRXCTRL_reg));
-
-
+ #endif /*WITHOUT_HW*/
}
#endif /* MDL_START */
real_T *y2 = ssGetOutputPortSignal(S,2);
unsigned int period;
unsigned int c0,c1,c2,c4;
-
+ #ifndef WITHOUT_HW
if (mf624_check(S) != 0)
- return;
-
+ return;
+
c0 = mf624_read32(MFST2REG(mfst,4,CTR0_reg));
c1 = mf624_read32(MFST2REG(mfst,4,CTR1_reg));
c2 = mf624_read32(MFST2REG(mfst,4,CTR2_reg));
c4 = mf624_read32(MFST2REG(mfst,4,CTR4_reg));
-
+
period = (unsigned int)(c4-(unsigned int)ssGetIWorkValue(S,3));
-
+
y0[0] = (real_T)(c0-(unsigned int)ssGetIWorkValue(S,0))/(real_T)period;
y1[0] = (real_T)(c1-(unsigned int)ssGetIWorkValue(S,1))/(real_T)period;
y2[0] = (real_T)(c2-(unsigned int)ssGetIWorkValue(S,2))/(real_T)period;
-
+
ssSetIWorkValue(S,0,c0);
ssSetIWorkValue(S,1,c1);
ssSetIWorkValue(S,2,c2);
ssSetIWorkValue(S,3,c4);
+ #else /*WITHOUT_HW*/
+ y0[0] = y1[0] = y2[0] = 0;
+ #endif /*WITHOUT_HW*/
}
*/
static void mdlTerminate(SimStruct *S)
{
+ #ifndef WITHOUT_HW
if (mf624_check(NULL) != 0)
- return;
+ return;
mf624_write32(CTR_STOP,MFST2REG(mfst,4,CTRXCTRL_reg));
mf624_done();
+ #endif /*WITHOUT_HW*/
}