Parallel port: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
No edit summary
m Bot: Replace deprecated source tag with syntaxhighlight
 
(3 intermediate revisions by 3 users not shown)
Line 1:
{{NoteBox|<b><code>NOTE:</codeb> Before doing anything, make sure to set the parallel ports mode to Standard or Normal in the BIOS instead of ECP/EPP if anything fails from your programming efforts, preferably before exhausting your options.</b>}}
 
[http://f.osdev.org/viewtopic.php?f=13&t=30279 <b>OSDev Forum:</b> Easy Parallel Port Programming Tests (Under Windows)]
 
 
Line 70 ⟶ 68:
In Standard (or Compatibility) mode, data is sent to the connected device by writing the byte to the data port, then pulsing the STROBE signal. This pulse informs the device that data is ready to be read. The device will respond by raising its BUSY signal and then reading the data and performing some processing on it. Once this processing is complete, the device will lower the Busy signal and may raise a brief ACK signal to indicate that it has finished.
 
<sourcesyntaxhighlight lang="c">
// Sends a byte to the printer
void Parallel_SendByte( unsigned char pData )
Line 77 ⟶ 75:
// Wait for the printer to be receptive
while ( ! Ports_In8inb( 0x379 ) & 0x80 )
{
Timer_Delay( 10 );
Line 83 ⟶ 81:
// Now put the data onto the data lines
Ports_Out8outb( 0x378, pData );
// Now pulse the strobe line to tell the printer to read the data
lControl = Ports_In8( 0x37A);
Ports_Out8outb( 0x37A, lControl | 1 );
Timer_Delay( 10 );
Ports_Out8outb( 0x37A, lControl );
// Now wait for the printer to finish processing
while ( ! Ports_In8inb( 0x379 ) & 0x80 )
{
Timer_Delay( 10 );
}
}
</syntaxhighlight>
</source>
 
<tt>Timer_Delay()</tt> pauses processing for the specified number of milliseconds. <tt>Ports_In8inb()</tt> and <tt>Ports_Out8outb()</tt> read and write a byte of data to/from the IO port. You can find the IO functions in the [[Inline_Assembly/Examples#OUTx|Inline Assembly Examples page]].
 
 
Line 112 ⟶ 110:
[[File:Win32_lpthandler_exe_0000.jpg]]
 
<sourcesyntaxhighlight lang="c">
/*
In short we only need:
 
Out32outl(LPT_Base_Address+2, 0); //Reset Control port with 0
Out32outl(LPT_Base_Address, 0xFF-0x00); //Write Data Port with any byte value
*/
 
Line 134 ⟶ 132:
//their bits:
///
Out32outl(LPT_Base_Address+2, 0);
 
//Now send an value betwewen 0 and 255 to the data port:
///
Out32outl(LPT_Base_Address, 0xFF-0x00);
 
</syntaxhighlight>
 
== See Also ==
</source>
=== Threads ===
* [http[Topic://f.osdev.org/viewtopic.php?f=13&t=30279 <b>OSDev Forum:</b> |Easy Parallel Port Programming Tests (Under Windows)]]
 
 
 
[[Category:Common Devices]]
[[Category:Hardware Interfaces]]