dragondos: floppy timer
authorAlan Cox <alan@linux.intel.com>
Wed, 3 Jun 2015 17:55:57 +0000 (18:55 +0100)
committerAlan Cox <alan@linux.intel.com>
Wed, 3 Jun 2015 17:55:57 +0000 (18:55 +0100)
Kernel/platform-dragon-nx32/devfd.c
Kernel/platform-dragon-nx32/devtty.c

index e77d777..c335e4b 100644 (file)
@@ -16,21 +16,27 @@ static uint8_t motorct;
 static uint8_t fd_selected = 0xFF;
 extern uint8_t fd_tab[];
 
-static void fd_motor_busy(void)
+static uint8_t motor_timeout = 0;
+
+static inline void fd_motor_busy(void)
 {
     motorct++;
+    motor_timeout = 240;
 }
 
-static void fd_motor_idle(void)
+static inline void fd_motor_idle(void)
 {
     motorct--;
-    // if (motorct == 0) ... start timer */
 }
 
-static void fd_motor_timeout(void)
+void fd_timer_tick(void)
 {
-    fd_selected = 0xff;
-    fd_motor_off();
+    if (!motorct && motor_timeout) {
+        if (motor_timeout-- == 1) {
+            fd_selected = 0xff;
+            fd_motor_off();
+        }
+    }
 }
 
 /*
index 0dde12e..56ee52f 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdbool.h>
 #include <devtty.h>
 #include <device.h>
+#include <devfd.h>
 #include <vt.h>
 #include <tty.h>
 #include <graphics.h>
@@ -212,6 +213,7 @@ void platform_interrupt(void)
                keyproc();
                if (keysdown < 3 && newkey)
                        keydecode();
+                fd_timer_tick();
                timer_interrupt();
        }
 }