]> rtime.felk.cvut.cz Git - mf624-simulink.git/blobdiff - sfDigitalInput.c
Add build mode WITHOUT_HW to edit model without MF624 hardware access.
[mf624-simulink.git] / sfDigitalInput.c
index d5fca66c47eadafbd9093b88afa5e583fef4ec76..a6294c6d719bb2eb83467b15ca4e47c3d38c030a 100644 (file)
  * 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*/
 }