[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] lp driver patch for the Firebee to extend the parallel port strobe duration



Hi all,

please find attached a patch to MiNT's lp driver.

It fixes the problem that with the Firebee's Coldfire processor, the parallel port strobe signal is not kept active long enough to be recognised by most printers. The original delay was two NOP's between toggling the PSG ports which is much too small for the Firebee. I have replaced this (only if __mcoldfire__ is defined) with a simple wait loop around a nop.

Loop count has been adjusted to meet the minimum requirement of 750 ns for strobe activation according to IEEE 1284.

This is not entirely clean (if we'll ever have another machine with different clock speed, it may fail again), but since the Firebee is the only known Coldfire machine with a PSG chip, I'd consider it good enough for now.

Note that this alone is not sufficient to make the Firebee print, you'll need a (hopefully soon to be released) FPGA fix as well. It also won't work (for yet unknown reasons) with MiNT running on top of FireTOS.

But it will make (with the FPGA fix) MiNT + EmuTOS print on the parallel port which I definitively consider an improvement.

Commit text:

lp driver patch to extend the parallel port strobe duration on the Firebee
Contributed by Markus Fröschle


Cheers,
Markus
Index: sys/xdd/lp/centr.S
===================================================================
RCS file: /mint/freemint/sys/xdd/lp/centr.S,v
retrieving revision 1.2
diff -u -r1.2 centr.S
--- sys/xdd/lp/centr.S	25 May 2011 08:54:59 -0000	1.2
+++ sys/xdd/lp/centr.S	3 Oct 2015 18:17:49 -0000
@@ -26,7 +26,21 @@
 	bclr	#0, 0xFFFFFA11
 #endif
 	rte
-	
+
+#ifdef __mcoldfire__
+|
+| stupid delay for Coldfires to keep the strobe signal
+| active long enough according to the standards
+|
+strobe_delay:
+	move.l	(sp)+,d0		| 1
+1:
+	nop				| 6
+	subq.l	#1,d0			| 1
+	bne	1b			| 0 = 8 clocks at best
+	rts
+#endif
+
 _print_byte:
 	movew	sp@(4), d0		| character to print
 #ifdef __mcoldfire__
@@ -41,12 +55,27 @@
 	movel	#0xFFFF8800, a0
 	moveb	#15, a0@		| select port B
 	moveb	d0, a0@(2)		| and write the character
+
+#ifdef __mcoldfire__
+	move.l	d0,-(sp)
+	move.l	#21,-(sp)		| 773 ns according to my calculations
+	bsr	strobe_delay		| ieee 1284 requires at least 750 ns
+	move.l	(sp)+,d0
+#endif
+
 	moveb	#14, a0@		| select port A
 	moveb	a0@, d0			| read it
 	bclr	#5, d0
 	moveb	d0, a0@(2)		| strobe low
+#ifdef __mcoldfire__
+	move.l	d0,-(sp)
+	move.l	#21,-(sp)		| see above
+	bsr	strobe_delay
+	move.l	(sp)+,d0
+#else
 	nop
 	nop
+#endif
 	bset	#5, d0
 	moveb	d0, a0@(2)		| strobe high
 #ifdef __mcoldfire__