X-Git-Url: https://rtime.felk.cvut.cz/gitweb/mf624-simulink.git/blobdiff_plain/feb21df26f15113aa8596193a4142273a84b5e12..13cde8a33f64c7b6d64c456a133efe6525e8a4a7:/sfDigitalInput.c diff --git a/sfDigitalInput.c b/sfDigitalInput.c index d5fca66..a6294c6 100644 --- a/sfDigitalInput.c +++ b/sfDigitalInput.c @@ -46,7 +46,10 @@ * its associated macro definitions. */ #include "simstruc.h" + +#ifndef WITHOUT_HW #include "mf624_SIMULINK.h" +#endif /*WITHOUT_HW*/ /* Error handling * -------------- @@ -159,8 +162,10 @@ static void mdlInitializeSampleTimes(SimStruct *S) */ static void mdlStart(SimStruct *S) { + #ifndef WITHOUT_HW if (mf624_init(NULL) != 0) - return; + return; + #endif /*WITHOUT_HW*/ } #endif /* MDL_START */ @@ -174,16 +179,20 @@ static void mdlInitializeSampleTimes(SimStruct *S) static void mdlOutputs(SimStruct *S, int_T tid) { real_T *y; - uint16_t din; + uint_T din; + + y = (real_T *)ssGetOutputPortSignal(S, 0); + #ifndef WITHOUT_HW if (mf624_check(S) != 0) return; - y = (real_T *)ssGetOutputPortSignal(S, 0); - din = mf624_read16(MFST2REG(mfst, 2, DIN_reg)); *y = din & (1 << (int)(CHNL_PRM(S)-1)) ? 0.0 : 1.0; + #else /*WITHOUT_HW*/ + *y = 0; + #endif /*WITHOUT_HW*/ } @@ -226,7 +235,9 @@ static void mdlOutputs(SimStruct *S, int_T tid) */ static void mdlTerminate(SimStruct *S) { - mf624_done(); + #ifndef WITHOUT_HW + mf624_done(); + #endif /*WITHOUT_HW*/ }